From 43098043c4ef31d9d5dead66568d7d9482a6b165 Mon Sep 17 00:00:00 2001 From: liamfallon Date: Tue, 25 Jan 2022 19:55:43 +0000 Subject: Rename TOSCA Control Loop to ACM This commit renames the TOSCA Control Loop functionality in CLAMP to Automation Composition Management. This review is a direct renaming review and, as everything is renamed together it is large. Issue-ID: POLICY-3939 Change-Id: I28f0a6dd889bf3570a4c1365ae9e71fc58db6d6c Signed-off-by: liamfallon --- .../exception/AutomationCompositionException.java | 95 + .../AutomationCompositionRuntimeException.java | 109 + .../common/acm/rest/CoderHttpMesageConverter.java | 74 + .../acm/rest/RequestResponseLoggingFilter.java | 69 + .../acm/startstop/CommonCommandLineArguments.java | 146 + .../common/exception/ControlLoopException.java | 94 - .../exception/ControlLoopRuntimeException.java | 107 - .../common/rest/CoderHttpMesageConverter.java | 74 - .../common/rest/RequestResponseLoggingFilter.java | 69 - .../startstop/CommonCommandLineArguments.java | 145 - .../controlloop/common/utils/CommonUtils.java | 152 - .../tosca/ApplicationServiceDescriptorTypes.yaml | 74 - ...mationCompositionTOSCAServiceTemplateTypes.yaml | 120 + .../tosca/CdsAutomationCompositionElementType.yaml | 27 + .../resources/tosca/CdsControlLoopElementType.yaml | 27 - .../ControlLoopTOSCAServiceTemplateTypes.yaml | 120 - .../tosca/DcaeControlLoopElementType.yaml | 51 - .../HttpAutomationCompositionElementType.yaml | 87 + .../tosca/HttpControlLoopElementType.yaml | 85 - ...KubernetesAutomationCompositionElementType.yaml | 76 + .../tosca/KubernetesControlLoopElementType.yaml | 76 - .../PolicyAutomationCompositionElementType.yaml | 44 + .../tosca/PolicyControlLoopElementType.yaml | 43 - .../clamp/common/acm/exception/ExceptionsTest.java | 85 + .../acm/rest/CoderHttpMessageConverterTest.java | 60 + .../acm/rest/RequestResponseLoggingFilterTest.java | 49 + .../startstop/CommonCommandLineArgumentsTest.java | 80 + .../common/exception/ExceptionsTest.java | 84 - .../common/rest/CoderHttpMessageConverterTest.java | 60 - .../rest/RequestResponseLoggingFilterTest.java | 49 - .../startstop/CommonCommandLineArgumentsTest.java | 80 - .../controlloop/common/utils/CommonUtilsTest.java | 151 - .../test/resources/asd/MyDomainASDDefintion.yaml | 131 - common/src/test/resources/demo/Notes.txt | 20 +- .../demo/config/DEMO.postman_collection.json | 28 +- .../demo/config/PolicyParticipantConfig.json | 10 +- .../test/resources/demo/config/RuntimeConfig.json | 8 +- .../resources/examples/acm/KubernetesHelm.yaml | 182 + .../examples/acm/PMSH/consul_call_body.json | 62 + .../resources/examples/acm/PMSH/consul_url.txt | 1 + .../acm/PMSH/pmsh.postman2.0_collection.json | 254 ++ .../examples/acm/PMSH/pmsh_cloudify_blueprint.yaml | 176 + .../examples/acm/PMSH/pmsh_monitoring_policy.json | 123 + .../examples/acm/PMSH/pmsh_monitoring_policy.yaml | 64 + .../acm/PMSH/pmsh_monitoring_policy_type.yaml | 264 ++ .../examples/acm/PMSH/pmsh_operational_policy.json | 2808 ++++++++++++++++ .../examples/acm/PMSH/pmsh_operational_policy.yaml | 2619 +++++++++++++++ .../examples/acm/PMSubscriptionHandling.yaml | 3325 ++++++++++++++++++ .../acm/PMSubscriptionHandling_GuilinFormat.yaml | 455 +++ .../http.postman2.0_collection.json | 254 ++ .../k8s-participant/k8s.postman2.0_collection.json | 254 ++ .../examples/controlloop/KubernetesHelm.yaml | 182 - .../controlloop/PMSH/consul_call_body.json | 62 - .../examples/controlloop/PMSH/consul_url.txt | 1 - .../PMSH/pmsh.postman2.0_collection.json | 254 -- .../controlloop/PMSH/pmsh_cloudify_blueprint.yaml | 176 - .../controlloop/PMSH/pmsh_monitoring_policy.json | 123 - .../controlloop/PMSH/pmsh_monitoring_policy.yaml | 64 - .../PMSH/pmsh_monitoring_policy_type.yaml | 264 -- .../controlloop/PMSH/pmsh_operational_policy.json | 2808 ---------------- .../controlloop/PMSH/pmsh_operational_policy.yaml | 2619 --------------- .../controlloop/PMSubscriptionHandling.yaml | 3325 ------------------ .../PMSubscriptionHandling_GuilinFormat.yaml | 455 --- .../http.postman2.0_collection.json | 254 -- .../k8s-participant/k8s.postman2.0_collection.json | 254 -- .../original/cloop_DCAE_VES_TCA_substitution.yaml | 83 - .../controlloop/original/cloop_base_types.yaml | 210 -- .../controlloop/original/cloop_dcae_example.yaml | 50 - .../controlloop/original/cloop_dcae_types.yaml | 140 - .../controlloop/original/cloop_other_types.yaml | 63 - .../controlloop/concepts/ClElementStatistics.java | 53 - .../concepts/ClElementStatisticsList.java | 33 - .../models/controlloop/concepts/ControlLoop.java | 116 - .../controlloop/concepts/ControlLoopElement.java | 89 - .../concepts/ControlLoopElementAck.java | 42 - .../concepts/ControlLoopElementDefinition.java | 64 - .../controlloop/concepts/ControlLoopInfo.java | 52 - .../concepts/ControlLoopOrderedState.java | 44 - .../controlloop/concepts/ControlLoopState.java | 63 - .../concepts/ControlLoopStatistics.java | 50 - .../models/controlloop/concepts/ControlLoops.java | 48 - .../models/controlloop/concepts/Participant.java | 77 - .../concepts/ParticipantDefinition.java | 59 - .../concepts/ParticipantHealthStatus.java | 52 - .../controlloop/concepts/ParticipantState.java | 61 - .../concepts/ParticipantStatistics.java | 52 - .../concepts/ParticipantStatisticsList.java | 33 - .../controlloop/concepts/ParticipantUpdates.java | 56 - .../controlloop/concepts/ParticipantUtils.java | 119 - .../concepts/JpaClElementStatistics.java | 196 -- .../persistence/concepts/JpaControlLoop.java | 263 -- .../concepts/JpaControlLoopElement.java | 253 -- .../persistence/concepts/JpaParticipant.java | 231 -- .../concepts/JpaParticipantStatistics.java | 239 -- .../provider/ClElementStatisticsProvider.java | 137 - .../persistence/provider/ControlLoopProvider.java | 279 -- .../persistence/provider/ParticipantProvider.java | 152 - .../provider/ParticipantStatisticsProvider.java | 138 - .../persistence/provider/ProviderUtils.java | 93 - .../provider/ServiceTemplateProvider.java | 261 -- .../repository/ClElementStatisticsRepository.java | 32 - .../repository/ControlLoopRepository.java | 31 - .../persistence/repository/FilterRepository.java | 53 - .../repository/FilterRepositoryImpl.java | 51 - .../repository/ParticipantRepository.java | 31 - .../ParticipantStatisticsRepository.java | 32 - .../repository/ToscaNodeTemplateRepository.java | 30 - .../repository/ToscaNodeTemplatesRepository.java | 29 - .../repository/ToscaServiceTemplateRepository.java | 30 - .../notification/ControlLoopNotification.java | 56 - .../dmaap/notification/ControlLoopStatus.java | 36 - .../messages/dmaap/participant/ControlLoopAck.java | 69 - .../dmaap/participant/ControlLoopStateChange.java | 60 - .../dmaap/participant/ControlLoopUpdate.java | 64 - .../dmaap/participant/ParticipantAckMessage.java | 115 - .../dmaap/participant/ParticipantDeregister.java | 51 - .../participant/ParticipantDeregisterAck.java | 51 - .../dmaap/participant/ParticipantMessage.java | 112 - .../dmaap/participant/ParticipantMessageType.java | 104 - .../dmaap/participant/ParticipantRegister.java | 51 - .../dmaap/participant/ParticipantRegisterAck.java | 51 - .../participant/ParticipantResponseStatus.java | 42 - .../dmaap/participant/ParticipantStatus.java | 78 - .../dmaap/participant/ParticipantStatusReq.java | 51 - .../dmaap/participant/ParticipantUpdate.java | 63 - .../dmaap/participant/ParticipantUpdateAck.java | 53 - .../models/messages/rest/GenericNameVersion.java | 30 - .../models/messages/rest/SimpleResponse.java | 37 - .../models/messages/rest/TypedSimpleResponse.java | 35 - .../rest/commissioning/CommissioningResponse.java | 38 - .../ControlLoopOrderStateResponse.java | 43 - .../rest/instantiation/ControlLoopPrimed.java | 32 - .../instantiation/ControlLoopPrimedResponse.java | 39 - .../instantiation/InstancePropertiesResponse.java | 38 - .../rest/instantiation/InstantiationCommand.java | 35 - .../InstantiationOrderStateResponse.java | 39 - .../rest/instantiation/InstantiationResponse.java | 38 - .../clamp/controlloop/models/rest/RestUtils.java | 43 - .../models/acm/concepts/AcElementStatistics.java | 53 + .../acm/concepts/AcElementStatisticsList.java | 33 + .../models/acm/concepts/AutomationComposition.java | 117 + .../acm/concepts/AutomationCompositionElement.java | 89 + .../concepts/AutomationCompositionElementAck.java | 42 + .../AutomationCompositionElementDefinition.java | 64 + .../acm/concepts/AutomationCompositionInfo.java | 52 + .../AutomationCompositionOrderedState.java | 47 + .../acm/concepts/AutomationCompositionState.java | 67 + .../concepts/AutomationCompositionStatistics.java | 50 + .../acm/concepts/AutomationCompositions.java | 48 + .../clamp/models/acm/concepts/Participant.java | 77 + .../models/acm/concepts/ParticipantDefinition.java | 60 + .../acm/concepts/ParticipantHealthStatus.java | 52 + .../models/acm/concepts/ParticipantState.java | 60 + .../models/acm/concepts/ParticipantStatistics.java | 52 + .../acm/concepts/ParticipantStatisticsList.java | 33 + .../models/acm/concepts/ParticipantUpdates.java | 56 + .../models/acm/concepts/ParticipantUtils.java | 123 + .../AutomationCompositionNotification.java | 56 + .../notification/AutomationCompositionStatus.java | 36 + .../participant/AutomationCompositionAck.java | 70 + .../AutomationCompositionStateChange.java | 60 + .../participant/AutomationCompositionUpdate.java | 64 + .../dmaap/participant/ParticipantAckMessage.java | 115 + .../dmaap/participant/ParticipantDeregister.java | 51 + .../participant/ParticipantDeregisterAck.java | 51 + .../dmaap/participant/ParticipantMessage.java | 112 + .../dmaap/participant/ParticipantMessageType.java | 104 + .../dmaap/participant/ParticipantRegister.java | 51 + .../dmaap/participant/ParticipantRegisterAck.java | 51 + .../participant/ParticipantResponseStatus.java | 42 + .../dmaap/participant/ParticipantStatus.java | 79 + .../dmaap/participant/ParticipantStatusReq.java | 51 + .../dmaap/participant/ParticipantUpdate.java | 63 + .../dmaap/participant/ParticipantUpdateAck.java | 53 + .../acm/messages/rest/GenericNameVersion.java | 30 + .../models/acm/messages/rest/SimpleResponse.java | 37 + .../acm/messages/rest/TypedSimpleResponse.java | 35 + .../rest/commissioning/CommissioningResponse.java | 38 + .../AutomationCompositionOrderStateResponse.java | 43 + .../instantiation/AutomationCompositionPrimed.java | 32 + .../AutomationCompositionPrimedResponse.java | 39 + .../instantiation/InstancePropertiesResponse.java | 38 + .../rest/instantiation/InstantiationCommand.java | 35 + .../InstantiationOrderStateResponse.java | 39 + .../rest/instantiation/InstantiationResponse.java | 38 + .../concepts/JpaAcElementStatistics.java | 196 ++ .../concepts/JpaAutomationComposition.java | 268 ++ .../concepts/JpaAutomationCompositionElement.java | 253 ++ .../acm/persistence/concepts/JpaParticipant.java | 231 ++ .../concepts/JpaParticipantStatistics.java | 239 ++ .../provider/AcElementStatisticsProvider.java | 139 + .../provider/AutomationCompositionProvider.java | 287 ++ .../persistence/provider/ParticipantProvider.java | 152 + .../provider/ParticipantStatisticsProvider.java | 138 + .../acm/persistence/provider/ProviderUtils.java | 93 + .../provider/ServiceTemplateProvider.java | 261 ++ .../repository/AcElementStatisticsRepository.java | 32 + .../AutomationCompositionRepository.java | 31 + .../persistence/repository/FilterRepository.java | 53 + .../repository/FilterRepositoryImpl.java | 51 + .../repository/ParticipantRepository.java | 31 + .../ParticipantStatisticsRepository.java | 32 + .../repository/ToscaNodeTemplateRepository.java | 30 + .../repository/ToscaNodeTemplatesRepository.java | 29 + .../repository/ToscaServiceTemplateRepository.java | 30 + .../policy/clamp/models/acm/rest/RestUtils.java | 43 + .../policy/clamp/models/acm/utils/AcmUtils.java | 152 + .../concepts/ClElementStatisticsTest.java | 67 - .../concepts/ControlLoopConceptPojosTest.java | 62 - .../concepts/ControlLoopElementTest.java | 103 - .../controlloop/concepts/ControlLoopTest.java | 160 - .../concepts/ParticipantStatisticsTest.java | 65 - .../controlloop/concepts/ParticipantTest.java | 84 - .../controlloop/concepts/ParticipantUtilsTest.java | 84 - .../concepts/DummyJpaClElementStatisticsChild.java | 28 - .../concepts/DummyJpaControlLoopChild.java | 28 - .../concepts/DummyJpaControlLoopElementChild.java | 28 - .../concepts/DummyJpaParticipantChild.java | 28 - .../DummyJpaParticipantStatisticsChild.java | 28 - .../concepts/JpaClElementStatisticsTest.java | 189 -- .../concepts/JpaControlLoopElementTest.java | 300 -- .../persistence/concepts/JpaControlLoopTest.java | 301 -- .../concepts/JpaParticipantStatisticsTest.java | 193 -- .../persistence/concepts/JpaParticipantTest.java | 254 -- .../persistence/concepts/PojosTest.java | 62 - .../provider/ClElementStatisticsProviderTest.java | 116 - .../provider/ControlLoopProviderTest.java | 290 -- .../provider/ParticipantProviderTest.java | 149 - .../ParticipantStatisticsProviderTest.java | 107 - .../provider/ServiceTemplateProviderTest.java | 169 - .../repository/FilterRepositoryImplTest.java | 106 - .../notification/ControlLoopNotificationTest.java | 83 - .../dmaap/notification/ControlLoopStatusTest.java | 48 - .../dmaap/notification/NotificationPojosTest.java | 58 - .../dmaap/participant/ControlLoopAckTest.java | 68 - .../participant/ControlLoopStateChangeTest.java | 65 - .../dmaap/participant/ControlLoopUpdateTest.java | 82 - .../participant/ParticipantAckMessageTest.java | 105 - .../participant/ParticipantDeregisterAckTest.java | 59 - .../participant/ParticipantDeregisterTest.java | 61 - .../dmaap/participant/ParticipantMessageTest.java | 107 - .../dmaap/participant/ParticipantMessageUtils.java | 55 - .../dmaap/participant/ParticipantPojosTest.java | 65 - .../participant/ParticipantRegisterAckTest.java | 59 - .../dmaap/participant/ParticipantRegisterTest.java | 61 - .../participant/ParticipantStatusReqTest.java | 56 - .../dmaap/participant/ParticipantStatusTest.java | 129 - .../participant/ParticipantUpdateAckTest.java | 59 - .../dmaap/participant/ParticipantUpdateTest.java | 101 - .../messages/rest/MessagesRestPojosTest.java | 59 - .../instantiation/InstantiationCommandTest.java | 60 - .../controlloop/models/rest/RestUtilsTest.java | 54 - .../acm/concepts/AcElementStatisticsTest.java | 67 + .../AutomationCompositionConceptPojosTest.java | 62 + .../concepts/AutomationCompositionElementTest.java | 103 + .../acm/concepts/AutomationCompositionTest.java | 160 + .../acm/concepts/ParticipantStatisticsTest.java | 65 + .../clamp/models/acm/concepts/ParticipantTest.java | 84 + .../models/acm/concepts/ParticipantUtilsTest.java | 91 + .../AutomationCompositionNotificationTest.java | 83 + .../AutomationCompositionStatusTest.java | 48 + .../dmaap/notification/NotificationPojosTest.java | 58 + .../participant/AutomationCompositionAckTest.java | 68 + .../AutomationCompositionStateChangeTest.java | 65 + .../AutomationCompositionUpdateTest.java | 82 + .../participant/ParticipantAckMessageTest.java | 105 + .../participant/ParticipantDeregisterAckTest.java | 59 + .../participant/ParticipantDeregisterTest.java | 61 + .../dmaap/participant/ParticipantMessageTest.java | 107 + .../dmaap/participant/ParticipantMessageUtils.java | 55 + .../dmaap/participant/ParticipantPojosTest.java | 65 + .../participant/ParticipantRegisterAckTest.java | 59 + .../dmaap/participant/ParticipantRegisterTest.java | 61 + .../participant/ParticipantStatusReqTest.java | 56 + .../dmaap/participant/ParticipantStatusTest.java | 129 + .../participant/ParticipantUpdateAckTest.java | 59 + .../dmaap/participant/ParticipantUpdateTest.java | 101 + .../acm/messages/rest/MessagesRestPojosTest.java | 59 + .../instantiation/InstantiationCommandTest.java | 60 + .../concepts/DummyJpaAcElementStatisticsChild.java | 28 + .../DummyJpaAutomationCompositionChild.java | 28 + .../DummyJpaAutomationCompositionElementChild.java | 28 + .../concepts/DummyJpaParticipantChild.java | 28 + .../DummyJpaParticipantStatisticsChild.java | 28 + .../concepts/JpaAcElementStatisticsTest.java | 189 ++ .../JpaAutomationCompositionElementTest.java | 315 ++ .../concepts/JpaAutomationCompositionTest.java | 310 ++ .../concepts/JpaParticipantStatisticsTest.java | 193 ++ .../persistence/concepts/JpaParticipantTest.java | 254 ++ .../models/acm/persistence/concepts/PojosTest.java | 62 + .../provider/AcElementStatisticsProviderTest.java | 116 + .../AutomationCompositionProviderTest.java | 305 ++ .../provider/ParticipantProviderTest.java | 149 + .../ParticipantStatisticsProviderTest.java | 107 + .../provider/ServiceTemplateProviderTest.java | 169 + .../repository/FilterRepositoryImplTest.java | 109 + .../clamp/models/acm/rest/RestUtilsTest.java | 54 + .../clamp/models/acm/utils/AcmUtilsTest.java | 149 + models/src/test/resources/META-INF/persistence.xml | 10 +- .../examples/acm/PMSubscriptionHandling.yaml | 3325 ++++++++++++++++++ .../controlloop/PMSubscriptionHandling.yaml | 3325 ------------------ ...AutomationCompositionElementNoOrderedState.json | 13 + .../json/AutomationCompositionNoOrderedState.json | 12 + .../json/ControlLoopElementNoOrderedState.json | 13 - .../resources/json/ControlLoopNoOrderedState.json | 12 - .../providers/TestAcElementStatistics.json | 24 + .../providers/TestAutomationCompositions.json | 142 + .../providers/TestClElementStatistics.json | 24 - .../test/resources/providers/TestControlLoops.json | 142 - .../test/resources/providers/TestParticipant.json | 4 +- .../providers/UpdateAutomationCompositions.json | 73 + .../resources/providers/UpdateControlLoops.json | 73 - packages/policy-clamp-docker/pom.xml | 23 +- .../src/main/docker/AcmRuntimeDockerfile | 53 + .../src/main/docker/ClRuntimeDockerfile | 53 - .../src/main/docker/HttpParticipantDockerfile | 2 +- .../main/docker/KubernetesParticipantDockerfile | 2 +- .../src/main/docker/PolicyParticipantDockerfile | 2 +- .../src/main/docker/acm-runtime.sh | 71 + .../src/main/docker/controlloop-runtime.sh | 71 - packages/policy-clamp-tarball/pom.xml | 2 +- .../main/resources/etc/AcRuntimeParameters.yaml | 68 + .../main/resources/etc/ClRuntimeParameters.yaml | 69 - .../resources/etc/HttpParticipantParameters.yaml | 10 +- .../etc/KubernetesParticipantParameters.yaml | 12 +- .../resources/etc/PolicyParticipantParameters.yaml | 10 +- .../participant-impl/participant-impl-cds/pom.xml | 2 +- .../clamp/acm/participant/http/Application.java | 49 + .../participant/http/config/ParticipantConfig.java | 43 + .../participant/http/config/SecurityConfig.java | 45 + .../main/exception/HttpWebClientException.java | 33 + .../AutomationCompositionElementHandler.java | 180 + .../http/main/models/ConfigRequest.java | 51 + .../http/main/models/ConfigurationEntity.java | 40 + .../participant/http/main/models/RestParams.java | 54 + .../http/main/webclient/AcHttpClient.java | 135 + .../http/parameters/ParticipantHttpParameters.java | 46 + .../controlloop/participant/http/Application.java | 45 - .../participant/http/config/ParticipantConfig.java | 43 - .../participant/http/config/SecurityConfig.java | 45 - .../main/exception/HttpWebClientException.java | 33 - .../main/handler/ControlLoopElementHandler.java | 178 - .../http/main/models/ConfigRequest.java | 51 - .../http/main/models/ConfigurationEntity.java | 40 - .../participant/http/main/models/RestParams.java | 54 - .../http/main/webclient/ClHttpClient.java | 135 - .../http/parameters/ParticipantHttpParameters.java | 47 - .../src/main/resources/config/application.yaml | 10 +- .../http/handler/AcElementHandlerTest.java | 106 + .../http/rest/ActuatorControllerTest.java | 92 + .../http/utils/CommonActuatorController.java | 114 + .../acm/participant/http/utils/CommonTestData.java | 137 + .../acm/participant/http/utils/ToscaUtils.java | 51 + .../http/webclient/AcHttpClientTest.java | 129 + .../http/handler/ClElementHandlerTest.java | 108 - .../http/rest/ActuatorControllerTest.java | 92 - .../http/utils/CommonActuatorController.java | 114 - .../participant/http/utils/CommonTestData.java | 152 - .../participant/http/utils/ToscaUtils.java | 51 - .../http/webclient/ClHttpClientTest.java | 129 - .../src/test/resources/HttpParticipantConfig.yaml | 48 +- .../src/test/resources/application_test.properties | 22 +- .../participant-impl-kubernetes/pom.xml | 2 +- .../acm/participant/kubernetes/Application.java | 49 + .../configurations/ParticipantConfig.java | 44 + .../ParticipantIntermediaryConfig.java | 43 + .../kubernetes/configurations/SecurityConfig.java | 45 + .../kubernetes/configurations/SpringFoxConfig.java | 45 + .../kubernetes/controller/ChartController.java | 195 ++ .../kubernetes/exception/ServiceException.java | 32 + .../AutomationCompositionElementHandler.java | 197 ++ .../participant/kubernetes/helm/HelmClient.java | 279 ++ .../kubernetes/helm/PodStatusValidator.java | 119 + .../participant/kubernetes/models/ChartInfo.java | 44 + .../participant/kubernetes/models/ChartList.java | 31 + .../kubernetes/models/HelmRepository.java | 39 + .../kubernetes/models/InstallationInfo.java | 29 + .../parameters/ParticipantK8sParameters.java | 52 + .../kubernetes/service/ChartService.java | 141 + .../participant/kubernetes/service/ChartStore.java | 219 ++ .../participant/kubernetes/Application.java | 45 - .../configurations/ParticipantConfig.java | 44 - .../ParticipantIntermediaryConfig.java | 43 - .../kubernetes/configurations/SecurityConfig.java | 45 - .../kubernetes/configurations/SpringFoxConfig.java | 45 - .../kubernetes/controller/ChartController.java | 195 -- .../kubernetes/exception/ServiceException.java | 32 - .../handler/ControlLoopElementHandler.java | 196 -- .../participant/kubernetes/helm/HelmClient.java | 279 -- .../kubernetes/helm/PodStatusValidator.java | 119 - .../participant/kubernetes/models/ChartInfo.java | 44 - .../participant/kubernetes/models/ChartList.java | 31 - .../kubernetes/models/HelmRepository.java | 39 - .../kubernetes/models/InstallationInfo.java | 29 - .../parameters/ParticipantK8sParameters.java | 52 - .../kubernetes/service/ChartService.java | 141 - .../participant/kubernetes/service/ChartStore.java | 219 -- .../src/main/resources/config/application.yaml | 16 +- .../AutomationCompositionElementHandlerTest.java | 182 + .../kubernetes/helm/HelmClientTest.java | 158 + .../kubernetes/helm/PodStatusValidatorTest.java | 107 + .../kubernetes/parameters/CommonTestData.java | 161 + .../parameters/ParticipantK8sParametersTest.java | 89 + .../kubernetes/rest/ActuatorControllerTest.java | 92 + .../kubernetes/rest/ChartControllerTest.java | 249 ++ .../kubernetes/service/ChartServiceTest.java | 148 + .../kubernetes/service/ChartStoreTest.java | 175 + .../kubernetes/utils/CommonActuatorController.java | 114 + .../participant/kubernetes/utils/TestUtils.java | 47 + .../handler/ControlLoopElementHandlerTest.java | 180 - .../kubernetes/helm/HelmClientTest.java | 158 - .../kubernetes/helm/PodStatusValidatorTest.java | 109 - .../kubernetes/parameters/CommonTestData.java | 161 - .../parameters/ParticipantK8sParametersTest.java | 89 - .../kubernetes/rest/ActuatorControllerTest.java | 92 - .../kubernetes/rest/ChartControllerTest.java | 249 -- .../kubernetes/service/ChartServiceTest.java | 148 - .../kubernetes/service/ChartStoreTest.java | 175 - .../kubernetes/utils/CommonActuatorController.java | 114 - .../participant/kubernetes/utils/TestUtils.java | 47 - .../src/test/resources/application_test.properties | 22 +- .../resources/servicetemplates/KubernetesHelm.yaml | 58 +- .../participant-impl-policy/pom.xml | 2 +- .../policy/PolicyParticipantApplication.java | 43 + .../policy/client/AbstractHttpClient.java | 76 + .../policy/client/PolicyApiHttpClient.java | 87 + .../policy/client/PolicyPapHttpClient.java | 85 + .../policy/config/ParticipantConfig.java | 43 + .../participant/policy/config/SecurityConfig.java | 45 + .../AutomationCompositionElementHandler.java | 227 ++ .../parameters/ParticipantPolicyParameters.java | 62 + .../policy/PolicyParticipantApplication.java | 42 - .../policy/client/AbstractHttpClient.java | 76 - .../policy/client/PolicyApiHttpClient.java | 87 - .../policy/client/PolicyPapHttpClient.java | 85 - .../policy/config/ParticipantConfig.java | 43 - .../participant/policy/config/SecurityConfig.java | 45 - .../main/handler/ControlLoopElementHandler.java | 220 -- .../parameters/ParticipantPolicyParameters.java | 62 - .../src/main/resources/META-INF/persistence.xml | 10 +- .../src/main/resources/config/application.yaml | 10 +- .../policy/endtoend/ParticipantMessagesTest.java | 174 + .../AutomationCompositionElementHandlerTest.java | 102 + .../policy/main/parameters/CommonTestData.java | 181 + .../ParticipantPolicyParametersTest.java | 67 + .../policy/main/rest/ActuatorControllerTest.java | 92 + .../main/utils/CommonActuatorController.java | 114 + .../policy/main/utils/TestListenerUtils.java | 321 ++ .../policy/endtoend/ParticipantMessagesTest.java | 174 - .../handler/ControlLoopElementHandlerTest.java | 102 - .../policy/main/parameters/CommonTestData.java | 180 - .../ParticipantPolicyParametersTest.java | 66 - .../policy/main/rest/ActuatorControllerTest.java | 92 - .../main/utils/CommonActuatorController.java | 114 - .../policy/main/utils/TestListenerUtils.java | 317 -- .../src/test/resources/application_test.properties | 20 +- .../test/resources/parameters/TestACParams.yaml | 172 + .../test/resources/parameters/TestCLParams.yaml | 172 - .../src/test/resources/parameters/logback-test.xml | 2 +- .../vCPE.policies.optimization.input.tosca.yaml | 348 -- .../resources/policytypes/onap.policies.Match.yaml | 8 - .../policytypes/onap.policies.Naming.yaml | 102 - .../policytypes/onap.policies.Optimization.yaml | 33 - .../onap.policies.controlloop.guard.Common.yaml | 28 - ...olicies.controlloop.guard.common.Blacklist.yaml | 16 - ...p.policies.controlloop.guard.common.Filter.yaml | 66 - ....controlloop.guard.common.FrequencyLimiter.yaml | 26 - ...p.policies.controlloop.guard.common.MinMax.yaml | 24 - ...lloop.guard.coordination.FirstBlocksSecond.yaml | 27 - ...ap.policies.controlloop.operational.Common.yaml | 143 - ...licies.controlloop.operational.common.Apex.yaml | 26 - ...cies.controlloop.operational.common.Drools.yaml | 14 - .../onap.policies.monitoring.dcae-pm-mapper.yaml | 50 - ...es.monitoring.dcae-pm-subscription-handler.yaml | 132 - ...policies.monitoring.dcae-restconfcollector.yaml | 128 - ...n2.collectors.datafile.datafile-app-server.yaml | 19 - .../onap.policies.monitoring.tcagen2.yaml | 161 - .../policytypes/onap.policies.native.Apex.yaml | 203 -- .../policytypes/onap.policies.native.Drools.yaml | 118 - .../policytypes/onap.policies.native.Xacml.yaml | 20 - .../onap.policies.optimization.Resource.yaml | 25 - .../onap.policies.optimization.Service.yaml | 17 - ...icies.optimization.resource.AffinityPolicy.yaml | 33 - ...icies.optimization.resource.DistancePolicy.yaml | 58 - ...p.policies.optimization.resource.HpaPolicy.yaml | 105 - ...s.optimization.resource.OptimizationPolicy.yaml | 68 - ...p.policies.optimization.resource.PciPolicy.yaml | 32 - ...nap.policies.optimization.resource.Vim_fit.yaml | 30 - ...p.policies.optimization.resource.VnfPolicy.yaml | 46 - ....policies.optimization.service.QueryPolicy.yaml | 26 - ...cies.optimization.service.SubscriberPolicy.yaml | 36 - .../pm_automation_composition_tosca.yaml | 164 + .../servicetemplates/pm_control_loop_tosca.yaml | 164 - .../participant-impl-simulator/pom.xml | 2 +- .../simulator/ParticipantSimulatorApplication.java | 46 + .../simulator/config/AafConfiguration.java | 46 + .../simulator/config/ParticipantConfig.java | 61 + .../simulator/config/SecurityConfig.java | 39 + .../simulator/config/SpringFoxConfig.java | 45 + .../simulator/config/YamlConfiguration.java | 43 + .../AutomationCompositionElementHandler.java | 112 + .../parameters/ParticipantSimulatorParameters.java | 45 + .../main/rest/AbstractRestController.java | 130 + .../rest/GlobalControllerExceptionHandler.java | 45 + .../main/rest/ParticipantErrorController.java | 97 + .../main/rest/ParticipantSimulatorAafFilter.java | 38 + .../simulator/simulation/SimulationProvider.java | 113 + .../rest/SimulationElementController.java | 188 ++ .../rest/SimulationParticipantController.java | 181 + .../simulator/ParticipantSimulatorApplication.java | 46 - .../simulator/config/AafConfiguration.java | 46 - .../simulator/config/ParticipantConfig.java | 61 - .../simulator/config/SecurityConfig.java | 39 - .../simulator/config/SpringFoxConfig.java | 45 - .../simulator/config/YamlConfiguration.java | 43 - .../main/handler/ControlLoopElementHandler.java | 111 - .../parameters/ParticipantSimulatorParameters.java | 45 - .../main/rest/AbstractRestController.java | 102 - .../rest/GlobalControllerExceptionHandler.java | 45 - .../main/rest/ParticipantErrorController.java | 97 - .../main/rest/ParticipantSimulatorAafFilter.java | 38 - .../simulator/simulation/SimulationProvider.java | 110 - .../rest/SimulationElementController.java | 183 - .../rest/SimulationParticipantController.java | 175 - .../src/main/resources/config/application.yaml | 6 +- .../src/main/resources/version.txt | 2 +- .../endtoend/ParticipantSimulatorTest.java | 288 ++ .../AutomationCompositionElementHandlerTest.java | 91 + .../simulator/main/parameters/CommonTestData.java | 140 + .../TestParticipantSimulatorParameters.java | 62 + .../simulator/main/rest/TestListenerUtils.java | 260 ++ .../endtoend/ParticipantSimulatorTest.java | 285 -- .../handler/ControlLoopElementHandlerTest.java | 98 - .../simulator/main/parameters/CommonTestData.java | 140 - .../TestParticipantSimulatorParameters.java | 62 - .../simulator/main/rest/TestListenerUtils.java | 257 -- .../src/test/resources/application_test.properties | 14 +- .../pm_automation_composition_tosca.yaml | 164 + .../servicetemplates/pm_control_loop_tosca.yaml | 164 - participant/participant-intermediary/pom.xml | 4 +- .../api/AutomationCompositionElementListener.java | 65 + .../api/ParticipantIntermediaryApi.java | 130 + .../api/impl/ParticipantIntermediaryApiImpl.java | 140 + .../AutomationCompositionStateChangeListener.java | 48 + .../comm/AutomationCompositionUpdateListener.java | 48 + .../intermediary/comm/MessageSender.java | 78 + .../intermediary/comm/ParticipantAckListener.java | 67 + .../comm/ParticipantDeregisterAckListener.java | 48 + .../intermediary/comm/ParticipantListener.java | 64 + .../comm/ParticipantMessagePublisher.java | 147 + .../comm/ParticipantRegisterAckListener.java | 48 + .../comm/ParticipantStatusReqListener.java | 47 + .../comm/ParticipantUpdateListener.java | 47 + .../handler/AutomationCompositionHandler.java | 476 +++ .../handler/IntermediaryActivator.java | 153 + .../participant/intermediary/handler/Listener.java | 41 + .../intermediary/handler/ParticipantHandler.java | 416 +++ .../intermediary/handler/Publisher.java | 34 + .../ParticipantIntermediaryParameters.java | 61 + .../parameters/ParticipantParameters.java | 26 + .../api/ControlLoopElementListener.java | 63 - .../api/ParticipantIntermediaryApi.java | 129 - .../api/impl/ParticipantIntermediaryApiImpl.java | 137 - .../comm/ControlLoopStateChangeListener.java | 48 - .../comm/ControlLoopUpdateListener.java | 47 - .../intermediary/comm/MessageSender.java | 78 - .../intermediary/comm/ParticipantAckListener.java | 67 - .../comm/ParticipantDeregisterAckListener.java | 48 - .../intermediary/comm/ParticipantListener.java | 64 - .../comm/ParticipantMessagePublisher.java | 147 - .../comm/ParticipantRegisterAckListener.java | 48 - .../comm/ParticipantStatusReqListener.java | 47 - .../comm/ParticipantUpdateListener.java | 47 - .../intermediary/handler/ControlLoopHandler.java | 454 --- .../handler/IntermediaryActivator.java | 154 - .../participant/intermediary/handler/Listener.java | 41 - .../intermediary/handler/ParticipantHandler.java | 415 --- .../intermediary/handler/Publisher.java | 34 - .../ParticipantIntermediaryParameters.java | 61 - .../parameters/ParticipantParameters.java | 26 - .../impl/ParticipantIntermediaryApiImplTest.java | 103 + .../intermediary/comm/ParticipantCommTest.java | 116 + .../handler/AutomationCompositionHandlerTest.java | 227 ++ .../handler/DummyParticipantParameters.java | 35 + .../handler/IntermediaryActivatorTest.java | 103 + .../handler/ParticipantHandlerTest.java | 176 + .../main/parameters/CommonTestData.java | 294 ++ .../TestParticipantIntermediaryParameters.java | 67 + .../impl/ParticipantIntermediaryApiImplTest.java | 102 - .../intermediary/comm/ParticipantCommTest.java | 119 - .../handler/ControlLoopHandlerTest.java | 226 -- .../handler/DummyParticipantParameters.java | 35 - .../handler/IntermediaryActivatorTest.java | 103 - .../handler/ParticipantHandlerTest.java | 176 - .../main/parameters/CommonTestData.java | 293 -- .../TestParticipantIntermediaryParameters.java | 67 - .../providers/TestAutomationCompositions.json | 142 + .../test/resources/providers/TestControlLoops.json | 142 - pom.xml | 5 +- runtime-acm/pom.xml | 124 + .../onap/policy/clamp/acm/runtime/Application.java | 53 + .../commissioning/CommissioningProvider.java | 383 +++ .../clamp/acm/runtime/config/AafConfiguration.java | 43 + .../acm/runtime/config/ConverterConfiguration.java | 44 + .../clamp/acm/runtime/config/FilterConfig.java | 45 + .../clamp/acm/runtime/config/SecurityConfig.java | 47 + .../clamp/acm/runtime/config/SpringFoxConfig.java | 45 + .../acm/runtime/config/messaging/Listener.java | 41 + .../messaging/MessageDispatcherActivator.java | 137 + .../acm/runtime/config/messaging/Publisher.java | 34 + ...AutomationCompositionInstantiationProvider.java | 637 ++++ .../main/parameters/AcRuntimeParameterGroup.java | 49 + .../main/parameters/ParticipantParameters.java | 45 + .../parameters/ParticipantUpdateParameters.java | 46 + .../runtime/main/rest/CommissioningController.java | 501 +++ .../runtime/main/rest/InstantiationController.java | 623 ++++ .../main/rest/MonitoringQueryController.java | 334 ++ .../runtime/main/web/AbstractRestController.java | 91 + .../main/web/AutomationConfiguraitonAafFilter.java | 38 + .../main/web/GlobalControllerExceptionHandler.java | 67 + .../runtime/main/web/RuntimeErrorController.java | 104 + .../acm/runtime/monitoring/MonitoringProvider.java | 247 ++ .../acm/runtime/supervision/HandleCounter.java | 106 + .../acm/runtime/supervision/MessageIntercept.java | 32 + .../acm/runtime/supervision/SupervisionAspect.java | 105 + .../runtime/supervision/SupervisionHandler.java | 518 +++ .../runtime/supervision/SupervisionScanner.java | 307 ++ .../comm/AbstractParticipantAckPublisher.java | 62 + .../comm/AbstractParticipantPublisher.java | 62 + ...utomationCompositionStateChangeAckListener.java | 70 + .../AutomationCompositionStateChangePublisher.java | 50 + .../AutomationCompositionUpdateAckListener.java | 70 + .../comm/AutomationCompositionUpdatePublisher.java | 91 + .../comm/ParticipantDeregisterAckPublisher.java | 45 + .../comm/ParticipantDeregisterListener.java | 69 + .../comm/ParticipantRegisterAckPublisher.java | 50 + .../comm/ParticipantRegisterListener.java | 69 + .../comm/ParticipantStatusListener.java | 68 + .../comm/ParticipantStatusReqPublisher.java | 48 + .../comm/ParticipantUpdateAckListener.java | 69 + .../comm/ParticipantUpdatePublisher.java | 127 + runtime-acm/src/main/resources/application.yaml | 66 + runtime-acm/src/main/resources/version.txt | 4 + .../commissioning/CommissioningProviderTest.java | 221 ++ .../rest/CommissioningControllerTest.java | 303 ++ .../messaging/MessageDispatcherActivatorTest.java | 102 + ...mationCompositionInstantiationProviderTest.java | 394 +++ .../runtime/instantiation/InstantiationUtils.java | 147 + .../rest/InstantiationControllerTest.java | 543 +++ .../runtime/main/rest/ActuatorControllerTest.java | 91 + .../runtime/monitoring/TestMonitoringProvider.java | 321 ++ .../rest/MonitoringQueryControllerTest.java | 242 ++ .../acm/runtime/supervision/HandleCounterTest.java | 84 + .../runtime/supervision/SupervisionAspectTest.java | 66 + .../supervision/SupervisionHandlerTest.java | 319 ++ .../supervision/SupervisionScannerTest.java | 214 ++ .../supervision/comm/SupervisionMessagesTest.java | 225 ++ .../clamp/acm/runtime/util/CommonTestData.java | 125 + .../runtime/util/rest/CommonRestController.java | 201 ++ .../src/test/resources/application_test.properties | 37 + .../test/resources/parameters/TestParameters.json | 44 + .../src/test/resources/parameters/logback-test.xml | 42 + .../acm/AutomationCompositionElementsNotFound.json | 142 + .../AutomationCompositionVersionNotMatches.json | 142 + .../resources/rest/acm/AutomationCompositions.json | 174 + .../rest/acm/AutomationCompositionsNotFound.json | 142 + .../rest/acm/AutomationCompositionsSmoke.json | 174 + .../rest/acm/AutomationCompositionsUpdate.json | 174 + .../test/resources/rest/acm/PassiveCommand.json | 13 + .../rest/monitoring/TestAcElementStatistics.json | 44 + .../TestAcElementStatistics_Invalid.json | 13 + .../rest/monitoring/TestParticipantStatistics.json | 46 + .../TestParticipantStatistics_Invalid.json | 16 + .../rest/servicetemplates/PMSHMultipleACTosca.yaml | 232 ++ .../full-tosca-with-common-properties.yaml | 3546 ++++++++++++++++++++ .../pm_automation_composition_tosca.yaml | 452 +++ .../servicetemplates/pmsh_multiple_ac_tosca.yaml | 238 ++ .../servicetemplates/tosca-for-smoke-testing.yaml | 3488 +++++++++++++++++++ .../test/resources/testscripts/listenOnTopic.sh | 31 + runtime-controlloop/pom.xml | 124 - .../clamp/controlloop/runtime/Application.java | 45 - .../commissioning/CommissioningProvider.java | 378 --- .../runtime/config/AafConfiguration.java | 46 - .../runtime/config/ConverterConfiguration.java | 44 - .../controlloop/runtime/config/FilterConfig.java | 45 - .../controlloop/runtime/config/SecurityConfig.java | 47 - .../runtime/config/SpringFoxConfig.java | 45 - .../runtime/config/messaging/Listener.java | 41 - .../messaging/MessageDispatcherActivator.java | 137 - .../runtime/config/messaging/Publisher.java | 34 - .../ControlLoopInstantiationProvider.java | 619 ---- .../main/parameters/ClRuntimeParameterGroup.java | 49 - .../main/parameters/ParticipantParameters.java | 45 - .../parameters/ParticipantUpdateParameters.java | 46 - .../runtime/main/rest/CommissioningController.java | 515 --- .../runtime/main/rest/InstantiationController.java | 637 ---- .../main/rest/MonitoringQueryController.java | 341 -- .../runtime/main/web/AbstractRestController.java | 91 - .../runtime/main/web/ControlLoopAafFilter.java | 38 - .../main/web/GlobalControllerExceptionHandler.java | 67 - .../runtime/main/web/RuntimeErrorController.java | 104 - .../runtime/monitoring/MonitoringProvider.java | 243 -- .../runtime/supervision/HandleCounter.java | 106 - .../runtime/supervision/MessageIntercept.java | 32 - .../runtime/supervision/SupervisionAspect.java | 105 - .../runtime/supervision/SupervisionHandler.java | 491 --- .../runtime/supervision/SupervisionScanner.java | 301 -- .../comm/AbstractParticipantAckPublisher.java | 62 - .../comm/AbstractParticipantPublisher.java | 62 - .../comm/ControlLoopStateChangeAckListener.java | 68 - .../comm/ControlLoopStateChangePublisher.java | 50 - .../comm/ControlLoopUpdateAckListener.java | 68 - .../comm/ControlLoopUpdatePublisher.java | 91 - .../comm/ParticipantDeregisterAckPublisher.java | 45 - .../comm/ParticipantDeregisterListener.java | 69 - .../comm/ParticipantRegisterAckPublisher.java | 50 - .../comm/ParticipantRegisterListener.java | 69 - .../comm/ParticipantStatusListener.java | 68 - .../comm/ParticipantStatusReqPublisher.java | 48 - .../comm/ParticipantUpdateAckListener.java | 69 - .../comm/ParticipantUpdatePublisher.java | 127 - .../src/main/resources/application.yaml | 67 - runtime-controlloop/src/main/resources/version.txt | 4 - .../commissioning/CommissioningProviderTest.java | 221 -- .../rest/CommissioningControllerTest.java | 303 -- .../messaging/MessageDispatcherActivatorTest.java | 102 - .../ControlLoopInstantiationProviderTest.java | 378 --- .../runtime/instantiation/InstantiationUtils.java | 141 - .../rest/InstantiationControllerTest.java | 527 --- .../runtime/main/rest/ActuatorControllerTest.java | 91 - .../runtime/monitoring/TestMonitoringProvider.java | 319 -- .../rest/MonitoringQueryControllerTest.java | 242 -- .../runtime/supervision/HandleCounterTest.java | 84 - .../runtime/supervision/SupervisionAspectTest.java | 66 - .../supervision/SupervisionHandlerTest.java | 307 -- .../supervision/SupervisionScannerTest.java | 214 -- .../supervision/comm/SupervisionMessagesTest.java | 225 -- .../controlloop/runtime/util/CommonTestData.java | 123 - .../runtime/util/rest/CommonRestController.java | 201 -- .../src/test/resources/application_test.properties | 37 - .../test/resources/parameters/TestParameters.json | 44 - .../src/test/resources/parameters/logback-test.xml | 42 - .../controlloops/ControlLoopElementsNotFound.json | 142 - .../resources/rest/controlloops/ControlLoops.json | 174 - .../rest/controlloops/ControlLoopsNotFound.json | 142 - .../rest/controlloops/ControlLoopsSmoke.json | 174 - .../rest/controlloops/ControlLoopsUpdate.json | 174 - .../ControlLoopsVersionNotMatches.json | 142 - .../rest/controlloops/PassiveCommand.json | 13 - .../rest/monitoring/TestClElementStatistics.json | 44 - .../TestClElementStatistics_Invalid.json | 13 - .../rest/monitoring/TestParticipantStatistics.json | 46 - .../TestParticipantStatistics_Invalid.json | 16 - .../rest/servicetemplates/PMSHMultipleCLTosca.yaml | 232 -- .../full-tosca-with-common-properties.yaml | 3546 -------------------- .../servicetemplates/pm_control_loop_tosca.yaml | 452 --- .../servicetemplates/pmsh_multiple_cl_tosca.yaml | 238 -- .../servicetemplates/tosca-for-smoke-testing.yaml | 3488 ------------------- .../test/resources/testscripts/listenOnTopic.sh | 31 - .../policy/clamp/clds/config/AafConfiguration.java | 2 +- .../main/resources/application-noaaf.properties | 6 +- runtime/src/main/resources/application.properties | 6 +- .../resources/clds/camel/rest/clamp-api-v2.xml | 34 +- .../main/resources/clds/camel/routes/acm-flows.xml | 387 +++ .../clds/camel/routes/controlloop-flows.xml | 387 --- .../RuntimeCommissioningResponseItTestCase.java | 2 +- .../RuntimeInstantiationResponseItTestCase.java | 5 +- runtime/src/test/resources/application.properties | 6 +- .../test/resources/http-cache/third_party_proxy.py | 36 +- 769 files changed, 57350 insertions(+), 60073 deletions(-) create mode 100644 common/src/main/java/org/onap/policy/clamp/common/acm/exception/AutomationCompositionException.java create mode 100644 common/src/main/java/org/onap/policy/clamp/common/acm/exception/AutomationCompositionRuntimeException.java create mode 100644 common/src/main/java/org/onap/policy/clamp/common/acm/rest/CoderHttpMesageConverter.java create mode 100644 common/src/main/java/org/onap/policy/clamp/common/acm/rest/RequestResponseLoggingFilter.java create mode 100644 common/src/main/java/org/onap/policy/clamp/common/acm/startstop/CommonCommandLineArguments.java delete mode 100644 common/src/main/java/org/onap/policy/clamp/controlloop/common/exception/ControlLoopException.java delete mode 100644 common/src/main/java/org/onap/policy/clamp/controlloop/common/exception/ControlLoopRuntimeException.java delete mode 100644 common/src/main/java/org/onap/policy/clamp/controlloop/common/rest/CoderHttpMesageConverter.java delete mode 100644 common/src/main/java/org/onap/policy/clamp/controlloop/common/rest/RequestResponseLoggingFilter.java delete mode 100644 common/src/main/java/org/onap/policy/clamp/controlloop/common/startstop/CommonCommandLineArguments.java delete mode 100644 common/src/main/java/org/onap/policy/clamp/controlloop/common/utils/CommonUtils.java delete mode 100644 common/src/main/resources/tosca/ApplicationServiceDescriptorTypes.yaml create mode 100644 common/src/main/resources/tosca/AutomationCompositionTOSCAServiceTemplateTypes.yaml create mode 100644 common/src/main/resources/tosca/CdsAutomationCompositionElementType.yaml delete mode 100644 common/src/main/resources/tosca/CdsControlLoopElementType.yaml delete mode 100644 common/src/main/resources/tosca/ControlLoopTOSCAServiceTemplateTypes.yaml delete mode 100644 common/src/main/resources/tosca/DcaeControlLoopElementType.yaml create mode 100644 common/src/main/resources/tosca/HttpAutomationCompositionElementType.yaml delete mode 100644 common/src/main/resources/tosca/HttpControlLoopElementType.yaml create mode 100644 common/src/main/resources/tosca/KubernetesAutomationCompositionElementType.yaml delete mode 100644 common/src/main/resources/tosca/KubernetesControlLoopElementType.yaml create mode 100644 common/src/main/resources/tosca/PolicyAutomationCompositionElementType.yaml delete mode 100644 common/src/main/resources/tosca/PolicyControlLoopElementType.yaml create mode 100644 common/src/test/java/org/onap/policy/clamp/common/acm/exception/ExceptionsTest.java create mode 100644 common/src/test/java/org/onap/policy/clamp/common/acm/rest/CoderHttpMessageConverterTest.java create mode 100644 common/src/test/java/org/onap/policy/clamp/common/acm/rest/RequestResponseLoggingFilterTest.java create mode 100644 common/src/test/java/org/onap/policy/clamp/common/acm/startstop/CommonCommandLineArgumentsTest.java delete mode 100644 common/src/test/java/org/onap/policy/clamp/controlloop/common/exception/ExceptionsTest.java delete mode 100644 common/src/test/java/org/onap/policy/clamp/controlloop/common/rest/CoderHttpMessageConverterTest.java delete mode 100644 common/src/test/java/org/onap/policy/clamp/controlloop/common/rest/RequestResponseLoggingFilterTest.java delete mode 100644 common/src/test/java/org/onap/policy/clamp/controlloop/common/startstop/CommonCommandLineArgumentsTest.java delete mode 100644 common/src/test/java/org/onap/policy/clamp/controlloop/common/utils/CommonUtilsTest.java delete mode 100644 common/src/test/resources/asd/MyDomainASDDefintion.yaml create mode 100644 common/src/test/resources/examples/acm/KubernetesHelm.yaml create mode 100644 common/src/test/resources/examples/acm/PMSH/consul_call_body.json create mode 100644 common/src/test/resources/examples/acm/PMSH/consul_url.txt create mode 100644 common/src/test/resources/examples/acm/PMSH/pmsh.postman2.0_collection.json create mode 100644 common/src/test/resources/examples/acm/PMSH/pmsh_cloudify_blueprint.yaml create mode 100644 common/src/test/resources/examples/acm/PMSH/pmsh_monitoring_policy.json create mode 100644 common/src/test/resources/examples/acm/PMSH/pmsh_monitoring_policy.yaml create mode 100644 common/src/test/resources/examples/acm/PMSH/pmsh_monitoring_policy_type.yaml create mode 100644 common/src/test/resources/examples/acm/PMSH/pmsh_operational_policy.json create mode 100644 common/src/test/resources/examples/acm/PMSH/pmsh_operational_policy.yaml create mode 100644 common/src/test/resources/examples/acm/PMSubscriptionHandling.yaml create mode 100644 common/src/test/resources/examples/acm/PMSubscriptionHandling_GuilinFormat.yaml create mode 100644 common/src/test/resources/examples/acm/http-participant/http.postman2.0_collection.json create mode 100644 common/src/test/resources/examples/acm/k8s-participant/k8s.postman2.0_collection.json delete mode 100644 common/src/test/resources/examples/controlloop/KubernetesHelm.yaml delete mode 100644 common/src/test/resources/examples/controlloop/PMSH/consul_call_body.json delete mode 100644 common/src/test/resources/examples/controlloop/PMSH/consul_url.txt delete mode 100644 common/src/test/resources/examples/controlloop/PMSH/pmsh.postman2.0_collection.json delete mode 100644 common/src/test/resources/examples/controlloop/PMSH/pmsh_cloudify_blueprint.yaml delete mode 100644 common/src/test/resources/examples/controlloop/PMSH/pmsh_monitoring_policy.json delete mode 100644 common/src/test/resources/examples/controlloop/PMSH/pmsh_monitoring_policy.yaml delete mode 100644 common/src/test/resources/examples/controlloop/PMSH/pmsh_monitoring_policy_type.yaml delete mode 100644 common/src/test/resources/examples/controlloop/PMSH/pmsh_operational_policy.json delete mode 100644 common/src/test/resources/examples/controlloop/PMSH/pmsh_operational_policy.yaml delete mode 100644 common/src/test/resources/examples/controlloop/PMSubscriptionHandling.yaml delete mode 100644 common/src/test/resources/examples/controlloop/PMSubscriptionHandling_GuilinFormat.yaml delete mode 100644 common/src/test/resources/examples/controlloop/http-participant/http.postman2.0_collection.json delete mode 100644 common/src/test/resources/examples/controlloop/k8s-participant/k8s.postman2.0_collection.json delete mode 100644 common/src/test/resources/examples/controlloop/original/cloop_DCAE_VES_TCA_substitution.yaml delete mode 100644 common/src/test/resources/examples/controlloop/original/cloop_base_types.yaml delete mode 100644 common/src/test/resources/examples/controlloop/original/cloop_dcae_example.yaml delete mode 100644 common/src/test/resources/examples/controlloop/original/cloop_dcae_types.yaml delete mode 100644 common/src/test/resources/examples/controlloop/original/cloop_other_types.yaml delete mode 100644 models/src/main/java/org/onap/policy/clamp/controlloop/models/controlloop/concepts/ClElementStatistics.java delete mode 100644 models/src/main/java/org/onap/policy/clamp/controlloop/models/controlloop/concepts/ClElementStatisticsList.java delete mode 100644 models/src/main/java/org/onap/policy/clamp/controlloop/models/controlloop/concepts/ControlLoop.java delete mode 100644 models/src/main/java/org/onap/policy/clamp/controlloop/models/controlloop/concepts/ControlLoopElement.java delete mode 100644 models/src/main/java/org/onap/policy/clamp/controlloop/models/controlloop/concepts/ControlLoopElementAck.java delete mode 100644 models/src/main/java/org/onap/policy/clamp/controlloop/models/controlloop/concepts/ControlLoopElementDefinition.java delete mode 100644 models/src/main/java/org/onap/policy/clamp/controlloop/models/controlloop/concepts/ControlLoopInfo.java delete mode 100644 models/src/main/java/org/onap/policy/clamp/controlloop/models/controlloop/concepts/ControlLoopOrderedState.java delete mode 100644 models/src/main/java/org/onap/policy/clamp/controlloop/models/controlloop/concepts/ControlLoopState.java delete mode 100644 models/src/main/java/org/onap/policy/clamp/controlloop/models/controlloop/concepts/ControlLoopStatistics.java delete mode 100644 models/src/main/java/org/onap/policy/clamp/controlloop/models/controlloop/concepts/ControlLoops.java delete mode 100644 models/src/main/java/org/onap/policy/clamp/controlloop/models/controlloop/concepts/Participant.java delete mode 100644 models/src/main/java/org/onap/policy/clamp/controlloop/models/controlloop/concepts/ParticipantDefinition.java delete mode 100644 models/src/main/java/org/onap/policy/clamp/controlloop/models/controlloop/concepts/ParticipantHealthStatus.java delete mode 100644 models/src/main/java/org/onap/policy/clamp/controlloop/models/controlloop/concepts/ParticipantState.java delete mode 100644 models/src/main/java/org/onap/policy/clamp/controlloop/models/controlloop/concepts/ParticipantStatistics.java delete mode 100644 models/src/main/java/org/onap/policy/clamp/controlloop/models/controlloop/concepts/ParticipantStatisticsList.java delete mode 100644 models/src/main/java/org/onap/policy/clamp/controlloop/models/controlloop/concepts/ParticipantUpdates.java delete mode 100644 models/src/main/java/org/onap/policy/clamp/controlloop/models/controlloop/concepts/ParticipantUtils.java delete mode 100644 models/src/main/java/org/onap/policy/clamp/controlloop/models/controlloop/persistence/concepts/JpaClElementStatistics.java delete mode 100644 models/src/main/java/org/onap/policy/clamp/controlloop/models/controlloop/persistence/concepts/JpaControlLoop.java delete mode 100644 models/src/main/java/org/onap/policy/clamp/controlloop/models/controlloop/persistence/concepts/JpaControlLoopElement.java delete mode 100644 models/src/main/java/org/onap/policy/clamp/controlloop/models/controlloop/persistence/concepts/JpaParticipant.java delete mode 100644 models/src/main/java/org/onap/policy/clamp/controlloop/models/controlloop/persistence/concepts/JpaParticipantStatistics.java delete mode 100644 models/src/main/java/org/onap/policy/clamp/controlloop/models/controlloop/persistence/provider/ClElementStatisticsProvider.java delete mode 100644 models/src/main/java/org/onap/policy/clamp/controlloop/models/controlloop/persistence/provider/ControlLoopProvider.java delete mode 100644 models/src/main/java/org/onap/policy/clamp/controlloop/models/controlloop/persistence/provider/ParticipantProvider.java delete mode 100644 models/src/main/java/org/onap/policy/clamp/controlloop/models/controlloop/persistence/provider/ParticipantStatisticsProvider.java delete mode 100644 models/src/main/java/org/onap/policy/clamp/controlloop/models/controlloop/persistence/provider/ProviderUtils.java delete mode 100644 models/src/main/java/org/onap/policy/clamp/controlloop/models/controlloop/persistence/provider/ServiceTemplateProvider.java delete mode 100644 models/src/main/java/org/onap/policy/clamp/controlloop/models/controlloop/persistence/repository/ClElementStatisticsRepository.java delete mode 100644 models/src/main/java/org/onap/policy/clamp/controlloop/models/controlloop/persistence/repository/ControlLoopRepository.java delete mode 100644 models/src/main/java/org/onap/policy/clamp/controlloop/models/controlloop/persistence/repository/FilterRepository.java delete mode 100644 models/src/main/java/org/onap/policy/clamp/controlloop/models/controlloop/persistence/repository/FilterRepositoryImpl.java delete mode 100644 models/src/main/java/org/onap/policy/clamp/controlloop/models/controlloop/persistence/repository/ParticipantRepository.java delete mode 100644 models/src/main/java/org/onap/policy/clamp/controlloop/models/controlloop/persistence/repository/ParticipantStatisticsRepository.java delete mode 100644 models/src/main/java/org/onap/policy/clamp/controlloop/models/controlloop/persistence/repository/ToscaNodeTemplateRepository.java delete mode 100644 models/src/main/java/org/onap/policy/clamp/controlloop/models/controlloop/persistence/repository/ToscaNodeTemplatesRepository.java delete mode 100644 models/src/main/java/org/onap/policy/clamp/controlloop/models/controlloop/persistence/repository/ToscaServiceTemplateRepository.java delete mode 100644 models/src/main/java/org/onap/policy/clamp/controlloop/models/messages/dmaap/notification/ControlLoopNotification.java delete mode 100644 models/src/main/java/org/onap/policy/clamp/controlloop/models/messages/dmaap/notification/ControlLoopStatus.java delete mode 100644 models/src/main/java/org/onap/policy/clamp/controlloop/models/messages/dmaap/participant/ControlLoopAck.java delete mode 100644 models/src/main/java/org/onap/policy/clamp/controlloop/models/messages/dmaap/participant/ControlLoopStateChange.java delete mode 100644 models/src/main/java/org/onap/policy/clamp/controlloop/models/messages/dmaap/participant/ControlLoopUpdate.java delete mode 100644 models/src/main/java/org/onap/policy/clamp/controlloop/models/messages/dmaap/participant/ParticipantAckMessage.java delete mode 100644 models/src/main/java/org/onap/policy/clamp/controlloop/models/messages/dmaap/participant/ParticipantDeregister.java delete mode 100644 models/src/main/java/org/onap/policy/clamp/controlloop/models/messages/dmaap/participant/ParticipantDeregisterAck.java delete mode 100644 models/src/main/java/org/onap/policy/clamp/controlloop/models/messages/dmaap/participant/ParticipantMessage.java delete mode 100644 models/src/main/java/org/onap/policy/clamp/controlloop/models/messages/dmaap/participant/ParticipantMessageType.java delete mode 100644 models/src/main/java/org/onap/policy/clamp/controlloop/models/messages/dmaap/participant/ParticipantRegister.java delete mode 100644 models/src/main/java/org/onap/policy/clamp/controlloop/models/messages/dmaap/participant/ParticipantRegisterAck.java delete mode 100644 models/src/main/java/org/onap/policy/clamp/controlloop/models/messages/dmaap/participant/ParticipantResponseStatus.java delete mode 100644 models/src/main/java/org/onap/policy/clamp/controlloop/models/messages/dmaap/participant/ParticipantStatus.java delete mode 100644 models/src/main/java/org/onap/policy/clamp/controlloop/models/messages/dmaap/participant/ParticipantStatusReq.java delete mode 100644 models/src/main/java/org/onap/policy/clamp/controlloop/models/messages/dmaap/participant/ParticipantUpdate.java delete mode 100644 models/src/main/java/org/onap/policy/clamp/controlloop/models/messages/dmaap/participant/ParticipantUpdateAck.java delete mode 100644 models/src/main/java/org/onap/policy/clamp/controlloop/models/messages/rest/GenericNameVersion.java delete mode 100644 models/src/main/java/org/onap/policy/clamp/controlloop/models/messages/rest/SimpleResponse.java delete mode 100644 models/src/main/java/org/onap/policy/clamp/controlloop/models/messages/rest/TypedSimpleResponse.java delete mode 100644 models/src/main/java/org/onap/policy/clamp/controlloop/models/messages/rest/commissioning/CommissioningResponse.java delete mode 100644 models/src/main/java/org/onap/policy/clamp/controlloop/models/messages/rest/instantiation/ControlLoopOrderStateResponse.java delete mode 100644 models/src/main/java/org/onap/policy/clamp/controlloop/models/messages/rest/instantiation/ControlLoopPrimed.java delete mode 100644 models/src/main/java/org/onap/policy/clamp/controlloop/models/messages/rest/instantiation/ControlLoopPrimedResponse.java delete mode 100644 models/src/main/java/org/onap/policy/clamp/controlloop/models/messages/rest/instantiation/InstancePropertiesResponse.java delete mode 100644 models/src/main/java/org/onap/policy/clamp/controlloop/models/messages/rest/instantiation/InstantiationCommand.java delete mode 100644 models/src/main/java/org/onap/policy/clamp/controlloop/models/messages/rest/instantiation/InstantiationOrderStateResponse.java delete mode 100644 models/src/main/java/org/onap/policy/clamp/controlloop/models/messages/rest/instantiation/InstantiationResponse.java delete mode 100644 models/src/main/java/org/onap/policy/clamp/controlloop/models/rest/RestUtils.java create mode 100644 models/src/main/java/org/onap/policy/clamp/models/acm/concepts/AcElementStatistics.java create mode 100644 models/src/main/java/org/onap/policy/clamp/models/acm/concepts/AcElementStatisticsList.java create mode 100644 models/src/main/java/org/onap/policy/clamp/models/acm/concepts/AutomationComposition.java create mode 100644 models/src/main/java/org/onap/policy/clamp/models/acm/concepts/AutomationCompositionElement.java create mode 100644 models/src/main/java/org/onap/policy/clamp/models/acm/concepts/AutomationCompositionElementAck.java create mode 100644 models/src/main/java/org/onap/policy/clamp/models/acm/concepts/AutomationCompositionElementDefinition.java create mode 100644 models/src/main/java/org/onap/policy/clamp/models/acm/concepts/AutomationCompositionInfo.java create mode 100644 models/src/main/java/org/onap/policy/clamp/models/acm/concepts/AutomationCompositionOrderedState.java create mode 100644 models/src/main/java/org/onap/policy/clamp/models/acm/concepts/AutomationCompositionState.java create mode 100644 models/src/main/java/org/onap/policy/clamp/models/acm/concepts/AutomationCompositionStatistics.java create mode 100644 models/src/main/java/org/onap/policy/clamp/models/acm/concepts/AutomationCompositions.java create mode 100644 models/src/main/java/org/onap/policy/clamp/models/acm/concepts/Participant.java create mode 100644 models/src/main/java/org/onap/policy/clamp/models/acm/concepts/ParticipantDefinition.java create mode 100644 models/src/main/java/org/onap/policy/clamp/models/acm/concepts/ParticipantHealthStatus.java create mode 100644 models/src/main/java/org/onap/policy/clamp/models/acm/concepts/ParticipantState.java create mode 100644 models/src/main/java/org/onap/policy/clamp/models/acm/concepts/ParticipantStatistics.java create mode 100644 models/src/main/java/org/onap/policy/clamp/models/acm/concepts/ParticipantStatisticsList.java create mode 100644 models/src/main/java/org/onap/policy/clamp/models/acm/concepts/ParticipantUpdates.java create mode 100644 models/src/main/java/org/onap/policy/clamp/models/acm/concepts/ParticipantUtils.java create mode 100644 models/src/main/java/org/onap/policy/clamp/models/acm/messages/dmaap/notification/AutomationCompositionNotification.java create mode 100644 models/src/main/java/org/onap/policy/clamp/models/acm/messages/dmaap/notification/AutomationCompositionStatus.java create mode 100644 models/src/main/java/org/onap/policy/clamp/models/acm/messages/dmaap/participant/AutomationCompositionAck.java create mode 100644 models/src/main/java/org/onap/policy/clamp/models/acm/messages/dmaap/participant/AutomationCompositionStateChange.java create mode 100644 models/src/main/java/org/onap/policy/clamp/models/acm/messages/dmaap/participant/AutomationCompositionUpdate.java create mode 100644 models/src/main/java/org/onap/policy/clamp/models/acm/messages/dmaap/participant/ParticipantAckMessage.java create mode 100644 models/src/main/java/org/onap/policy/clamp/models/acm/messages/dmaap/participant/ParticipantDeregister.java create mode 100644 models/src/main/java/org/onap/policy/clamp/models/acm/messages/dmaap/participant/ParticipantDeregisterAck.java create mode 100644 models/src/main/java/org/onap/policy/clamp/models/acm/messages/dmaap/participant/ParticipantMessage.java create mode 100644 models/src/main/java/org/onap/policy/clamp/models/acm/messages/dmaap/participant/ParticipantMessageType.java create mode 100644 models/src/main/java/org/onap/policy/clamp/models/acm/messages/dmaap/participant/ParticipantRegister.java create mode 100644 models/src/main/java/org/onap/policy/clamp/models/acm/messages/dmaap/participant/ParticipantRegisterAck.java create mode 100644 models/src/main/java/org/onap/policy/clamp/models/acm/messages/dmaap/participant/ParticipantResponseStatus.java create mode 100644 models/src/main/java/org/onap/policy/clamp/models/acm/messages/dmaap/participant/ParticipantStatus.java create mode 100644 models/src/main/java/org/onap/policy/clamp/models/acm/messages/dmaap/participant/ParticipantStatusReq.java create mode 100644 models/src/main/java/org/onap/policy/clamp/models/acm/messages/dmaap/participant/ParticipantUpdate.java create mode 100644 models/src/main/java/org/onap/policy/clamp/models/acm/messages/dmaap/participant/ParticipantUpdateAck.java create mode 100644 models/src/main/java/org/onap/policy/clamp/models/acm/messages/rest/GenericNameVersion.java create mode 100644 models/src/main/java/org/onap/policy/clamp/models/acm/messages/rest/SimpleResponse.java create mode 100644 models/src/main/java/org/onap/policy/clamp/models/acm/messages/rest/TypedSimpleResponse.java create mode 100644 models/src/main/java/org/onap/policy/clamp/models/acm/messages/rest/commissioning/CommissioningResponse.java create mode 100644 models/src/main/java/org/onap/policy/clamp/models/acm/messages/rest/instantiation/AutomationCompositionOrderStateResponse.java create mode 100644 models/src/main/java/org/onap/policy/clamp/models/acm/messages/rest/instantiation/AutomationCompositionPrimed.java create mode 100644 models/src/main/java/org/onap/policy/clamp/models/acm/messages/rest/instantiation/AutomationCompositionPrimedResponse.java create mode 100644 models/src/main/java/org/onap/policy/clamp/models/acm/messages/rest/instantiation/InstancePropertiesResponse.java create mode 100644 models/src/main/java/org/onap/policy/clamp/models/acm/messages/rest/instantiation/InstantiationCommand.java create mode 100644 models/src/main/java/org/onap/policy/clamp/models/acm/messages/rest/instantiation/InstantiationOrderStateResponse.java create mode 100644 models/src/main/java/org/onap/policy/clamp/models/acm/messages/rest/instantiation/InstantiationResponse.java create mode 100644 models/src/main/java/org/onap/policy/clamp/models/acm/persistence/concepts/JpaAcElementStatistics.java create mode 100644 models/src/main/java/org/onap/policy/clamp/models/acm/persistence/concepts/JpaAutomationComposition.java create mode 100644 models/src/main/java/org/onap/policy/clamp/models/acm/persistence/concepts/JpaAutomationCompositionElement.java create mode 100644 models/src/main/java/org/onap/policy/clamp/models/acm/persistence/concepts/JpaParticipant.java create mode 100644 models/src/main/java/org/onap/policy/clamp/models/acm/persistence/concepts/JpaParticipantStatistics.java create mode 100644 models/src/main/java/org/onap/policy/clamp/models/acm/persistence/provider/AcElementStatisticsProvider.java create mode 100644 models/src/main/java/org/onap/policy/clamp/models/acm/persistence/provider/AutomationCompositionProvider.java create mode 100644 models/src/main/java/org/onap/policy/clamp/models/acm/persistence/provider/ParticipantProvider.java create mode 100644 models/src/main/java/org/onap/policy/clamp/models/acm/persistence/provider/ParticipantStatisticsProvider.java create mode 100644 models/src/main/java/org/onap/policy/clamp/models/acm/persistence/provider/ProviderUtils.java create mode 100644 models/src/main/java/org/onap/policy/clamp/models/acm/persistence/provider/ServiceTemplateProvider.java create mode 100644 models/src/main/java/org/onap/policy/clamp/models/acm/persistence/repository/AcElementStatisticsRepository.java create mode 100644 models/src/main/java/org/onap/policy/clamp/models/acm/persistence/repository/AutomationCompositionRepository.java create mode 100644 models/src/main/java/org/onap/policy/clamp/models/acm/persistence/repository/FilterRepository.java create mode 100644 models/src/main/java/org/onap/policy/clamp/models/acm/persistence/repository/FilterRepositoryImpl.java create mode 100644 models/src/main/java/org/onap/policy/clamp/models/acm/persistence/repository/ParticipantRepository.java create mode 100644 models/src/main/java/org/onap/policy/clamp/models/acm/persistence/repository/ParticipantStatisticsRepository.java create mode 100644 models/src/main/java/org/onap/policy/clamp/models/acm/persistence/repository/ToscaNodeTemplateRepository.java create mode 100644 models/src/main/java/org/onap/policy/clamp/models/acm/persistence/repository/ToscaNodeTemplatesRepository.java create mode 100644 models/src/main/java/org/onap/policy/clamp/models/acm/persistence/repository/ToscaServiceTemplateRepository.java create mode 100644 models/src/main/java/org/onap/policy/clamp/models/acm/rest/RestUtils.java create mode 100644 models/src/main/java/org/onap/policy/clamp/models/acm/utils/AcmUtils.java delete mode 100644 models/src/test/java/org/onap/policy/clamp/controlloop/models/controlloop/concepts/ClElementStatisticsTest.java delete mode 100644 models/src/test/java/org/onap/policy/clamp/controlloop/models/controlloop/concepts/ControlLoopConceptPojosTest.java delete mode 100644 models/src/test/java/org/onap/policy/clamp/controlloop/models/controlloop/concepts/ControlLoopElementTest.java delete mode 100644 models/src/test/java/org/onap/policy/clamp/controlloop/models/controlloop/concepts/ControlLoopTest.java delete mode 100644 models/src/test/java/org/onap/policy/clamp/controlloop/models/controlloop/concepts/ParticipantStatisticsTest.java delete mode 100644 models/src/test/java/org/onap/policy/clamp/controlloop/models/controlloop/concepts/ParticipantTest.java delete mode 100644 models/src/test/java/org/onap/policy/clamp/controlloop/models/controlloop/concepts/ParticipantUtilsTest.java delete mode 100644 models/src/test/java/org/onap/policy/clamp/controlloop/models/controlloop/persistence/concepts/DummyJpaClElementStatisticsChild.java delete mode 100644 models/src/test/java/org/onap/policy/clamp/controlloop/models/controlloop/persistence/concepts/DummyJpaControlLoopChild.java delete mode 100644 models/src/test/java/org/onap/policy/clamp/controlloop/models/controlloop/persistence/concepts/DummyJpaControlLoopElementChild.java delete mode 100644 models/src/test/java/org/onap/policy/clamp/controlloop/models/controlloop/persistence/concepts/DummyJpaParticipantChild.java delete mode 100644 models/src/test/java/org/onap/policy/clamp/controlloop/models/controlloop/persistence/concepts/DummyJpaParticipantStatisticsChild.java delete mode 100644 models/src/test/java/org/onap/policy/clamp/controlloop/models/controlloop/persistence/concepts/JpaClElementStatisticsTest.java delete mode 100644 models/src/test/java/org/onap/policy/clamp/controlloop/models/controlloop/persistence/concepts/JpaControlLoopElementTest.java delete mode 100644 models/src/test/java/org/onap/policy/clamp/controlloop/models/controlloop/persistence/concepts/JpaControlLoopTest.java delete mode 100644 models/src/test/java/org/onap/policy/clamp/controlloop/models/controlloop/persistence/concepts/JpaParticipantStatisticsTest.java delete mode 100644 models/src/test/java/org/onap/policy/clamp/controlloop/models/controlloop/persistence/concepts/JpaParticipantTest.java delete mode 100644 models/src/test/java/org/onap/policy/clamp/controlloop/models/controlloop/persistence/concepts/PojosTest.java delete mode 100644 models/src/test/java/org/onap/policy/clamp/controlloop/models/controlloop/persistence/provider/ClElementStatisticsProviderTest.java delete mode 100644 models/src/test/java/org/onap/policy/clamp/controlloop/models/controlloop/persistence/provider/ControlLoopProviderTest.java delete mode 100644 models/src/test/java/org/onap/policy/clamp/controlloop/models/controlloop/persistence/provider/ParticipantProviderTest.java delete mode 100644 models/src/test/java/org/onap/policy/clamp/controlloop/models/controlloop/persistence/provider/ParticipantStatisticsProviderTest.java delete mode 100644 models/src/test/java/org/onap/policy/clamp/controlloop/models/controlloop/persistence/provider/ServiceTemplateProviderTest.java delete mode 100644 models/src/test/java/org/onap/policy/clamp/controlloop/models/controlloop/persistence/repository/FilterRepositoryImplTest.java delete mode 100644 models/src/test/java/org/onap/policy/clamp/controlloop/models/messages/dmaap/notification/ControlLoopNotificationTest.java delete mode 100644 models/src/test/java/org/onap/policy/clamp/controlloop/models/messages/dmaap/notification/ControlLoopStatusTest.java delete mode 100644 models/src/test/java/org/onap/policy/clamp/controlloop/models/messages/dmaap/notification/NotificationPojosTest.java delete mode 100644 models/src/test/java/org/onap/policy/clamp/controlloop/models/messages/dmaap/participant/ControlLoopAckTest.java delete mode 100644 models/src/test/java/org/onap/policy/clamp/controlloop/models/messages/dmaap/participant/ControlLoopStateChangeTest.java delete mode 100644 models/src/test/java/org/onap/policy/clamp/controlloop/models/messages/dmaap/participant/ControlLoopUpdateTest.java delete mode 100644 models/src/test/java/org/onap/policy/clamp/controlloop/models/messages/dmaap/participant/ParticipantAckMessageTest.java delete mode 100644 models/src/test/java/org/onap/policy/clamp/controlloop/models/messages/dmaap/participant/ParticipantDeregisterAckTest.java delete mode 100644 models/src/test/java/org/onap/policy/clamp/controlloop/models/messages/dmaap/participant/ParticipantDeregisterTest.java delete mode 100644 models/src/test/java/org/onap/policy/clamp/controlloop/models/messages/dmaap/participant/ParticipantMessageTest.java delete mode 100644 models/src/test/java/org/onap/policy/clamp/controlloop/models/messages/dmaap/participant/ParticipantMessageUtils.java delete mode 100644 models/src/test/java/org/onap/policy/clamp/controlloop/models/messages/dmaap/participant/ParticipantPojosTest.java delete mode 100644 models/src/test/java/org/onap/policy/clamp/controlloop/models/messages/dmaap/participant/ParticipantRegisterAckTest.java delete mode 100644 models/src/test/java/org/onap/policy/clamp/controlloop/models/messages/dmaap/participant/ParticipantRegisterTest.java delete mode 100644 models/src/test/java/org/onap/policy/clamp/controlloop/models/messages/dmaap/participant/ParticipantStatusReqTest.java delete mode 100644 models/src/test/java/org/onap/policy/clamp/controlloop/models/messages/dmaap/participant/ParticipantStatusTest.java delete mode 100644 models/src/test/java/org/onap/policy/clamp/controlloop/models/messages/dmaap/participant/ParticipantUpdateAckTest.java delete mode 100644 models/src/test/java/org/onap/policy/clamp/controlloop/models/messages/dmaap/participant/ParticipantUpdateTest.java delete mode 100644 models/src/test/java/org/onap/policy/clamp/controlloop/models/messages/rest/MessagesRestPojosTest.java delete mode 100644 models/src/test/java/org/onap/policy/clamp/controlloop/models/messages/rest/instantiation/InstantiationCommandTest.java delete mode 100644 models/src/test/java/org/onap/policy/clamp/controlloop/models/rest/RestUtilsTest.java create mode 100644 models/src/test/java/org/onap/policy/clamp/models/acm/concepts/AcElementStatisticsTest.java create mode 100644 models/src/test/java/org/onap/policy/clamp/models/acm/concepts/AutomationCompositionConceptPojosTest.java create mode 100644 models/src/test/java/org/onap/policy/clamp/models/acm/concepts/AutomationCompositionElementTest.java create mode 100644 models/src/test/java/org/onap/policy/clamp/models/acm/concepts/AutomationCompositionTest.java create mode 100644 models/src/test/java/org/onap/policy/clamp/models/acm/concepts/ParticipantStatisticsTest.java create mode 100644 models/src/test/java/org/onap/policy/clamp/models/acm/concepts/ParticipantTest.java create mode 100644 models/src/test/java/org/onap/policy/clamp/models/acm/concepts/ParticipantUtilsTest.java create mode 100644 models/src/test/java/org/onap/policy/clamp/models/acm/messages/dmaap/notification/AutomationCompositionNotificationTest.java create mode 100644 models/src/test/java/org/onap/policy/clamp/models/acm/messages/dmaap/notification/AutomationCompositionStatusTest.java create mode 100644 models/src/test/java/org/onap/policy/clamp/models/acm/messages/dmaap/notification/NotificationPojosTest.java create mode 100644 models/src/test/java/org/onap/policy/clamp/models/acm/messages/dmaap/participant/AutomationCompositionAckTest.java create mode 100644 models/src/test/java/org/onap/policy/clamp/models/acm/messages/dmaap/participant/AutomationCompositionStateChangeTest.java create mode 100644 models/src/test/java/org/onap/policy/clamp/models/acm/messages/dmaap/participant/AutomationCompositionUpdateTest.java create mode 100644 models/src/test/java/org/onap/policy/clamp/models/acm/messages/dmaap/participant/ParticipantAckMessageTest.java create mode 100644 models/src/test/java/org/onap/policy/clamp/models/acm/messages/dmaap/participant/ParticipantDeregisterAckTest.java create mode 100644 models/src/test/java/org/onap/policy/clamp/models/acm/messages/dmaap/participant/ParticipantDeregisterTest.java create mode 100644 models/src/test/java/org/onap/policy/clamp/models/acm/messages/dmaap/participant/ParticipantMessageTest.java create mode 100644 models/src/test/java/org/onap/policy/clamp/models/acm/messages/dmaap/participant/ParticipantMessageUtils.java create mode 100644 models/src/test/java/org/onap/policy/clamp/models/acm/messages/dmaap/participant/ParticipantPojosTest.java create mode 100644 models/src/test/java/org/onap/policy/clamp/models/acm/messages/dmaap/participant/ParticipantRegisterAckTest.java create mode 100644 models/src/test/java/org/onap/policy/clamp/models/acm/messages/dmaap/participant/ParticipantRegisterTest.java create mode 100644 models/src/test/java/org/onap/policy/clamp/models/acm/messages/dmaap/participant/ParticipantStatusReqTest.java create mode 100644 models/src/test/java/org/onap/policy/clamp/models/acm/messages/dmaap/participant/ParticipantStatusTest.java create mode 100644 models/src/test/java/org/onap/policy/clamp/models/acm/messages/dmaap/participant/ParticipantUpdateAckTest.java create mode 100644 models/src/test/java/org/onap/policy/clamp/models/acm/messages/dmaap/participant/ParticipantUpdateTest.java create mode 100644 models/src/test/java/org/onap/policy/clamp/models/acm/messages/rest/MessagesRestPojosTest.java create mode 100644 models/src/test/java/org/onap/policy/clamp/models/acm/messages/rest/instantiation/InstantiationCommandTest.java create mode 100644 models/src/test/java/org/onap/policy/clamp/models/acm/persistence/concepts/DummyJpaAcElementStatisticsChild.java create mode 100644 models/src/test/java/org/onap/policy/clamp/models/acm/persistence/concepts/DummyJpaAutomationCompositionChild.java create mode 100644 models/src/test/java/org/onap/policy/clamp/models/acm/persistence/concepts/DummyJpaAutomationCompositionElementChild.java create mode 100644 models/src/test/java/org/onap/policy/clamp/models/acm/persistence/concepts/DummyJpaParticipantChild.java create mode 100644 models/src/test/java/org/onap/policy/clamp/models/acm/persistence/concepts/DummyJpaParticipantStatisticsChild.java create mode 100644 models/src/test/java/org/onap/policy/clamp/models/acm/persistence/concepts/JpaAcElementStatisticsTest.java create mode 100644 models/src/test/java/org/onap/policy/clamp/models/acm/persistence/concepts/JpaAutomationCompositionElementTest.java create mode 100644 models/src/test/java/org/onap/policy/clamp/models/acm/persistence/concepts/JpaAutomationCompositionTest.java create mode 100644 models/src/test/java/org/onap/policy/clamp/models/acm/persistence/concepts/JpaParticipantStatisticsTest.java create mode 100644 models/src/test/java/org/onap/policy/clamp/models/acm/persistence/concepts/JpaParticipantTest.java create mode 100644 models/src/test/java/org/onap/policy/clamp/models/acm/persistence/concepts/PojosTest.java create mode 100644 models/src/test/java/org/onap/policy/clamp/models/acm/persistence/provider/AcElementStatisticsProviderTest.java create mode 100644 models/src/test/java/org/onap/policy/clamp/models/acm/persistence/provider/AutomationCompositionProviderTest.java create mode 100644 models/src/test/java/org/onap/policy/clamp/models/acm/persistence/provider/ParticipantProviderTest.java create mode 100644 models/src/test/java/org/onap/policy/clamp/models/acm/persistence/provider/ParticipantStatisticsProviderTest.java create mode 100644 models/src/test/java/org/onap/policy/clamp/models/acm/persistence/provider/ServiceTemplateProviderTest.java create mode 100644 models/src/test/java/org/onap/policy/clamp/models/acm/persistence/repository/FilterRepositoryImplTest.java create mode 100644 models/src/test/java/org/onap/policy/clamp/models/acm/rest/RestUtilsTest.java create mode 100644 models/src/test/java/org/onap/policy/clamp/models/acm/utils/AcmUtilsTest.java create mode 100644 models/src/test/resources/examples/acm/PMSubscriptionHandling.yaml delete mode 100644 models/src/test/resources/examples/controlloop/PMSubscriptionHandling.yaml create mode 100644 models/src/test/resources/json/AutomationCompositionElementNoOrderedState.json create mode 100644 models/src/test/resources/json/AutomationCompositionNoOrderedState.json delete mode 100644 models/src/test/resources/json/ControlLoopElementNoOrderedState.json delete mode 100644 models/src/test/resources/json/ControlLoopNoOrderedState.json create mode 100644 models/src/test/resources/providers/TestAcElementStatistics.json create mode 100644 models/src/test/resources/providers/TestAutomationCompositions.json delete mode 100644 models/src/test/resources/providers/TestClElementStatistics.json delete mode 100644 models/src/test/resources/providers/TestControlLoops.json create mode 100644 models/src/test/resources/providers/UpdateAutomationCompositions.json delete mode 100644 models/src/test/resources/providers/UpdateControlLoops.json create mode 100644 packages/policy-clamp-docker/src/main/docker/AcmRuntimeDockerfile delete mode 100644 packages/policy-clamp-docker/src/main/docker/ClRuntimeDockerfile create mode 100644 packages/policy-clamp-docker/src/main/docker/acm-runtime.sh delete mode 100644 packages/policy-clamp-docker/src/main/docker/controlloop-runtime.sh create mode 100644 packages/policy-clamp-tarball/src/main/resources/etc/AcRuntimeParameters.yaml delete mode 100644 packages/policy-clamp-tarball/src/main/resources/etc/ClRuntimeParameters.yaml create mode 100644 participant/participant-impl/participant-impl-http/src/main/java/org/onap/policy/clamp/acm/participant/http/Application.java create mode 100644 participant/participant-impl/participant-impl-http/src/main/java/org/onap/policy/clamp/acm/participant/http/config/ParticipantConfig.java create mode 100644 participant/participant-impl/participant-impl-http/src/main/java/org/onap/policy/clamp/acm/participant/http/config/SecurityConfig.java create mode 100644 participant/participant-impl/participant-impl-http/src/main/java/org/onap/policy/clamp/acm/participant/http/main/exception/HttpWebClientException.java create mode 100644 participant/participant-impl/participant-impl-http/src/main/java/org/onap/policy/clamp/acm/participant/http/main/handler/AutomationCompositionElementHandler.java create mode 100644 participant/participant-impl/participant-impl-http/src/main/java/org/onap/policy/clamp/acm/participant/http/main/models/ConfigRequest.java create mode 100644 participant/participant-impl/participant-impl-http/src/main/java/org/onap/policy/clamp/acm/participant/http/main/models/ConfigurationEntity.java create mode 100644 participant/participant-impl/participant-impl-http/src/main/java/org/onap/policy/clamp/acm/participant/http/main/models/RestParams.java create mode 100644 participant/participant-impl/participant-impl-http/src/main/java/org/onap/policy/clamp/acm/participant/http/main/webclient/AcHttpClient.java create mode 100644 participant/participant-impl/participant-impl-http/src/main/java/org/onap/policy/clamp/acm/participant/http/parameters/ParticipantHttpParameters.java delete mode 100644 participant/participant-impl/participant-impl-http/src/main/java/org/onap/policy/clamp/controlloop/participant/http/Application.java delete mode 100644 participant/participant-impl/participant-impl-http/src/main/java/org/onap/policy/clamp/controlloop/participant/http/config/ParticipantConfig.java delete mode 100644 participant/participant-impl/participant-impl-http/src/main/java/org/onap/policy/clamp/controlloop/participant/http/config/SecurityConfig.java delete mode 100644 participant/participant-impl/participant-impl-http/src/main/java/org/onap/policy/clamp/controlloop/participant/http/main/exception/HttpWebClientException.java delete mode 100644 participant/participant-impl/participant-impl-http/src/main/java/org/onap/policy/clamp/controlloop/participant/http/main/handler/ControlLoopElementHandler.java delete mode 100644 participant/participant-impl/participant-impl-http/src/main/java/org/onap/policy/clamp/controlloop/participant/http/main/models/ConfigRequest.java delete mode 100644 participant/participant-impl/participant-impl-http/src/main/java/org/onap/policy/clamp/controlloop/participant/http/main/models/ConfigurationEntity.java delete mode 100644 participant/participant-impl/participant-impl-http/src/main/java/org/onap/policy/clamp/controlloop/participant/http/main/models/RestParams.java delete mode 100644 participant/participant-impl/participant-impl-http/src/main/java/org/onap/policy/clamp/controlloop/participant/http/main/webclient/ClHttpClient.java delete mode 100644 participant/participant-impl/participant-impl-http/src/main/java/org/onap/policy/clamp/controlloop/participant/http/parameters/ParticipantHttpParameters.java create mode 100644 participant/participant-impl/participant-impl-http/src/test/java/org/onap/policy/clamp/acm/participant/http/handler/AcElementHandlerTest.java create mode 100644 participant/participant-impl/participant-impl-http/src/test/java/org/onap/policy/clamp/acm/participant/http/rest/ActuatorControllerTest.java create mode 100644 participant/participant-impl/participant-impl-http/src/test/java/org/onap/policy/clamp/acm/participant/http/utils/CommonActuatorController.java create mode 100644 participant/participant-impl/participant-impl-http/src/test/java/org/onap/policy/clamp/acm/participant/http/utils/CommonTestData.java create mode 100644 participant/participant-impl/participant-impl-http/src/test/java/org/onap/policy/clamp/acm/participant/http/utils/ToscaUtils.java create mode 100644 participant/participant-impl/participant-impl-http/src/test/java/org/onap/policy/clamp/acm/participant/http/webclient/AcHttpClientTest.java delete mode 100644 participant/participant-impl/participant-impl-http/src/test/java/org/onap/policy/clamp/controlloop/participant/http/handler/ClElementHandlerTest.java delete mode 100644 participant/participant-impl/participant-impl-http/src/test/java/org/onap/policy/clamp/controlloop/participant/http/rest/ActuatorControllerTest.java delete mode 100644 participant/participant-impl/participant-impl-http/src/test/java/org/onap/policy/clamp/controlloop/participant/http/utils/CommonActuatorController.java delete mode 100644 participant/participant-impl/participant-impl-http/src/test/java/org/onap/policy/clamp/controlloop/participant/http/utils/CommonTestData.java delete mode 100644 participant/participant-impl/participant-impl-http/src/test/java/org/onap/policy/clamp/controlloop/participant/http/utils/ToscaUtils.java delete mode 100644 participant/participant-impl/participant-impl-http/src/test/java/org/onap/policy/clamp/controlloop/participant/http/webclient/ClHttpClientTest.java create mode 100644 participant/participant-impl/participant-impl-kubernetes/src/main/java/org/onap/policy/clamp/acm/participant/kubernetes/Application.java create mode 100644 participant/participant-impl/participant-impl-kubernetes/src/main/java/org/onap/policy/clamp/acm/participant/kubernetes/configurations/ParticipantConfig.java create mode 100644 participant/participant-impl/participant-impl-kubernetes/src/main/java/org/onap/policy/clamp/acm/participant/kubernetes/configurations/ParticipantIntermediaryConfig.java create mode 100644 participant/participant-impl/participant-impl-kubernetes/src/main/java/org/onap/policy/clamp/acm/participant/kubernetes/configurations/SecurityConfig.java create mode 100644 participant/participant-impl/participant-impl-kubernetes/src/main/java/org/onap/policy/clamp/acm/participant/kubernetes/configurations/SpringFoxConfig.java create mode 100644 participant/participant-impl/participant-impl-kubernetes/src/main/java/org/onap/policy/clamp/acm/participant/kubernetes/controller/ChartController.java create mode 100644 participant/participant-impl/participant-impl-kubernetes/src/main/java/org/onap/policy/clamp/acm/participant/kubernetes/exception/ServiceException.java create mode 100644 participant/participant-impl/participant-impl-kubernetes/src/main/java/org/onap/policy/clamp/acm/participant/kubernetes/handler/AutomationCompositionElementHandler.java create mode 100644 participant/participant-impl/participant-impl-kubernetes/src/main/java/org/onap/policy/clamp/acm/participant/kubernetes/helm/HelmClient.java create mode 100644 participant/participant-impl/participant-impl-kubernetes/src/main/java/org/onap/policy/clamp/acm/participant/kubernetes/helm/PodStatusValidator.java create mode 100644 participant/participant-impl/participant-impl-kubernetes/src/main/java/org/onap/policy/clamp/acm/participant/kubernetes/models/ChartInfo.java create mode 100644 participant/participant-impl/participant-impl-kubernetes/src/main/java/org/onap/policy/clamp/acm/participant/kubernetes/models/ChartList.java create mode 100644 participant/participant-impl/participant-impl-kubernetes/src/main/java/org/onap/policy/clamp/acm/participant/kubernetes/models/HelmRepository.java create mode 100644 participant/participant-impl/participant-impl-kubernetes/src/main/java/org/onap/policy/clamp/acm/participant/kubernetes/models/InstallationInfo.java create mode 100644 participant/participant-impl/participant-impl-kubernetes/src/main/java/org/onap/policy/clamp/acm/participant/kubernetes/parameters/ParticipantK8sParameters.java create mode 100644 participant/participant-impl/participant-impl-kubernetes/src/main/java/org/onap/policy/clamp/acm/participant/kubernetes/service/ChartService.java create mode 100644 participant/participant-impl/participant-impl-kubernetes/src/main/java/org/onap/policy/clamp/acm/participant/kubernetes/service/ChartStore.java delete mode 100644 participant/participant-impl/participant-impl-kubernetes/src/main/java/org/onap/policy/clamp/controlloop/participant/kubernetes/Application.java delete mode 100644 participant/participant-impl/participant-impl-kubernetes/src/main/java/org/onap/policy/clamp/controlloop/participant/kubernetes/configurations/ParticipantConfig.java delete mode 100644 participant/participant-impl/participant-impl-kubernetes/src/main/java/org/onap/policy/clamp/controlloop/participant/kubernetes/configurations/ParticipantIntermediaryConfig.java delete mode 100644 participant/participant-impl/participant-impl-kubernetes/src/main/java/org/onap/policy/clamp/controlloop/participant/kubernetes/configurations/SecurityConfig.java delete mode 100644 participant/participant-impl/participant-impl-kubernetes/src/main/java/org/onap/policy/clamp/controlloop/participant/kubernetes/configurations/SpringFoxConfig.java delete mode 100644 participant/participant-impl/participant-impl-kubernetes/src/main/java/org/onap/policy/clamp/controlloop/participant/kubernetes/controller/ChartController.java delete mode 100644 participant/participant-impl/participant-impl-kubernetes/src/main/java/org/onap/policy/clamp/controlloop/participant/kubernetes/exception/ServiceException.java delete mode 100644 participant/participant-impl/participant-impl-kubernetes/src/main/java/org/onap/policy/clamp/controlloop/participant/kubernetes/handler/ControlLoopElementHandler.java delete mode 100644 participant/participant-impl/participant-impl-kubernetes/src/main/java/org/onap/policy/clamp/controlloop/participant/kubernetes/helm/HelmClient.java delete mode 100644 participant/participant-impl/participant-impl-kubernetes/src/main/java/org/onap/policy/clamp/controlloop/participant/kubernetes/helm/PodStatusValidator.java delete mode 100644 participant/participant-impl/participant-impl-kubernetes/src/main/java/org/onap/policy/clamp/controlloop/participant/kubernetes/models/ChartInfo.java delete mode 100644 participant/participant-impl/participant-impl-kubernetes/src/main/java/org/onap/policy/clamp/controlloop/participant/kubernetes/models/ChartList.java delete mode 100644 participant/participant-impl/participant-impl-kubernetes/src/main/java/org/onap/policy/clamp/controlloop/participant/kubernetes/models/HelmRepository.java delete mode 100644 participant/participant-impl/participant-impl-kubernetes/src/main/java/org/onap/policy/clamp/controlloop/participant/kubernetes/models/InstallationInfo.java delete mode 100644 participant/participant-impl/participant-impl-kubernetes/src/main/java/org/onap/policy/clamp/controlloop/participant/kubernetes/parameters/ParticipantK8sParameters.java delete mode 100644 participant/participant-impl/participant-impl-kubernetes/src/main/java/org/onap/policy/clamp/controlloop/participant/kubernetes/service/ChartService.java delete mode 100644 participant/participant-impl/participant-impl-kubernetes/src/main/java/org/onap/policy/clamp/controlloop/participant/kubernetes/service/ChartStore.java create mode 100644 participant/participant-impl/participant-impl-kubernetes/src/test/java/org/onap/policy/clamp/acm/participant/kubernetes/handler/AutomationCompositionElementHandlerTest.java create mode 100644 participant/participant-impl/participant-impl-kubernetes/src/test/java/org/onap/policy/clamp/acm/participant/kubernetes/helm/HelmClientTest.java create mode 100644 participant/participant-impl/participant-impl-kubernetes/src/test/java/org/onap/policy/clamp/acm/participant/kubernetes/helm/PodStatusValidatorTest.java create mode 100644 participant/participant-impl/participant-impl-kubernetes/src/test/java/org/onap/policy/clamp/acm/participant/kubernetes/parameters/CommonTestData.java create mode 100644 participant/participant-impl/participant-impl-kubernetes/src/test/java/org/onap/policy/clamp/acm/participant/kubernetes/parameters/ParticipantK8sParametersTest.java create mode 100644 participant/participant-impl/participant-impl-kubernetes/src/test/java/org/onap/policy/clamp/acm/participant/kubernetes/rest/ActuatorControllerTest.java create mode 100644 participant/participant-impl/participant-impl-kubernetes/src/test/java/org/onap/policy/clamp/acm/participant/kubernetes/rest/ChartControllerTest.java create mode 100644 participant/participant-impl/participant-impl-kubernetes/src/test/java/org/onap/policy/clamp/acm/participant/kubernetes/service/ChartServiceTest.java create mode 100644 participant/participant-impl/participant-impl-kubernetes/src/test/java/org/onap/policy/clamp/acm/participant/kubernetes/service/ChartStoreTest.java create mode 100644 participant/participant-impl/participant-impl-kubernetes/src/test/java/org/onap/policy/clamp/acm/participant/kubernetes/utils/CommonActuatorController.java create mode 100644 participant/participant-impl/participant-impl-kubernetes/src/test/java/org/onap/policy/clamp/acm/participant/kubernetes/utils/TestUtils.java delete mode 100644 participant/participant-impl/participant-impl-kubernetes/src/test/java/org/onap/policy/clamp/controlloop/participant/kubernetes/handler/ControlLoopElementHandlerTest.java delete mode 100644 participant/participant-impl/participant-impl-kubernetes/src/test/java/org/onap/policy/clamp/controlloop/participant/kubernetes/helm/HelmClientTest.java delete mode 100644 participant/participant-impl/participant-impl-kubernetes/src/test/java/org/onap/policy/clamp/controlloop/participant/kubernetes/helm/PodStatusValidatorTest.java delete mode 100644 participant/participant-impl/participant-impl-kubernetes/src/test/java/org/onap/policy/clamp/controlloop/participant/kubernetes/parameters/CommonTestData.java delete mode 100644 participant/participant-impl/participant-impl-kubernetes/src/test/java/org/onap/policy/clamp/controlloop/participant/kubernetes/parameters/ParticipantK8sParametersTest.java delete mode 100644 participant/participant-impl/participant-impl-kubernetes/src/test/java/org/onap/policy/clamp/controlloop/participant/kubernetes/rest/ActuatorControllerTest.java delete mode 100644 participant/participant-impl/participant-impl-kubernetes/src/test/java/org/onap/policy/clamp/controlloop/participant/kubernetes/rest/ChartControllerTest.java delete mode 100644 participant/participant-impl/participant-impl-kubernetes/src/test/java/org/onap/policy/clamp/controlloop/participant/kubernetes/service/ChartServiceTest.java delete mode 100644 participant/participant-impl/participant-impl-kubernetes/src/test/java/org/onap/policy/clamp/controlloop/participant/kubernetes/service/ChartStoreTest.java delete mode 100644 participant/participant-impl/participant-impl-kubernetes/src/test/java/org/onap/policy/clamp/controlloop/participant/kubernetes/utils/CommonActuatorController.java delete mode 100644 participant/participant-impl/participant-impl-kubernetes/src/test/java/org/onap/policy/clamp/controlloop/participant/kubernetes/utils/TestUtils.java create mode 100644 participant/participant-impl/participant-impl-policy/src/main/java/org/onap/policy/clamp/acm/participant/policy/PolicyParticipantApplication.java create mode 100644 participant/participant-impl/participant-impl-policy/src/main/java/org/onap/policy/clamp/acm/participant/policy/client/AbstractHttpClient.java create mode 100644 participant/participant-impl/participant-impl-policy/src/main/java/org/onap/policy/clamp/acm/participant/policy/client/PolicyApiHttpClient.java create mode 100644 participant/participant-impl/participant-impl-policy/src/main/java/org/onap/policy/clamp/acm/participant/policy/client/PolicyPapHttpClient.java create mode 100644 participant/participant-impl/participant-impl-policy/src/main/java/org/onap/policy/clamp/acm/participant/policy/config/ParticipantConfig.java create mode 100644 participant/participant-impl/participant-impl-policy/src/main/java/org/onap/policy/clamp/acm/participant/policy/config/SecurityConfig.java create mode 100644 participant/participant-impl/participant-impl-policy/src/main/java/org/onap/policy/clamp/acm/participant/policy/main/handler/AutomationCompositionElementHandler.java create mode 100644 participant/participant-impl/participant-impl-policy/src/main/java/org/onap/policy/clamp/acm/participant/policy/main/parameters/ParticipantPolicyParameters.java delete mode 100644 participant/participant-impl/participant-impl-policy/src/main/java/org/onap/policy/clamp/controlloop/participant/policy/PolicyParticipantApplication.java delete mode 100644 participant/participant-impl/participant-impl-policy/src/main/java/org/onap/policy/clamp/controlloop/participant/policy/client/AbstractHttpClient.java delete mode 100644 participant/participant-impl/participant-impl-policy/src/main/java/org/onap/policy/clamp/controlloop/participant/policy/client/PolicyApiHttpClient.java delete mode 100644 participant/participant-impl/participant-impl-policy/src/main/java/org/onap/policy/clamp/controlloop/participant/policy/client/PolicyPapHttpClient.java delete mode 100644 participant/participant-impl/participant-impl-policy/src/main/java/org/onap/policy/clamp/controlloop/participant/policy/config/ParticipantConfig.java delete mode 100644 participant/participant-impl/participant-impl-policy/src/main/java/org/onap/policy/clamp/controlloop/participant/policy/config/SecurityConfig.java delete mode 100644 participant/participant-impl/participant-impl-policy/src/main/java/org/onap/policy/clamp/controlloop/participant/policy/main/handler/ControlLoopElementHandler.java delete mode 100644 participant/participant-impl/participant-impl-policy/src/main/java/org/onap/policy/clamp/controlloop/participant/policy/main/parameters/ParticipantPolicyParameters.java create mode 100644 participant/participant-impl/participant-impl-policy/src/test/java/org/onap/policy/clamp/acm/participant/policy/endtoend/ParticipantMessagesTest.java create mode 100644 participant/participant-impl/participant-impl-policy/src/test/java/org/onap/policy/clamp/acm/participant/policy/main/handler/AutomationCompositionElementHandlerTest.java create mode 100644 participant/participant-impl/participant-impl-policy/src/test/java/org/onap/policy/clamp/acm/participant/policy/main/parameters/CommonTestData.java create mode 100644 participant/participant-impl/participant-impl-policy/src/test/java/org/onap/policy/clamp/acm/participant/policy/main/parameters/ParticipantPolicyParametersTest.java create mode 100644 participant/participant-impl/participant-impl-policy/src/test/java/org/onap/policy/clamp/acm/participant/policy/main/rest/ActuatorControllerTest.java create mode 100644 participant/participant-impl/participant-impl-policy/src/test/java/org/onap/policy/clamp/acm/participant/policy/main/utils/CommonActuatorController.java create mode 100644 participant/participant-impl/participant-impl-policy/src/test/java/org/onap/policy/clamp/acm/participant/policy/main/utils/TestListenerUtils.java delete mode 100644 participant/participant-impl/participant-impl-policy/src/test/java/org/onap/policy/clamp/controlloop/participant/policy/endtoend/ParticipantMessagesTest.java delete mode 100644 participant/participant-impl/participant-impl-policy/src/test/java/org/onap/policy/clamp/controlloop/participant/policy/main/handler/ControlLoopElementHandlerTest.java delete mode 100644 participant/participant-impl/participant-impl-policy/src/test/java/org/onap/policy/clamp/controlloop/participant/policy/main/parameters/CommonTestData.java delete mode 100644 participant/participant-impl/participant-impl-policy/src/test/java/org/onap/policy/clamp/controlloop/participant/policy/main/parameters/ParticipantPolicyParametersTest.java delete mode 100644 participant/participant-impl/participant-impl-policy/src/test/java/org/onap/policy/clamp/controlloop/participant/policy/main/rest/ActuatorControllerTest.java delete mode 100644 participant/participant-impl/participant-impl-policy/src/test/java/org/onap/policy/clamp/controlloop/participant/policy/main/utils/CommonActuatorController.java delete mode 100644 participant/participant-impl/participant-impl-policy/src/test/java/org/onap/policy/clamp/controlloop/participant/policy/main/utils/TestListenerUtils.java create mode 100644 participant/participant-impl/participant-impl-policy/src/test/resources/parameters/TestACParams.yaml delete mode 100644 participant/participant-impl/participant-impl-policy/src/test/resources/parameters/TestCLParams.yaml delete mode 100644 participant/participant-impl/participant-impl-policy/src/test/resources/policies/vCPE.policies.optimization.input.tosca.yaml delete mode 100644 participant/participant-impl/participant-impl-policy/src/test/resources/policytypes/onap.policies.Match.yaml delete mode 100644 participant/participant-impl/participant-impl-policy/src/test/resources/policytypes/onap.policies.Naming.yaml delete mode 100644 participant/participant-impl/participant-impl-policy/src/test/resources/policytypes/onap.policies.Optimization.yaml delete mode 100644 participant/participant-impl/participant-impl-policy/src/test/resources/policytypes/onap.policies.controlloop.guard.Common.yaml delete mode 100644 participant/participant-impl/participant-impl-policy/src/test/resources/policytypes/onap.policies.controlloop.guard.common.Blacklist.yaml delete mode 100644 participant/participant-impl/participant-impl-policy/src/test/resources/policytypes/onap.policies.controlloop.guard.common.Filter.yaml delete mode 100644 participant/participant-impl/participant-impl-policy/src/test/resources/policytypes/onap.policies.controlloop.guard.common.FrequencyLimiter.yaml delete mode 100644 participant/participant-impl/participant-impl-policy/src/test/resources/policytypes/onap.policies.controlloop.guard.common.MinMax.yaml delete mode 100644 participant/participant-impl/participant-impl-policy/src/test/resources/policytypes/onap.policies.controlloop.guard.coordination.FirstBlocksSecond.yaml delete mode 100644 participant/participant-impl/participant-impl-policy/src/test/resources/policytypes/onap.policies.controlloop.operational.Common.yaml delete mode 100644 participant/participant-impl/participant-impl-policy/src/test/resources/policytypes/onap.policies.controlloop.operational.common.Apex.yaml delete mode 100644 participant/participant-impl/participant-impl-policy/src/test/resources/policytypes/onap.policies.controlloop.operational.common.Drools.yaml delete mode 100644 participant/participant-impl/participant-impl-policy/src/test/resources/policytypes/onap.policies.monitoring.dcae-pm-mapper.yaml delete mode 100644 participant/participant-impl/participant-impl-policy/src/test/resources/policytypes/onap.policies.monitoring.dcae-pm-subscription-handler.yaml delete mode 100644 participant/participant-impl/participant-impl-policy/src/test/resources/policytypes/onap.policies.monitoring.dcae-restconfcollector.yaml delete mode 100644 participant/participant-impl/participant-impl-policy/src/test/resources/policytypes/onap.policies.monitoring.dcaegen2.collectors.datafile.datafile-app-server.yaml delete mode 100644 participant/participant-impl/participant-impl-policy/src/test/resources/policytypes/onap.policies.monitoring.tcagen2.yaml delete mode 100644 participant/participant-impl/participant-impl-policy/src/test/resources/policytypes/onap.policies.native.Apex.yaml delete mode 100644 participant/participant-impl/participant-impl-policy/src/test/resources/policytypes/onap.policies.native.Drools.yaml delete mode 100644 participant/participant-impl/participant-impl-policy/src/test/resources/policytypes/onap.policies.native.Xacml.yaml delete mode 100644 participant/participant-impl/participant-impl-policy/src/test/resources/policytypes/onap.policies.optimization.Resource.yaml delete mode 100644 participant/participant-impl/participant-impl-policy/src/test/resources/policytypes/onap.policies.optimization.Service.yaml delete mode 100644 participant/participant-impl/participant-impl-policy/src/test/resources/policytypes/onap.policies.optimization.resource.AffinityPolicy.yaml delete mode 100644 participant/participant-impl/participant-impl-policy/src/test/resources/policytypes/onap.policies.optimization.resource.DistancePolicy.yaml delete mode 100644 participant/participant-impl/participant-impl-policy/src/test/resources/policytypes/onap.policies.optimization.resource.HpaPolicy.yaml delete mode 100644 participant/participant-impl/participant-impl-policy/src/test/resources/policytypes/onap.policies.optimization.resource.OptimizationPolicy.yaml delete mode 100644 participant/participant-impl/participant-impl-policy/src/test/resources/policytypes/onap.policies.optimization.resource.PciPolicy.yaml delete mode 100644 participant/participant-impl/participant-impl-policy/src/test/resources/policytypes/onap.policies.optimization.resource.Vim_fit.yaml delete mode 100644 participant/participant-impl/participant-impl-policy/src/test/resources/policytypes/onap.policies.optimization.resource.VnfPolicy.yaml delete mode 100644 participant/participant-impl/participant-impl-policy/src/test/resources/policytypes/onap.policies.optimization.service.QueryPolicy.yaml delete mode 100644 participant/participant-impl/participant-impl-policy/src/test/resources/policytypes/onap.policies.optimization.service.SubscriberPolicy.yaml create mode 100644 participant/participant-impl/participant-impl-policy/src/test/resources/utils/servicetemplates/pm_automation_composition_tosca.yaml delete mode 100644 participant/participant-impl/participant-impl-policy/src/test/resources/utils/servicetemplates/pm_control_loop_tosca.yaml create mode 100644 participant/participant-impl/participant-impl-simulator/src/main/java/org/onap/policy/clamp/acm/participant/simulator/ParticipantSimulatorApplication.java create mode 100644 participant/participant-impl/participant-impl-simulator/src/main/java/org/onap/policy/clamp/acm/participant/simulator/config/AafConfiguration.java create mode 100644 participant/participant-impl/participant-impl-simulator/src/main/java/org/onap/policy/clamp/acm/participant/simulator/config/ParticipantConfig.java create mode 100644 participant/participant-impl/participant-impl-simulator/src/main/java/org/onap/policy/clamp/acm/participant/simulator/config/SecurityConfig.java create mode 100644 participant/participant-impl/participant-impl-simulator/src/main/java/org/onap/policy/clamp/acm/participant/simulator/config/SpringFoxConfig.java create mode 100644 participant/participant-impl/participant-impl-simulator/src/main/java/org/onap/policy/clamp/acm/participant/simulator/config/YamlConfiguration.java create mode 100644 participant/participant-impl/participant-impl-simulator/src/main/java/org/onap/policy/clamp/acm/participant/simulator/main/handler/AutomationCompositionElementHandler.java create mode 100644 participant/participant-impl/participant-impl-simulator/src/main/java/org/onap/policy/clamp/acm/participant/simulator/main/parameters/ParticipantSimulatorParameters.java create mode 100644 participant/participant-impl/participant-impl-simulator/src/main/java/org/onap/policy/clamp/acm/participant/simulator/main/rest/AbstractRestController.java create mode 100644 participant/participant-impl/participant-impl-simulator/src/main/java/org/onap/policy/clamp/acm/participant/simulator/main/rest/GlobalControllerExceptionHandler.java create mode 100644 participant/participant-impl/participant-impl-simulator/src/main/java/org/onap/policy/clamp/acm/participant/simulator/main/rest/ParticipantErrorController.java create mode 100644 participant/participant-impl/participant-impl-simulator/src/main/java/org/onap/policy/clamp/acm/participant/simulator/main/rest/ParticipantSimulatorAafFilter.java create mode 100644 participant/participant-impl/participant-impl-simulator/src/main/java/org/onap/policy/clamp/acm/participant/simulator/simulation/SimulationProvider.java create mode 100644 participant/participant-impl/participant-impl-simulator/src/main/java/org/onap/policy/clamp/acm/participant/simulator/simulation/rest/SimulationElementController.java create mode 100644 participant/participant-impl/participant-impl-simulator/src/main/java/org/onap/policy/clamp/acm/participant/simulator/simulation/rest/SimulationParticipantController.java delete mode 100644 participant/participant-impl/participant-impl-simulator/src/main/java/org/onap/policy/clamp/controlloop/participant/simulator/ParticipantSimulatorApplication.java delete mode 100644 participant/participant-impl/participant-impl-simulator/src/main/java/org/onap/policy/clamp/controlloop/participant/simulator/config/AafConfiguration.java delete mode 100644 participant/participant-impl/participant-impl-simulator/src/main/java/org/onap/policy/clamp/controlloop/participant/simulator/config/ParticipantConfig.java delete mode 100644 participant/participant-impl/participant-impl-simulator/src/main/java/org/onap/policy/clamp/controlloop/participant/simulator/config/SecurityConfig.java delete mode 100644 participant/participant-impl/participant-impl-simulator/src/main/java/org/onap/policy/clamp/controlloop/participant/simulator/config/SpringFoxConfig.java delete mode 100644 participant/participant-impl/participant-impl-simulator/src/main/java/org/onap/policy/clamp/controlloop/participant/simulator/config/YamlConfiguration.java delete mode 100644 participant/participant-impl/participant-impl-simulator/src/main/java/org/onap/policy/clamp/controlloop/participant/simulator/main/handler/ControlLoopElementHandler.java delete mode 100644 participant/participant-impl/participant-impl-simulator/src/main/java/org/onap/policy/clamp/controlloop/participant/simulator/main/parameters/ParticipantSimulatorParameters.java delete mode 100644 participant/participant-impl/participant-impl-simulator/src/main/java/org/onap/policy/clamp/controlloop/participant/simulator/main/rest/AbstractRestController.java delete mode 100644 participant/participant-impl/participant-impl-simulator/src/main/java/org/onap/policy/clamp/controlloop/participant/simulator/main/rest/GlobalControllerExceptionHandler.java delete mode 100644 participant/participant-impl/participant-impl-simulator/src/main/java/org/onap/policy/clamp/controlloop/participant/simulator/main/rest/ParticipantErrorController.java delete mode 100644 participant/participant-impl/participant-impl-simulator/src/main/java/org/onap/policy/clamp/controlloop/participant/simulator/main/rest/ParticipantSimulatorAafFilter.java delete mode 100644 participant/participant-impl/participant-impl-simulator/src/main/java/org/onap/policy/clamp/controlloop/participant/simulator/simulation/SimulationProvider.java delete mode 100644 participant/participant-impl/participant-impl-simulator/src/main/java/org/onap/policy/clamp/controlloop/participant/simulator/simulation/rest/SimulationElementController.java delete mode 100644 participant/participant-impl/participant-impl-simulator/src/main/java/org/onap/policy/clamp/controlloop/participant/simulator/simulation/rest/SimulationParticipantController.java create mode 100644 participant/participant-impl/participant-impl-simulator/src/test/java/org/onap/policy/clamp/acm/participant/simulator/endtoend/ParticipantSimulatorTest.java create mode 100644 participant/participant-impl/participant-impl-simulator/src/test/java/org/onap/policy/clamp/acm/participant/simulator/main/handler/AutomationCompositionElementHandlerTest.java create mode 100644 participant/participant-impl/participant-impl-simulator/src/test/java/org/onap/policy/clamp/acm/participant/simulator/main/parameters/CommonTestData.java create mode 100644 participant/participant-impl/participant-impl-simulator/src/test/java/org/onap/policy/clamp/acm/participant/simulator/main/parameters/TestParticipantSimulatorParameters.java create mode 100644 participant/participant-impl/participant-impl-simulator/src/test/java/org/onap/policy/clamp/acm/participant/simulator/main/rest/TestListenerUtils.java delete mode 100644 participant/participant-impl/participant-impl-simulator/src/test/java/org/onap/policy/clamp/controlloop/participant/simulator/endtoend/ParticipantSimulatorTest.java delete mode 100644 participant/participant-impl/participant-impl-simulator/src/test/java/org/onap/policy/clamp/controlloop/participant/simulator/main/handler/ControlLoopElementHandlerTest.java delete mode 100644 participant/participant-impl/participant-impl-simulator/src/test/java/org/onap/policy/clamp/controlloop/participant/simulator/main/parameters/CommonTestData.java delete mode 100644 participant/participant-impl/participant-impl-simulator/src/test/java/org/onap/policy/clamp/controlloop/participant/simulator/main/parameters/TestParticipantSimulatorParameters.java delete mode 100644 participant/participant-impl/participant-impl-simulator/src/test/java/org/onap/policy/clamp/controlloop/participant/simulator/main/rest/TestListenerUtils.java create mode 100644 participant/participant-impl/participant-impl-simulator/src/test/resources/rest/servicetemplates/pm_automation_composition_tosca.yaml delete mode 100644 participant/participant-impl/participant-impl-simulator/src/test/resources/rest/servicetemplates/pm_control_loop_tosca.yaml create mode 100644 participant/participant-intermediary/src/main/java/org/onap/policy/clamp/acm/participant/intermediary/api/AutomationCompositionElementListener.java create mode 100644 participant/participant-intermediary/src/main/java/org/onap/policy/clamp/acm/participant/intermediary/api/ParticipantIntermediaryApi.java create mode 100644 participant/participant-intermediary/src/main/java/org/onap/policy/clamp/acm/participant/intermediary/api/impl/ParticipantIntermediaryApiImpl.java create mode 100644 participant/participant-intermediary/src/main/java/org/onap/policy/clamp/acm/participant/intermediary/comm/AutomationCompositionStateChangeListener.java create mode 100644 participant/participant-intermediary/src/main/java/org/onap/policy/clamp/acm/participant/intermediary/comm/AutomationCompositionUpdateListener.java create mode 100644 participant/participant-intermediary/src/main/java/org/onap/policy/clamp/acm/participant/intermediary/comm/MessageSender.java create mode 100644 participant/participant-intermediary/src/main/java/org/onap/policy/clamp/acm/participant/intermediary/comm/ParticipantAckListener.java create mode 100644 participant/participant-intermediary/src/main/java/org/onap/policy/clamp/acm/participant/intermediary/comm/ParticipantDeregisterAckListener.java create mode 100644 participant/participant-intermediary/src/main/java/org/onap/policy/clamp/acm/participant/intermediary/comm/ParticipantListener.java create mode 100644 participant/participant-intermediary/src/main/java/org/onap/policy/clamp/acm/participant/intermediary/comm/ParticipantMessagePublisher.java create mode 100644 participant/participant-intermediary/src/main/java/org/onap/policy/clamp/acm/participant/intermediary/comm/ParticipantRegisterAckListener.java create mode 100644 participant/participant-intermediary/src/main/java/org/onap/policy/clamp/acm/participant/intermediary/comm/ParticipantStatusReqListener.java create mode 100644 participant/participant-intermediary/src/main/java/org/onap/policy/clamp/acm/participant/intermediary/comm/ParticipantUpdateListener.java create mode 100644 participant/participant-intermediary/src/main/java/org/onap/policy/clamp/acm/participant/intermediary/handler/AutomationCompositionHandler.java create mode 100644 participant/participant-intermediary/src/main/java/org/onap/policy/clamp/acm/participant/intermediary/handler/IntermediaryActivator.java create mode 100644 participant/participant-intermediary/src/main/java/org/onap/policy/clamp/acm/participant/intermediary/handler/Listener.java create mode 100644 participant/participant-intermediary/src/main/java/org/onap/policy/clamp/acm/participant/intermediary/handler/ParticipantHandler.java create mode 100644 participant/participant-intermediary/src/main/java/org/onap/policy/clamp/acm/participant/intermediary/handler/Publisher.java create mode 100644 participant/participant-intermediary/src/main/java/org/onap/policy/clamp/acm/participant/intermediary/parameters/ParticipantIntermediaryParameters.java create mode 100644 participant/participant-intermediary/src/main/java/org/onap/policy/clamp/acm/participant/intermediary/parameters/ParticipantParameters.java delete mode 100644 participant/participant-intermediary/src/main/java/org/onap/policy/clamp/controlloop/participant/intermediary/api/ControlLoopElementListener.java delete mode 100644 participant/participant-intermediary/src/main/java/org/onap/policy/clamp/controlloop/participant/intermediary/api/ParticipantIntermediaryApi.java delete mode 100644 participant/participant-intermediary/src/main/java/org/onap/policy/clamp/controlloop/participant/intermediary/api/impl/ParticipantIntermediaryApiImpl.java delete mode 100644 participant/participant-intermediary/src/main/java/org/onap/policy/clamp/controlloop/participant/intermediary/comm/ControlLoopStateChangeListener.java delete mode 100644 participant/participant-intermediary/src/main/java/org/onap/policy/clamp/controlloop/participant/intermediary/comm/ControlLoopUpdateListener.java delete mode 100644 participant/participant-intermediary/src/main/java/org/onap/policy/clamp/controlloop/participant/intermediary/comm/MessageSender.java delete mode 100644 participant/participant-intermediary/src/main/java/org/onap/policy/clamp/controlloop/participant/intermediary/comm/ParticipantAckListener.java delete mode 100644 participant/participant-intermediary/src/main/java/org/onap/policy/clamp/controlloop/participant/intermediary/comm/ParticipantDeregisterAckListener.java delete mode 100644 participant/participant-intermediary/src/main/java/org/onap/policy/clamp/controlloop/participant/intermediary/comm/ParticipantListener.java delete mode 100644 participant/participant-intermediary/src/main/java/org/onap/policy/clamp/controlloop/participant/intermediary/comm/ParticipantMessagePublisher.java delete mode 100644 participant/participant-intermediary/src/main/java/org/onap/policy/clamp/controlloop/participant/intermediary/comm/ParticipantRegisterAckListener.java delete mode 100644 participant/participant-intermediary/src/main/java/org/onap/policy/clamp/controlloop/participant/intermediary/comm/ParticipantStatusReqListener.java delete mode 100644 participant/participant-intermediary/src/main/java/org/onap/policy/clamp/controlloop/participant/intermediary/comm/ParticipantUpdateListener.java delete mode 100644 participant/participant-intermediary/src/main/java/org/onap/policy/clamp/controlloop/participant/intermediary/handler/ControlLoopHandler.java delete mode 100644 participant/participant-intermediary/src/main/java/org/onap/policy/clamp/controlloop/participant/intermediary/handler/IntermediaryActivator.java delete mode 100644 participant/participant-intermediary/src/main/java/org/onap/policy/clamp/controlloop/participant/intermediary/handler/Listener.java delete mode 100644 participant/participant-intermediary/src/main/java/org/onap/policy/clamp/controlloop/participant/intermediary/handler/ParticipantHandler.java delete mode 100644 participant/participant-intermediary/src/main/java/org/onap/policy/clamp/controlloop/participant/intermediary/handler/Publisher.java delete mode 100644 participant/participant-intermediary/src/main/java/org/onap/policy/clamp/controlloop/participant/intermediary/parameters/ParticipantIntermediaryParameters.java delete mode 100644 participant/participant-intermediary/src/main/java/org/onap/policy/clamp/controlloop/participant/intermediary/parameters/ParticipantParameters.java create mode 100644 participant/participant-intermediary/src/test/java/org/onap/policy/clamp/acm/participant/intermediary/api/impl/ParticipantIntermediaryApiImplTest.java create mode 100644 participant/participant-intermediary/src/test/java/org/onap/policy/clamp/acm/participant/intermediary/comm/ParticipantCommTest.java create mode 100644 participant/participant-intermediary/src/test/java/org/onap/policy/clamp/acm/participant/intermediary/handler/AutomationCompositionHandlerTest.java create mode 100644 participant/participant-intermediary/src/test/java/org/onap/policy/clamp/acm/participant/intermediary/handler/DummyParticipantParameters.java create mode 100644 participant/participant-intermediary/src/test/java/org/onap/policy/clamp/acm/participant/intermediary/handler/IntermediaryActivatorTest.java create mode 100644 participant/participant-intermediary/src/test/java/org/onap/policy/clamp/acm/participant/intermediary/handler/ParticipantHandlerTest.java create mode 100644 participant/participant-intermediary/src/test/java/org/onap/policy/clamp/acm/participant/intermediary/main/parameters/CommonTestData.java create mode 100644 participant/participant-intermediary/src/test/java/org/onap/policy/clamp/acm/participant/intermediary/main/parameters/TestParticipantIntermediaryParameters.java delete mode 100644 participant/participant-intermediary/src/test/java/org/onap/policy/clamp/controlloop/participant/intermediary/api/impl/ParticipantIntermediaryApiImplTest.java delete mode 100644 participant/participant-intermediary/src/test/java/org/onap/policy/clamp/controlloop/participant/intermediary/comm/ParticipantCommTest.java delete mode 100644 participant/participant-intermediary/src/test/java/org/onap/policy/clamp/controlloop/participant/intermediary/handler/ControlLoopHandlerTest.java delete mode 100644 participant/participant-intermediary/src/test/java/org/onap/policy/clamp/controlloop/participant/intermediary/handler/DummyParticipantParameters.java delete mode 100644 participant/participant-intermediary/src/test/java/org/onap/policy/clamp/controlloop/participant/intermediary/handler/IntermediaryActivatorTest.java delete mode 100644 participant/participant-intermediary/src/test/java/org/onap/policy/clamp/controlloop/participant/intermediary/handler/ParticipantHandlerTest.java delete mode 100644 participant/participant-intermediary/src/test/java/org/onap/policy/clamp/controlloop/participant/intermediary/main/parameters/CommonTestData.java delete mode 100644 participant/participant-intermediary/src/test/java/org/onap/policy/clamp/controlloop/participant/intermediary/main/parameters/TestParticipantIntermediaryParameters.java create mode 100644 participant/participant-intermediary/src/test/resources/providers/TestAutomationCompositions.json delete mode 100644 participant/participant-intermediary/src/test/resources/providers/TestControlLoops.json create mode 100644 runtime-acm/pom.xml create mode 100644 runtime-acm/src/main/java/org/onap/policy/clamp/acm/runtime/Application.java create mode 100644 runtime-acm/src/main/java/org/onap/policy/clamp/acm/runtime/commissioning/CommissioningProvider.java create mode 100644 runtime-acm/src/main/java/org/onap/policy/clamp/acm/runtime/config/AafConfiguration.java create mode 100644 runtime-acm/src/main/java/org/onap/policy/clamp/acm/runtime/config/ConverterConfiguration.java create mode 100644 runtime-acm/src/main/java/org/onap/policy/clamp/acm/runtime/config/FilterConfig.java create mode 100644 runtime-acm/src/main/java/org/onap/policy/clamp/acm/runtime/config/SecurityConfig.java create mode 100644 runtime-acm/src/main/java/org/onap/policy/clamp/acm/runtime/config/SpringFoxConfig.java create mode 100644 runtime-acm/src/main/java/org/onap/policy/clamp/acm/runtime/config/messaging/Listener.java create mode 100644 runtime-acm/src/main/java/org/onap/policy/clamp/acm/runtime/config/messaging/MessageDispatcherActivator.java create mode 100644 runtime-acm/src/main/java/org/onap/policy/clamp/acm/runtime/config/messaging/Publisher.java create mode 100644 runtime-acm/src/main/java/org/onap/policy/clamp/acm/runtime/instantiation/AutomationCompositionInstantiationProvider.java create mode 100644 runtime-acm/src/main/java/org/onap/policy/clamp/acm/runtime/main/parameters/AcRuntimeParameterGroup.java create mode 100644 runtime-acm/src/main/java/org/onap/policy/clamp/acm/runtime/main/parameters/ParticipantParameters.java create mode 100644 runtime-acm/src/main/java/org/onap/policy/clamp/acm/runtime/main/parameters/ParticipantUpdateParameters.java create mode 100644 runtime-acm/src/main/java/org/onap/policy/clamp/acm/runtime/main/rest/CommissioningController.java create mode 100644 runtime-acm/src/main/java/org/onap/policy/clamp/acm/runtime/main/rest/InstantiationController.java create mode 100644 runtime-acm/src/main/java/org/onap/policy/clamp/acm/runtime/main/rest/MonitoringQueryController.java create mode 100644 runtime-acm/src/main/java/org/onap/policy/clamp/acm/runtime/main/web/AbstractRestController.java create mode 100644 runtime-acm/src/main/java/org/onap/policy/clamp/acm/runtime/main/web/AutomationConfiguraitonAafFilter.java create mode 100644 runtime-acm/src/main/java/org/onap/policy/clamp/acm/runtime/main/web/GlobalControllerExceptionHandler.java create mode 100644 runtime-acm/src/main/java/org/onap/policy/clamp/acm/runtime/main/web/RuntimeErrorController.java create mode 100644 runtime-acm/src/main/java/org/onap/policy/clamp/acm/runtime/monitoring/MonitoringProvider.java create mode 100644 runtime-acm/src/main/java/org/onap/policy/clamp/acm/runtime/supervision/HandleCounter.java create mode 100644 runtime-acm/src/main/java/org/onap/policy/clamp/acm/runtime/supervision/MessageIntercept.java create mode 100644 runtime-acm/src/main/java/org/onap/policy/clamp/acm/runtime/supervision/SupervisionAspect.java create mode 100644 runtime-acm/src/main/java/org/onap/policy/clamp/acm/runtime/supervision/SupervisionHandler.java create mode 100644 runtime-acm/src/main/java/org/onap/policy/clamp/acm/runtime/supervision/SupervisionScanner.java create mode 100644 runtime-acm/src/main/java/org/onap/policy/clamp/acm/runtime/supervision/comm/AbstractParticipantAckPublisher.java create mode 100644 runtime-acm/src/main/java/org/onap/policy/clamp/acm/runtime/supervision/comm/AbstractParticipantPublisher.java create mode 100644 runtime-acm/src/main/java/org/onap/policy/clamp/acm/runtime/supervision/comm/AutomationCompositionStateChangeAckListener.java create mode 100644 runtime-acm/src/main/java/org/onap/policy/clamp/acm/runtime/supervision/comm/AutomationCompositionStateChangePublisher.java create mode 100644 runtime-acm/src/main/java/org/onap/policy/clamp/acm/runtime/supervision/comm/AutomationCompositionUpdateAckListener.java create mode 100644 runtime-acm/src/main/java/org/onap/policy/clamp/acm/runtime/supervision/comm/AutomationCompositionUpdatePublisher.java create mode 100644 runtime-acm/src/main/java/org/onap/policy/clamp/acm/runtime/supervision/comm/ParticipantDeregisterAckPublisher.java create mode 100644 runtime-acm/src/main/java/org/onap/policy/clamp/acm/runtime/supervision/comm/ParticipantDeregisterListener.java create mode 100644 runtime-acm/src/main/java/org/onap/policy/clamp/acm/runtime/supervision/comm/ParticipantRegisterAckPublisher.java create mode 100644 runtime-acm/src/main/java/org/onap/policy/clamp/acm/runtime/supervision/comm/ParticipantRegisterListener.java create mode 100644 runtime-acm/src/main/java/org/onap/policy/clamp/acm/runtime/supervision/comm/ParticipantStatusListener.java create mode 100644 runtime-acm/src/main/java/org/onap/policy/clamp/acm/runtime/supervision/comm/ParticipantStatusReqPublisher.java create mode 100644 runtime-acm/src/main/java/org/onap/policy/clamp/acm/runtime/supervision/comm/ParticipantUpdateAckListener.java create mode 100644 runtime-acm/src/main/java/org/onap/policy/clamp/acm/runtime/supervision/comm/ParticipantUpdatePublisher.java create mode 100644 runtime-acm/src/main/resources/application.yaml create mode 100644 runtime-acm/src/main/resources/version.txt create mode 100644 runtime-acm/src/test/java/org/onap/policy/clamp/acm/runtime/commissioning/CommissioningProviderTest.java create mode 100644 runtime-acm/src/test/java/org/onap/policy/clamp/acm/runtime/commissioning/rest/CommissioningControllerTest.java create mode 100644 runtime-acm/src/test/java/org/onap/policy/clamp/acm/runtime/config/messaging/MessageDispatcherActivatorTest.java create mode 100644 runtime-acm/src/test/java/org/onap/policy/clamp/acm/runtime/instantiation/AutomationCompositionInstantiationProviderTest.java create mode 100644 runtime-acm/src/test/java/org/onap/policy/clamp/acm/runtime/instantiation/InstantiationUtils.java create mode 100644 runtime-acm/src/test/java/org/onap/policy/clamp/acm/runtime/instantiation/rest/InstantiationControllerTest.java create mode 100644 runtime-acm/src/test/java/org/onap/policy/clamp/acm/runtime/main/rest/ActuatorControllerTest.java create mode 100644 runtime-acm/src/test/java/org/onap/policy/clamp/acm/runtime/monitoring/TestMonitoringProvider.java create mode 100644 runtime-acm/src/test/java/org/onap/policy/clamp/acm/runtime/monitoring/rest/MonitoringQueryControllerTest.java create mode 100644 runtime-acm/src/test/java/org/onap/policy/clamp/acm/runtime/supervision/HandleCounterTest.java create mode 100644 runtime-acm/src/test/java/org/onap/policy/clamp/acm/runtime/supervision/SupervisionAspectTest.java create mode 100644 runtime-acm/src/test/java/org/onap/policy/clamp/acm/runtime/supervision/SupervisionHandlerTest.java create mode 100644 runtime-acm/src/test/java/org/onap/policy/clamp/acm/runtime/supervision/SupervisionScannerTest.java create mode 100644 runtime-acm/src/test/java/org/onap/policy/clamp/acm/runtime/supervision/comm/SupervisionMessagesTest.java create mode 100644 runtime-acm/src/test/java/org/onap/policy/clamp/acm/runtime/util/CommonTestData.java create mode 100644 runtime-acm/src/test/java/org/onap/policy/clamp/acm/runtime/util/rest/CommonRestController.java create mode 100644 runtime-acm/src/test/resources/application_test.properties create mode 100644 runtime-acm/src/test/resources/parameters/TestParameters.json create mode 100644 runtime-acm/src/test/resources/parameters/logback-test.xml create mode 100644 runtime-acm/src/test/resources/rest/acm/AutomationCompositionElementsNotFound.json create mode 100644 runtime-acm/src/test/resources/rest/acm/AutomationCompositionVersionNotMatches.json create mode 100644 runtime-acm/src/test/resources/rest/acm/AutomationCompositions.json create mode 100644 runtime-acm/src/test/resources/rest/acm/AutomationCompositionsNotFound.json create mode 100644 runtime-acm/src/test/resources/rest/acm/AutomationCompositionsSmoke.json create mode 100644 runtime-acm/src/test/resources/rest/acm/AutomationCompositionsUpdate.json create mode 100644 runtime-acm/src/test/resources/rest/acm/PassiveCommand.json create mode 100644 runtime-acm/src/test/resources/rest/monitoring/TestAcElementStatistics.json create mode 100644 runtime-acm/src/test/resources/rest/monitoring/TestAcElementStatistics_Invalid.json create mode 100644 runtime-acm/src/test/resources/rest/monitoring/TestParticipantStatistics.json create mode 100644 runtime-acm/src/test/resources/rest/monitoring/TestParticipantStatistics_Invalid.json create mode 100644 runtime-acm/src/test/resources/rest/servicetemplates/PMSHMultipleACTosca.yaml create mode 100644 runtime-acm/src/test/resources/rest/servicetemplates/full-tosca-with-common-properties.yaml create mode 100644 runtime-acm/src/test/resources/rest/servicetemplates/pm_automation_composition_tosca.yaml create mode 100644 runtime-acm/src/test/resources/rest/servicetemplates/pmsh_multiple_ac_tosca.yaml create mode 100644 runtime-acm/src/test/resources/rest/servicetemplates/tosca-for-smoke-testing.yaml create mode 100755 runtime-acm/src/test/resources/testscripts/listenOnTopic.sh delete mode 100644 runtime-controlloop/pom.xml delete mode 100644 runtime-controlloop/src/main/java/org/onap/policy/clamp/controlloop/runtime/Application.java delete mode 100644 runtime-controlloop/src/main/java/org/onap/policy/clamp/controlloop/runtime/commissioning/CommissioningProvider.java delete mode 100644 runtime-controlloop/src/main/java/org/onap/policy/clamp/controlloop/runtime/config/AafConfiguration.java delete mode 100644 runtime-controlloop/src/main/java/org/onap/policy/clamp/controlloop/runtime/config/ConverterConfiguration.java delete mode 100644 runtime-controlloop/src/main/java/org/onap/policy/clamp/controlloop/runtime/config/FilterConfig.java delete mode 100644 runtime-controlloop/src/main/java/org/onap/policy/clamp/controlloop/runtime/config/SecurityConfig.java delete mode 100644 runtime-controlloop/src/main/java/org/onap/policy/clamp/controlloop/runtime/config/SpringFoxConfig.java delete mode 100644 runtime-controlloop/src/main/java/org/onap/policy/clamp/controlloop/runtime/config/messaging/Listener.java delete mode 100644 runtime-controlloop/src/main/java/org/onap/policy/clamp/controlloop/runtime/config/messaging/MessageDispatcherActivator.java delete mode 100644 runtime-controlloop/src/main/java/org/onap/policy/clamp/controlloop/runtime/config/messaging/Publisher.java delete mode 100644 runtime-controlloop/src/main/java/org/onap/policy/clamp/controlloop/runtime/instantiation/ControlLoopInstantiationProvider.java delete mode 100644 runtime-controlloop/src/main/java/org/onap/policy/clamp/controlloop/runtime/main/parameters/ClRuntimeParameterGroup.java delete mode 100644 runtime-controlloop/src/main/java/org/onap/policy/clamp/controlloop/runtime/main/parameters/ParticipantParameters.java delete mode 100644 runtime-controlloop/src/main/java/org/onap/policy/clamp/controlloop/runtime/main/parameters/ParticipantUpdateParameters.java delete mode 100644 runtime-controlloop/src/main/java/org/onap/policy/clamp/controlloop/runtime/main/rest/CommissioningController.java delete mode 100644 runtime-controlloop/src/main/java/org/onap/policy/clamp/controlloop/runtime/main/rest/InstantiationController.java delete mode 100644 runtime-controlloop/src/main/java/org/onap/policy/clamp/controlloop/runtime/main/rest/MonitoringQueryController.java delete mode 100644 runtime-controlloop/src/main/java/org/onap/policy/clamp/controlloop/runtime/main/web/AbstractRestController.java delete mode 100644 runtime-controlloop/src/main/java/org/onap/policy/clamp/controlloop/runtime/main/web/ControlLoopAafFilter.java delete mode 100644 runtime-controlloop/src/main/java/org/onap/policy/clamp/controlloop/runtime/main/web/GlobalControllerExceptionHandler.java delete mode 100644 runtime-controlloop/src/main/java/org/onap/policy/clamp/controlloop/runtime/main/web/RuntimeErrorController.java delete mode 100644 runtime-controlloop/src/main/java/org/onap/policy/clamp/controlloop/runtime/monitoring/MonitoringProvider.java delete mode 100644 runtime-controlloop/src/main/java/org/onap/policy/clamp/controlloop/runtime/supervision/HandleCounter.java delete mode 100644 runtime-controlloop/src/main/java/org/onap/policy/clamp/controlloop/runtime/supervision/MessageIntercept.java delete mode 100644 runtime-controlloop/src/main/java/org/onap/policy/clamp/controlloop/runtime/supervision/SupervisionAspect.java delete mode 100644 runtime-controlloop/src/main/java/org/onap/policy/clamp/controlloop/runtime/supervision/SupervisionHandler.java delete mode 100644 runtime-controlloop/src/main/java/org/onap/policy/clamp/controlloop/runtime/supervision/SupervisionScanner.java delete mode 100644 runtime-controlloop/src/main/java/org/onap/policy/clamp/controlloop/runtime/supervision/comm/AbstractParticipantAckPublisher.java delete mode 100644 runtime-controlloop/src/main/java/org/onap/policy/clamp/controlloop/runtime/supervision/comm/AbstractParticipantPublisher.java delete mode 100644 runtime-controlloop/src/main/java/org/onap/policy/clamp/controlloop/runtime/supervision/comm/ControlLoopStateChangeAckListener.java delete mode 100644 runtime-controlloop/src/main/java/org/onap/policy/clamp/controlloop/runtime/supervision/comm/ControlLoopStateChangePublisher.java delete mode 100644 runtime-controlloop/src/main/java/org/onap/policy/clamp/controlloop/runtime/supervision/comm/ControlLoopUpdateAckListener.java delete mode 100644 runtime-controlloop/src/main/java/org/onap/policy/clamp/controlloop/runtime/supervision/comm/ControlLoopUpdatePublisher.java delete mode 100644 runtime-controlloop/src/main/java/org/onap/policy/clamp/controlloop/runtime/supervision/comm/ParticipantDeregisterAckPublisher.java delete mode 100644 runtime-controlloop/src/main/java/org/onap/policy/clamp/controlloop/runtime/supervision/comm/ParticipantDeregisterListener.java delete mode 100644 runtime-controlloop/src/main/java/org/onap/policy/clamp/controlloop/runtime/supervision/comm/ParticipantRegisterAckPublisher.java delete mode 100644 runtime-controlloop/src/main/java/org/onap/policy/clamp/controlloop/runtime/supervision/comm/ParticipantRegisterListener.java delete mode 100644 runtime-controlloop/src/main/java/org/onap/policy/clamp/controlloop/runtime/supervision/comm/ParticipantStatusListener.java delete mode 100644 runtime-controlloop/src/main/java/org/onap/policy/clamp/controlloop/runtime/supervision/comm/ParticipantStatusReqPublisher.java delete mode 100644 runtime-controlloop/src/main/java/org/onap/policy/clamp/controlloop/runtime/supervision/comm/ParticipantUpdateAckListener.java delete mode 100644 runtime-controlloop/src/main/java/org/onap/policy/clamp/controlloop/runtime/supervision/comm/ParticipantUpdatePublisher.java delete mode 100644 runtime-controlloop/src/main/resources/application.yaml delete mode 100644 runtime-controlloop/src/main/resources/version.txt delete mode 100644 runtime-controlloop/src/test/java/org/onap/policy/clamp/controlloop/runtime/commissioning/CommissioningProviderTest.java delete mode 100644 runtime-controlloop/src/test/java/org/onap/policy/clamp/controlloop/runtime/commissioning/rest/CommissioningControllerTest.java delete mode 100644 runtime-controlloop/src/test/java/org/onap/policy/clamp/controlloop/runtime/config/messaging/MessageDispatcherActivatorTest.java delete mode 100644 runtime-controlloop/src/test/java/org/onap/policy/clamp/controlloop/runtime/instantiation/ControlLoopInstantiationProviderTest.java delete mode 100644 runtime-controlloop/src/test/java/org/onap/policy/clamp/controlloop/runtime/instantiation/InstantiationUtils.java delete mode 100644 runtime-controlloop/src/test/java/org/onap/policy/clamp/controlloop/runtime/instantiation/rest/InstantiationControllerTest.java delete mode 100644 runtime-controlloop/src/test/java/org/onap/policy/clamp/controlloop/runtime/main/rest/ActuatorControllerTest.java delete mode 100644 runtime-controlloop/src/test/java/org/onap/policy/clamp/controlloop/runtime/monitoring/TestMonitoringProvider.java delete mode 100644 runtime-controlloop/src/test/java/org/onap/policy/clamp/controlloop/runtime/monitoring/rest/MonitoringQueryControllerTest.java delete mode 100644 runtime-controlloop/src/test/java/org/onap/policy/clamp/controlloop/runtime/supervision/HandleCounterTest.java delete mode 100644 runtime-controlloop/src/test/java/org/onap/policy/clamp/controlloop/runtime/supervision/SupervisionAspectTest.java delete mode 100644 runtime-controlloop/src/test/java/org/onap/policy/clamp/controlloop/runtime/supervision/SupervisionHandlerTest.java delete mode 100644 runtime-controlloop/src/test/java/org/onap/policy/clamp/controlloop/runtime/supervision/SupervisionScannerTest.java delete mode 100644 runtime-controlloop/src/test/java/org/onap/policy/clamp/controlloop/runtime/supervision/comm/SupervisionMessagesTest.java delete mode 100644 runtime-controlloop/src/test/java/org/onap/policy/clamp/controlloop/runtime/util/CommonTestData.java delete mode 100644 runtime-controlloop/src/test/java/org/onap/policy/clamp/controlloop/runtime/util/rest/CommonRestController.java delete mode 100644 runtime-controlloop/src/test/resources/application_test.properties delete mode 100644 runtime-controlloop/src/test/resources/parameters/TestParameters.json delete mode 100644 runtime-controlloop/src/test/resources/parameters/logback-test.xml delete mode 100644 runtime-controlloop/src/test/resources/rest/controlloops/ControlLoopElementsNotFound.json delete mode 100644 runtime-controlloop/src/test/resources/rest/controlloops/ControlLoops.json delete mode 100644 runtime-controlloop/src/test/resources/rest/controlloops/ControlLoopsNotFound.json delete mode 100644 runtime-controlloop/src/test/resources/rest/controlloops/ControlLoopsSmoke.json delete mode 100644 runtime-controlloop/src/test/resources/rest/controlloops/ControlLoopsUpdate.json delete mode 100644 runtime-controlloop/src/test/resources/rest/controlloops/ControlLoopsVersionNotMatches.json delete mode 100644 runtime-controlloop/src/test/resources/rest/controlloops/PassiveCommand.json delete mode 100644 runtime-controlloop/src/test/resources/rest/monitoring/TestClElementStatistics.json delete mode 100644 runtime-controlloop/src/test/resources/rest/monitoring/TestClElementStatistics_Invalid.json delete mode 100644 runtime-controlloop/src/test/resources/rest/monitoring/TestParticipantStatistics.json delete mode 100644 runtime-controlloop/src/test/resources/rest/monitoring/TestParticipantStatistics_Invalid.json delete mode 100644 runtime-controlloop/src/test/resources/rest/servicetemplates/PMSHMultipleCLTosca.yaml delete mode 100644 runtime-controlloop/src/test/resources/rest/servicetemplates/full-tosca-with-common-properties.yaml delete mode 100644 runtime-controlloop/src/test/resources/rest/servicetemplates/pm_control_loop_tosca.yaml delete mode 100644 runtime-controlloop/src/test/resources/rest/servicetemplates/pmsh_multiple_cl_tosca.yaml delete mode 100644 runtime-controlloop/src/test/resources/rest/servicetemplates/tosca-for-smoke-testing.yaml delete mode 100755 runtime-controlloop/src/test/resources/testscripts/listenOnTopic.sh create mode 100644 runtime/src/main/resources/clds/camel/routes/acm-flows.xml delete mode 100644 runtime/src/main/resources/clds/camel/routes/controlloop-flows.xml diff --git a/common/src/main/java/org/onap/policy/clamp/common/acm/exception/AutomationCompositionException.java b/common/src/main/java/org/onap/policy/clamp/common/acm/exception/AutomationCompositionException.java new file mode 100644 index 000000000..c22aa920e --- /dev/null +++ b/common/src/main/java/org/onap/policy/clamp/common/acm/exception/AutomationCompositionException.java @@ -0,0 +1,95 @@ +/*- + * ============LICENSE_START======================================================= + * Copyright (C) 2021 Nordix Foundation. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * SPDX-License-Identifier: Apache-2.0 + * ============LICENSE_END========================================================= + */ + +package org.onap.policy.clamp.common.acm.exception; + +import javax.ws.rs.core.Response; +import lombok.Getter; +import lombok.ToString; +import org.onap.policy.models.errors.concepts.ErrorResponse; +import org.onap.policy.models.errors.concepts.ErrorResponseInfo; +import org.onap.policy.models.errors.concepts.ErrorResponseUtils; + +/** + * This class is a base exception from which all automation composition exceptions are sub classes. + */ +@Getter +@ToString +public class AutomationCompositionException extends Exception implements ErrorResponseInfo { + private static final long serialVersionUID = -8507246953751956974L; + + // The error response of the exception + private final ErrorResponse errorResponse = new ErrorResponse(); + + // The object on which the exception was thrown + private final transient Object object; + + /** + * Instantiates a new automation composition exception. + * + * @param statusCode the status code for the response as a HTTP status code + * @param message the message on the exception + */ + public AutomationCompositionException(final Response.Status statusCode, final String message) { + this(statusCode, message, null); + } + + /** + * Instantiates a new automation composition exception. + * + * @param statusCode the return code for the exception + * @param message the message on the exception + * @param object the object that the exception was thrown on + */ + public AutomationCompositionException(final Response.Status statusCode, final String message, final Object object) { + super(message); + errorResponse.setResponseCode(statusCode); + ErrorResponseUtils.getExceptionMessages(errorResponse, this); + this.object = object; + } + + /** + * Instantiates a new automation composition exception. + * + * @param statusCode the return code for the exception + * @param message the message on the exception + * @param exception the exception that caused this exception + */ + public AutomationCompositionException(final Response.Status statusCode, final String message, + final Exception exception) { + this(statusCode, message, exception, null); + } + + /** + * Instantiates a new exception. + * + * @param statusCode the return code for the exception + * @param message the message on the exception + * @param exception the exception that caused this exception + * @param object the object that the exception was thrown on + */ + public AutomationCompositionException(final Response.Status statusCode, final String message, + final Exception exception, final Object object) { + super(message, exception); + errorResponse.setResponseCode(statusCode); + ErrorResponseUtils.getExceptionMessages(errorResponse, this); + this.object = object; + } +} diff --git a/common/src/main/java/org/onap/policy/clamp/common/acm/exception/AutomationCompositionRuntimeException.java b/common/src/main/java/org/onap/policy/clamp/common/acm/exception/AutomationCompositionRuntimeException.java new file mode 100644 index 000000000..2fc427db8 --- /dev/null +++ b/common/src/main/java/org/onap/policy/clamp/common/acm/exception/AutomationCompositionRuntimeException.java @@ -0,0 +1,109 @@ +/*- + * ============LICENSE_START======================================================= + * Copyright (C) 2021 Nordix Foundation. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * SPDX-License-Identifier: Apache-2.0 + * ============LICENSE_END========================================================= + */ + +package org.onap.policy.clamp.common.acm.exception; + +import javax.ws.rs.core.Response; +import lombok.Getter; +import lombok.ToString; +import org.onap.policy.models.errors.concepts.ErrorResponse; +import org.onap.policy.models.errors.concepts.ErrorResponseInfo; +import org.onap.policy.models.errors.concepts.ErrorResponseUtils; + +/** + * This class is a base automation composition run time exception from which all automation composition run time + * exceptions are sub classes. + */ +@Getter +@ToString +public class AutomationCompositionRuntimeException extends RuntimeException implements ErrorResponseInfo { + private static final long serialVersionUID = -8507246953751956974L; + + // The error response of the exception + private final ErrorResponse errorResponse = new ErrorResponse(); + + // The object on which the exception was thrown + private final transient Object object; + + /** + * Instantiates a new automation composition runtime exception. + * + * @param statusCode the return code for the exception + * @param message the message on the exception + */ + public AutomationCompositionRuntimeException(final Response.Status statusCode, final String message) { + this(statusCode, message, null); + } + + /** + * Instantiates a new automation composition runtime exception. + * + * @param statusCode the return code for the exception + * @param message the message on the exception + * @param object the object that the exception was thrown on + */ + public AutomationCompositionRuntimeException(final Response.Status statusCode, final String message, + final Object object) { + super(message); + this.object = object; + errorResponse.setResponseCode(statusCode); + ErrorResponseUtils.getExceptionMessages(errorResponse, this); + } + + /** + * Instantiates a new automation composition runtime exception. + * + * @param statusCode the return code for the exception + * @param message the message on the exception + * @param exception the exception that caused this automation composition exception + */ + public AutomationCompositionRuntimeException(final Response.Status statusCode, final String message, + final Exception exception) { + this(statusCode, message, exception, null); + } + + /** + * Instantiates a new model runtime exception from an AutomationCompositionException instance. + * + * @param exception the exception that caused this automation composition exception + */ + public AutomationCompositionRuntimeException(final AutomationCompositionException exception) { + super(exception.getMessage(), exception); + this.object = exception.getObject(); + errorResponse.setResponseCode(exception.getErrorResponse().getResponseCode()); + ErrorResponseUtils.getExceptionMessages(errorResponse, this); + } + + /** + * Instantiates a new automation composition runtime exception. + * + * @param statusCode the return code for the exception + * @param message the message on the exception + * @param exception the exception that caused this automation composition exception + * @param object the object that the exception was thrown on + */ + public AutomationCompositionRuntimeException(final Response.Status statusCode, final String message, + final Exception exception, final Object object) { + super(message, exception); + this.object = object; + errorResponse.setResponseCode(statusCode); + ErrorResponseUtils.getExceptionMessages(errorResponse, this); + } +} diff --git a/common/src/main/java/org/onap/policy/clamp/common/acm/rest/CoderHttpMesageConverter.java b/common/src/main/java/org/onap/policy/clamp/common/acm/rest/CoderHttpMesageConverter.java new file mode 100644 index 000000000..f445364ad --- /dev/null +++ b/common/src/main/java/org/onap/policy/clamp/common/acm/rest/CoderHttpMesageConverter.java @@ -0,0 +1,74 @@ +/*- + * ============LICENSE_START======================================================= + * Copyright (C) 2021 Nordix Foundation. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * SPDX-License-Identifier: Apache-2.0 + * ============LICENSE_END========================================================= + */ + +package org.onap.policy.clamp.common.acm.rest; + +import java.io.IOException; +import java.io.InputStreamReader; +import java.io.OutputStreamWriter; +import java.nio.charset.StandardCharsets; +import javax.ws.rs.core.Response; +import org.onap.policy.clamp.common.acm.exception.AutomationCompositionRuntimeException; +import org.onap.policy.common.utils.coder.Coder; +import org.onap.policy.common.utils.coder.CoderException; +import org.onap.policy.common.utils.coder.StandardCoder; +import org.onap.policy.common.utils.coder.StandardYamlCoder; +import org.springframework.http.HttpInputMessage; +import org.springframework.http.HttpOutputMessage; +import org.springframework.http.MediaType; +import org.springframework.http.converter.AbstractHttpMessageConverter; +import org.springframework.http.converter.HttpMessageNotReadableException; +import org.springframework.http.converter.HttpMessageNotWritableException; + +public class CoderHttpMesageConverter extends AbstractHttpMessageConverter { + + private Coder coder; + + public CoderHttpMesageConverter(String type) { + super(new MediaType("application", type, StandardCharsets.UTF_8)); + this.coder = "json".equals(type) ? new StandardCoder() : new StandardYamlCoder(); + } + + @Override + protected boolean supports(Class clazz) { + return true; + } + + @Override + protected T readInternal(Class clazz, HttpInputMessage inputMessage) + throws IOException, HttpMessageNotReadableException { + try (var is = new InputStreamReader(inputMessage.getBody(), StandardCharsets.UTF_8)) { + return coder.decode(is, clazz); + } catch (CoderException e) { + throw new AutomationCompositionRuntimeException(Response.Status.BAD_REQUEST, e.getMessage(), e); + } + } + + @Override + protected void writeInternal(T t, HttpOutputMessage outputMessage) + throws IOException, HttpMessageNotWritableException { + try (var writer = new OutputStreamWriter(outputMessage.getBody(), StandardCharsets.UTF_8)) { + coder.encode(writer, t); + } catch (CoderException e) { + throw new AutomationCompositionRuntimeException(Response.Status.BAD_REQUEST, e.getMessage(), e); + } + } + +} diff --git a/common/src/main/java/org/onap/policy/clamp/common/acm/rest/RequestResponseLoggingFilter.java b/common/src/main/java/org/onap/policy/clamp/common/acm/rest/RequestResponseLoggingFilter.java new file mode 100644 index 000000000..4b6dce46d --- /dev/null +++ b/common/src/main/java/org/onap/policy/clamp/common/acm/rest/RequestResponseLoggingFilter.java @@ -0,0 +1,69 @@ +/*- + * ============LICENSE_START======================================================= + * Copyright (C) 2021 Nordix Foundation. + * ================================================================================ + * Modifications Copyright (C) 2021 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * SPDX-License-Identifier: Apache-2.0 + * ============LICENSE_END========================================================= + */ + +package org.onap.policy.clamp.common.acm.rest; + +import java.io.IOException; +import java.util.UUID; +import javax.servlet.Filter; +import javax.servlet.FilterChain; +import javax.servlet.ServletException; +import javax.servlet.ServletRequest; +import javax.servlet.ServletResponse; +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; +import org.springframework.core.annotation.Order; +import org.springframework.stereotype.Component; + +@Component +@Order(2) +public class RequestResponseLoggingFilter implements Filter { + + private static final String VERSION_MINOR_NAME = "X-MinorVersion"; + private static final String VERSION_PATCH_NAME = "X-PatchVersion"; + private static final String VERSION_LATEST_NAME = "X-LatestVersion"; + public static final String API_VERSION = "1.0.0"; + public static final String REQUEST_ID_NAME = "X-ONAP-RequestID"; + + @Override + public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain) + throws IOException, ServletException { + + + HttpServletResponse res = (HttpServletResponse) response; + HttpServletRequest req = (HttpServletRequest) request; + + /* + * Disabling sonar because of ONAP requires the request ID to be copied from the request + * to the response. + */ + String requestId = req.getHeader(REQUEST_ID_NAME); + res.addHeader(REQUEST_ID_NAME, requestId != null ? requestId : UUID.randomUUID().toString()); // NOSONAR + + res.addHeader(VERSION_MINOR_NAME, "0"); + res.addHeader(VERSION_PATCH_NAME, "0"); + res.addHeader(VERSION_LATEST_NAME, API_VERSION); + + chain.doFilter(request, response); + } + +} diff --git a/common/src/main/java/org/onap/policy/clamp/common/acm/startstop/CommonCommandLineArguments.java b/common/src/main/java/org/onap/policy/clamp/common/acm/startstop/CommonCommandLineArguments.java new file mode 100644 index 000000000..6f6fb6a4b --- /dev/null +++ b/common/src/main/java/org/onap/policy/clamp/common/acm/startstop/CommonCommandLineArguments.java @@ -0,0 +1,146 @@ +/*- + * ============LICENSE_START======================================================= + * Copyright (C) 2021 Nordix Foundation. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * SPDX-License-Identifier: Apache-2.0 + * ============LICENSE_END========================================================= + */ + +package org.onap.policy.clamp.common.acm.startstop; + +import java.io.File; +import java.io.PrintWriter; +import java.io.StringWriter; +import javax.ws.rs.core.Response; +import org.apache.commons.cli.HelpFormatter; +import org.apache.commons.cli.Option; +import org.apache.commons.cli.Options; +import org.apache.commons.lang3.StringUtils; +import org.onap.policy.clamp.common.acm.exception.AutomationCompositionException; +import org.onap.policy.common.utils.resources.ResourceUtils; + +/** + * This class reads and handles command line parameters. + * + */ +public class CommonCommandLineArguments { + private static final String FILE_MESSAGE_PREAMBLE = " file \""; + private static final int HELP_LINE_LENGTH = 120; + + /** + * Construct the options for the policy participant. + * + * @param options the options for the command line + */ + public CommonCommandLineArguments(final Options options) { + //@formatter:off + options.addOption(Option.builder("h") + .longOpt("help") + .desc("outputs the usage of this command") + .required(false) + .type(Boolean.class) + .build()); + options.addOption(Option.builder("v") + .longOpt("version") + .desc("outputs the version of policy participant") + .required(false) + .type(Boolean.class) + .build()); + options.addOption(Option.builder("c") + .longOpt("config-file") + .desc("the full path to the configuration file to use, " + + "the configuration file must be a Json file containing the " + + "policy participant parameters") + .hasArg() + .argName("CONFIG_FILE") + .required(false) + .type(String.class) + .build()); + //@formatter:on + } + + /** + * Validate the command line options. + * + * @param configurationFilePath the path to the configuration file + * @throws AutomationCompositionException on command argument validation errors + */ + public void validate(final String configurationFilePath) throws AutomationCompositionException { + validateReadableFile("policy participant configuration", configurationFilePath); + } + + /** + * Print version information for policy participant. + * + * @return the version string + */ + public String version() { + return ResourceUtils.getResourceAsString("version.txt"); + } + + /** + * Print help information for policy participant. + * + * @param mainClassName the main class name + * @param options the options for the command + * @return the help string + */ + public String help(final String mainClassName, final Options options) { + final var helpFormatter = new HelpFormatter(); + final var stringWriter = new StringWriter(); + final var printWriter = new PrintWriter(stringWriter); + + helpFormatter.printHelp(printWriter, HELP_LINE_LENGTH, mainClassName + " [options...]", "options", options, 0, + 0, ""); + + return stringWriter.toString(); + } + + /** + * Validate readable file. + * + * @param fileTag the file tag + * @param fileName the file name + * @throws AutomationCompositionException on the file name passed as a parameter + */ + private void validateReadableFile(final String fileTag, final String fileName) + throws AutomationCompositionException { + if (StringUtils.isEmpty(fileName)) { + throw new AutomationCompositionException(Response.Status.NOT_ACCEPTABLE, + fileTag + " file was not specified as an argument"); + } + + // The file name refers to a resource on the local file system + final var fileUrl = ResourceUtils.getUrl4Resource(fileName); + if (fileUrl == null) { + throw new AutomationCompositionException(Response.Status.NOT_ACCEPTABLE, + fileTag + FILE_MESSAGE_PREAMBLE + fileName + "\" does not exist"); + } + + final var theFile = new File(fileUrl.getPath()); + if (!theFile.exists()) { + throw new AutomationCompositionException(Response.Status.NOT_ACCEPTABLE, + fileTag + FILE_MESSAGE_PREAMBLE + fileName + "\" does not exist"); + } + if (!theFile.isFile()) { + throw new AutomationCompositionException(Response.Status.NOT_ACCEPTABLE, + fileTag + FILE_MESSAGE_PREAMBLE + fileName + "\" is not a normal file"); + } + if (!theFile.canRead()) { + throw new AutomationCompositionException(Response.Status.NOT_ACCEPTABLE, + fileTag + FILE_MESSAGE_PREAMBLE + fileName + "\" is unreadable"); + } + } +} diff --git a/common/src/main/java/org/onap/policy/clamp/controlloop/common/exception/ControlLoopException.java b/common/src/main/java/org/onap/policy/clamp/controlloop/common/exception/ControlLoopException.java deleted file mode 100644 index 58b5368a9..000000000 --- a/common/src/main/java/org/onap/policy/clamp/controlloop/common/exception/ControlLoopException.java +++ /dev/null @@ -1,94 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * Copyright (C) 2021 Nordix Foundation. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - * SPDX-License-Identifier: Apache-2.0 - * ============LICENSE_END========================================================= - */ - -package org.onap.policy.clamp.controlloop.common.exception; - -import javax.ws.rs.core.Response; -import lombok.Getter; -import lombok.ToString; -import org.onap.policy.models.errors.concepts.ErrorResponse; -import org.onap.policy.models.errors.concepts.ErrorResponseInfo; -import org.onap.policy.models.errors.concepts.ErrorResponseUtils; - -/** - * This class is a base exception from which all control loop exceptions are sub classes. - */ -@Getter -@ToString -public class ControlLoopException extends Exception implements ErrorResponseInfo { - private static final long serialVersionUID = -8507246953751956974L; - - // The error response of the exception - private final ErrorResponse errorResponse = new ErrorResponse(); - - // The object on which the exception was thrown - private final transient Object object; - - /** - * Instantiates a new control loop exception. - * - * @param statusCode the status code for the response as a HTTP status code - * @param message the message on the exception - */ - public ControlLoopException(final Response.Status statusCode, final String message) { - this(statusCode, message, null); - } - - /** - * Instantiates a new control loop exception. - * - * @param statusCode the return code for the exception - * @param message the message on the exception - * @param object the object that the exception was thrown on - */ - public ControlLoopException(final Response.Status statusCode, final String message, final Object object) { - super(message); - errorResponse.setResponseCode(statusCode); - ErrorResponseUtils.getExceptionMessages(errorResponse, this); - this.object = object; - } - - /** - * Instantiates a new control loop exception. - * - * @param statusCode the return code for the exception - * @param message the message on the exception - * @param exception the exception that caused this exception - */ - public ControlLoopException(final Response.Status statusCode, final String message, final Exception exception) { - this(statusCode, message, exception, null); - } - - /** - * Instantiates a new exception. - * - * @param statusCode the return code for the exception - * @param message the message on the exception - * @param exception the exception that caused this exception - * @param object the object that the exception was thrown on - */ - public ControlLoopException(final Response.Status statusCode, final String message, final Exception exception, - final Object object) { - super(message, exception); - errorResponse.setResponseCode(statusCode); - ErrorResponseUtils.getExceptionMessages(errorResponse, this); - this.object = object; - } -} diff --git a/common/src/main/java/org/onap/policy/clamp/controlloop/common/exception/ControlLoopRuntimeException.java b/common/src/main/java/org/onap/policy/clamp/controlloop/common/exception/ControlLoopRuntimeException.java deleted file mode 100644 index b110a4362..000000000 --- a/common/src/main/java/org/onap/policy/clamp/controlloop/common/exception/ControlLoopRuntimeException.java +++ /dev/null @@ -1,107 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * Copyright (C) 2021 Nordix Foundation. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - * SPDX-License-Identifier: Apache-2.0 - * ============LICENSE_END========================================================= - */ - -package org.onap.policy.clamp.controlloop.common.exception; - -import javax.ws.rs.core.Response; -import lombok.Getter; -import lombok.ToString; -import org.onap.policy.models.errors.concepts.ErrorResponse; -import org.onap.policy.models.errors.concepts.ErrorResponseInfo; -import org.onap.policy.models.errors.concepts.ErrorResponseUtils; - -/** - * This class is a base control loop run time exception from which all control loop run time exceptions are sub classes. - */ -@Getter -@ToString -public class ControlLoopRuntimeException extends RuntimeException implements ErrorResponseInfo { - private static final long serialVersionUID = -8507246953751956974L; - - // The error response of the exception - private final ErrorResponse errorResponse = new ErrorResponse(); - - // The object on which the exception was thrown - private final transient Object object; - - /** - * Instantiates a new control loop runtime exception. - * - * @param statusCode the return code for the exception - * @param message the message on the exception - */ - public ControlLoopRuntimeException(final Response.Status statusCode, final String message) { - this(statusCode, message, null); - } - - /** - * Instantiates a new control loop runtime exception. - * - * @param statusCode the return code for the exception - * @param message the message on the exception - * @param object the object that the exception was thrown on - */ - public ControlLoopRuntimeException(final Response.Status statusCode, final String message, final Object object) { - super(message); - this.object = object; - errorResponse.setResponseCode(statusCode); - ErrorResponseUtils.getExceptionMessages(errorResponse, this); - } - - /** - * Instantiates a new control loop runtime exception. - * - * @param statusCode the return code for the exception - * @param message the message on the exception - * @param exception the exception that caused this control loop exception - */ - public ControlLoopRuntimeException(final Response.Status statusCode, final String message, - final Exception exception) { - this(statusCode, message, exception, null); - } - - /** - * Instantiates a new model runtime exception from a ControlLoopException instance. - * - * @param exception the exception that caused this control loop exception - */ - public ControlLoopRuntimeException(final ControlLoopException exception) { - super(exception.getMessage(), exception); - this.object = exception.getObject(); - errorResponse.setResponseCode(exception.getErrorResponse().getResponseCode()); - ErrorResponseUtils.getExceptionMessages(errorResponse, this); - } - - /** - * Instantiates a new control loop runtime exception. - * - * @param statusCode the return code for the exception - * @param message the message on the exception - * @param exception the exception that caused this control loop exception - * @param object the object that the exception was thrown on - */ - public ControlLoopRuntimeException(final Response.Status statusCode, final String message, - final Exception exception, final Object object) { - super(message, exception); - this.object = object; - errorResponse.setResponseCode(statusCode); - ErrorResponseUtils.getExceptionMessages(errorResponse, this); - } -} diff --git a/common/src/main/java/org/onap/policy/clamp/controlloop/common/rest/CoderHttpMesageConverter.java b/common/src/main/java/org/onap/policy/clamp/controlloop/common/rest/CoderHttpMesageConverter.java deleted file mode 100644 index 9eb43fd6f..000000000 --- a/common/src/main/java/org/onap/policy/clamp/controlloop/common/rest/CoderHttpMesageConverter.java +++ /dev/null @@ -1,74 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * Copyright (C) 2021 Nordix Foundation. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - * SPDX-License-Identifier: Apache-2.0 - * ============LICENSE_END========================================================= - */ - -package org.onap.policy.clamp.controlloop.common.rest; - -import java.io.IOException; -import java.io.InputStreamReader; -import java.io.OutputStreamWriter; -import java.nio.charset.StandardCharsets; -import javax.ws.rs.core.Response; -import org.onap.policy.clamp.controlloop.common.exception.ControlLoopRuntimeException; -import org.onap.policy.common.utils.coder.Coder; -import org.onap.policy.common.utils.coder.CoderException; -import org.onap.policy.common.utils.coder.StandardCoder; -import org.onap.policy.common.utils.coder.StandardYamlCoder; -import org.springframework.http.HttpInputMessage; -import org.springframework.http.HttpOutputMessage; -import org.springframework.http.MediaType; -import org.springframework.http.converter.AbstractHttpMessageConverter; -import org.springframework.http.converter.HttpMessageNotReadableException; -import org.springframework.http.converter.HttpMessageNotWritableException; - -public class CoderHttpMesageConverter extends AbstractHttpMessageConverter { - - private Coder coder; - - public CoderHttpMesageConverter(String type) { - super(new MediaType("application", type, StandardCharsets.UTF_8)); - this.coder = "json".equals(type) ? new StandardCoder() : new StandardYamlCoder(); - } - - @Override - protected boolean supports(Class clazz) { - return true; - } - - @Override - protected T readInternal(Class clazz, HttpInputMessage inputMessage) - throws IOException, HttpMessageNotReadableException { - try (var is = new InputStreamReader(inputMessage.getBody(), StandardCharsets.UTF_8)) { - return coder.decode(is, clazz); - } catch (CoderException e) { - throw new ControlLoopRuntimeException(Response.Status.BAD_REQUEST, e.getMessage(), e); - } - } - - @Override - protected void writeInternal(T t, HttpOutputMessage outputMessage) - throws IOException, HttpMessageNotWritableException { - try (var writer = new OutputStreamWriter(outputMessage.getBody(), StandardCharsets.UTF_8)) { - coder.encode(writer, t); - } catch (CoderException e) { - throw new ControlLoopRuntimeException(Response.Status.BAD_REQUEST, e.getMessage(), e); - } - } - -} diff --git a/common/src/main/java/org/onap/policy/clamp/controlloop/common/rest/RequestResponseLoggingFilter.java b/common/src/main/java/org/onap/policy/clamp/controlloop/common/rest/RequestResponseLoggingFilter.java deleted file mode 100644 index 915cdf0b2..000000000 --- a/common/src/main/java/org/onap/policy/clamp/controlloop/common/rest/RequestResponseLoggingFilter.java +++ /dev/null @@ -1,69 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * Copyright (C) 2021 Nordix Foundation. - * ================================================================================ - * Modifications Copyright (C) 2021 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - * SPDX-License-Identifier: Apache-2.0 - * ============LICENSE_END========================================================= - */ - -package org.onap.policy.clamp.controlloop.common.rest; - -import java.io.IOException; -import java.util.UUID; -import javax.servlet.Filter; -import javax.servlet.FilterChain; -import javax.servlet.ServletException; -import javax.servlet.ServletRequest; -import javax.servlet.ServletResponse; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; -import org.springframework.core.annotation.Order; -import org.springframework.stereotype.Component; - -@Component -@Order(2) -public class RequestResponseLoggingFilter implements Filter { - - private static final String VERSION_MINOR_NAME = "X-MinorVersion"; - private static final String VERSION_PATCH_NAME = "X-PatchVersion"; - private static final String VERSION_LATEST_NAME = "X-LatestVersion"; - public static final String API_VERSION = "1.0.0"; - public static final String REQUEST_ID_NAME = "X-ONAP-RequestID"; - - @Override - public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain) - throws IOException, ServletException { - - - HttpServletResponse res = (HttpServletResponse) response; - HttpServletRequest req = (HttpServletRequest) request; - - /* - * Disabling sonar because of ONAP requires the request ID to be copied from the request - * to the response. - */ - String requestId = req.getHeader(REQUEST_ID_NAME); - res.addHeader(REQUEST_ID_NAME, requestId != null ? requestId : UUID.randomUUID().toString()); // NOSONAR - - res.addHeader(VERSION_MINOR_NAME, "0"); - res.addHeader(VERSION_PATCH_NAME, "0"); - res.addHeader(VERSION_LATEST_NAME, API_VERSION); - - chain.doFilter(request, response); - } - -} diff --git a/common/src/main/java/org/onap/policy/clamp/controlloop/common/startstop/CommonCommandLineArguments.java b/common/src/main/java/org/onap/policy/clamp/controlloop/common/startstop/CommonCommandLineArguments.java deleted file mode 100644 index 525da259f..000000000 --- a/common/src/main/java/org/onap/policy/clamp/controlloop/common/startstop/CommonCommandLineArguments.java +++ /dev/null @@ -1,145 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * Copyright (C) 2021 Nordix Foundation. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - * SPDX-License-Identifier: Apache-2.0 - * ============LICENSE_END========================================================= - */ - -package org.onap.policy.clamp.controlloop.common.startstop; - -import java.io.File; -import java.io.PrintWriter; -import java.io.StringWriter; -import javax.ws.rs.core.Response; -import org.apache.commons.cli.HelpFormatter; -import org.apache.commons.cli.Option; -import org.apache.commons.cli.Options; -import org.apache.commons.lang3.StringUtils; -import org.onap.policy.clamp.controlloop.common.exception.ControlLoopException; -import org.onap.policy.common.utils.resources.ResourceUtils; - -/** - * This class reads and handles command line parameters. - * - */ -public class CommonCommandLineArguments { - private static final String FILE_MESSAGE_PREAMBLE = " file \""; - private static final int HELP_LINE_LENGTH = 120; - - /** - * Construct the options for the policy participant. - * - * @param options the options for the command line - */ - public CommonCommandLineArguments(final Options options) { - //@formatter:off - options.addOption(Option.builder("h") - .longOpt("help") - .desc("outputs the usage of this command") - .required(false) - .type(Boolean.class) - .build()); - options.addOption(Option.builder("v") - .longOpt("version") - .desc("outputs the version of policy participant") - .required(false) - .type(Boolean.class) - .build()); - options.addOption(Option.builder("c") - .longOpt("config-file") - .desc("the full path to the configuration file to use, " - + "the configuration file must be a Json file containing the " - + "policy participant parameters") - .hasArg() - .argName("CONFIG_FILE") - .required(false) - .type(String.class) - .build()); - //@formatter:on - } - - /** - * Validate the command line options. - * - * @param configurationFilePath the path to the configuration file - * @throws ControlLoopException on command argument validation errors - */ - public void validate(final String configurationFilePath) throws ControlLoopException { - validateReadableFile("policy participant configuration", configurationFilePath); - } - - /** - * Print version information for policy participant. - * - * @return the version string - */ - public String version() { - return ResourceUtils.getResourceAsString("version.txt"); - } - - /** - * Print help information for policy participant. - * - * @param mainClassName the main class name - * @param options the options for the command - * @return the help string - */ - public String help(final String mainClassName, final Options options) { - final var helpFormatter = new HelpFormatter(); - final var stringWriter = new StringWriter(); - final var printWriter = new PrintWriter(stringWriter); - - helpFormatter.printHelp(printWriter, HELP_LINE_LENGTH, mainClassName + " [options...]", "options", options, 0, - 0, ""); - - return stringWriter.toString(); - } - - /** - * Validate readable file. - * - * @param fileTag the file tag - * @param fileName the file name - * @throws ControlLoopException on the file name passed as a parameter - */ - private void validateReadableFile(final String fileTag, final String fileName) throws ControlLoopException { - if (StringUtils.isEmpty(fileName)) { - throw new ControlLoopException(Response.Status.NOT_ACCEPTABLE, - fileTag + " file was not specified as an argument"); - } - - // The file name refers to a resource on the local file system - final var fileUrl = ResourceUtils.getUrl4Resource(fileName); - if (fileUrl == null) { - throw new ControlLoopException(Response.Status.NOT_ACCEPTABLE, - fileTag + FILE_MESSAGE_PREAMBLE + fileName + "\" does not exist"); - } - - final var theFile = new File(fileUrl.getPath()); - if (!theFile.exists()) { - throw new ControlLoopException(Response.Status.NOT_ACCEPTABLE, - fileTag + FILE_MESSAGE_PREAMBLE + fileName + "\" does not exist"); - } - if (!theFile.isFile()) { - throw new ControlLoopException(Response.Status.NOT_ACCEPTABLE, - fileTag + FILE_MESSAGE_PREAMBLE + fileName + "\" is not a normal file"); - } - if (!theFile.canRead()) { - throw new ControlLoopException(Response.Status.NOT_ACCEPTABLE, - fileTag + FILE_MESSAGE_PREAMBLE + fileName + "\" is unreadable"); - } - } -} diff --git a/common/src/main/java/org/onap/policy/clamp/controlloop/common/utils/CommonUtils.java b/common/src/main/java/org/onap/policy/clamp/controlloop/common/utils/CommonUtils.java deleted file mode 100644 index 4ebd0aaa8..000000000 --- a/common/src/main/java/org/onap/policy/clamp/controlloop/common/utils/CommonUtils.java +++ /dev/null @@ -1,152 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * Copyright (C) 2021 Nordix Foundation. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - * SPDX-License-Identifier: Apache-2.0 - * ============LICENSE_END========================================================= - */ - -package org.onap.policy.clamp.controlloop.common.utils; - -import java.util.ArrayList; -import java.util.List; -import java.util.Map; -import org.onap.policy.clamp.controlloop.models.controlloop.concepts.ControlLoopElement; -import org.onap.policy.clamp.controlloop.models.controlloop.concepts.ControlLoopElementDefinition; -import org.onap.policy.clamp.controlloop.models.controlloop.concepts.ParticipantDefinition; -import org.onap.policy.clamp.controlloop.models.controlloop.concepts.ParticipantUpdates; -import org.onap.policy.models.tosca.authorative.concepts.ToscaConceptIdentifier; -import org.onap.policy.models.tosca.authorative.concepts.ToscaNodeTemplate; -import org.onap.policy.models.tosca.authorative.concepts.ToscaNodeType; -import org.onap.policy.models.tosca.authorative.concepts.ToscaServiceTemplate; -import org.onap.policy.models.tosca.authorative.concepts.ToscaTopologyTemplate; - -/** - * Utility functions used in controlloop-runtime and participants. - * - */ -public class CommonUtils { - - private CommonUtils() { - throw new IllegalStateException("Utility class"); - } - - /** - * Prepare participant updates map. - * - * @param clElement controlloop element - * @param participantUpdates list of participantUpdates - */ - public static void prepareParticipantUpdate(ControlLoopElement clElement, - List participantUpdates) { - if (participantUpdates.isEmpty()) { - participantUpdates.add(getControlLoopElementList(clElement)); - return; - } - - var participantExists = false; - for (ParticipantUpdates participantUpdate : participantUpdates) { - if (participantUpdate.getParticipantId().equals(clElement.getParticipantId())) { - participantUpdate.setControlLoopElementList(List.of(clElement)); - participantExists = true; - } - } - if (!participantExists) { - participantUpdates.add(getControlLoopElementList(clElement)); - } - } - - private static ParticipantUpdates getControlLoopElementList(ControlLoopElement clElement) { - var participantUpdate = new ParticipantUpdates(); - participantUpdate.setParticipantId(clElement.getParticipantId()); - participantUpdate.setControlLoopElementList(List.of(clElement)); - return participantUpdate; - } - - /** - * Set the Policy information in the service template for the controlloopelement. - * - * @param clElement controlloop element - * @param toscaServiceTemplate ToscaServiceTemplate - */ - public static void setServiceTemplatePolicyInfo(ControlLoopElement clElement, - ToscaServiceTemplate toscaServiceTemplate) { - // Pass respective PolicyTypes or Policies as part of toscaServiceTemplateFragment - if (toscaServiceTemplate.getPolicyTypes() == null - && toscaServiceTemplate.getToscaTopologyTemplate().getPolicies() == null) { - return; - } - ToscaServiceTemplate toscaServiceTemplateFragment = new ToscaServiceTemplate(); - toscaServiceTemplateFragment.setPolicyTypes(toscaServiceTemplate.getPolicyTypes()); - ToscaTopologyTemplate toscaTopologyTemplate = new ToscaTopologyTemplate(); - toscaTopologyTemplate.setPolicies(toscaServiceTemplate.getToscaTopologyTemplate().getPolicies()); - toscaServiceTemplateFragment.setToscaTopologyTemplate(toscaTopologyTemplate); - toscaServiceTemplateFragment.setDataTypes(toscaServiceTemplate.getDataTypes()); - clElement.setToscaServiceTemplateFragment(toscaServiceTemplateFragment); - } - - /** - * Prepare ParticipantDefinitionUpdate to set in the message. - * - * @param clParticipantType controlloop element - * @param entryKey key for the entry - * @param entryValue value relates to toscaNodeTemplate - * @param participantDefinitionUpdates list of participantDefinitionUpdates - * @param commonPropertiesMap common properties map - */ - public static void prepareParticipantDefinitionUpdate(ToscaConceptIdentifier clParticipantType, String entryKey, - ToscaNodeTemplate entryValue, List participantDefinitionUpdates, - Map commonPropertiesMap) { - - var clDefinition = new ControlLoopElementDefinition(); - clDefinition.setClElementDefinitionId(new ToscaConceptIdentifier(entryKey, entryValue.getVersion())); - clDefinition.setControlLoopElementToscaNodeTemplate(entryValue); - if (commonPropertiesMap != null) { - ToscaNodeType nodeType = commonPropertiesMap.get(entryValue.getType()); - if (nodeType != null) { - clDefinition.setCommonPropertiesMap(nodeType.getProperties()); - } - } - - List controlLoopElementDefinitionList = new ArrayList<>(); - - if (participantDefinitionUpdates.isEmpty()) { - participantDefinitionUpdates - .add(getParticipantDefinition(clDefinition, clParticipantType, controlLoopElementDefinitionList)); - } else { - var participantExists = false; - for (ParticipantDefinition participantDefinitionUpdate : participantDefinitionUpdates) { - if (participantDefinitionUpdate.getParticipantType().equals(clParticipantType)) { - participantDefinitionUpdate.getControlLoopElementDefinitionList().add(clDefinition); - participantExists = true; - } - } - if (!participantExists) { - participantDefinitionUpdates.add( - getParticipantDefinition(clDefinition, clParticipantType, controlLoopElementDefinitionList)); - } - } - } - - private static ParticipantDefinition getParticipantDefinition(ControlLoopElementDefinition clDefinition, - ToscaConceptIdentifier clParticipantType, - List controlLoopElementDefinitionList) { - var participantDefinition = new ParticipantDefinition(); - participantDefinition.setParticipantType(clParticipantType); - controlLoopElementDefinitionList.add(clDefinition); - participantDefinition.setControlLoopElementDefinitionList(controlLoopElementDefinitionList); - return participantDefinition; - } -} diff --git a/common/src/main/resources/tosca/ApplicationServiceDescriptorTypes.yaml b/common/src/main/resources/tosca/ApplicationServiceDescriptorTypes.yaml deleted file mode 100644 index ad16173b9..000000000 --- a/common/src/main/resources/tosca/ApplicationServiceDescriptorTypes.yaml +++ /dev/null @@ -1,74 +0,0 @@ -# ============LICENSE_START======================================================= -# Copyright (C) 2021 Nordix Foundation. -# ================================================================================ -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# -# SPDX-License-Identifier: Apache-2.0 -# ============LICENSE_END========================================================= -tosca_definitions_version: tosca_simple_yaml_1_3 -node_types: - org.oran.asd.DeploymentItem: - version: 1.0.1 - derived_from: org.onap.policy.clamp.controlloop.KubernetesControlLoopElement - properties: - deployemntItemId: - type: onap.datatypes.ToscaConceptIdentifier - required: true - description: The identifier of this deployment item - artifactId: - type: onap.datatypes.ToscaConceptIdentifier - required: true - description: Reference to a DeploymentArtifact - lifecycleParameters: - type: string - required: false - description: List of parameters that can be overridden at deployment time - (e.g. values for values.yaml in the chart this item references) - org.oran.asd.ASD: - version: 1.0.1 - derived_from: org.onap.policy.clamp.controlloop.ControlLoop - properties: - asdId: - type: onap.datatypes.ToscaConceptIdentifier - required: true - description: The identifier of this deployment item - asdSchemaVersion: - type: onap.datatypes.ToscaConceptIdentifier - required: true - description: Reference to a DeploymentArtifact - asdApplication: - type: onap.datatypes.ToscaConceptIdentifier - required: true - description: Reference to a DeploymentArtifact - asdApplicationInfoName: - type: string - required: false - description: Human readable name for the Application service. Can change during the AS lifetime. - asdExtCpd: - type: string - required: false - description: Describes external interface(s) exposed by this AS enabling connection with a VL. - (Similar to VnfExtCpd on VNF-D, but only describing L3 and above interfaces, since - K8S can’t do ("yaml"); + var j = new CoderHttpMesageConverter<>("json"); + + assertTrue(y.supports(CommonCommandLineArguments.class)); + assertTrue(j.supports(CommonCommandLineArguments.class)); + var testInputStream = new ByteArrayInputStream("testdata".getBytes()); + HttpInputMessage input = Mockito.mock(HttpInputMessage.class); + Mockito.when(input.getBody()).thenReturn(testInputStream); + assertThrows(AutomationCompositionRuntimeException.class, () -> { + y.readInternal(RequestResponseLoggingFilterTest.class, input); + }); + + var testOutputStream = new ByteArrayOutputStream(); + HttpOutputMessage output = Mockito.mock(HttpOutputMessage.class); + Mockito.when(output.getBody()).thenReturn(testOutputStream); + assertThrows(AutomationCompositionRuntimeException.class, () -> { + j.writeInternal(String.class, output); + }); + } +} diff --git a/common/src/test/java/org/onap/policy/clamp/common/acm/rest/RequestResponseLoggingFilterTest.java b/common/src/test/java/org/onap/policy/clamp/common/acm/rest/RequestResponseLoggingFilterTest.java new file mode 100644 index 000000000..ff6e1cd34 --- /dev/null +++ b/common/src/test/java/org/onap/policy/clamp/common/acm/rest/RequestResponseLoggingFilterTest.java @@ -0,0 +1,49 @@ +/*- + * ============LICENSE_START======================================================= + * Copyright (C) 2021 Nordix Foundation. + * ================================================================================ + * Modifications Copyright (C) 2021 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * SPDX-License-Identifier: Apache-2.0 + * ============LICENSE_END========================================================= + */ + +package org.onap.policy.clamp.common.acm.rest; + +import static org.junit.jupiter.api.Assertions.assertDoesNotThrow; + +import java.io.IOException; +import javax.servlet.FilterChain; +import javax.servlet.ServletException; +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; +import org.junit.jupiter.api.Test; +import org.mockito.Mockito; + +class RequestResponseLoggingFilterTest { + + @Test + void initTest() throws IOException, ServletException { + var e = new RequestResponseLoggingFilter(); + var res = Mockito.mock(HttpServletResponse.class); + var req = Mockito.mock(HttpServletRequest.class); + var chain = Mockito.mock(FilterChain.class); + Mockito.when(req + .getHeader(RequestResponseLoggingFilter.REQUEST_ID_NAME)) + .thenReturn("id"); + + assertDoesNotThrow(() -> e.doFilter(req, res, chain)); + } +} diff --git a/common/src/test/java/org/onap/policy/clamp/common/acm/startstop/CommonCommandLineArgumentsTest.java b/common/src/test/java/org/onap/policy/clamp/common/acm/startstop/CommonCommandLineArgumentsTest.java new file mode 100644 index 000000000..93b500df0 --- /dev/null +++ b/common/src/test/java/org/onap/policy/clamp/common/acm/startstop/CommonCommandLineArgumentsTest.java @@ -0,0 +1,80 @@ +/*- + * ============LICENSE_START======================================================= + * Copyright (C) 2021 Nordix Foundation. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * SPDX-License-Identifier: Apache-2.0 + * ============LICENSE_END========================================================= + */ + +package org.onap.policy.clamp.common.acm.startstop; + +import static org.assertj.core.api.Assertions.assertThat; +import static org.assertj.core.api.Assertions.assertThatCode; +import static org.assertj.core.api.Assertions.assertThatThrownBy; + +import org.apache.commons.cli.Options; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.Test; + +class CommonCommandLineArgumentsTest { + + public static CommonCommandLineArguments cli; + + @BeforeAll + static void setup() { + cli = new CommonCommandLineArguments(new Options()); + } + + @Test + void testConstructor() { + assertThat(cli).isNotNull(); + } + + @Test + void testHelp() { + assertThat(cli.help("DummyClass", new Options())) + .contains("DummyClass [options...]" + System.lineSeparator() + "options"); + } + + @Test + void testVersion() { + assertThatCode(() -> cli.version()).doesNotThrowAnyException(); + } + + @Test + void testValidateEmptyFileName() { + assertThatThrownBy(() -> cli.validate("")) + .hasMessageContaining("file was not specified as an argument"); + } + + @Test + void testValidateFileUrlNull() { + assertThatThrownBy(() -> cli.validate("abcd")) + .hasMessageContaining("does not exist"); + } + + @Test + void testValidateFileFound() { + String configFile = "demo/config/RuntimeConfig.json"; + assertThatCode(() -> cli.validate(configFile)).doesNotThrowAnyException(); + } + + @Test + void testValidateNotNormalFile() { + String badFile = "demo/config"; + assertThatThrownBy(() -> cli.validate(badFile)).hasMessageContaining("is not a normal file"); + } + +} diff --git a/common/src/test/java/org/onap/policy/clamp/controlloop/common/exception/ExceptionsTest.java b/common/src/test/java/org/onap/policy/clamp/controlloop/common/exception/ExceptionsTest.java deleted file mode 100644 index 6d39337f7..000000000 --- a/common/src/test/java/org/onap/policy/clamp/controlloop/common/exception/ExceptionsTest.java +++ /dev/null @@ -1,84 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * Copyright (C) 2021 Nordix Foundation. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - * SPDX-License-Identifier: Apache-2.0 - * ============LICENSE_END========================================================= - */ - -package org.onap.policy.clamp.controlloop.common.exception; - -import static org.assertj.core.api.Assertions.assertThat; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertNotNull; - -import java.io.IOException; -import javax.ws.rs.core.Response; -import javax.ws.rs.core.Response.Status; -import org.junit.jupiter.api.Test; -import org.onap.policy.models.errors.concepts.ErrorResponse; - -class ExceptionsTest { - - private static final String STRING_TEXT = "String"; - private static final String MESSAGE = "Message"; - - @Test - void testExceptions() { - assertNotNull(new ControlLoopException(Response.Status.OK, MESSAGE)); - assertNotNull(new ControlLoopException(Response.Status.OK, MESSAGE, STRING_TEXT)); - assertNotNull(new ControlLoopException(Response.Status.OK, MESSAGE, new IOException())); - assertNotNull(new ControlLoopException(Response.Status.OK, MESSAGE, new IOException(), STRING_TEXT)); - - String key = "A String"; - ControlLoopException ae = - new ControlLoopException(Response.Status.OK, MESSAGE, new IOException("IO exception message"), key); - ErrorResponse errorResponse = ae.getErrorResponse(); - assertEquals("Message\nIO exception message", String.join("\n", errorResponse.getErrorDetails())); - assertEquals(key, ae.getObject()); - - assertNotNull(new ControlLoopRuntimeException(Response.Status.OK, MESSAGE)); - assertNotNull(new ControlLoopRuntimeException(Response.Status.OK, MESSAGE, STRING_TEXT)); - assertNotNull(new ControlLoopRuntimeException(Response.Status.OK, MESSAGE, new IOException())); - assertNotNull(new ControlLoopRuntimeException(Response.Status.OK, MESSAGE, new IOException(), STRING_TEXT)); - - String rkey = "A String"; - ControlLoopRuntimeException re = new ControlLoopRuntimeException(Response.Status.OK, "Runtime Message", - new IOException("IO runtime exception message"), rkey); - errorResponse = re.getErrorResponse(); - assertEquals("Runtime Message\nIO runtime exception message", - String.join("\n", errorResponse.getErrorDetails())); - assertEquals(key, re.getObject()); - - ControlLoopRuntimeException clre = new ControlLoopRuntimeException(ae); - assertEquals(ae.getErrorResponse().getResponseCode(), clre.getErrorResponse().getResponseCode()); - assertEquals(ae.getMessage(), clre.getMessage()); - - try { - try { - throw new ControlLoopException(Status.BAD_GATEWAY, "An Exception"); - } catch (ControlLoopException cle) { - throw new ControlLoopRuntimeException(cle); - } - } catch (ControlLoopRuntimeException clred) { - assertEquals(Status.BAD_GATEWAY, clred.getErrorResponse().getResponseCode()); - assertEquals("An Exception", clred.getMessage()); - assertEquals(ControlLoopException.class.getName(), clred.getCause().getClass().getName()); - } - - assertThat(ae.toString()).contains("A String"); - assertThat(re.toString()).contains("A String"); - } -} diff --git a/common/src/test/java/org/onap/policy/clamp/controlloop/common/rest/CoderHttpMessageConverterTest.java b/common/src/test/java/org/onap/policy/clamp/controlloop/common/rest/CoderHttpMessageConverterTest.java deleted file mode 100644 index 58015ae3d..000000000 --- a/common/src/test/java/org/onap/policy/clamp/controlloop/common/rest/CoderHttpMessageConverterTest.java +++ /dev/null @@ -1,60 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * Copyright (C) 2021 Nordix Foundation. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - * SPDX-License-Identifier: Apache-2.0 - * ============LICENSE_END========================================================= - */ - -package org.onap.policy.clamp.controlloop.common.rest; - -import static org.junit.Assert.assertTrue; -import static org.junit.jupiter.api.Assertions.assertThrows; - -import java.io.ByteArrayInputStream; -import java.io.ByteArrayOutputStream; -import java.io.IOException; -import org.junit.jupiter.api.Test; -import org.mockito.Mockito; -import org.onap.policy.clamp.controlloop.common.exception.ControlLoopRuntimeException; -import org.onap.policy.clamp.controlloop.common.startstop.CommonCommandLineArguments; -import org.springframework.http.HttpInputMessage; -import org.springframework.http.HttpOutputMessage; - -class CoderHttpMessageConverterTest { - - - @Test - void coderHttpMesageConverterTest() throws ControlLoopRuntimeException, IOException { - var y = new CoderHttpMesageConverter<>("yaml"); - var j = new CoderHttpMesageConverter<>("json"); - - assertTrue(y.supports(CommonCommandLineArguments.class)); - assertTrue(j.supports(CommonCommandLineArguments.class)); - var testInputStream = new ByteArrayInputStream("testdata".getBytes()); - HttpInputMessage input = Mockito.mock(HttpInputMessage.class); - Mockito.when(input.getBody()).thenReturn(testInputStream); - assertThrows(ControlLoopRuntimeException.class, () -> { - y.readInternal(RequestResponseLoggingFilterTest.class, input); - }); - - var testOutputStream = new ByteArrayOutputStream(); - HttpOutputMessage output = Mockito.mock(HttpOutputMessage.class); - Mockito.when(output.getBody()).thenReturn(testOutputStream); - assertThrows(ControlLoopRuntimeException.class, () -> { - j.writeInternal(String.class, output); - }); - } -} diff --git a/common/src/test/java/org/onap/policy/clamp/controlloop/common/rest/RequestResponseLoggingFilterTest.java b/common/src/test/java/org/onap/policy/clamp/controlloop/common/rest/RequestResponseLoggingFilterTest.java deleted file mode 100644 index 7621c9219..000000000 --- a/common/src/test/java/org/onap/policy/clamp/controlloop/common/rest/RequestResponseLoggingFilterTest.java +++ /dev/null @@ -1,49 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * Copyright (C) 2021 Nordix Foundation. - * ================================================================================ - * Modifications Copyright (C) 2021 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - * SPDX-License-Identifier: Apache-2.0 - * ============LICENSE_END========================================================= - */ - -package org.onap.policy.clamp.controlloop.common.rest; - -import static org.junit.jupiter.api.Assertions.assertDoesNotThrow; - -import java.io.IOException; -import javax.servlet.FilterChain; -import javax.servlet.ServletException; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; -import org.junit.jupiter.api.Test; -import org.mockito.Mockito; - -class RequestResponseLoggingFilterTest { - - @Test - void initTest() throws IOException, ServletException { - var e = new RequestResponseLoggingFilter(); - var res = Mockito.mock(HttpServletResponse.class); - var req = Mockito.mock(HttpServletRequest.class); - var chain = Mockito.mock(FilterChain.class); - Mockito.when(req - .getHeader(RequestResponseLoggingFilter.REQUEST_ID_NAME)) - .thenReturn("id"); - - assertDoesNotThrow(() -> e.doFilter(req, res, chain)); - } -} diff --git a/common/src/test/java/org/onap/policy/clamp/controlloop/common/startstop/CommonCommandLineArgumentsTest.java b/common/src/test/java/org/onap/policy/clamp/controlloop/common/startstop/CommonCommandLineArgumentsTest.java deleted file mode 100644 index 8eff21248..000000000 --- a/common/src/test/java/org/onap/policy/clamp/controlloop/common/startstop/CommonCommandLineArgumentsTest.java +++ /dev/null @@ -1,80 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * Copyright (C) 2021 Nordix Foundation. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - * SPDX-License-Identifier: Apache-2.0 - * ============LICENSE_END========================================================= - */ - -package org.onap.policy.clamp.controlloop.common.startstop; - -import static org.assertj.core.api.Assertions.assertThat; -import static org.assertj.core.api.Assertions.assertThatCode; -import static org.assertj.core.api.Assertions.assertThatThrownBy; - -import org.apache.commons.cli.Options; -import org.junit.jupiter.api.BeforeAll; -import org.junit.jupiter.api.Test; - -class CommonCommandLineArgumentsTest { - - public static CommonCommandLineArguments cli; - - @BeforeAll - static void setup() { - cli = new CommonCommandLineArguments(new Options()); - } - - @Test - void testConstructor() { - assertThat(cli).isNotNull(); - } - - @Test - void testHelp() { - assertThat(cli.help("DummyClass", new Options())) - .contains("DummyClass [options...]" + System.lineSeparator() + "options"); - } - - @Test - void testVersion() { - assertThatCode(() -> cli.version()).doesNotThrowAnyException(); - } - - @Test - void testValidateEmptyFileName() { - assertThatThrownBy(() -> cli.validate("")) - .hasMessageContaining("file was not specified as an argument"); - } - - @Test - void testValidateFileUrlNull() { - assertThatThrownBy(() -> cli.validate("abcd")) - .hasMessageContaining("does not exist"); - } - - @Test - void testValidateFileFound() { - String configFile = "demo/config/RuntimeConfig.json"; - assertThatCode(() -> cli.validate(configFile)).doesNotThrowAnyException(); - } - - @Test - void testValidateNotNormalFile() { - String badFile = "demo/config"; - assertThatThrownBy(() -> cli.validate(badFile)).hasMessageContaining("is not a normal file"); - } - -} diff --git a/common/src/test/java/org/onap/policy/clamp/controlloop/common/utils/CommonUtilsTest.java b/common/src/test/java/org/onap/policy/clamp/controlloop/common/utils/CommonUtilsTest.java deleted file mode 100644 index 52e86cf61..000000000 --- a/common/src/test/java/org/onap/policy/clamp/controlloop/common/utils/CommonUtilsTest.java +++ /dev/null @@ -1,151 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * Copyright (C) 2021 Nordix Foundation. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - * SPDX-License-Identifier: Apache-2.0 - * ============LICENSE_END========================================================= - */ - -package org.onap.policy.clamp.controlloop.common.utils; - -import static org.assertj.core.api.Assertions.assertThat; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertNotEquals; - -import java.util.ArrayList; -import java.util.HashMap; -import java.util.List; -import java.util.Map; -import org.junit.jupiter.api.Test; -import org.onap.policy.clamp.controlloop.models.controlloop.concepts.ControlLoopElement; -import org.onap.policy.clamp.controlloop.models.controlloop.concepts.ParticipantDefinition; -import org.onap.policy.clamp.controlloop.models.controlloop.concepts.ParticipantUpdates; -import org.onap.policy.clamp.controlloop.models.controlloop.concepts.ParticipantUtils; -import org.onap.policy.models.tosca.authorative.concepts.ToscaConceptIdentifier; -import org.onap.policy.models.tosca.authorative.concepts.ToscaDataType; -import org.onap.policy.models.tosca.authorative.concepts.ToscaNodeTemplate; -import org.onap.policy.models.tosca.authorative.concepts.ToscaPolicy; -import org.onap.policy.models.tosca.authorative.concepts.ToscaPolicyType; -import org.onap.policy.models.tosca.authorative.concepts.ToscaServiceTemplate; -import org.onap.policy.models.tosca.authorative.concepts.ToscaTopologyTemplate; - -class CommonUtilsTest { - - private ToscaConceptIdentifier id = new ToscaConceptIdentifier("id", "1.0.0"); - private ToscaConceptIdentifier idNode = new ToscaConceptIdentifier( - "org.onap.dcae.controlloop.DCAEMicroserviceControlLoopParticipant", "0.0.0"); - - @Test - void testCommonUtilsParticipantUpdate() { - var clElement = new ControlLoopElement(); - List participantUpdates = new ArrayList<>(); - assertThat(participantUpdates).isEmpty(); - - CommonUtils.prepareParticipantUpdate(clElement, participantUpdates); - assertThat(participantUpdates).isNotEmpty(); - assertEquals(clElement, participantUpdates.get(0).getControlLoopElementList().get(0)); - - CommonUtils.prepareParticipantUpdate(clElement, participantUpdates); - assertNotEquals(id, participantUpdates.get(0).getParticipantId()); - - clElement.setParticipantId(id); - clElement.setParticipantType(id); - CommonUtils.prepareParticipantUpdate(clElement, participantUpdates); - assertEquals(id, participantUpdates.get(1).getParticipantId()); - } - - @Test - void testCommonUtilsServiceTemplate() { - var clElement = new ControlLoopElement(); - var toscaServiceTemplate = getDummyToscaServiceTemplate(); - CommonUtils.setServiceTemplatePolicyInfo(clElement, toscaServiceTemplate); - assertEquals(getDummyToscaDataTypeMap(), clElement.getToscaServiceTemplateFragment().getDataTypes()); - } - - @Test - void testCommonUtilsDefinitionUpdate() { - var toscaServiceTemplate = getDummyToscaServiceTemplate(); - List participantDefinitionUpdates = new ArrayList<>(); - assertThat(participantDefinitionUpdates).isEmpty(); - - checkParticipantDefinitionUpdate(toscaServiceTemplate, participantDefinitionUpdates); - assertThat(participantDefinitionUpdates).isNotEmpty(); - assertEquals(id, participantDefinitionUpdates.get(0).getParticipantType()); - - checkParticipantDefinitionUpdate(toscaServiceTemplate, participantDefinitionUpdates); - assertEquals(idNode, participantDefinitionUpdates.get(0) - .getControlLoopElementDefinitionList().get(0) - .getClElementDefinitionId()); - } - - private ToscaServiceTemplate getDummyToscaServiceTemplate() { - var toscaServiceTemplate = new ToscaServiceTemplate(); - var policyTypes = getDummyPolicyTypesMap(); - toscaServiceTemplate.setPolicyTypes(policyTypes); - - var dataTypes = getDummyToscaDataTypeMap(); - dataTypes.put("onap.datatypes.ToscaConceptIdentifier", new ToscaDataType()); - toscaServiceTemplate.setDataTypes(dataTypes); - - var toscaTopologyTemplate = new ToscaTopologyTemplate(); - Map policy = new HashMap<>(); - toscaTopologyTemplate.setPolicies(List.of(policy)); - var nodeTemplates = getDummyNodeTemplates(); - toscaTopologyTemplate.setNodeTemplates(nodeTemplates); - - toscaServiceTemplate.setToscaTopologyTemplate(toscaTopologyTemplate); - toscaServiceTemplate.setDerivedFrom("tosca.nodetypes.Root"); - toscaServiceTemplate.setDescription("description"); - toscaServiceTemplate.setMetadata(null); - toscaServiceTemplate.setName("name"); - toscaServiceTemplate.setToscaDefinitionsVersion("1.0.0"); - toscaServiceTemplate.setVersion("1.0.1"); - return toscaServiceTemplate; - } - - private Map getDummyPolicyTypesMap() { - Map policyTypes = new HashMap<>(); - policyTypes.put("onap.policies.Match", new ToscaPolicyType()); - return policyTypes; - } - - private Map getDummyToscaDataTypeMap() { - Map dataTypes = new HashMap<>(); - dataTypes.put("onap.datatypes.ToscaConceptIdentifier", new ToscaDataType()); - return dataTypes; - } - - private Map getDummyNodeTemplates() { - Map nodeTemplates = new HashMap<>(); - var nodeTemplate = new ToscaNodeTemplate(); - nodeTemplate.setType("org.onap.policy.clamp.controlloop.ControlLoopElement"); - nodeTemplates.put("org.onap.dcae.controlloop.DCAEMicroserviceControlLoopParticipant", nodeTemplate); - return nodeTemplates; - } - - private void checkParticipantDefinitionUpdate( - ToscaServiceTemplate toscaServiceTemplate, - List participantDefinitionUpdates) { - - for (Map.Entry toscaInputEntry : toscaServiceTemplate.getToscaTopologyTemplate() - .getNodeTemplates().entrySet()) { - if (ParticipantUtils.checkIfNodeTemplateIsControlLoopElement(toscaInputEntry.getValue(), - toscaServiceTemplate)) { - CommonUtils.prepareParticipantDefinitionUpdate(id, toscaInputEntry.getKey(), - toscaInputEntry.getValue(), participantDefinitionUpdates, null); - } - } - } -} diff --git a/common/src/test/resources/asd/MyDomainASDDefintion.yaml b/common/src/test/resources/asd/MyDomainASDDefintion.yaml deleted file mode 100644 index f354ea075..000000000 --- a/common/src/test/resources/asd/MyDomainASDDefintion.yaml +++ /dev/null @@ -1,131 +0,0 @@ -# ============LICENSE_START======================================================= -# Copyright (C) 2021 Nordix Foundation. -# ================================================================================ -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# -# SPDX-License-Identifier: Apache-2.0 -# ============LICENSE_END========================================================= -tosca_definitions_version: tosca_simple_yaml_1_3 -topology_template: - node_templates: - org.oran.asd.MyApplicationServiceDeploymentItem0: - version: 1.0.0 - type: org.oran.asd.DeploymentItem - type_version: 1.0.1 - description: The first Deployment Item in our Application Service - properties: - deployemntItemId: org.oran.asd.MyApplicationServiceDeploymentItem0:1.0.0 - artifactId: org.oran.asd.MyApplicationServiceDeploymentArtifact0:1.0.0 - lifecycleParameters: To be defined - provider: Ericsson - participantType: org.onap.policy.controlloop.participant.Kubernetes:1.0.0 - startPhase: 2 - uninitializedToPassiveTimeout: 180 - chart: - chartId: MyApplicationServiceDeploymentItem0Chart:1.0.0 - releaseName: SomeRelease - namespace: org.oran.asd.MyApplicationService - org.oran.asd.MyApplicationServiceDeploymentItem1: - version: 1.0.0 - type: org.oran.asd.DeploymentItem - type_version: 1.0.1 - description: The second Deployment Item in our Application Service - properties: - deployemntItemId: org.oran.asd.MyApplicationServiceDeploymentItem1:1.0.0 - artifactId: org.oran.asd.MyApplicationServiceDeploymentArtifact1:1.0.0 - lifecycleParameters: To be defined - provider: Ericsson - participantType: org.onap.policy.controlloop.participant.Kubernetes:1.0.0 - startPhase: 4 - uninitializedToPassiveTimeout: 10 - chart: - chartId: MyApplicationServiceDeploymentItem1Chart:1.0.0 - releaseName: SomeRelease - namespace: org.oran.asd.MyApplicationService - org.oran.asd.MyApplicationRestConfig: - version: 1.0.0 - type: org.onap.policy.clamp.controlloop.HttpControlLoopElement - type_version: 1.0.1 - description: The REST configuration for My Application - properties: - provider: Ericsson - participantType: org.onap.policy.controlloop.participant.Http:1.0.0 - startPhase: 1 - baseUrl: https://10.10.10.10:12345/MyApplicationServiceDeploymentItem0RestEndpoint - httpHeaders: - "Content-Type": "application/json" - "Accept": "application/json" - configurationEntities: - org.onap.policy.controlloop.gentleguidance.setDomainConfig:1.0.0: - configurationEntityId: org.onap.policy.controlloop.gentleguidance.setDomainConfig:1.0.0 - restSequence: - - restRequestId: org.oran.asd.myapplication.setDomainConfig.CreateConfig:1.0.0 - httpMethd: POST - path: "gentle/create" - body: - gentleLevel: veryGentle - gentleType: softAndFurry - expectedResponse: 200 - - restRequestId: org.oran.asd.myapplication.setDomainConfig.CreateConfig:1.0.0 - httpMethd: POST - path: "guidance/create" - body: - guidanceLevel: high - guidanceType: subtle - expectedResponse: 200 - org.oran.asd.myapplication.updateDomainConfig:1.0.0: - configurationEntityId: org.oran.asd.myapplication.updateDomainConfig:1.0.0 - restSequence: - - restRequestId: org.oran.asd.myapplication.updateDomainConfig.UpdateConfig:1.0.0 - httpMethd: PUT - path: "gentle/update]" - body: - gentleLevel: robust - gentleType: hardAndGritty - expectedResponse: 200 - - restRequestId: org.oran.asd.myapplication.updateDomainConfig.UpdateConfig:1.0.0 - httpMethd: PUT - path: "guidance/update" - body: - guidanceLevel: low - guidanceType: terse - expectedResponse: 200 - org.oran.asd.MyApplicationPolicy: - version: 1.0.0 - type: org.onap.policy.clamp.controlloop.PolicyControlLoopElement - type_version: 1.0.1 - description: My Application Operational Policy - properties: - provider: Ericsson - participantType: org.onap.policy.controlloop.participant.Policy:1.0.0 - startPhase: 0 - policyType: onap.policies.controlloop.operational.common.Apex:1.0.0 - policyId: org.oran.asd.myapplication.ServiceControlPolicy:1.0.0 - org.org.oran.asd.MyApplicationService: - version: 1.0.0 - type: org.oran.asd.ASD - type_version: 1.0.1 - description: ASD Definition of the My Application Service - properties: - asdId: org.org.oran.asd.MyApplicationService:1.0.0 - asdSchemaVersion: 2.3.2 - provider: Ericsson - asdApplication: org.oran.asd.MyWonderfulApplicationService:1.2.1 - asdApplicationInfoName: The wonderful ASD service that does everything imaginable - asdExtCpd: To be defined - enhancedCludterCapabilities: To be defined - elements: - - org.oran.asd.MyApplicationServiceDeploymentItem0:1.0.0 - - org.oran.asd.MyApplicationServiceDeploymentItem1:1.0.0 - - org.oran.asd.MyApplicationRestConfig:1.0.0 - - org.oran.asd.MyApplicationPolicy:1.0.0 diff --git a/common/src/test/resources/demo/Notes.txt b/common/src/test/resources/demo/Notes.txt index f937e0969..5cd981d04 100644 --- a/common/src/test/resources/demo/Notes.txt +++ b/common/src/test/resources/demo/Notes.txt @@ -10,7 +10,7 @@ Go to policy/models/models-sim/policy-models-simulators mvn exec:java -Dexec.mainClass=org.onap.policy.models.simulators.Main -Dexec.args="src/test/resources/simParameters.json" Run CL from command line -Go to clamp/runtime-controlloop +Go to clamp/runtime-acm mvn spring-boot:run -Dspring-boot.run.arguments="--topicServer=localhost --mariadb.host=localhost" Run Participant from command line using Maven @@ -26,15 +26,15 @@ java -jar target/policy-clamp-participant-impl-kubernetes-6.1.2-SNAPSHOT.jar Config of DB Prompt > mysql -MariaDB [(none)]> create database controlloop; +MariaDB [(none)]> create database acm; MariaDB [(none)]> CREATE USER 'policy'@localhost IDENTIFIED BY 'P01icY'; -MariaDB [(none)]> GRANT ALL PRIVILEGES ON controlloop.* TO 'policy'@'localhost';\ +MariaDB [(none)]> GRANT ALL PRIVILEGES ON acm.* TO 'policy'@'localhost';\ MariaDB [(none)]> SHOW GRANTS for 'policy'@localhost; +---------------------------------------------------------------------------------------------------------------+ | Grants for policy@localhost | +---------------------------------------------------------------------------------------------------------------+ | GRANT USAGE ON *.* TO `policy`@`localhost` IDENTIFIED BY PASSWORD '*D0574A541C5DEDF11838FB41CA04E256FD5A04CC' | -| GRANT ALL PRIVILEGES ON `controlloop`.* TO `policy`@`localhost` | +| GRANT ALL PRIVILEGES ON `acm`.* TO `policy`@`localhost` | +---------------------------------------------------------------------------------------------------------------+ 2 rows in set (0.000 sec) @@ -46,16 +46,16 @@ cd docker/csit //the keystore generated: /docker/csit/config/ks.jks Run Participant from command line using Docker -docker run --add-host=message-router: -p 6969:6969 --mount type=bind,source=,target=/opt/app/policy/clamp/etc/ssl/policy-keystore onap/policy-clamp-cl-runtime -docker run --add-host=message-router: -p 8083:8083 --mount type=bind,source=,target=/opt/app/policy/clamp/etc/ssl/policy-keystore onap/policy-clamp-cl-k8s-ppnt -docker run --add-host=message-router: --mount type=bind,source=,target=/opt/app/policy/clamp/etc/ssl/policy-keystore onap/policy-clamp-cl-http-ppnt -docker run --add-host=message-router: --mount type=bind,source=,target=/opt/app/policy/clamp/etc/ssl/policy-keystore onap/policy-clamp-cl-pf-ppnt +docker run --add-host=message-router: -p 6969:6969 --mount type=bind,source=,target=/opt/app/policy/clamp/etc/ssl/policy-keystore onap/policy-clamp-runtime-acm +docker run --add-host=message-router: -p 8083:8083 --mount type=bind,source=,target=/opt/app/policy/clamp/etc/ssl/policy-keystore onap/policy-clamp-ac-k8s-ppnt +docker run --add-host=message-router: --mount type=bind,source=,target=/opt/app/policy/clamp/etc/ssl/policy-keystore onap/policy-clamp-ac-http-ppnt +docker run --add-host=message-router: --mount type=bind,source=,target=/opt/app/policy/clamp/etc/ssl/policy-keystore onap/policy-clamp-ac-pf-ppnt Note: /policy-clamp-tarball/src/main/resources/etc/ssl/policy-truststore is the truststore for DMaap of oom project Participant-k8 swagger: https://localhost:8083/onap/k8sparticipant/swagger-ui/ -CL-Runtime swagger: https://localhost:6969/onap/controlloop/swagger-ui/ +CL-Runtime swagger: https://localhost:6969/onap/acm/swagger-ui/ Run Policy API: -mvn exec:java -Dexec.mainClass=org.onap.policy.api.main.startstop.Main -Dexec.args="-c ../../clamp-tpn/tosca-controlloop/common/src/test/resources/demo/policy-api/PolicyAPIConfig.json" +mvn exec:java -Dexec.mainClass=org.onap.policy.api.main.startstop.Main -Dexec.args="-c common/src/test/resources/demo/config/RuntimeConfig.json" diff --git a/common/src/test/resources/demo/config/DEMO.postman_collection.json b/common/src/test/resources/demo/config/DEMO.postman_collection.json index 31c12bfc6..8e85422ff 100644 --- a/common/src/test/resources/demo/config/DEMO.postman_collection.json +++ b/common/src/test/resources/demo/config/DEMO.postman_collection.json @@ -6,7 +6,7 @@ }, "item": [ { - "name": "Demo: Comission control loop definition Multiple Copy", + "name": "Demo: Comission automation composition definition Multiple Copy", "protocolProfileBehavior": { "disabledSystemHeaders": { "content-type": true @@ -43,7 +43,7 @@ ], "body": { "mode": "raw", - "raw": "tosca_definitions_version: tosca_simple_yaml_1_1_0\ndata_types:\n onap.datatypes.ToscaConceptIdentifier:\n derived_from: tosca.datatypes.Root\n properties:\n name:\n type: string\n required: true\n version:\n type: string\n required: true\n org.onap.datatypes.policy.clamp.controlloop.DCAEMicroserviceControlLoopElementConsulInfo:\n name: org.onap.datatypes.policy.clamp.controlloop.DCAEMicroserviceControlLoopElementConsulInfo\n version: 0.0.0\n derived_from: tosca.datatypes.Root\n properties:\n consulUrl:\n name: consulUrl\n type: string\n typeVersion: 0.0.0\n description: Consul url for this entry\n required: true\n consul_body:\n name: consulBody\n type: string\n typeVersion: 0.0.0\n description: Body of Consul entry\n required: true\n onap.datatype.controlloop.Target:\n derived_from: tosca.datatypes.Root\n description: Definition for a entity in A&AI to perform a control loop operation on\n properties:\n targetType:\n type: string\n description: Category for the target type\n required: true\n constraints:\n - valid_values:\n - VNF\n - VM\n - VFMODULE\n - PNF\n entityIds:\n type: map\n description: |\n Map of values that identify the resource. If none are provided, it is assumed that the\n entity that generated the ONSET event will be the target.\n required: false\n metadata:\n clamp_possible_values: ClampExecution:CSAR_RESOURCES\n entry_schema:\n type: string\n onap.datatype.controlloop.Actor:\n derived_from: tosca.datatypes.Root\n description: An actor/operation/target definition\n properties:\n actor:\n type: string\n description: The actor performing the operation.\n required: true\n metadata:\n clamp_possible_values: Dictionary:DefaultActors,ClampExecution:CDS/actor\n operation:\n type: string\n description: The operation the actor is performing.\n metadata:\n clamp_possible_values: Dictionary:DefaultOperations,ClampExecution:CDS/operation\n required: true\n target:\n type: onap.datatype.controlloop.Target\n description: The resource the operation should be performed on.\n required: true\n payload:\n type: map\n description: Name/value pairs of payload information passed by Policy to the actor\n required: false\n metadata:\n clamp_possible_values: ClampExecution:CDS/payload\n entry_schema:\n type: string\n onap.datatype.controlloop.Operation:\n derived_from: tosca.datatypes.Root\n description: An operation supported by an actor\n properties:\n id:\n type: string\n description: Unique identifier for the operation\n required: true\n description:\n type: string\n description: A user-friendly description of the intent for the operation\n required: false\n operation:\n type: onap.datatype.controlloop.Actor\n description: The definition of the operation to be performed.\n required: true\n timeout:\n type: integer\n description: The amount of time for the actor to perform the operation.\n required: true\n retries:\n type: integer\n description: The number of retries the actor should attempt to perform the operation.\n required: true\n default: 0\n success:\n type: string\n description: Points to the operation to invoke on success. A value of \"final_success\" indicates and end to the operation.\n required: false\n default: final_success\n failure:\n type: string\n description: Points to the operation to invoke on Actor operation failure.\n required: false\n default: final_failure\n failure_timeout:\n type: string\n description: Points to the operation to invoke when the time out for the operation occurs.\n required: false\n default: final_failure_timeout\n failure_retries:\n type: string\n description: Points to the operation to invoke when the current operation has exceeded its max retries.\n required: false\n default: final_failure_retries\n failure_exception:\n type: string\n description: Points to the operation to invoke when the current operation causes an exception.\n required: false\n default: final_failure_exception\n failure_guard:\n type: string\n description: Points to the operation to invoke when the current operation is blocked due to guard policy enforcement.\n required: false\n default: final_failure_guard\n onap.datatypes.monitoring.managedObjectDNsBasic:\n constraints: []\n properties:\n DN:\n name: DN\n type: string\n typeVersion: 0.0.0\n description: Managed object distinguished name\n required: true\n constraints: []\n metadata: {}\n name: onap.datatypes.monitoring.managedObjectDNsBasic\n version: 0.0.0\n derived_from: tosca.datatypes.Root\n metadata: {}\n onap.datatypes.monitoring.managedObjectDNsBasics:\n constraints: []\n properties:\n managedObjectDNsBasic:\n name: managedObjectDNsBasic\n type: map\n typeVersion: 0.0.0\n description: Managed object distinguished name object\n required: true\n constraints: []\n entry_schema:\n type: onap.datatypes.monitoring.managedObjectDNsBasic\n typeVersion: 0.0.0\n constraints: []\n metadata: {}\n name: onap.datatypes.monitoring.managedObjectDNsBasics\n version: 0.0.0\n derived_from: tosca.datatypes.Root\n metadata: {}\n onap.datatypes.monitoring.measurementGroup:\n constraints: []\n properties:\n measurementTypes:\n name: measurementTypes\n type: list\n typeVersion: 0.0.0\n description: List of measurement types\n required: true\n constraints: []\n entry_schema:\n type: onap.datatypes.monitoring.measurementTypes\n typeVersion: 0.0.0\n constraints: []\n metadata: {}\n managedObjectDNsBasic:\n name: managedObjectDNsBasic\n type: list\n typeVersion: 0.0.0\n description: List of managed object distinguished names\n required: true\n constraints: []\n entry_schema:\n type: onap.datatypes.monitoring.managedObjectDNsBasics\n typeVersion: 0.0.0\n constraints: []\n metadata: {}\n name: onap.datatypes.monitoring.measurementGroup\n version: 0.0.0\n derived_from: tosca.datatypes.Root\n metadata: {}\n onap.datatypes.monitoring.measurementGroups:\n constraints: []\n properties:\n measurementGroup:\n name: measurementGroup\n type: map\n typeVersion: 0.0.0\n description: Measurement Group\n required: true\n constraints: []\n entry_schema:\n type: onap.datatypes.monitoring.measurementGroup\n typeVersion: 0.0.0\n constraints: []\n metadata: {}\n name: onap.datatypes.monitoring.measurementGroups\n version: 0.0.0\n derived_from: tosca.datatypes.Root\n metadata: {}\n onap.datatypes.monitoring.measurementType:\n constraints: []\n properties:\n measurementType:\n name: measurementType\n type: string\n typeVersion: 0.0.0\n description: Measurement type\n required: true\n constraints: []\n metadata: {}\n name: onap.datatypes.monitoring.measurementType\n version: 0.0.0\n derived_from: tosca.datatypes.Root\n metadata: {}\n onap.datatypes.monitoring.measurementTypes:\n constraints: []\n properties:\n measurementType:\n name: measurementType\n type: map\n typeVersion: 0.0.0\n description: Measurement type object\n required: true\n constraints: []\n entry_schema:\n type: onap.datatypes.monitoring.measurementType\n typeVersion: 0.0.0\n constraints: []\n metadata: {}\n name: onap.datatypes.monitoring.measurementTypes\n version: 0.0.0\n derived_from: tosca.datatypes.Root\n metadata: {}\n onap.datatypes.monitoring.nfFilter:\n constraints: []\n properties:\n modelNames:\n name: modelNames\n type: list\n typeVersion: 0.0.0\n description: List of model names\n required: true\n constraints: []\n entry_schema:\n type: string\n typeVersion: 0.0.0\n constraints: []\n metadata: {}\n modelInvariantIDs:\n name: modelInvariantIDs\n type: list\n typeVersion: 0.0.0\n description: List of model invariant IDs\n required: true\n constraints: []\n entry_schema:\n type: string\n typeVersion: 0.0.0\n constraints: []\n metadata: {}\n modelVersionIDs:\n name: modelVersionIDs\n type: list\n typeVersion: 0.0.0\n description: List of model version IDs\n required: true\n constraints: []\n entry_schema:\n type: string\n typeVersion: 0.0.0\n constraints: []\n metadata: {}\n nfNames:\n name: nfNames\n type: list\n typeVersion: 0.0.0\n description: List of network functions\n required: true\n constraints: []\n entry_schema:\n type: string\n typeVersion: 0.0.0\n constraints: []\n metadata: {}\n name: onap.datatypes.monitoring.nfFilter\n version: 0.0.0\n derived_from: tosca.datatypes.Root\n metadata: {}\n onap.datatypes.monitoring.subscription:\n constraints: []\n properties:\n measurementGroups:\n name: measurementGroups\n type: list\n typeVersion: 0.0.0\n description: Measurement Groups\n required: true\n constraints: []\n entry_schema:\n type: onap.datatypes.monitoring.measurementGroups\n typeVersion: 0.0.0\n constraints: []\n metadata: {}\n fileBasedGP:\n name: fileBasedGP\n type: integer\n typeVersion: 0.0.0\n description: File based granularity period\n required: true\n constraints: []\n metadata: {}\n fileLocation:\n name: fileLocation\n type: string\n typeVersion: 0.0.0\n description: ROP file location\n required: true\n constraints: []\n metadata: {}\n subscriptionName:\n name: subscriptionName\n type: string\n typeVersion: 0.0.0\n description: Name of the subscription\n required: true\n constraints: []\n metadata: {}\n administrativeState:\n name: administrativeState\n type: string\n typeVersion: 0.0.0\n description: State of the subscription\n required: true\n constraints:\n - valid_values:\n - LOCKED\n - UNLOCKED\n metadata: {}\n nfFilter:\n name: nfFilter\n type: map\n typeVersion: 0.0.0\n description: Network function filter\n required: true\n constraints: []\n entry_schema:\n type: onap.datatypes.monitoring.nfFilter\n typeVersion: 0.0.0\n constraints: []\n metadata: {}\n name: onap.datatypes.monitoring.subscription\n version: 0.0.0\n derived_from: tosca.datatypes.Root\n metadata: {}\npolicy_types:\n onap.policies.Monitoring:\n derived_from: tosca.policies.Root\n description: a base policy type for all policies that govern monitoring provisioning\n version: 1.0.0\n name: onap.policies.Monitoring\n onap.policies.Sirisha:\n derived_from: tosca.policies.Root\n description: a base policy type for all policies that govern monitoring provisioning\n version: 1.0.0\n name: onap.policies.Sirisha\n onap.policies.monitoring.dcae-pm-subscription-handler:\n properties:\n pmsh_policy:\n name: pmsh_policy\n type: onap.datatypes.monitoring.subscription\n typeVersion: 0.0.0\n description: PMSH Policy JSON\n required: false\n constraints: []\n metadata: {}\n name: onap.policies.monitoring.dcae-pm-subscription-handler\n version: 1.0.0\n derived_from: onap.policies.Monitoring\n metadata: {}\n onap.policies.controlloop.operational.Common:\n derived_from: tosca.policies.Root\n version: 1.0.0\n name: onap.policies.controlloop.operational.Common\n description: |\n Operational Policy for Control Loop execution. Originated in Frankfurt to support TOSCA Compliant\n Policy Types. This does NOT support the legacy Policy YAML policy type.\n properties:\n id:\n type: string\n description: The unique control loop id.\n required: true\n timeout:\n type: integer\n description: |\n Overall timeout for executing all the operations. This timeout should equal or exceed the total\n timeout for each operation listed.\n required: true\n abatement:\n type: boolean\n description: Whether an abatement event message will be expected for the control loop from DCAE.\n required: true\n default: false\n trigger:\n type: string\n description: Initial operation to execute upon receiving an Onset event message for the Control Loop.\n required: true\n operations:\n type: list\n description: List of operations to be performed when Control Loop is triggered.\n required: true\n entry_schema:\n type: onap.datatype.controlloop.Operation\n onap.policies.controlloop.operational.common.Apex:\n derived_from: onap.policies.controlloop.operational.Common\n type_version: 1.0.0\n version: 1.0.0\n name: onap.policies.controlloop.operational.common.Apex\n description: Operational policies for Apex PDP\n properties:\n engineServiceParameters:\n type: string\n description: The engine parameters like name, instanceCount, policy implementation, parameters etc.\n required: true\n eventInputParameters:\n type: string\n description: The event input parameters.\n required: true\n eventOutputParameters:\n type: string\n description: The event output parameters.\n required: true\n javaProperties:\n type: string\n description: Name/value pairs of properties to be set for APEX if needed.\n required: false\nnode_types:\n org.onap.policy.clamp.controlloop.Participant:\n version: 1.0.1\n derived_from: tosca.nodetypes.Root\n properties:\n provider:\n type: string\n requred: false\n org.onap.policy.clamp.controlloop.ControlLoopElement:\n version: 1.0.1\n derived_from: tosca.nodetypes.Root\n properties:\n provider:\n type: string\n required: false\n metadata:\n common: true\n description: Specifies the organization that provides the control loop element\n participantType:\n type: onap.datatypes.ToscaConceptIdentifier\n required: true\n metadata:\n common: true\n description: The identity of the participant type that hosts this type of Control Loop Element\n startPhase:\n type: integer\n required: false\n constraints:\n - greater-or-equal: 0\n metadata:\n common: true\n description: A value indicating the start phase in which this control loop element will be started, the\n first start phase is zero. Control Loop Elements are started in their start_phase order and stopped\n in reverse start phase order. Control Loop Elements with the same start phase are started and\n stopped simultaneously\n uninitializedToPassiveTimeout:\n type: integer\n required: false\n constraints:\n - greater-or-equal: 0\n default: 60\n metadata:\n common: true\n description: The maximum time in seconds to wait for a state chage from uninitialized to passive\n passiveToRunningTimeout:\n type: integer\n required: false\n constraints:\n - greater-or-equal: 0\n default: 60\n metadata:\n common: true\n description: The maximum time in seconds to wait for a state chage from passive to running\n runningToPassiveTimeout:\n type: integer\n required: false\n constraints:\n - greater-or-equal: 0\n default: 60\n metadata:\n common: true\n description: The maximum time in seconds to wait for a state chage from running to passive\n passiveToUninitializedTimeout:\n type: integer\n required: false\n constraints:\n - greater-or-equal: 0\n default: 60\n metadata:\n common: true\n description: The maximum time in seconds to wait for a state chage from passive to uninitialized\n\n org.onap.policy.clamp.controlloop.ControlLoop:\n version: 1.0.1\n derived_from: tosca.nodetypes.Root\n properties:\n provider:\n type: string\n requred: false\n elements:\n type: list\n required: true\n entry_schema:\n type: onap.datatypes.ToscaConceptIdentifier\n org.onap.policy.clamp.controlloop.DCAEMicroserviceControlLoopElement:\n version: 1.0.1\n derived_from: org.onap.policy.clamp.controlloop.ControlLoopElement\n properties:\n dcae_blueprint_id:\n type: onap.datatypes.ToscaConceptIdentifier\n requred: false\n dcae_blueprint:\n type: onap.dcae.cloudify_blueprint\n requred: false\n consul_info:\n type: list\n required: false\n entry_schema:\n type: org.onap.datatypes.policy.clamp.controlloop.DCAEMicroserviceControlLoopElementConsulInfo\n org.onap.policy.clamp.controlloop.PolicyControlLoopElement:\n version: 1.0.1\n derived_from: org.onap.policy.clamp.controlloop.ControlLoopElement\n properties:\n policy_type_id:\n type: onap.datatypes.ToscaConceptIdentifier\n requred: true\n policy_id:\n type: onap.datatypes.ToscaConceptIdentifier\n requred: false\n org.onap.policy.clamp.controlloop.CDSControlLoopElement:\n version: 1.0.1\n derived_from: org.onap.policy.clamp.controlloop.ControlLoopElement\n properties:\n cds_blueprint_id:\n type: onap.datatypes.ToscaConceptIdentifier\n requred: true\ntopology_template:\n inputs:\n pmsh_monitoring_policy:\n type: onap.datatypes.ToscaConceptIdentifier\n description: The ID of the PMSH monitoring policy to use\n default:\n name: MICROSERVICE_vLoadBalancerMS_v1_0_dcae-pm-subscription-handler_1_0_0test\n version: 1.0.0\n pmsh_operational_policy:\n type: onap.datatypes.ToscaConceptIdentifier\n description: The ID of the PMSH operational policy to use\n default:\n name: operational.apex.pmcontrol\n version: 1.0.0\n node_templates:\n org.onap.dcae.controlloop.DCAEMicroserviceControlLoopParticipant:\n version: 2.3.4\n type: org.onap.policy.clamp.controlloop.Participant\n type_version: 1.0.1\n description: Participant for DCAE microservices\n properties:\n provider: ONAP\n org.onap.policy.controlloop.PolicyControlLoopParticipant:\n version: 2.3.1\n type: org.onap.policy.clamp.controlloop.Participant\n type_version: 1.0.1\n description: Participant for DCAE microservices\n properties:\n provider: ONAP\n org.onap.domain.pmsh.PMSH_DCAEMicroservice:\n version: 1.2.3\n type: org.onap.policy.clamp.controlloop.DCAEMicroserviceControlLoopElement\n type_version: 1.0.0\n description: Control loop element for the DCAE microservice for Performance Management Subscription Handling\n properties:\n provider: Ericsson\n participantType:\n name: org.onap.dcae.controlloop.DCAEMicroserviceControlLoopParticipant\n version: 2.3.4\n startPhase: 0\n dcae_blueprint:\n tosca_definitions_version: cloudify_dsl_1_3\n imports:\n - https://www.getcloudify.org/spec/cloudify/4.5.5/types.yaml\n - plugin:k8splugin?version=3.7.0\n - plugin:pgaas?version=1.3.0\n - plugin:clamppolicyplugin?version=1.1.0\n inputs:\n tag_version:\n type: string\n description: Docker image to be used\n default: nexus3.onap.org:10001/onap/org.onap.dcaegen2.services.pmsh:1.1.2\n replicas:\n type: integer\n description: Number of instances\n default: 1\n operational_policy_name:\n type: string\n default: operational.apex.pmcontrol\n control_loop_name:\n type: string\n default: pmsh-control-loop\n pmsh_publish_topic_name:\n type: string\n default: unauthenticated.DCAE_CL_OUTPUT\n policy_feedback_topic_name:\n type: string\n default: unauthenticated.PMSH_CL_INPUT\n aai_notification_topic_name:\n type: string\n default: AAI-EVENT\n publisher_client_role:\n type: string\n description: Client role to request secure access to topic\n default: org.onap.dcae.pmPublisher\n subscriber_client_role:\n type: string\n description: Client role to request secure access to topic\n default: org.onap.dcae.pmSubscriber\n dcae_location:\n type: string\n description: DCAE location for the subscriber, used to set up routing\n default: san-francisco\n cpu_limit:\n type: string\n default: 1000m\n cpu_request:\n type: string\n default: 1000m\n memory_limit:\n type: string\n default: 1024Mi\n memory_request:\n type: string\n default: 1024Mi\n pgaas_cluster_name:\n type: string\n default: dcae-pg-primary.onap\n enable_tls:\n type: boolean\n default: true\n protocol:\n type: string\n description: PMSH protocol. If enable_tls is false, set to http\n default: https\n policy_model_id:\n type: string\n default: onap.policies.monitoring.dcae-pm-subscription-handler\n policy_id:\n type: string\n default: MICROSERVICE_vLoadBalancerMS_v1_0_dcae-pm-subscription-handler_1_0_0test\n node_templates:\n pgaasvm:\n type: dcae.nodes.pgaas.database\n properties:\n writerfqdn:\n get_input: pgaas_cluster_name\n name: pmsh\n pmsh:\n type: dcae.nodes.ContainerizedServiceComponentUsingDmaap\n interfaces:\n cloudify.interfaces.lifecycle:\n create:\n inputs:\n ports:\n - '8443:0'\n envs:\n PMSH_PG_URL:\n get_attribute:\n - pgaasvm\n - admin\n - host\n PMSH_PG_PASSWORD:\n get_attribute:\n - pgaasvm\n - admin\n - password\n PMSH_PG_USERNAME:\n get_attribute:\n - pgaasvm\n - admin\n - user\n PMSH_DB_NAME:\n get_attribute:\n - pgaasvm\n - admin\n - database\n relationships:\n - target: pmsh-policy\n type: cloudify.relationships.depends_on\n properties:\n service_component_type: dcae-pmsh\n service_component_name_override: dcae-pmsh\n application_config:\n enable_tls:\n get_input: enable_tls\n aaf_identity: dcae@dcae.onap.org\n aaf_password: demo123456!\n operational_policy_name:\n get_input: operational_policy_name\n control_loop_name:\n get_input: control_loop_name\n cert_path: /opt/app/pmsh/etc/certs/cert.pem\n key_path: /opt/app/pmsh/etc/certs/key.pem\n ca_cert_path: /opt/app/pmsh/etc/certs/cacert.pem\n streams_publishes:\n policy_pm_publisher:\n type: message_router\n dmaap_info:\n topic_url:\n concat:\n - http://message-router:3904/events/\n - get_input: pmsh_publish_topic_name\n streams_subscribes:\n policy_pm_subscriber:\n type: message_router\n dmaap_info:\n topic_url:\n concat:\n - http://message-router:3904/events/\n - get_input: policy_feedback_topic_name\n aai_subscriber:\n type: message_router\n dmaap_info:\n topic_url:\n concat:\n - http://message-router:3904/events/\n - get_input: aai_notification_topic_name\n resource_config:\n limits:\n cpu:\n get_input: cpu_limit\n memory:\n get_input: memory_limit\n requests:\n cpu:\n get_input: cpu_request\n memory:\n get_input: memory_request\n docker_config:\n healthcheck:\n endpoint: /healthcheck\n interval: 15s\n timeout: 1s\n type:\n get_input: protocol\n image:\n get_input: tag_version\n replicas:\n get_input: replicas\n log_info:\n log_directory: /var/log/ONAP/dcaegen2/services/pmsh\n tls_info:\n cert_directory: /opt/app/pmsh/etc/certs\n use_tls:\n get_input: enable_tls\n pmsh-policy:\n type: clamp.nodes.policy\n properties:\n policy_model_id:\n get_input: policy_model_id\n policy_id:\n get_input: policy_id\n consul_info:\n - consulUrl: http://consul:31321/v1/kv/dcae-pmsh:policy\n consulBody:\n subscription:\n subscriptionName: subscriptiona\n administrativeState: UNLOCKED\n fileBasedGP: 15\n fileLocation: /pm/pm.xml\n nfFilter:\n nfNames:\n - ^pnf1.*\n modelInvariantIDs:\n - 5845y423-g654-6fju-po78-8n53154532k6\n - 7129e420-d396-4efb-af02-6b83499b12f8\n modelVersionIDs:\n - e80a6ae3-cafd-4d24-850d-e14c084a5ca9\n measurementGroups:\n - measurementGroup:\n measurementTypes:\n - measurementType: countera\n - measurementType: counterb\n managedObjectDNsBasic:\n - DN: dna\n - DN: dnb\n - measurementGroup:\n measurementTypes:\n - measurementType: counterc\n - measurementType: counterd\n managedObjectDNsBasic:\n - DN: dnc\n - DN: dnd\n org.onap.domain.pmsh.PMSH_MonitoringPolicyControlLoopElement:\n version: 1.2.3\n type: org.onap.policy.clamp.controlloop.PolicyControlLoopElement\n type_version: 1.0.0\n description: Control loop element for the monitoring policy for Performance Management Subscription Handling\n properties:\n provider: Ericsson\n participantType:\n name: org.onap.policy.controlloop.PolicyControlLoopParticipant\n version: 2.3.1\n startPhase: 0\n policy_type_id:\n name: onap.policies.monitoring.pm-subscription-handler\n version: 1.0.0\n policy_id:\n get_input: pmsh_monitoring_policy\n org.onap.domain.pmsh.PMSH_OperationalPolicyControlLoopElement:\n version: 1.2.3\n type: org.onap.policy.clamp.controlloop.PolicyControlLoopElement\n type_version: 1.0.0\n description: Control loop element for the operational policy for Performance Management Subscription Handling\n properties:\n provider: Ericsson\n participantType:\n name: org.onap.policy.controlloop.PolicyControlLoopParticipant\n version: 2.3.1\n startPhase: 0\n policy_type_id:\n name: onap.policies.operational.pm-subscription-handler\n version: 1.0.0\n policy_id:\n get_input: pmsh_operational_policy\n org.onap.domain.pmsh.PMSHControlLoopDefinition:\n version: 1.2.3\n type: org.onap.policy.clamp.controlloop.ControlLoop\n type_version: 1.0.0\n description: Control loop for Performance Management Subscription Handling\n properties:\n provider: Ericsson\n elements:\n - name: org.onap.domain.pmsh.PMSH_DCAEMicroservice\n version: 1.2.3\n - name: org.onap.domain.pmsh.PMSH_MonitoringPolicyControlLoopElement\n version: 1.2.3\n - name: org.onap.domain.pmsh.PMSH_OperationalPolicyControlLoopElement\n version: 1.2.3\n policies:\n - MICROSERVICE_vLoadBalancerMS_v1_0_dcae-pm-subscription-handler_1_0_0test:\n type: onap.policies.monitoring.dcae-pm-subscription-handler\n type_version: 1.0.0\n name: MICROSERVICE_vLoadBalancerMS_v1_0_dcae-pm-subscription-handler_1_0_0test\n version: 1.0.0\n metadata:\n policy-id: MICROSERVICE_vLoadBalancerMS_v1_0_dcae-pm-subscription-handler_1_0_0test\n policy-version: 1.0.0\n properties:\n pmsh_policy:\n fileBasedGP: 15\n fileLocation: /pm/pm.xml\n subscriptionName: subscriptiona\n administrativeState: UNLOCKED\n nfFilter:\n onap.datatypes.monitoring.nfFilter:\n modelVersionIDs:\n - e80a6ae3-cafd-4d24-850d-e14c084a5ca9\n modelInvariantIDs:\n - 5845y423-g654-6fju-po78-8n53154532k6\n - 7129e420-d396-4efb-af02-6b83499b12f8\n modelNames: []\n nfNames:\n - '\"^pnf1.*\"'\n measurementGroups:\n - measurementGroup:\n onap.datatypes.monitoring.measurementGroup:\n measurementTypes:\n - measurementType:\n onap.datatypes.monitoring.measurementType:\n measurementType: countera\n - measurementType:\n onap.datatypes.monitoring.measurementType:\n measurementType: counterb\n managedObjectDNsBasic:\n - managedObjectDNsBasic:\n onap.datatypes.monitoring.managedObjectDNsBasic:\n DN: dna\n - managedObjectDNsBasic:\n onap.datatypes.monitoring.managedObjectDNsBasic:\n DN: dnb\n - measurementGroup:\n onap.datatypes.monitoring.measurementGroup:\n measurementTypes:\n - measurementType:\n onap.datatypes.monitoring.measurementType:\n measurementType: counterc\n - measurementType:\n onap.datatypes.monitoring.measurementType:\n measurementType: counterd\n managedObjectDNsBasic:\n - managedObjectDNsBasic:\n onap.datatypes.monitoring.managedObjectDNsBasic:\n DN: dnc\n - managedObjectDNsBasic:\n onap.datatypes.monitoring.managedObjectDNsBasic:\n DN: dnd\n - operational.apex.pmcontrol:\n type: onap.policies.controlloop.operational.common.Apex\n type_version: 1.0.0\n version: 1.0.0\n metadata:\n policy-id: operational.apex.pmcontrol\n policy-version: 1\n properties:\n engineServiceParameters:\n name: MyApexEngine\n version: 0.0.1\n id: 45\n instanceCount: 2\n deploymentPort: 12561\n policy_type_impl:\n apexPolicyModel:\n key:\n name: PMControlPolicy\n version: 0.0.1\n keyInformation:\n key:\n name: PMControlPolicy_KeyInfo\n version: 0.0.1\n keyInfoMap:\n entry:\n - key:\n name: CDSActionIdentifiersType\n version: 0.0.1\n value:\n key:\n name: CDSActionIdentifiersType\n version: 0.0.1\n UUID: 6e5fa19b-14df-37e3-a4ae-8c537e861a82\n description: Generated description for concept referred to by key \"CDSActionIdentifiersType:0.0.1\"\n - key:\n name: CDSCreateResponseEvent\n version: 0.0.1\n value:\n key:\n name: CDSCreateResponseEvent\n version: 0.0.1\n UUID: 14b29e38-ac75-3273-aa4e-8583c0aa7dad\n description: Generated description for concept referred to by key \"CDSCreateResponseEvent:0.0.1\"\n - key:\n name: CDSCreateResponsePayloadType\n version: 0.0.1\n value:\n key:\n name: CDSCreateResponsePayloadType\n version: 0.0.1\n UUID: 04573f8f-e772-30a5-b1d9-d7318d4a1e13\n description: Generated description for concept referred to by key \"CDSCreateResponsePayloadType:0.0.1\"\n - key:\n name: CDSCreateResponsePolicy\n version: 0.0.1\n value:\n key:\n name: CDSCreateResponsePolicy\n version: 0.0.1\n UUID: e126c965-fc09-3bfe-8f55-70f380a4a49c\n description: Generated description for concept referred to by key \"CDSCreateResponsePolicy:0.0.1\"\n - key:\n name: CDSCreateResponseTask\n version: 0.0.1\n value:\n key:\n name: CDSCreateResponseTask\n version: 0.0.1\n UUID: 6165ee82-afd2-3aab-a517-f00b3f2461d2\n description: Generated description for concept referred to by key \"CDSCreateResponseTask:0.0.1\"\n - key:\n name: CDSCreateSubscriptionPayloadType\n version: 0.0.1\n value:\n key:\n name: CDSCreateSubscriptionPayloadType\n version: 0.0.1\n UUID: 8350ac5e-c157-38b9-9614-a0f93a830e60\n description: Generated description for concept referred to by key \"CDSCreateSubscriptionPayloadType:0.0.1\"\n - key:\n name: CDSCreateSubscriptionRequestEvent\n version: 0.0.1\n value:\n key:\n name: CDSCreateSubscriptionRequestEvent\n version: 0.0.1\n UUID: cfa325ba-226b-3a31-9183-ec43e2b6e9a2\n description: Generated description for concept referred to by key \"CDSCreateSubscriptionRequestEvent:0.0.1\"\n - key:\n name: CDSDeleteResponseEvent\n version: 0.0.1\n value:\n key:\n name: CDSDeleteResponseEvent\n version: 0.0.1\n UUID: 8be9c0fa-7437-3841-aff2-b3cec6ae3bd8\n description: Generated description for concept referred to by key \"CDSDeleteResponseEvent:0.0.1\"\n - key:\n name: CDSDeleteResponsePayloadType\n version: 0.0.1\n value:\n key:\n name: CDSDeleteResponsePayloadType\n version: 0.0.1\n UUID: 3fbfe0c9-152e-34d3-a504-09cd13c058d0\n description: Generated description for concept referred to by key \"CDSDeleteResponsePayloadType:0.0.1\"\n - key:\n name: CDSDeleteResponsePolicy\n version: 0.0.1\n value:\n key:\n name: CDSDeleteResponsePolicy\n version: 0.0.1\n UUID: a780251c-edd5-3132-b865-04313246b43c\n description: Generated description for concept referred to by key \"CDSDeleteResponsePolicy:0.0.1\"\n - key:\n name: CDSDeleteResponseTask\n version: 0.0.1\n value:\n key:\n name: CDSDeleteResponseTask\n version: 0.0.1\n UUID: afce4555-3aa3-3521-a7d8-ee8cdf0d3efc\n description: Generated description for concept referred to by key \"CDSDeleteResponseTask:0.0.1\"\n - key:\n name: CDSDeleteSubscriptionPayloadType\n version: 0.0.1\n value:\n key:\n name: CDSDeleteSubscriptionPayloadType\n version: 0.0.1\n UUID: 12658406-9147-3c9d-a38c-5ad5e30b092b\n description: Generated description for concept referred to by key \"CDSDeleteSubscriptionPayloadType:0.0.1\"\n - key:\n name: CDSDeleteSubscriptionRequestEvent\n version: 0.0.1\n value:\n key:\n name: CDSDeleteSubscriptionRequestEvent\n version: 0.0.1\n UUID: 24380c95-9289-36e6-8cbf-0edefa15ccd9\n description: Generated description for concept referred to by key \"CDSDeleteSubscriptionRequestEvent:0.0.1\"\n - key:\n name: CDSRequestCommonHeaderType\n version: 0.0.1\n value:\n key:\n name: CDSRequestCommonHeaderType\n version: 0.0.1\n UUID: 35590ac0-062c-39f1-8786-b4ff716e30b1\n description: Generated description for concept referred to by key \"CDSRequestCommonHeaderType:0.0.1\"\n - key:\n name: CDSResponseCommonHeaderType\n version: 0.0.1\n value:\n key:\n name: CDSResponseCommonHeaderType\n version: 0.0.1\n UUID: dd7e1805-885a-350b-aaf9-ed541321ae3c\n description: Generated description for concept referred to by key \"CDSResponseCommonHeaderType:0.0.1\"\n - key:\n name: CDSResponseStatusEvent\n version: 0.0.1\n value:\n key:\n name: CDSResponseStatusEvent\n version: 0.0.1\n UUID: 7986e21b-32f7-302e-9554-31f21b673493\n description: Generated description for concept referred to by key \"CDSResponseStatusEvent:0.0.1\"\n - key:\n name: CDSResponseStatusType\n version: 0.0.1\n value:\n key:\n name: CDSResponseStatusType\n version: 0.0.1\n UUID: 92b8a2cf-344e-3ce1-8cc0-2b7d3cb695fa\n description: Generated description for concept referred to by key \"CDSResponseStatusType:0.0.1\"\n - key:\n name: CreateSubscriptionPayloadEvent\n version: 0.0.1\n value:\n key:\n name: CreateSubscriptionPayloadEvent\n version: 0.0.1\n UUID: 92162397-1a8e-3a3f-a469-d2af7700af4a\n description: Generated description for concept referred to by key \"CreateSubscriptionPayloadEvent:0.0.1\"\n - key:\n name: CreateSubscriptionPayloadTask\n version: 0.0.1\n value:\n key:\n name: CreateSubscriptionPayloadTask\n version: 0.0.1\n UUID: bc0c69f0-52ed-38ea-b468-ae4a6fd1730d\n description: Generated description for concept referred to by key \"CreateSubscriptionPayloadTask:0.0.1\"\n - key:\n name: CreateSubscriptionRequestTask\n version: 0.0.1\n value:\n key:\n name: CreateSubscriptionRequestTask\n version: 0.0.1\n UUID: 89cb75e9-f06c-30d3-b4ff-698d45f63869\n description: Generated description for concept referred to by key \"CreateSubscriptionRequestTask:0.0.1\"\n - key:\n name: DeleteSubscriptionPayloadEvent\n version: 0.0.1\n value:\n key:\n name: DeleteSubscriptionPayloadEvent\n version: 0.0.1\n UUID: 994fa441-04ab-33bb-832d-1cd12ab5d074\n description: Generated description for concept referred to by key \"DeleteSubscriptionPayloadEvent:0.0.1\"\n - key:\n name: DeleteSubscriptionPayloadTask\n version: 0.0.1\n value:\n key:\n name: DeleteSubscriptionPayloadTask\n version: 0.0.1\n UUID: 0f519117-5fea-3e4b-941f-8f778100465f\n description: Generated description for concept referred to by key \"DeleteSubscriptionPayloadTask:0.0.1\"\n - key:\n name: DeleteSubscriptionRequestTask\n version: 0.0.1\n value:\n key:\n name: DeleteSubscriptionRequestTask\n version: 0.0.1\n UUID: acb772fe-d442-39e3-98f9-b1080caf4150\n description: Generated description for concept referred to by key \"DeleteSubscriptionRequestTask:0.0.1\"\n - key:\n name: MRResponseEvent\n version: 0.0.1\n value:\n key:\n name: MRResponseEvent\n version: 0.0.1\n UUID: 13c747a3-6bae-3bcf-9c80-b152e01dc194\n description: Generated description for concept referred to by key \"MRResponseEvent:0.0.1\"\n - key:\n name: PMControlPolicy\n version: 0.0.1\n value:\n key:\n name: PMControlPolicy\n version: 0.0.1\n UUID: acf1e55c-7bc5-3bd5-975a-0ca54afcd8a4\n description: Generated description for concept referred to by key \"PMControlPolicy:0.0.1\"\n - key:\n name: PMControlPolicy_Albums\n version: 0.0.1\n value:\n key:\n name: PMControlPolicy_Albums\n version: 0.0.1\n UUID: b38ad204-c2c8-32f4-9b5a-dda0aeb0145b\n description: Generated description for concept referred to by key \"PMControlPolicy_Albums:0.0.1\"\n - key:\n name: PMControlPolicy_Events\n version: 0.0.1\n value:\n key:\n name: PMControlPolicy_Events\n version: 0.0.1\n UUID: be3871a0-c42a-3113-a066-82d192840eca\n description: Generated description for concept referred to by key \"PMControlPolicy_Events:0.0.1\"\n - key:\n name: PMControlPolicy_KeyInfo\n version: 0.0.1\n value:\n key:\n name: PMControlPolicy_KeyInfo\n version: 0.0.1\n UUID: ced37634-28a4-3178-b7f6-2980794927b0\n description: Generated description for concept referred to by key \"PMControlPolicy_KeyInfo:0.0.1\"\n - key:\n name: PMControlPolicy_Policies\n version: 0.0.1\n value:\n key:\n name: PMControlPolicy_Policies\n version: 0.0.1\n UUID: be3d180d-ef9c-3a75-8e9c-84271a038bed\n description: Generated description for concept referred to by key \"PMControlPolicy_Policies:0.0.1\"\n - key:\n name: PMControlPolicy_Schemas\n version: 0.0.1\n value:\n key:\n name: PMControlPolicy_Schemas\n version: 0.0.1\n UUID: e61973f1-189c-39e5-82f6-0d3afe298a20\n description: Generated description for concept referred to by key \"PMControlPolicy_Schemas:0.0.1\"\n - key:\n name: PMControlPolicy_Tasks\n version: 0.0.1\n value:\n key:\n name: PMControlPolicy_Tasks\n version: 0.0.1\n UUID: 5658adb3-2962-30a3-a241-fae75bb8eb4a\n description: Generated description for concept referred to by key \"PMControlPolicy_Tasks:0.0.1\"\n - key:\n name: PMSubscriptionAlbum\n version: 0.0.1\n value:\n key:\n name: PMSubscriptionAlbum\n version: 0.0.1\n UUID: c2bd6f0d-6854-317a-9be2-97c08338428c\n description: Generated description for concept referred to by key \"PMSubscriptionAlbum:0.0.1\"\n - key:\n name: PMSubscriptionOutputEvent\n version: 0.0.1\n value:\n key:\n name: PMSubscriptionOutputEvent\n version: 0.0.1\n UUID: 992b7819-9f69-3aa0-bb0f-6e45ea15ce05\n description: Generated description for concept referred to by key \"PMSubscriptionOutputEvent:0.0.1\"\n - key:\n name: PMSubscriptionType\n version: 0.0.1\n value:\n key:\n name: PMSubscriptionType\n version: 0.0.1\n UUID: 73c1c397-4fc3-357f-93b6-a8ad707fbaae\n description: Generated description for concept referred to by key \"PMSubscriptionType:0.0.1\"\n - key:\n name: ReceiveEventPolicy\n version: 0.0.1\n value:\n key:\n name: ReceiveEventPolicy\n version: 0.0.1\n UUID: 568b7345-9de1-36d3-b6a3-9b857e6809a1\n description: Generated description for concept referred to by key \"ReceiveEventPolicy:0.0.1\"\n - key:\n name: ReceiveSubscriptionTask\n version: 0.0.1\n value:\n key:\n name: ReceiveSubscriptionTask\n version: 0.0.1\n UUID: f596afc8-100c-35eb-92c8-352355ea457d\n description: Generated description for concept referred to by key \"ReceiveSubscriptionTask:0.0.1\"\n - key:\n name: SimpleIntType\n version: 0.0.1\n value:\n key:\n name: SimpleIntType\n version: 0.0.1\n UUID: 153791fd-ae0a-36a7-88a5-309a7936415d\n description: Generated description for concept referred to by key \"SimpleIntType:0.0.1\"\n - key:\n name: SimpleStringType\n version: 0.0.1\n value:\n key:\n name: SimpleStringType\n version: 0.0.1\n UUID: 8a4957cf-9493-3a76-8c22-a208e23259af\n description: Generated description for concept referred to by key \"SimpleStringType:0.0.1\"\n - key:\n name: SubscriptionStatusType\n version: 0.0.1\n value:\n key:\n name: SubscriptionStatusType\n version: 0.0.1\n UUID: 597643b1-9db1-31ce-85d0-e1c63c43b30b\n description: Generated description for concept referred to by key \"SubscriptionStatusType:0.0.1\"\n - key:\n name: SubscriptionType\n version: 0.0.1\n value:\n key:\n name: SubscriptionType\n version: 0.0.1\n UUID: 184547bb-7d64-3cb2-a273-d7185102c5ce\n description: Generated description for concept referred to by key \"SubscriptionType:0.0.1\"\n - key:\n name: UUIDType\n version: 0.0.1\n value:\n key:\n name: UUIDType\n version: 0.0.1\n UUID: 6a8cc68e-dfc8-3403-9c6d-071c886b319c\n description: Generated description for concept referred to by key \"UUIDType:0.0.1\"\n - key:\n name: pmsh-operational-policy\n version: 0.0.1\n value:\n key:\n name: pmsh-operational-policy\n version: 0.0.1\n UUID: fdf2c9ff-6422-3ea6-b6b6-49b12116265d\n description: Generated description for concept referred to by key \"pmsh-operational-policy:0.0.1\"\n policies:\n key:\n name: PMControlPolicy_Policies\n version: 0.0.1\n policyMap:\n entry:\n - key:\n name: CDSCreateResponsePolicy\n version: 0.0.1\n value:\n policyKey:\n name: CDSCreateResponsePolicy\n version: 0.0.1\n template: Freestyle\n state:\n entry:\n - key: CDSCreateResponseState\n value:\n stateKey:\n parentKeyName: CDSCreateResponsePolicy\n parentKeyVersion: 0.0.1\n parentLocalName: 'NULL'\n localName: CDSCreateResponseState\n trigger:\n name: CDSCreateResponseEvent\n version: 0.0.1\n stateOutputs:\n entry:\n - key: ResponseOutput\n value:\n key:\n parentKeyName: CDSCreateResponsePolicy\n parentKeyVersion: 0.0.1\n parentLocalName: CDSCreateResponseState\n localName: ResponseOutput\n outgoingEvent:\n name: CDSResponseStatusEvent\n version: 0.0.1\n nextState:\n parentKeyName: 'NULL'\n parentKeyVersion: 0.0.0\n parentLocalName: 'NULL'\n localName: 'NULL'\n contextAlbumReference: []\n taskSelectionLogic:\n key: 'NULL'\n logicFlavour: UNDEFINED\n logic: ''\n stateFinalizerLogicMap:\n entry: []\n defaultTask:\n name: CDSCreateResponseTask\n version: 0.0.1\n taskReferences:\n entry:\n - key:\n name: CDSCreateResponseTask\n version: 0.0.1\n value:\n key:\n parentKeyName: CDSCreateResponsePolicy\n parentKeyVersion: 0.0.1\n parentLocalName: CDSCreateResponseState\n localName: CDSCreateResponsePolicy\n outputType: DIRECT\n output:\n parentKeyName: CDSCreateResponsePolicy\n parentKeyVersion: 0.0.1\n parentLocalName: CDSCreateResponseState\n localName: ResponseOutput\n firstState: CDSCreateResponseState\n - key:\n name: CDSDeleteResponsePolicy\n version: 0.0.1\n value:\n policyKey:\n name: CDSDeleteResponsePolicy\n version: 0.0.1\n template: Freestyle\n state:\n entry:\n - key: CDSDeleteResponseState\n value:\n stateKey:\n parentKeyName: CDSDeleteResponsePolicy\n parentKeyVersion: 0.0.1\n parentLocalName: 'NULL'\n localName: CDSDeleteResponseState\n trigger:\n name: CDSDeleteResponseEvent\n version: 0.0.1\n stateOutputs:\n entry:\n - key: ResponseOutput\n value:\n key:\n parentKeyName: CDSDeleteResponsePolicy\n parentKeyVersion: 0.0.1\n parentLocalName: CDSDeleteResponseState\n localName: ResponseOutput\n outgoingEvent:\n name: CDSResponseStatusEvent\n version: 0.0.1\n nextState:\n parentKeyName: 'NULL'\n parentKeyVersion: 0.0.0\n parentLocalName: 'NULL'\n localName: 'NULL'\n contextAlbumReference: []\n taskSelectionLogic:\n key: 'NULL'\n logicFlavour: UNDEFINED\n logic: ''\n stateFinalizerLogicMap:\n entry: []\n defaultTask:\n name: CDSDeleteResponseTask\n version: 0.0.1\n taskReferences:\n entry:\n - key:\n name: CDSDeleteResponseTask\n version: 0.0.1\n value:\n key:\n parentKeyName: CDSDeleteResponsePolicy\n parentKeyVersion: 0.0.1\n parentLocalName: CDSDeleteResponseState\n localName: CDSDeleteResponsePolicy\n outputType: DIRECT\n output:\n parentKeyName: CDSDeleteResponsePolicy\n parentKeyVersion: 0.0.1\n parentLocalName: CDSDeleteResponseState\n localName: ResponseOutput\n firstState: CDSDeleteResponseState\n - key:\n name: ReceiveEventPolicy\n version: 0.0.1\n value:\n policyKey:\n name: ReceiveEventPolicy\n version: 0.0.1\n template: Freestyle\n state:\n entry:\n - key: CreateOrDeleteState\n value:\n stateKey:\n parentKeyName: ReceiveEventPolicy\n parentKeyVersion: 0.0.1\n parentLocalName: 'NULL'\n localName: CreateOrDeleteState\n trigger:\n name: PMSubscriptionOutputEvent\n version: 0.0.1\n stateOutputs:\n entry:\n - key: CreateSubscriptionPayload\n value:\n key:\n parentKeyName: ReceiveEventPolicy\n parentKeyVersion: 0.0.1\n parentLocalName: CreateOrDeleteState\n localName: CreateSubscriptionPayload\n outgoingEvent:\n name: CreateSubscriptionPayloadEvent\n version: 0.0.1\n nextState:\n parentKeyName: ReceiveEventPolicy\n parentKeyVersion: 0.0.1\n parentLocalName: 'NULL'\n localName: CreateSubscription\n - key: DeleteSubscriptionPayload\n value:\n key:\n parentKeyName: ReceiveEventPolicy\n parentKeyVersion: 0.0.1\n parentLocalName: CreateOrDeleteState\n localName: DeleteSubscriptionPayload\n outgoingEvent:\n name: DeleteSubscriptionPayloadEvent\n version: 0.0.1\n nextState:\n parentKeyName: ReceiveEventPolicy\n parentKeyVersion: 0.0.1\n parentLocalName: 'NULL'\n localName: DeleteSubscription\n contextAlbumReference:\n - name: PMSubscriptionAlbum\n version: 0.0.1\n taskSelectionLogic:\n key: TaskSelectionLogic\n logicFlavour: JAVASCRIPT\n logic: |-\n /*\n * ============LICENSE_START=======================================================\n * Copyright (C) 2020 Nordix. All rights reserved.\n * ================================================================================\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n *\n * SPDX-License-Identifier: Apache-2.0\n * ============LICENSE_END=========================================================\n */\n\n executor.logger.info(executor.subject.id);\n\n var pmSubscriptionInfo = executor.getContextAlbum(\"PMSubscriptionAlbum\").get(executor.inFields.get(\"albumID\").toString())\n var changeType = pmSubscriptionInfo.get(\"changeType\").toString()\n\n executor.logger.info(\"Change Type is \" + changeType)\n\n if (\"CREATE\".equals(changeType)) {\n executor.logger.info(\"Choosing to create a subscription\")\n executor.subject.getTaskKey(\"CreateSubscriptionPayloadTask\").copyTo(executor.selectedTask);\n }\n else if (\"DELETE\".equals(changeType)) {\n executor.logger.info(\"Choosing to delete a subscription\")\n executor.subject.getTaskKey(\"DeleteSubscriptionPayloadTask\").copyTo(executor.selectedTask);\n }\n\n //var returnValue = executor.isTrue;\n true;\n stateFinalizerLogicMap:\n entry: []\n defaultTask:\n name: CreateSubscriptionPayloadTask\n version: 0.0.1\n taskReferences:\n entry:\n - key:\n name: CreateSubscriptionPayloadTask\n version: 0.0.1\n value:\n key:\n parentKeyName: ReceiveEventPolicy\n parentKeyVersion: 0.0.1\n parentLocalName: CreateOrDeleteState\n localName: ReceiveEventPolicy\n outputType: DIRECT\n output:\n parentKeyName: ReceiveEventPolicy\n parentKeyVersion: 0.0.1\n parentLocalName: CreateOrDeleteState\n localName: CreateSubscriptionPayload\n - key:\n name: DeleteSubscriptionPayloadTask\n version: 0.0.1\n value:\n key:\n parentKeyName: ReceiveEventPolicy\n parentKeyVersion: 0.0.1\n parentLocalName: CreateOrDeleteState\n localName: ReceiveEventPolicy\n outputType: DIRECT\n output:\n parentKeyName: ReceiveEventPolicy\n parentKeyVersion: 0.0.1\n parentLocalName: CreateOrDeleteState\n localName: DeleteSubscriptionPayload\n - key: CreateSubscription\n value:\n stateKey:\n parentKeyName: ReceiveEventPolicy\n parentKeyVersion: 0.0.1\n parentLocalName: 'NULL'\n localName: CreateSubscription\n trigger:\n name: CreateSubscriptionPayloadEvent\n version: 0.0.1\n stateOutputs:\n entry:\n - key: IssueCreateSubscriptionRequestOutput\n value:\n key:\n parentKeyName: ReceiveEventPolicy\n parentKeyVersion: 0.0.1\n parentLocalName: CreateSubscription\n localName: IssueCreateSubscriptionRequestOutput\n outgoingEvent:\n name: CDSCreateSubscriptionRequestEvent\n version: 0.0.1\n nextState:\n parentKeyName: 'NULL'\n parentKeyVersion: 0.0.0\n parentLocalName: 'NULL'\n localName: 'NULL'\n contextAlbumReference:\n - name: PMSubscriptionAlbum\n version: 0.0.1\n taskSelectionLogic:\n key: 'NULL'\n logicFlavour: UNDEFINED\n logic: ''\n stateFinalizerLogicMap:\n entry: []\n defaultTask:\n name: CreateSubscriptionRequestTask\n version: 0.0.1\n taskReferences:\n entry:\n - key:\n name: CreateSubscriptionRequestTask\n version: 0.0.1\n value:\n key:\n parentKeyName: ReceiveEventPolicy\n parentKeyVersion: 0.0.1\n parentLocalName: CreateSubscription\n localName: ReceiveEventPolicy\n outputType: DIRECT\n output:\n parentKeyName: ReceiveEventPolicy\n parentKeyVersion: 0.0.1\n parentLocalName: CreateSubscription\n localName: IssueCreateSubscriptionRequestOutput\n - key: DeleteSubscription\n value:\n stateKey:\n parentKeyName: ReceiveEventPolicy\n parentKeyVersion: 0.0.1\n parentLocalName: 'NULL'\n localName: DeleteSubscription\n trigger:\n name: DeleteSubscriptionPayloadEvent\n version: 0.0.1\n stateOutputs:\n entry:\n - key: IssueDeleteSubscriptionRequestOutput\n value:\n key:\n parentKeyName: ReceiveEventPolicy\n parentKeyVersion: 0.0.1\n parentLocalName: DeleteSubscription\n localName: IssueDeleteSubscriptionRequestOutput\n outgoingEvent:\n name: CDSDeleteSubscriptionRequestEvent\n version: 0.0.1\n nextState:\n parentKeyName: 'NULL'\n parentKeyVersion: 0.0.0\n parentLocalName: 'NULL'\n localName: 'NULL'\n contextAlbumReference:\n - name: PMSubscriptionAlbum\n version: 0.0.1\n taskSelectionLogic:\n key: 'NULL'\n logicFlavour: UNDEFINED\n logic: ''\n stateFinalizerLogicMap:\n entry: []\n defaultTask:\n name: DeleteSubscriptionRequestTask\n version: 0.0.1\n taskReferences:\n entry:\n - key:\n name: DeleteSubscriptionRequestTask\n version: 0.0.1\n value:\n key:\n parentKeyName: ReceiveEventPolicy\n parentKeyVersion: 0.0.1\n parentLocalName: DeleteSubscription\n localName: ReceiveEventPolicy\n outputType: DIRECT\n output:\n parentKeyName: ReceiveEventPolicy\n parentKeyVersion: 0.0.1\n parentLocalName: DeleteSubscription\n localName: IssueDeleteSubscriptionRequestOutput\n - key: ReceiveSubscriptionState\n value:\n stateKey:\n parentKeyName: ReceiveEventPolicy\n parentKeyVersion: 0.0.1\n parentLocalName: 'NULL'\n localName: ReceiveSubscriptionState\n trigger:\n name: pmsh-operational-policy\n version: 0.0.1\n stateOutputs:\n entry:\n - key: ReceivePMSubscriptionOutput\n value:\n key:\n parentKeyName: ReceiveEventPolicy\n parentKeyVersion: 0.0.1\n parentLocalName: ReceiveSubscriptionState\n localName: ReceivePMSubscriptionOutput\n outgoingEvent:\n name: PMSubscriptionOutputEvent\n version: 0.0.1\n nextState:\n parentKeyName: ReceiveEventPolicy\n parentKeyVersion: 0.0.1\n parentLocalName: 'NULL'\n localName: CreateOrDeleteState\n contextAlbumReference:\n - name: PMSubscriptionAlbum\n version: 0.0.1\n taskSelectionLogic:\n key: 'NULL'\n logicFlavour: UNDEFINED\n logic: ''\n stateFinalizerLogicMap:\n entry: []\n defaultTask:\n name: ReceiveSubscriptionTask\n version: 0.0.1\n taskReferences:\n entry:\n - key:\n name: ReceiveSubscriptionTask\n version: 0.0.1\n value:\n key:\n parentKeyName: ReceiveEventPolicy\n parentKeyVersion: 0.0.1\n parentLocalName: ReceiveSubscriptionState\n localName: ReceiveEventPolicy\n outputType: DIRECT\n output:\n parentKeyName: ReceiveEventPolicy\n parentKeyVersion: 0.0.1\n parentLocalName: ReceiveSubscriptionState\n localName: ReceivePMSubscriptionOutput\n firstState: ReceiveSubscriptionState\n tasks:\n key:\n name: PMControlPolicy_Tasks\n version: 0.0.1\n taskMap:\n entry:\n - key:\n name: CDSCreateResponseTask\n version: 0.0.1\n value:\n key:\n name: CDSCreateResponseTask\n version: 0.0.1\n inputFields:\n entry:\n - key: actionIdentifiers\n value:\n key: actionIdentifiers\n fieldSchemaKey:\n name: CDSActionIdentifiersType\n version: 0.0.1\n optional: false\n - key: commonHeader\n value:\n key: commonHeader\n fieldSchemaKey:\n name: CDSResponseCommonHeaderType\n version: 0.0.1\n optional: false\n - key: payload\n value:\n key: payload\n fieldSchemaKey:\n name: CDSCreateResponsePayloadType\n version: 0.0.1\n optional: false\n - key: status\n value:\n key: status\n fieldSchemaKey:\n name: CDSResponseStatusType\n version: 0.0.1\n optional: false\n outputFields:\n entry:\n - key: status\n value:\n key: status\n fieldSchemaKey:\n name: SubscriptionStatusType\n version: 0.0.1\n optional: false\n taskParameters:\n entry: []\n contextAlbumReference:\n - name: PMSubscriptionAlbum\n version: 0.0.1\n taskLogic:\n key: TaskLogic\n logicFlavour: JAVASCRIPT\n logic: |-\n /*\n * ============LICENSE_START=======================================================\n * Copyright (C) 2020 Nordix. All rights reserved.\n * ================================================================================\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n *\n * SPDX-License-Identifier: Apache-2.0\n * ============LICENSE_END=========================================================\n */\n\n executor.logger.info(executor.subject.id);\n\n var commonHeader = executor.inFields.get(\"commonHeader\")\n var response = executor.inFields.get(\"payload\")\n var albumID = commonHeader.get(\"requestId\")\n\n var pmSubscriptionInfo = executor.getContextAlbum(\"PMSubscriptionAlbum\").get(albumID.toString());\n var responseStatus = executor.subject.getOutFieldSchemaHelper(\"status\").createNewInstance();\n\n responseStatus.put(\"subscriptionName\", pmSubscriptionInfo.get(\"subscription\").get(\"subscriptionName\"))\n responseStatus.put(\"nfName\", pmSubscriptionInfo.get(\"nfName\"))\n responseStatus.put(\"changeType\", pmSubscriptionInfo.get(\"changeType\"))\n\n var status = response.get(pmSubscriptionInfo.get(\"changeType\").toLowerCase() + \"_DasH_subscription_DasH_response\").get(\"odl_DasH_response\").get(\"status\")\n\n executor.logger.info(\"RESPONSE STATUS = \" + status)\n\n if(status == \"success\") {\n responseStatus.put(\"message\", \"success\")\n } else {\n responseStatus.put(\"message\", \"failed\")\n }\n\n executor.outFields.put(\"status\", responseStatus)\n\n //var returnValue = executor.isTrue;\n true;\n - key:\n name: CDSDeleteResponseTask\n version: 0.0.1\n value:\n key:\n name: CDSDeleteResponseTask\n version: 0.0.1\n inputFields:\n entry:\n - key: actionIdentifiers\n value:\n key: actionIdentifiers\n fieldSchemaKey:\n name: CDSActionIdentifiersType\n version: 0.0.1\n optional: false\n - key: commonHeader\n value:\n key: commonHeader\n fieldSchemaKey:\n name: CDSResponseCommonHeaderType\n version: 0.0.1\n optional: false\n - key: payload\n value:\n key: payload\n fieldSchemaKey:\n name: CDSDeleteResponsePayloadType\n version: 0.0.1\n optional: false\n - key: status\n value:\n key: status\n fieldSchemaKey:\n name: CDSResponseStatusType\n version: 0.0.1\n optional: false\n outputFields:\n entry:\n - key: status\n value:\n key: status\n fieldSchemaKey:\n name: SubscriptionStatusType\n version: 0.0.1\n optional: false\n taskParameters:\n entry: []\n contextAlbumReference:\n - name: PMSubscriptionAlbum\n version: 0.0.1\n taskLogic:\n key: TaskLogic\n logicFlavour: JAVASCRIPT\n logic: |-\n /*\n * ============LICENSE_START=======================================================\n * Copyright (C) 2020 Nordix. All rights reserved.\n * ================================================================================\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n *\n * SPDX-License-Identifier: Apache-2.0\n * ============LICENSE_END=========================================================\n */\n\n executor.logger.info(executor.subject.id);\n\n var commonHeader = executor.inFields.get(\"commonHeader\")\n var response = executor.inFields.get(\"payload\")\n var albumID = commonHeader.get(\"requestId\")\n\n var pmSubscriptionInfo = executor.getContextAlbum(\"PMSubscriptionAlbum\").get(albumID.toString());\n var responseStatus = executor.subject.getOutFieldSchemaHelper(\"status\").createNewInstance();\n\n responseStatus.put(\"subscriptionName\", pmSubscriptionInfo.get(\"subscription\").get(\"subscriptionName\"))\n responseStatus.put(\"nfName\", pmSubscriptionInfo.get(\"nfName\"))\n responseStatus.put(\"changeType\", pmSubscriptionInfo.get(\"changeType\"))\n\n var status = response.get(pmSubscriptionInfo.get(\"changeType\").toLowerCase() + \"_DasH_subscription_DasH_response\").get(\"odl_DasH_response\").get(\"status\")\n\n executor.logger.info(\"RESPONSE STATUS = \" + status)\n\n if(status == \"success\") {\n responseStatus.put(\"message\", \"success\")\n } else {\n responseStatus.put(\"message\", \"failed\")\n }\n\n executor.outFields.put(\"status\", responseStatus)\n\n //var returnValue = executor.isTrue;\n true;\n - key:\n name: CreateSubscriptionPayloadTask\n version: 0.0.1\n value:\n key:\n name: CreateSubscriptionPayloadTask\n version: 0.0.1\n inputFields:\n entry:\n - key: albumID\n value:\n key: albumID\n fieldSchemaKey:\n name: UUIDType\n version: 0.0.1\n optional: false\n outputFields:\n entry:\n - key: albumID\n value:\n key: albumID\n fieldSchemaKey:\n name: UUIDType\n version: 0.0.1\n optional: false\n - key: payload\n value:\n key: payload\n fieldSchemaKey:\n name: CDSCreateSubscriptionPayloadType\n version: 0.0.1\n optional: false\n taskParameters:\n entry: []\n contextAlbumReference:\n - name: PMSubscriptionAlbum\n version: 0.0.1\n taskLogic:\n key: TaskLogic\n logicFlavour: JAVASCRIPT\n logic: |-\n /*\n * ============LICENSE_START=======================================================\n * Copyright (C) 2020 Nordix. All rights reserved.\n * ================================================================================\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n *\n * SPDX-License-Identifier: Apache-2.0\n * ============LICENSE_END=========================================================\n */\n\n executor.logger.info(executor.subject.id);\n\n var pmSubscriptionInfo = executor.getContextAlbum(\"PMSubscriptionAlbum\").get(executor.inFields.get(\"albumID\").toString())\n\n var changeType = pmSubscriptionInfo.get(\"changeType\").toLowerCase()\n\n var payloadProperties = executor.subject.getOutFieldSchemaHelper(\"payload\").createNewSubInstance(changeType + \"_DasH_subscription_DasH_properties_record\");\n\n payloadProperties.put(\"nfName\", pmSubscriptionInfo.get(\"nfName\"))\n payloadProperties.put(\"subscriptionName\", pmSubscriptionInfo.get(\"subscription\").get(\"subscriptionName\"))\n payloadProperties.put(\"administrativeState\", pmSubscriptionInfo.get(\"subscription\").get(\"administrativeState\"))\n payloadProperties.put(\"fileBasedGP\", pmSubscriptionInfo.get(\"subscription\").get(\"fileBasedGP\").toString())\n payloadProperties.put(\"fileLocation\", pmSubscriptionInfo.get(\"subscription\").get(\"fileLocation\"))\n payloadProperties.put(\"measurementGroups\", pmSubscriptionInfo.get(\"subscription\").get(\"measurementGroups\"))\n\n var payloadEntry = executor.subject.getOutFieldSchemaHelper(\"payload\").createNewSubInstance(\"CDSRequestPayloadEntry\");\n payloadEntry.put(changeType + \"_DasH_subscription_DasH_properties\", payloadProperties)\n\n var payload = executor.subject.getOutFieldSchemaHelper(\"payload\").createNewInstance();\n payload.put(changeType + \"_DasH_subscription_DasH_request\", payloadEntry);\n\n executor.outFields.put(\"albumID\", executor.inFields.get(\"albumID\"))\n executor.outFields.put(\"payload\", payload);\n\n //var returnValue = executor.isTrue;\n true;\n - key:\n name: CreateSubscriptionRequestTask\n version: 0.0.1\n value:\n key:\n name: CreateSubscriptionRequestTask\n version: 0.0.1\n inputFields:\n entry:\n - key: albumID\n value:\n key: albumID\n fieldSchemaKey:\n name: UUIDType\n version: 0.0.1\n optional: false\n - key: payload\n value:\n key: payload\n fieldSchemaKey:\n name: CDSCreateSubscriptionPayloadType\n version: 0.0.1\n optional: false\n outputFields:\n entry:\n - key: actionIdentifiers\n value:\n key: actionIdentifiers\n fieldSchemaKey:\n name: CDSActionIdentifiersType\n version: 0.0.1\n optional: false\n - key: commonHeader\n value:\n key: commonHeader\n fieldSchemaKey:\n name: CDSRequestCommonHeaderType\n version: 0.0.1\n optional: false\n - key: payload\n value:\n key: payload\n fieldSchemaKey:\n name: CDSCreateSubscriptionPayloadType\n version: 0.0.1\n optional: false\n taskParameters:\n entry: []\n contextAlbumReference:\n - name: PMSubscriptionAlbum\n version: 0.0.1\n taskLogic:\n key: TaskLogic\n logicFlavour: JAVASCRIPT\n logic: |-\n /*\n * ============LICENSE_START=======================================================\n * Copyright (C) 2020 Nordix. All rights reserved.\n * ================================================================================\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n *\n * SPDX-License-Identifier: Apache-2.0\n * ============LICENSE_END=========================================================\n */\n\n executor.logger.info(executor.subject.id);\n\n var pmSubscriptionInfo = executor.getContextAlbum(\"PMSubscriptionAlbum\").get(executor.inFields.get(\"albumID\").toString())\n\n var changeType = pmSubscriptionInfo.get(\"changeType\").toLowerCase()\n var blueprintName = pmSubscriptionInfo.get(\"blueprintName\").toLowerCase()\n var blueprintVersion = pmSubscriptionInfo.get(\"blueprintVersion\").toLowerCase()\n var payload = executor.inFields.get(\"payload\")\n var actionName = changeType + \"-subscription\"\n\n var commonHeader = executor.subject.getOutFieldSchemaHelper(\"commonHeader\").createNewInstance();\n commonHeader.put(\"originatorId\", \"sdnc\");\n commonHeader.put(\"requestId\", executor.inFields.get(\"albumID\").toString());\n commonHeader.put(\"subRequestId\", \"sub-123456-1000\");\n\n var actionIdentifiers = executor.subject.getOutFieldSchemaHelper(\"actionIdentifiers\").createNewInstance();\n actionIdentifiers.put(\"actionName\", actionName);\n actionIdentifiers.put(\"blueprintName\", blueprintName);\n actionIdentifiers.put(\"blueprintVersion\", blueprintVersion);\n actionIdentifiers.put(\"mode\", \"sync\");\n\n executor.outFields.put(\"commonHeader\", commonHeader);\n executor.outFields.put(\"actionIdentifiers\", actionIdentifiers);\n executor.outFields.put(\"payload\", payload);\n\n //var returnValue = executor.isTrue;\n true;\n - key:\n name: DeleteSubscriptionPayloadTask\n version: 0.0.1\n value:\n key:\n name: DeleteSubscriptionPayloadTask\n version: 0.0.1\n inputFields:\n entry:\n - key: albumID\n value:\n key: albumID\n fieldSchemaKey:\n name: UUIDType\n version: 0.0.1\n optional: false\n outputFields:\n entry:\n - key: albumID\n value:\n key: albumID\n fieldSchemaKey:\n name: UUIDType\n version: 0.0.1\n optional: false\n - key: payload\n value:\n key: payload\n fieldSchemaKey:\n name: CDSDeleteSubscriptionPayloadType\n version: 0.0.1\n optional: false\n taskParameters:\n entry: []\n contextAlbumReference:\n - name: PMSubscriptionAlbum\n version: 0.0.1\n taskLogic:\n key: TaskLogic\n logicFlavour: JAVASCRIPT\n logic: |-\n /*\n * ============LICENSE_START=======================================================\n * Copyright (C) 2020 Nordix. All rights reserved.\n * ================================================================================\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n *\n * SPDX-License-Identifier: Apache-2.0\n * ============LICENSE_END=========================================================\n */\n\n executor.logger.info(executor.subject.id);\n\n var pmSubscriptionInfo = executor.getContextAlbum(\"PMSubscriptionAlbum\").get(executor.inFields.get(\"albumID\").toString())\n\n var changeType = pmSubscriptionInfo.get(\"changeType\").toLowerCase()\n\n var payloadProperties = executor.subject.getOutFieldSchemaHelper(\"payload\").createNewSubInstance(changeType + \"_DasH_subscription_DasH_properties_record\");\n\n payloadProperties.put(\"nfName\", pmSubscriptionInfo.get(\"nfName\"))\n payloadProperties.put(\"subscriptionName\", pmSubscriptionInfo.get(\"subscription\").get(\"subscriptionName\"))\n payloadProperties.put(\"administrativeState\", pmSubscriptionInfo.get(\"subscription\").get(\"administrativeState\"))\n payloadProperties.put(\"fileBasedGP\", pmSubscriptionInfo.get(\"subscription\").get(\"fileBasedGP\").toString())\n payloadProperties.put(\"fileLocation\", pmSubscriptionInfo.get(\"subscription\").get(\"fileLocation\"))\n payloadProperties.put(\"measurementGroups\", pmSubscriptionInfo.get(\"subscription\").get(\"measurementGroups\"))\n\n var payloadEntry = executor.subject.getOutFieldSchemaHelper(\"payload\").createNewSubInstance(\"CDSRequestPayloadEntry\");\n payloadEntry.put(changeType + \"_DasH_subscription_DasH_properties\", payloadProperties)\n\n var payload = executor.subject.getOutFieldSchemaHelper(\"payload\").createNewInstance();\n payload.put(changeType + \"_DasH_subscription_DasH_request\", payloadEntry);\n\n executor.outFields.put(\"albumID\", executor.inFields.get(\"albumID\"))\n executor.outFields.put(\"payload\", payload);\n\n //var returnValue = executor.isTrue;\n true;\n - key:\n name: DeleteSubscriptionRequestTask\n version: 0.0.1\n value:\n key:\n name: DeleteSubscriptionRequestTask\n version: 0.0.1\n inputFields:\n entry:\n - key: albumID\n value:\n key: albumID\n fieldSchemaKey:\n name: UUIDType\n version: 0.0.1\n optional: false\n - key: payload\n value:\n key: payload\n fieldSchemaKey:\n name: CDSDeleteSubscriptionPayloadType\n version: 0.0.1\n optional: false\n outputFields:\n entry:\n - key: actionIdentifiers\n value:\n key: actionIdentifiers\n fieldSchemaKey:\n name: CDSActionIdentifiersType\n version: 0.0.1\n optional: false\n - key: commonHeader\n value:\n key: commonHeader\n fieldSchemaKey:\n name: CDSRequestCommonHeaderType\n version: 0.0.1\n optional: false\n - key: payload\n value:\n key: payload\n fieldSchemaKey:\n name: CDSDeleteSubscriptionPayloadType\n version: 0.0.1\n optional: false\n taskParameters:\n entry: []\n contextAlbumReference:\n - name: PMSubscriptionAlbum\n version: 0.0.1\n taskLogic:\n key: TaskLogic\n logicFlavour: JAVASCRIPT\n logic: |-\n /*\n * ============LICENSE_START=======================================================\n * Copyright (C) 2020 Nordix. All rights reserved.\n * ================================================================================\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n *\n * SPDX-License-Identifier: Apache-2.0\n * ============LICENSE_END=========================================================\n */\n\n executor.logger.info(executor.subject.id);\n\n var pmSubscriptionInfo = executor.getContextAlbum(\"PMSubscriptionAlbum\").get(executor.inFields.get(\"albumID\").toString())\n\n var changeType = pmSubscriptionInfo.get(\"changeType\").toLowerCase()\n var blueprintName = pmSubscriptionInfo.get(\"blueprintName\").toLowerCase()\n var blueprintVersion = pmSubscriptionInfo.get(\"blueprintVersion\").toLowerCase()\n var payload = executor.inFields.get(\"payload\")\n var actionName = changeType + \"-subscription\"\n\n var commonHeader = executor.subject.getOutFieldSchemaHelper(\"commonHeader\").createNewInstance();\n commonHeader.put(\"originatorId\", \"sdnc\");\n commonHeader.put(\"requestId\", executor.inFields.get(\"albumID\").toString());\n commonHeader.put(\"subRequestId\", \"sub-123456-1000\");\n\n var actionIdentifiers = executor.subject.getOutFieldSchemaHelper(\"actionIdentifiers\").createNewInstance();\n actionIdentifiers.put(\"actionName\", actionName);\n actionIdentifiers.put(\"blueprintName\", blueprintName);\n actionIdentifiers.put(\"blueprintVersion\", blueprintVersion);\n actionIdentifiers.put(\"mode\", \"sync\");\n\n executor.outFields.put(\"commonHeader\", commonHeader);\n executor.outFields.put(\"actionIdentifiers\", actionIdentifiers);\n executor.outFields.put(\"payload\", payload);\n\n //var returnValue = executor.isTrue;\n true;\n - key:\n name: ReceiveSubscriptionTask\n version: 0.0.1\n value:\n key:\n name: ReceiveSubscriptionTask\n version: 0.0.1\n inputFields:\n entry:\n - key: blueprintName\n value:\n key: blueprintName\n fieldSchemaKey:\n name: SimpleStringType\n version: 0.0.1\n optional: false\n - key: blueprintVersion\n value:\n key: blueprintVersion\n fieldSchemaKey:\n name: SimpleStringType\n version: 0.0.1\n optional: false\n - key: changeType\n value:\n key: changeType\n fieldSchemaKey:\n name: SimpleStringType\n version: 0.0.1\n optional: false\n - key: closedLoopControlName\n value:\n key: closedLoopControlName\n fieldSchemaKey:\n name: SimpleStringType\n version: 0.0.1\n optional: false\n - key: nfName\n value:\n key: nfName\n fieldSchemaKey:\n name: SimpleStringType\n version: 0.0.1\n optional: false\n - key: policyName\n value:\n key: policyName\n fieldSchemaKey:\n name: SimpleStringType\n version: 0.0.1\n optional: false\n - key: subscription\n value:\n key: subscription\n fieldSchemaKey:\n name: SubscriptionType\n version: 0.0.1\n optional: false\n outputFields:\n entry:\n - key: albumID\n value:\n key: albumID\n fieldSchemaKey:\n name: UUIDType\n version: 0.0.1\n optional: false\n taskParameters:\n entry: []\n contextAlbumReference:\n - name: PMSubscriptionAlbum\n version: 0.0.1\n taskLogic:\n key: TaskLogic\n logicFlavour: JAVASCRIPT\n logic: |-\n /*\n * ============LICENSE_START=======================================================\n * Copyright (C) 2020 Nordix. All rights reserved.\n * ================================================================================\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n *\n * SPDX-License-Identifier: Apache-2.0\n * ============LICENSE_END=========================================================\n */\n var uuidType = java.util.UUID;\n\n executor.logger.info(executor.subject.id);\n\n //albumID will be used to fetch info from our album later\n var albumID = uuidType.randomUUID();\n var pmSubscriptionInfo = executor.getContextAlbum(\"PMSubscriptionAlbum\").getSchemaHelper().createNewInstance();\n var returnValue = true;\n\n if(executor.inFields.get(\"policyName\") != null) {\n executor.logger.info(\"nfName in receive sub event \" + executor.inFields.get(\"nfName\"));\n\n var changeType = executor.inFields.get(\"changeType\")\n var nfName = executor.inFields.get(\"nfName\")\n var policyName = executor.inFields.get(\"policyName\")\n var closedLoopControlName = executor.inFields.get(\"closedLoopControlName\")\n var subscription = executor.inFields.get(\"subscription\")\n var blueprintName = executor.inFields.get(\"blueprintName\")\n var blueprintVersion = executor.inFields.get(\"blueprintVersion\")\n\n pmSubscriptionInfo.put(\"nfName\", executor.inFields.get(\"nfName\"));\n pmSubscriptionInfo.put(\"changeType\", executor.inFields.get(\"changeType\"))\n pmSubscriptionInfo.put(\"policyName\", executor.inFields.get(\"policyName\"))\n pmSubscriptionInfo.put(\"closedLoopControlName\", executor.inFields.get(\"closedLoopControlName\"))\n pmSubscriptionInfo.put(\"subscription\", subscription)\n pmSubscriptionInfo.put(\"blueprintName\", blueprintName)\n pmSubscriptionInfo.put(\"blueprintVersion\", blueprintVersion)\n\n\n executor.getContextAlbum(\"PMSubscriptionAlbum\").put(albumID.toString(), pmSubscriptionInfo);\n\n executor.outFields.put(\"albumID\", albumID)\n } else {\n executor.message = \"Received invalid event\"\n returnValue = false;\n }\n\n returnValue;\n events:\n key:\n name: PMControlPolicy_Events\n version: 0.0.1\n eventMap:\n entry:\n - key:\n name: CDSCreateResponseEvent\n version: 0.0.1\n value:\n key:\n name: CDSCreateResponseEvent\n version: 0.0.1\n nameSpace: org.onap.policy.apex.onap.pmcontrol\n source: CDS\n target: APEX\n parameter:\n entry:\n - key: actionIdentifiers\n value:\n key: actionIdentifiers\n fieldSchemaKey:\n name: CDSActionIdentifiersType\n version: 0.0.1\n optional: false\n - key: commonHeader\n value:\n key: commonHeader\n fieldSchemaKey:\n name: CDSResponseCommonHeaderType\n version: 0.0.1\n optional: false\n - key: payload\n value:\n key: payload\n fieldSchemaKey:\n name: CDSCreateResponsePayloadType\n version: 0.0.1\n optional: false\n - key: status\n value:\n key: status\n fieldSchemaKey:\n name: CDSResponseStatusType\n version: 0.0.1\n optional: false\n - key:\n name: CDSCreateSubscriptionRequestEvent\n version: 0.0.1\n value:\n key:\n name: CDSCreateSubscriptionRequestEvent\n version: 0.0.1\n nameSpace: org.onap.policy.apex.onap.pmcontrol\n source: APEX\n target: APEX\n parameter:\n entry:\n - key: actionIdentifiers\n value:\n key: actionIdentifiers\n fieldSchemaKey:\n name: CDSActionIdentifiersType\n version: 0.0.1\n optional: false\n - key: commonHeader\n value:\n key: commonHeader\n fieldSchemaKey:\n name: CDSRequestCommonHeaderType\n version: 0.0.1\n optional: false\n - key: payload\n value:\n key: payload\n fieldSchemaKey:\n name: CDSCreateSubscriptionPayloadType\n version: 0.0.1\n optional: false\n - key:\n name: CDSDeleteResponseEvent\n version: 0.0.1\n value:\n key:\n name: CDSDeleteResponseEvent\n version: 0.0.1\n nameSpace: org.onap.policy.apex.onap.pmcontrol\n source: CDS\n target: APEX\n parameter:\n entry:\n - key: actionIdentifiers\n value:\n key: actionIdentifiers\n fieldSchemaKey:\n name: CDSActionIdentifiersType\n version: 0.0.1\n optional: false\n - key: commonHeader\n value:\n key: commonHeader\n fieldSchemaKey:\n name: CDSResponseCommonHeaderType\n version: 0.0.1\n optional: false\n - key: payload\n value:\n key: payload\n fieldSchemaKey:\n name: CDSDeleteResponsePayloadType\n version: 0.0.1\n optional: false\n - key: status\n value:\n key: status\n fieldSchemaKey:\n name: CDSResponseStatusType\n version: 0.0.1\n optional: false\n - key:\n name: CDSDeleteSubscriptionRequestEvent\n version: 0.0.1\n value:\n key:\n name: CDSDeleteSubscriptionRequestEvent\n version: 0.0.1\n nameSpace: org.onap.policy.apex.onap.pmcontrol\n source: APEX\n target: APEX\n parameter:\n entry:\n - key: actionIdentifiers\n value:\n key: actionIdentifiers\n fieldSchemaKey:\n name: CDSActionIdentifiersType\n version: 0.0.1\n optional: false\n - key: commonHeader\n value:\n key: commonHeader\n fieldSchemaKey:\n name: CDSRequestCommonHeaderType\n version: 0.0.1\n optional: false\n - key: payload\n value:\n key: payload\n fieldSchemaKey:\n name: CDSDeleteSubscriptionPayloadType\n version: 0.0.1\n optional: false\n - key:\n name: CDSResponseStatusEvent\n version: 0.0.1\n value:\n key:\n name: CDSResponseStatusEvent\n version: 0.0.1\n nameSpace: org.onap.policy.apex.onap.pmcontrol\n source: APEX\n target: DCAE\n parameter:\n entry:\n - key: status\n value:\n key: status\n fieldSchemaKey:\n name: SubscriptionStatusType\n version: 0.0.1\n optional: false\n - key:\n name: CreateSubscriptionPayloadEvent\n version: 0.0.1\n value:\n key:\n name: CreateSubscriptionPayloadEvent\n version: 0.0.1\n nameSpace: org.onap.policy.apex.onap.pmcontrol\n source: APEX\n target: APEX\n parameter:\n entry:\n - key: albumID\n value:\n key: albumID\n fieldSchemaKey:\n name: UUIDType\n version: 0.0.1\n optional: false\n - key: payload\n value:\n key: payload\n fieldSchemaKey:\n name: CDSCreateSubscriptionPayloadType\n version: 0.0.1\n optional: false\n - key:\n name: DeleteSubscriptionPayloadEvent\n version: 0.0.1\n value:\n key:\n name: DeleteSubscriptionPayloadEvent\n version: 0.0.1\n nameSpace: org.onap.policy.apex.onap.pmcontrol\n source: APEX\n target: APEX\n parameter:\n entry:\n - key: albumID\n value:\n key: albumID\n fieldSchemaKey:\n name: UUIDType\n version: 0.0.1\n optional: false\n - key: payload\n value:\n key: payload\n fieldSchemaKey:\n name: CDSDeleteSubscriptionPayloadType\n version: 0.0.1\n optional: false\n - key:\n name: MRResponseEvent\n version: 0.0.1\n value:\n key:\n name: MRResponseEvent\n version: 0.0.1\n nameSpace: org.onap.policy.apex.onap.pmcontrol\n source: DCAE\n target: APEX\n parameter:\n entry:\n - key: count\n value:\n key: count\n fieldSchemaKey:\n name: SimpleIntType\n version: 0.0.1\n optional: false\n - key: serverTimeMs\n value:\n key: serverTimeMs\n fieldSchemaKey:\n name: SimpleIntType\n version: 0.0.1\n optional: false\n - key:\n name: PMSubscriptionOutputEvent\n version: 0.0.1\n value:\n key:\n name: PMSubscriptionOutputEvent\n version: 0.0.1\n nameSpace: org.onap.policy.apex.onap.pmcontrol\n source: APEX\n target: APEX\n parameter:\n entry:\n - key: albumID\n value:\n key: albumID\n fieldSchemaKey:\n name: UUIDType\n version: 0.0.1\n optional: false\n - key:\n name: pmsh-operational-policy\n version: 0.0.1\n value:\n key:\n name: pmsh-operational-policy\n version: 0.0.1\n nameSpace: org.onap.policy.apex.onap.pmcontrol\n source: DCAE\n target: APEX\n parameter:\n entry:\n - key: blueprintName\n value:\n key: blueprintName\n fieldSchemaKey:\n name: SimpleStringType\n version: 0.0.1\n optional: false\n - key: blueprintVersion\n value:\n key: blueprintVersion\n fieldSchemaKey:\n name: SimpleStringType\n version: 0.0.1\n optional: false\n - key: changeType\n value:\n key: changeType\n fieldSchemaKey:\n name: SimpleStringType\n version: 0.0.1\n optional: false\n - key: closedLoopControlName\n value:\n key: closedLoopControlName\n fieldSchemaKey:\n name: SimpleStringType\n version: 0.0.1\n optional: false\n - key: nfName\n value:\n key: nfName\n fieldSchemaKey:\n name: SimpleStringType\n version: 0.0.1\n optional: false\n - key: policyName\n value:\n key: policyName\n fieldSchemaKey:\n name: SimpleStringType\n version: 0.0.1\n optional: false\n - key: subscription\n value:\n key: subscription\n fieldSchemaKey:\n name: SubscriptionType\n version: 0.0.1\n optional: false\n albums:\n key:\n name: PMControlPolicy_Albums\n version: 0.0.1\n albums:\n entry:\n - key:\n name: PMSubscriptionAlbum\n version: 0.0.1\n value:\n key:\n name: PMSubscriptionAlbum\n version: 0.0.1\n scope: policy\n isWritable: true\n itemSchema:\n name: PMSubscriptionType\n version: 0.0.1\n schemas:\n key:\n name: PMControlPolicy_Schemas\n version: 0.0.1\n schemas:\n entry:\n - key:\n name: CDSActionIdentifiersType\n version: 0.0.1\n value:\n key:\n name: CDSActionIdentifiersType\n version: 0.0.1\n schemaFlavour: Avro\n schemaDefinition: |-\n {\n \"type\": \"record\",\n \"name\": \"ActionIdentifiers_Type\",\n \"namespace\": \"org.onap.policy.apex.onap.helloworld\",\n \"fields\": [\n {\n \"name\": \"actionName\",\n \"type\": \"string\"\n },\n {\n \"name\": \"blueprintName\",\n \"type\": \"string\"\n },\n {\n \"name\": \"blueprintVersion\",\n \"type\": \"string\"\n },\n {\n \"name\": \"mode\",\n \"type\": \"string\"\n }\n ]\n }\n - key:\n name: CDSCreateResponsePayloadType\n version: 0.0.1\n value:\n key:\n name: CDSCreateResponsePayloadType\n version: 0.0.1\n schemaFlavour: Avro\n schemaDefinition: |-\n {\n \"name\": \"CreateResponsePayloadEntry\",\n \"type\": \"record\",\n \"namespace\": \"org.onap.policy.apex.onap.helloworld\",\n \"fields\": [\n {\n \"name\": \"create_DasH_subscription_DasH_response\",\n \"type\": {\n \"name\": \"create_DasH_subscription_DasH_response\",\n \"type\": \"record\",\n \"fields\": [\n {\n \"name\": \"odl_DasH_response\",\n \"type\": {\n \"name\": \"odl_DasH_response\",\n \"type\": \"record\",\n \"fields\": [\n {\n \"name\": \"status\",\n \"type\": \"string\"\n }\n ]\n }\n }\n ]\n }\n }\n ]\n }\n - key:\n name: CDSCreateSubscriptionPayloadType\n version: 0.0.1\n value:\n key:\n name: CDSCreateSubscriptionPayloadType\n version: 0.0.1\n schemaFlavour: Avro\n schemaDefinition: |-\n {\n \"type\": \"map\",\n \"values\": {\n \"type\": \"record\",\n \"name\": \"CDSRequestPayloadEntry\",\n \"fields\": [\n {\n \"name\": \"create_DasH_subscription_DasH_properties\",\n \"type\": {\n \"name\": \"create_DasH_subscription_DasH_properties_record\",\n \"type\": \"record\",\n \"fields\": [\n {\n \"name\": \"nfName\",\n \"type\": \"string\"\n },\n {\n \"name\": \"subscriptionName\",\n \"type\": \"string\"\n },\n {\n \"name\": \"administrativeState\",\n \"type\": \"string\"\n },\n {\n \"name\": \"fileBasedGP\",\n \"type\": \"string\"\n },\n {\n \"name\": \"fileLocation\",\n \"type\": \"string\"\n },\n {\n \"name\": \"measurementGroups\",\n \"type\": {\n \"type\": \"array\",\n \"items\": {\n \"name\": \"measurementGroups_record\",\n \"type\": \"record\",\n \"fields\": [\n {\n \"name\": \"measurementGroup\",\n \"type\": {\n \"name\": \"measurementGroup\",\n \"type\": \"record\",\n \"fields\": [\n {\n \"name\": \"measurementTypes\",\n \"type\": {\n \"type\": \"array\",\n \"items\": {\n \"name\": \"measurementTypes_record\",\n \"type\": \"record\",\n \"fields\": [\n {\n \"name\": \"measurementType\",\n \"type\": \"string\"\n }\n ]\n }\n }\n },\n {\n \"name\": \"managedObjectDNsBasic\",\n \"type\": {\n \"type\": \"array\",\n \"items\": {\n \"name\": \"managedObjectDNsBasic_record\",\n \"type\": \"record\",\n \"fields\": [\n {\n \"name\": \"DN\",\n \"type\": \"string\"\n }\n ]\n }\n }\n }\n ]\n }\n }\n ]\n }\n }\n }\n ]\n }\n }\n ]\n }\n }\n - key:\n name: CDSDeleteResponsePayloadType\n version: 0.0.1\n value:\n key:\n name: CDSDeleteResponsePayloadType\n version: 0.0.1\n schemaFlavour: Avro\n schemaDefinition: |-\n {\n \"name\": \"DeleteResponsePayloadEntry\",\n \"type\": \"record\",\n \"namespace\": \"com.acme.avro\",\n \"fields\": [\n {\n \"name\": \"delete_DasH_subscription_DasH_response\",\n \"type\": {\n \"name\": \"delete_DasH_subscription_DasH_response\",\n \"type\": \"record\",\n \"fields\": [\n {\n \"name\": \"odl_DasH_response\",\n \"type\": {\n \"name\": \"odl_DasH_response\",\n \"type\": \"record\",\n \"fields\": [\n {\n \"name\": \"status\",\n \"type\": \"string\"\n }\n ]\n }\n }\n ]\n }\n }\n ]\n }\n - key:\n name: CDSDeleteSubscriptionPayloadType\n version: 0.0.1\n value:\n key:\n name: CDSDeleteSubscriptionPayloadType\n version: 0.0.1\n schemaFlavour: Avro\n schemaDefinition: |-\n {\n \"type\": \"map\",\n \"values\": {\n \"type\": \"record\",\n \"name\": \"CDSRequestPayloadEntry\",\n \"fields\": [\n {\n \"name\": \"delete_DasH_subscription_DasH_properties\",\n \"type\": {\n \"name\": \"delete_DasH_subscription_DasH_properties_record\",\n \"type\": \"record\",\n \"fields\": [\n {\n \"name\": \"nfName\",\n \"type\": \"string\"\n },\n {\n \"name\": \"subscriptionName\",\n \"type\": \"string\"\n },\n {\n \"name\": \"administrativeState\",\n \"type\": \"string\"\n },\n {\n \"name\": \"fileBasedGP\",\n \"type\": \"string\"\n },\n {\n \"name\": \"fileLocation\",\n \"type\": \"string\"\n },\n {\n \"name\": \"measurementGroups\",\n \"type\": {\n \"type\": \"array\",\n \"items\": {\n \"name\": \"measurementGroups_record\",\n \"type\": \"record\",\n \"fields\": [\n {\n \"name\": \"measurementGroup\",\n \"type\": {\n \"name\": \"measurementGroup\",\n \"type\": \"record\",\n \"fields\": [\n {\n \"name\": \"measurementTypes\",\n \"type\": {\n \"type\": \"array\",\n \"items\": {\n \"name\": \"measurementTypes_record\",\n \"type\": \"record\",\n \"fields\": [\n {\n \"name\": \"measurementType\",\n \"type\": \"string\"\n }\n ]\n }\n }\n },\n {\n \"name\": \"managedObjectDNsBasic\",\n \"type\": {\n \"type\": \"array\",\n \"items\": {\n \"name\": \"managedObjectDNsBasic_record\",\n \"type\": \"record\",\n \"fields\": [\n {\n \"name\": \"DN\",\n \"type\": \"string\"\n }\n ]\n }\n }\n }\n ]\n }\n }\n ]\n }\n }\n }\n ]\n }\n }\n ]\n }\n }\n - key:\n name: CDSRequestCommonHeaderType\n version: 0.0.1\n value:\n key:\n name: CDSRequestCommonHeaderType\n version: 0.0.1\n schemaFlavour: Avro\n schemaDefinition: |-\n {\n \"type\": \"record\",\n \"name\": \"RequestCommonHeader_Type\",\n \"namespace\": \"org.onap.policy.apex.onap.helloworld\",\n \"fields\": [\n {\n \"name\": \"originatorId\",\n \"type\": \"string\"\n },\n {\n \"name\": \"requestId\",\n \"type\": \"string\"\n },\n {\n \"name\": \"subRequestId\",\n \"type\": \"string\"\n }\n ]\n }\n - key:\n name: CDSResponseCommonHeaderType\n version: 0.0.1\n value:\n key:\n name: CDSResponseCommonHeaderType\n version: 0.0.1\n schemaFlavour: Avro\n schemaDefinition: |-\n {\n \"type\": \"record\",\n \"name\": \"ResponseCommonHeader_Type\",\n \"namespace\": \"org.onap.policy.apex.onap.helloworld\",\n \"fields\": [\n {\n \"name\": \"originatorId\",\n \"type\": \"string\"\n },\n {\n \"name\": \"requestId\",\n \"type\": \"string\"\n },\n {\n \"name\": \"subRequestId\",\n \"type\": \"string\"\n },\n {\n \"name\": \"timestamp\",\n \"type\": \"string\"\n },\n {\n \"name\": \"flags\",\n \"type\": [\"null\", \"string\"]\n }\n ]\n }\n - key:\n name: CDSResponseStatusType\n version: 0.0.1\n value:\n key:\n name: CDSResponseStatusType\n version: 0.0.1\n schemaFlavour: Avro\n schemaDefinition: |-\n {\n \"type\": \"record\",\n \"name\": \"ResponseStatus_Type\",\n \"namespace\": \"org.onap.policy.apex.onap.helloworld\",\n \"fields\": [\n {\n \"name\": \"code\",\n \"type\": \"int\"\n },\n {\n \"name\": \"eventType\",\n \"type\": \"string\"\n },\n {\n \"name\": \"timestamp\",\n \"type\": \"string\"\n },\n {\n \"name\": \"message\",\n \"type\": \"string\"\n }\n ]\n }\n - key:\n name: PMSubscriptionType\n version: 0.0.1\n value:\n key:\n name: PMSubscriptionType\n version: 0.0.1\n schemaFlavour: Avro\n schemaDefinition: \"{\\n\\t\\\"name\\\": \\\"PMSubscription\\\",\\n\\t\\\"type\\\": \\\"record\\\",\\n\\t\\\"namespace\\\": \\\"\\\n org.onap.policy.apex.onap.pmcontrol\\\",\\n\\t\\\"fields\\\": [\\n {\\n \\\"name\\\": \\\"nfName\\\"\\\n ,\\n \\\"type\\\": \\\"string\\\"\\n },\\n\\t {\\n\\t\\t\\t\\\"name\\\": \\\"changeType\\\",\\n\\t\\t\\t\\\"\\\n type\\\": \\\"string\\\"\\n\\t\\t},\\n\\t\\t{\\n\\t\\t\\t\\\"name\\\": \\\"closedLoopControlName\\\",\\n\\t\\t\\t\\\"type\\\": \\\"\\\n string\\\"\\n\\t\\t},\\n\\t\\t{\\n\\t\\t\\t\\\"name\\\": \\\"policyName\\\",\\n\\t\\t\\t\\\"type\\\": \\\"string\\\"\\n\\t\\t},\\n\\t\\t\\\n {\\n\\t\\t \\\"name\\\": \\\"blueprintName\\\",\\n\\t\\t \\\"type\\\": \\\"string\\\"\\n\\t\\t},\\n\\t\\t{\\n\\t\\t \\\"name\\\"\\\n : \\\"blueprintVersion\\\",\\n\\t\\t \\\"type\\\": \\\"string\\\"\\n\\t\\t},\\n\\t\\t{\\n\\t\\t\\t\\\"name\\\": \\\"subscription\\\"\\\n ,\\n\\t\\t\\t\\\"type\\\": {\\n\\t\\t\\t\\t\\\"name\\\": \\\"subscription\\\",\\n\\t\\t\\t\\t\\\"type\\\": \\\"record\\\",\\n\\t\\t\\t\\t\\\n \\\"fields\\\": [{\\n\\t\\t\\t\\t\\t\\t\\\"name\\\": \\\"subscriptionName\\\",\\n\\t\\t\\t\\t\\t\\t\\\"type\\\": \\\"string\\\"\\n\\t\\t\\\n \\t\\t\\t},\\n\\t\\t\\t\\t\\t{\\n\\t\\t\\t\\t\\t\\t\\\"name\\\": \\\"administrativeState\\\",\\n\\t\\t\\t\\t\\t\\t\\\"type\\\": \\\"string\\\"\\\n \\n\\t\\t\\t\\t\\t},\\n\\t\\t\\t\\t\\t{\\n\\t\\t\\t\\t\\t\\t\\\"name\\\": \\\"fileBasedGP\\\",\\n\\t\\t\\t\\t\\t\\t\\\"type\\\": \\\"int\\\"\\\n \\n\\t\\t\\t\\t\\t},\\n\\t\\t\\t\\t\\t{\\n\\t\\t\\t\\t\\t\\t\\\"name\\\": \\\"fileLocation\\\",\\n\\t\\t\\t\\t\\t\\t\\\"type\\\": \\\"string\\\"\\\n \\n\\t\\t\\t\\t\\t},\\n\\t\\t\\t\\t\\t{\\n\\t\\t\\t\\t\\t\\t\\\"name\\\": \\\"measurementGroups\\\",\\n\\t\\t\\t\\t\\t\\t\\\"type\\\": {\\n\\\n \\t\\t\\t\\t\\t\\t\\t\\\"type\\\": \\\"array\\\",\\n\\t\\t\\t\\t\\t\\t\\t\\\"items\\\": {\\n\\t\\t\\t\\t\\t\\t\\t\\t\\\"name\\\": \\\"Measurement_Groups_Type\\\"\\\n ,\\n\\t\\t\\t\\t\\t\\t\\t\\t\\\"type\\\": \\\"record\\\",\\n\\t\\t\\t\\t\\t\\t\\t\\t\\\"fields\\\": [{\\n\\t\\t\\t\\t\\t\\t\\t\\t\\t\\\"name\\\"\\\n : \\\"measurementGroup\\\",\\n\\t\\t\\t\\t\\t\\t\\t\\t\\t\\\"type\\\": {\\n\\t\\t\\t\\t\\t\\t\\t\\t\\t\\t\\\"name\\\": \\\"Measurement_Group_Type\\\"\\\n ,\\n\\t\\t\\t\\t\\t\\t\\t\\t\\t\\t\\\"type\\\": \\\"record\\\",\\n\\t\\t\\t\\t\\t\\t\\t\\t\\t\\t\\\"fields\\\": [{\\n\\t\\t\\t\\t\\t\\t\\t\\t\\\n \\t\\t\\t\\t\\\"name\\\": \\\"measurementTypes\\\",\\n\\t\\t\\t\\t\\t\\t\\t\\t\\t\\t\\t\\t\\\"type\\\": {\\n\\t\\t\\t\\t\\t\\t\\t\\t\\t\\t\\\n \\t\\t\\t\\\"type\\\": \\\"array\\\",\\n\\t\\t\\t\\t\\t\\t\\t\\t\\t\\t\\t\\t\\t\\\"items\\\": {\\n\\t\\t\\t\\t\\t\\t\\t\\t\\t\\t\\t\\t\\t\\t\\\"\\\n name\\\": \\\"Measurement_Types_Type\\\",\\n\\t\\t\\t\\t\\t\\t\\t\\t\\t\\t\\t\\t\\t\\t\\\"type\\\": \\\"record\\\",\\n\\t\\t\\t\\t\\t\\\n \\t\\t\\t\\t\\t\\t\\t\\t\\t\\\"fields\\\": [{\\n\\t\\t\\t\\t\\t\\t\\t\\t\\t\\t\\t\\t\\t\\t\\t\\\"name\\\": \\\"measurementType\\\",\\n\\t\\\n \\t\\t\\t\\t\\t\\t\\t\\t\\t\\t\\t\\t\\t\\t\\\"type\\\": \\\"string\\\"\\n\\t\\t\\t\\t\\t\\t\\t\\t\\t\\t\\t\\t\\t\\t}]\\n\\t\\t\\t\\t\\t\\t\\t\\t\\\n \\t\\t\\t\\t\\t}\\n\\t\\t\\t\\t\\t\\t\\t\\t\\t\\t\\t\\t}\\n\\t\\t\\t\\t\\t\\t\\t\\t\\t\\t\\t},\\n\\t\\t\\t\\t\\t\\t\\t\\t\\t\\t\\t{\\n\\t\\t\\t\\t\\\n \\t\\t\\t\\t\\t\\t\\t\\t\\\"name\\\": \\\"managedObjectDNsBasic\\\",\\n\\t\\t\\t\\t\\t\\t\\t\\t\\t\\t\\t\\t\\\"type\\\": {\\n\\t\\t\\t\\t\\\n \\t\\t\\t\\t\\t\\t\\t\\t\\t\\\"type\\\": \\\"array\\\",\\n\\t\\t\\t\\t\\t\\t\\t\\t\\t\\t\\t\\t\\t\\\"items\\\": {\\n\\t\\t\\t\\t\\t\\t\\t\\t\\t\\\n \\t\\t\\t\\t\\t\\\"name\\\": \\\"Managed_Object_Dns_Basic_Type\\\",\\n\\t\\t\\t\\t\\t\\t\\t\\t\\t\\t\\t\\t\\t\\t\\\"type\\\": \\\"record\\\"\\\n ,\\n\\t\\t\\t\\t\\t\\t\\t\\t\\t\\t\\t\\t\\t\\t\\\"fields\\\": [{\\n\\t\\t\\t\\t\\t\\t\\t\\t\\t\\t\\t\\t\\t\\t\\t\\\"name\\\": \\\"DN\\\",\\n\\t\\\n \\t\\t\\t\\t\\t\\t\\t\\t\\t\\t\\t\\t\\t\\t\\\"type\\\": \\\"string\\\"\\n\\t\\t\\t\\t\\t\\t\\t\\t\\t\\t\\t\\t\\t\\t}]\\n\\t\\t\\t\\t\\t\\t\\t\\t\\\n \\t\\t\\t\\t\\t}\\n\\t\\t\\t\\t\\t\\t\\t\\t\\t\\t\\t\\t}\\n\\t\\t\\t\\t\\t\\t\\t\\t\\t\\t\\t}\\n\\t\\t\\t\\t\\t\\t\\t\\t\\t\\t]\\n\\t\\t\\t\\t\\t\\\n \\t\\t\\t\\t}\\n\\t\\t\\t\\t\\t\\t\\t\\t}]\\n\\t\\t\\t\\t\\t\\t\\t}\\n\\t\\t\\t\\t\\t\\t}\\n\\t\\t\\t\\t\\t}\\n\\t\\t\\t\\t]\\n\\t\\t\\t}\\n\\t\\\n \\t}\\n\\t]\\n}\"\n - key:\n name: SimpleIntType\n version: 0.0.1\n value:\n key:\n name: SimpleIntType\n version: 0.0.1\n schemaFlavour: Java\n schemaDefinition: java.lang.Integer\n - key:\n name: SimpleStringType\n version: 0.0.1\n value:\n key:\n name: SimpleStringType\n version: 0.0.1\n schemaFlavour: Java\n schemaDefinition: java.lang.String\n - key:\n name: SubscriptionStatusType\n version: 0.0.1\n value:\n key:\n name: SubscriptionStatusType\n version: 0.0.1\n schemaFlavour: Avro\n schemaDefinition: |-\n {\n \"type\": \"record\",\n \"name\": \"ActivateSubscriptionStatus_Type\",\n \"namespace\": \"org.onap.policy.apex.onap.helloworld\",\n \"fields\": [\n {\n \"name\": \"subscriptionName\",\n \"type\": \"string\"\n },\n {\n \"name\": \"nfName\",\n \"type\": \"string\"\n },\n {\n \"name\": \"changeType\",\n \"type\": \"string\"\n },\n {\n \"name\": \"message\",\n \"type\": \"string\"\n }\n ]\n }\n - key:\n name: SubscriptionType\n version: 0.0.1\n value:\n key:\n name: SubscriptionType\n version: 0.0.1\n schemaFlavour: Avro\n schemaDefinition: \"{\\n\\t\\\"name\\\": \\\"subscription\\\",\\n\\t\\\"type\\\": \\\"record\\\",\\n\\t\\\"fields\\\": [{\\n\\t\\t\\\n \\t\\\"name\\\": \\\"subscriptionName\\\",\\n\\t\\t\\t\\\"type\\\": \\\"string\\\"\\n\\t\\t},\\n\\t\\t{\\n\\t\\t\\t\\\"name\\\": \\\"administrativeState\\\"\\\n ,\\n\\t\\t\\t\\\"type\\\": \\\"string\\\"\\n\\t\\t},\\n\\t\\t{\\n\\t\\t\\t\\\"name\\\": \\\"fileBasedGP\\\",\\n\\t\\t\\t\\\"type\\\": \\\"\\\n int\\\"\\n\\t\\t},\\n\\t\\t{\\n\\t\\t\\t\\\"name\\\": \\\"fileLocation\\\",\\n\\t\\t\\t\\\"type\\\": \\\"string\\\"\\n\\t\\t},\\n\\t\\t\\\n {\\n\\t\\t\\t\\\"name\\\": \\\"measurementGroups\\\",\\n\\t\\t\\t\\\"type\\\": {\\n\\t\\t\\t\\t\\\"type\\\": \\\"array\\\",\\n\\t\\t\\t\\\n \\t\\\"items\\\": {\\n\\t\\t\\t\\t\\t\\\"name\\\": \\\"Measurement_Groups_Type\\\",\\n\\t\\t\\t\\t\\t\\\"type\\\": \\\"record\\\",\\n\\\n \\t\\t\\t\\t\\t\\\"fields\\\": [{\\n\\t\\t\\t\\t\\t\\t\\\"name\\\": \\\"measurementGroup\\\",\\n\\t\\t\\t\\t\\t\\t\\\"type\\\": {\\n\\t\\\n \\t\\t\\t\\t\\t\\t\\\"name\\\": \\\"Measurement_Group_Type\\\",\\n\\t\\t\\t\\t\\t\\t\\t\\\"type\\\": \\\"record\\\",\\n\\t\\t\\t\\t\\t\\\n \\t\\t\\\"fields\\\": [{\\n\\t\\t\\t\\t\\t\\t\\t\\t\\t\\\"name\\\": \\\"measurementTypes\\\",\\n\\t\\t\\t\\t\\t\\t\\t\\t\\t\\\"type\\\"\\\n : {\\n\\t\\t\\t\\t\\t\\t\\t\\t\\t\\t\\\"type\\\": \\\"array\\\",\\n\\t\\t\\t\\t\\t\\t\\t\\t\\t\\t\\\"items\\\": {\\n\\t\\t\\t\\t\\t\\t\\t\\t\\t\\\n \\t\\t\\\"name\\\": \\\"Measurement_Types_Type\\\",\\n\\t\\t\\t\\t\\t\\t\\t\\t\\t\\t\\t\\\"type\\\": \\\"record\\\",\\n\\t\\t\\t\\t\\t\\\n \\t\\t\\t\\t\\t\\t\\\"fields\\\": [{\\n\\t\\t\\t\\t\\t\\t\\t\\t\\t\\t\\t\\t\\\"name\\\": \\\"measurementType\\\",\\n\\t\\t\\t\\t\\t\\t\\t\\\n \\t\\t\\t\\t\\t\\\"type\\\": \\\"string\\\"\\n\\t\\t\\t\\t\\t\\t\\t\\t\\t\\t\\t}]\\n\\t\\t\\t\\t\\t\\t\\t\\t\\t\\t}\\n\\t\\t\\t\\t\\t\\t\\t\\t\\t\\\n }\\n\\t\\t\\t\\t\\t\\t\\t\\t},\\n\\t\\t\\t\\t\\t\\t\\t\\t{\\n\\t\\t\\t\\t\\t\\t\\t\\t\\t\\\"name\\\": \\\"managedObjectDNsBasic\\\",\\n\\\n \\t\\t\\t\\t\\t\\t\\t\\t\\t\\\"type\\\": {\\n\\t\\t\\t\\t\\t\\t\\t\\t\\t\\t\\\"type\\\": \\\"array\\\",\\n\\t\\t\\t\\t\\t\\t\\t\\t\\t\\t\\\"items\\\"\\\n : {\\n\\t\\t\\t\\t\\t\\t\\t\\t\\t\\t\\t\\\"name\\\": \\\"Managed_Object_Dns_Basic_Type\\\",\\n\\t\\t\\t\\t\\t\\t\\t\\t\\t\\t\\t\\\"\\\n type\\\": \\\"record\\\",\\n\\t\\t\\t\\t\\t\\t\\t\\t\\t\\t\\t\\\"fields\\\": [{\\n\\t\\t\\t\\t\\t\\t\\t\\t\\t\\t\\t\\t\\\"name\\\": \\\"DN\\\"\\\n ,\\n\\t\\t\\t\\t\\t\\t\\t\\t\\t\\t\\t\\t\\\"type\\\": \\\"string\\\"\\n\\t\\t\\t\\t\\t\\t\\t\\t\\t\\t\\t}]\\n\\t\\t\\t\\t\\t\\t\\t\\t\\t\\t}\\n\\\n \\t\\t\\t\\t\\t\\t\\t\\t\\t}\\n\\t\\t\\t\\t\\t\\t\\t\\t}\\n\\t\\t\\t\\t\\t\\t\\t]\\n\\t\\t\\t\\t\\t\\t}\\n\\t\\t\\t\\t\\t}]\\n\\t\\t\\t\\t}\\n\\t\\\n \\t\\t}\\n\\t\\t}\\n\\t]\\n}\"\n - key:\n name: UUIDType\n version: 0.0.1\n value:\n key:\n name: UUIDType\n version: 0.0.1\n schemaFlavour: Java\n schemaDefinition: java.util.UUID\n engineParameters:\n executorParameters:\n JAVASCRIPT:\n parameterClassName: org.onap.policy.apex.plugins.executor.javascript.JavascriptExecutorParameters\n contextParameters:\n parameterClassName: org.onap.policy.apex.context.parameters.ContextParameters\n schemaParameters:\n Avro:\n parameterClassName: org.onap.policy.apex.plugins.context.schema.avro.AvroSchemaHelperParameters\n Java:\n parameterClassName: org.onap.policy.apex.context.impl.schema.java.JavaSchemaHelperParameters\n jsonAdapters:\n Instant:\n adaptedClass: java.time.Instant\n adaptorClass: org.onap.policy.controlloop.util.Serialization$GsonInstantAdapter\n eventInputParameters:\n DCAEConsumer:\n carrierTechnologyParameters:\n carrierTechnology: RESTCLIENT\n parameterClassName: org.onap.policy.apex.plugins.event.carrier.restclient.RestClientCarrierTechnologyParameters\n parameters:\n consumerPollTime: '50'\n url: https://message-router:3905/events/unauthenticated.DCAE_CL_OUTPUT/cg1/sg1\n eventProtocolParameters:\n eventProtocol: JSON\n parameters:\n nameAlias: policyName\n eventName: pmsh-operational-policy\n eventNameFilter: pmsh-operational-policy\n CDSRequestConsumer:\n carrierTechnologyParameters:\n carrierTechnology: RESTREQUESTOR\n parameterClassName: org.onap.policy.apex.plugins.event.carrier.restrequestor.RestRequestorCarrierTechnologyParameters\n parameters:\n url: http://10.10.10.184:30254/api/v1/execution-service/process\n httpMethod: POST\n restRequestTimeout: 2000\n httpHeaders:\n - - Authorization\n - Basic Y2NzZGthcHBzOmNjc2RrYXBwcw==\n eventProtocolParameters:\n eventProtocol: JSON\n eventName: CDSCreateResponseEvent\n eventNameFilter: CDSCreateResponseEvent\n requestorMode: true\n requestorPeer: CDSRequestProducer\n requestorTimeout: 500\n CDSDeleteRequestConsumer:\n carrierTechnologyParameters:\n carrierTechnology: RESTREQUESTOR\n parameterClassName: org.onap.policy.apex.plugins.event.carrier.restrequestor.RestRequestorCarrierTechnologyParameters\n parameters:\n url: http://10.10.10.184:30254/api/v1/execution-service/process\n httpMethod: POST\n restRequestTimeout: 2000\n httpHeaders:\n - - Authorization\n - Basic Y2NzZGthcHBzOmNjc2RrYXBwcw==\n eventProtocolParameters:\n eventProtocol: JSON\n eventName: CDSDeleteResponseEvent\n eventNameFilter: CDSDeleteResponseEvent\n requestorMode: true\n requestorPeer: CDSDeleteRequestProducer\n requestorTimeout: 500\n CDSReplyConsumer:\n carrierTechnologyParameters:\n carrierTechnology: RESTREQUESTOR\n parameterClassName: org.onap.policy.apex.plugins.event.carrier.restrequestor.RestRequestorCarrierTechnologyParameters\n parameters:\n url: https://message-router:3905/events/unauthenticated.PMSH_CL_INPUT\n httpMethod: POST\n restRequestTimeout: 2000\n eventProtocolParameters:\n eventProtocol: JSON\n eventName: MRResponseEvent\n eventNameFilter: MRResponseEvent\n requestorMode: true\n requestorPeer: CDSReplyProducer\n requestorTimeout: 500\n eventOutputParameters:\n logOutputter:\n carrierTechnologyParameters:\n carrierTechnology: FILE\n parameters:\n fileName: /tmp/outputevents.log\n eventProtocolParameters:\n eventProtocol: JSON\n StdOutOutputter:\n carrierTechnologyParameters:\n carrierTechnology: FILE\n parameters:\n standardIo: true\n eventProtocolParameters:\n eventProtocol: JSON\n CDSRequestProducer:\n carrierTechnologyParameters:\n carrierTechnology: RESTREQUESTOR\n parameterClassName: org.onap.policy.apex.plugins.event.carrier.restrequestor.RestRequestorCarrierTechnologyParameters\n eventProtocolParameters:\n eventProtocol: JSON\n eventNameFilter: CDSCreateSubscriptionRequestEvent\n requestorMode: true\n requestorPeer: CDSRequestConsumer\n requestorTimeout: 500\n CDSDeleteRequestProducer:\n carrierTechnologyParameters:\n carrierTechnology: RESTREQUESTOR\n parameterClassName: org.onap.policy.apex.plugins.event.carrier.restrequestor.RestRequestorCarrierTechnologyParameters\n eventProtocolParameters:\n eventProtocol: JSON\n eventNameFilter: CDSDeleteSubscriptionRequestEvent\n requestorMode: true\n requestorPeer: CDSDeleteRequestConsumer\n requestorTimeout: 500\n CDSReplyProducer:\n carrierTechnologyParameters:\n carrierTechnology: RESTREQUESTOR\n parameterClassName: org.onap.policy.apex.plugins.event.carrier.restrequestor.RestRequestorCarrierTechnologyParameters\n eventProtocolParameters:\n eventProtocol: JSON\n eventNameFilter: CDSResponseStatusEvent\n requestorMode: true\n requestorPeer: CDSReplyConsumer\n requestorTimeout: 500", + "raw": "tosca_definitions_version: tosca_simple_yaml_1_1_0\ndata_types:\n onap.datatypes.ToscaConceptIdentifier:\n derived_from: tosca.datatypes.Root\n properties:\n name:\n type: string\n required: true\n version:\n type: string\n required: true\n org.onap.datatypes.policy.clamp.acm.DCAEMicroserviceControlLoopElementConsulInfo:\n name: org.onap.datatypes.policy.clamp.acm.DCAEMicroserviceControlLoopElementConsulInfo\n version: 0.0.0\n derived_from: tosca.datatypes.Root\n properties:\n consulUrl:\n name: consulUrl\n type: string\n typeVersion: 0.0.0\n description: Consul url for this entry\n required: true\n consul_body:\n name: consulBody\n type: string\n typeVersion: 0.0.0\n description: Body of Consul entry\n required: true\n onap.datatype.acm.Target:\n derived_from: tosca.datatypes.Root\n description: Definition for a entity in A&AI to perform a automation composition operation on\n properties:\n targetType:\n type: string\n description: Category for the target type\n required: true\n constraints:\n - valid_values:\n - VNF\n - VM\n - VFMODULE\n - PNF\n entityIds:\n type: map\n description: |\n Map of values that identify the resource. If none are provided, it is assumed that the\n entity that generated the ONSET event will be the target.\n required: false\n metadata:\n clamp_possible_values: ClampExecution:CSAR_RESOURCES\n entry_schema:\n type: string\n onap.datatype.acm.Actor:\n derived_from: tosca.datatypes.Root\n description: An actor/operation/target definition\n properties:\n actor:\n type: string\n description: The actor performing the operation.\n required: true\n metadata:\n clamp_possible_values: Dictionary:DefaultActors,ClampExecution:CDS/actor\n operation:\n type: string\n description: The operation the actor is performing.\n metadata:\n clamp_possible_values: Dictionary:DefaultOperations,ClampExecution:CDS/operation\n required: true\n target:\n type: onap.datatype.acm.Target\n description: The resource the operation should be performed on.\n required: true\n payload:\n type: map\n description: Name/value pairs of payload information passed by Policy to the actor\n required: false\n metadata:\n clamp_possible_values: ClampExecution:CDS/payload\n entry_schema:\n type: string\n onap.datatype.acm.Operation:\n derived_from: tosca.datatypes.Root\n description: An operation supported by an actor\n properties:\n id:\n type: string\n description: Unique identifier for the operation\n required: true\n description:\n type: string\n description: A user-friendly description of the intent for the operation\n required: false\n operation:\n type: onap.datatype.acm.Actor\n description: The definition of the operation to be performed.\n required: true\n timeout:\n type: integer\n description: The amount of time for the actor to perform the operation.\n required: true\n retries:\n type: integer\n description: The number of retries the actor should attempt to perform the operation.\n required: true\n default: 0\n success:\n type: string\n description: Points to the operation to invoke on success. A value of \"final_success\" indicates and end to the operation.\n required: false\n default: final_success\n failure:\n type: string\n description: Points to the operation to invoke on Actor operation failure.\n required: false\n default: final_failure\n failure_timeout:\n type: string\n description: Points to the operation to invoke when the time out for the operation occurs.\n required: false\n default: final_failure_timeout\n failure_retries:\n type: string\n description: Points to the operation to invoke when the current operation has exceeded its max retries.\n required: false\n default: final_failure_retries\n failure_exception:\n type: string\n description: Points to the operation to invoke when the current operation causes an exception.\n required: false\n default: final_failure_exception\n failure_guard:\n type: string\n description: Points to the operation to invoke when the current operation is blocked due to guard policy enforcement.\n required: false\n default: final_failure_guard\n onap.datatypes.monitoring.managedObjectDNsBasic:\n constraints: []\n properties:\n DN:\n name: DN\n type: string\n typeVersion: 0.0.0\n description: Managed object distinguished name\n required: true\n constraints: []\n metadata: {}\n name: onap.datatypes.monitoring.managedObjectDNsBasic\n version: 0.0.0\n derived_from: tosca.datatypes.Root\n metadata: {}\n onap.datatypes.monitoring.managedObjectDNsBasics:\n constraints: []\n properties:\n managedObjectDNsBasic:\n name: managedObjectDNsBasic\n type: map\n typeVersion: 0.0.0\n description: Managed object distinguished name object\n required: true\n constraints: []\n entry_schema:\n type: onap.datatypes.monitoring.managedObjectDNsBasic\n typeVersion: 0.0.0\n constraints: []\n metadata: {}\n name: onap.datatypes.monitoring.managedObjectDNsBasics\n version: 0.0.0\n derived_from: tosca.datatypes.Root\n metadata: {}\n onap.datatypes.monitoring.measurementGroup:\n constraints: []\n properties:\n measurementTypes:\n name: measurementTypes\n type: list\n typeVersion: 0.0.0\n description: List of measurement types\n required: true\n constraints: []\n entry_schema:\n type: onap.datatypes.monitoring.measurementTypes\n typeVersion: 0.0.0\n constraints: []\n metadata: {}\n managedObjectDNsBasic:\n name: managedObjectDNsBasic\n type: list\n typeVersion: 0.0.0\n description: List of managed object distinguished names\n required: true\n constraints: []\n entry_schema:\n type: onap.datatypes.monitoring.managedObjectDNsBasics\n typeVersion: 0.0.0\n constraints: []\n metadata: {}\n name: onap.datatypes.monitoring.measurementGroup\n version: 0.0.0\n derived_from: tosca.datatypes.Root\n metadata: {}\n onap.datatypes.monitoring.measurementGroups:\n constraints: []\n properties:\n measurementGroup:\n name: measurementGroup\n type: map\n typeVersion: 0.0.0\n description: Measurement Group\n required: true\n constraints: []\n entry_schema:\n type: onap.datatypes.monitoring.measurementGroup\n typeVersion: 0.0.0\n constraints: []\n metadata: {}\n name: onap.datatypes.monitoring.measurementGroups\n version: 0.0.0\n derived_from: tosca.datatypes.Root\n metadata: {}\n onap.datatypes.monitoring.measurementType:\n constraints: []\n properties:\n measurementType:\n name: measurementType\n type: string\n typeVersion: 0.0.0\n description: Measurement type\n required: true\n constraints: []\n metadata: {}\n name: onap.datatypes.monitoring.measurementType\n version: 0.0.0\n derived_from: tosca.datatypes.Root\n metadata: {}\n onap.datatypes.monitoring.measurementTypes:\n constraints: []\n properties:\n measurementType:\n name: measurementType\n type: map\n typeVersion: 0.0.0\n description: Measurement type object\n required: true\n constraints: []\n entry_schema:\n type: onap.datatypes.monitoring.measurementType\n typeVersion: 0.0.0\n constraints: []\n metadata: {}\n name: onap.datatypes.monitoring.measurementTypes\n version: 0.0.0\n derived_from: tosca.datatypes.Root\n metadata: {}\n onap.datatypes.monitoring.nfFilter:\n constraints: []\n properties:\n modelNames:\n name: modelNames\n type: list\n typeVersion: 0.0.0\n description: List of model names\n required: true\n constraints: []\n entry_schema:\n type: string\n typeVersion: 0.0.0\n constraints: []\n metadata: {}\n modelInvariantIDs:\n name: modelInvariantIDs\n type: list\n typeVersion: 0.0.0\n description: List of model invariant IDs\n required: true\n constraints: []\n entry_schema:\n type: string\n typeVersion: 0.0.0\n constraints: []\n metadata: {}\n modelVersionIDs:\n name: modelVersionIDs\n type: list\n typeVersion: 0.0.0\n description: List of model version IDs\n required: true\n constraints: []\n entry_schema:\n type: string\n typeVersion: 0.0.0\n constraints: []\n metadata: {}\n nfNames:\n name: nfNames\n type: list\n typeVersion: 0.0.0\n description: List of network functions\n required: true\n constraints: []\n entry_schema:\n type: string\n typeVersion: 0.0.0\n constraints: []\n metadata: {}\n name: onap.datatypes.monitoring.nfFilter\n version: 0.0.0\n derived_from: tosca.datatypes.Root\n metadata: {}\n onap.datatypes.monitoring.subscription:\n constraints: []\n properties:\n measurementGroups:\n name: measurementGroups\n type: list\n typeVersion: 0.0.0\n description: Measurement Groups\n required: true\n constraints: []\n entry_schema:\n type: onap.datatypes.monitoring.measurementGroups\n typeVersion: 0.0.0\n constraints: []\n metadata: {}\n fileBasedGP:\n name: fileBasedGP\n type: integer\n typeVersion: 0.0.0\n description: File based granularity period\n required: true\n constraints: []\n metadata: {}\n fileLocation:\n name: fileLocation\n type: string\n typeVersion: 0.0.0\n description: ROP file location\n required: true\n constraints: []\n metadata: {}\n subscriptionName:\n name: subscriptionName\n type: string\n typeVersion: 0.0.0\n description: Name of the subscription\n required: true\n constraints: []\n metadata: {}\n administrativeState:\n name: administrativeState\n type: string\n typeVersion: 0.0.0\n description: State of the subscription\n required: true\n constraints:\n - valid_values:\n - LOCKED\n - UNLOCKED\n metadata: {}\n nfFilter:\n name: nfFilter\n type: map\n typeVersion: 0.0.0\n description: Network function filter\n required: true\n constraints: []\n entry_schema:\n type: onap.datatypes.monitoring.nfFilter\n typeVersion: 0.0.0\n constraints: []\n metadata: {}\n name: onap.datatypes.monitoring.subscription\n version: 0.0.0\n derived_from: tosca.datatypes.Root\n metadata: {}\npolicy_types:\n onap.policies.Monitoring:\n derived_from: tosca.policies.Root\n description: a base policy type for all policies that govern monitoring provisioning\n version: 1.0.0\n name: onap.policies.Monitoring\n onap.policies.Sirisha:\n derived_from: tosca.policies.Root\n description: a base policy type for all policies that govern monitoring provisioning\n version: 1.0.0\n name: onap.policies.Sirisha\n onap.policies.monitoring.dcae-pm-subscription-handler:\n properties:\n pmsh_policy:\n name: pmsh_policy\n type: onap.datatypes.monitoring.subscription\n typeVersion: 0.0.0\n description: PMSH Policy JSON\n required: false\n constraints: []\n metadata: {}\n name: onap.policies.monitoring.dcae-pm-subscription-handler\n version: 1.0.0\n derived_from: onap.policies.Monitoring\n metadata: {}\n onap.policies.acm.operational.Common:\n derived_from: tosca.policies.Root\n version: 1.0.0\n name: onap.policies.acm.operational.Common\n description: |\n Operational Policy for Control Loop execution. Originated in Frankfurt to support TOSCA Compliant\n Policy Types. This does NOT support the legacy Policy YAML policy type.\n properties:\n id:\n type: string\n description: The unique automation composition id.\n required: true\n timeout:\n type: integer\n description: |\n Overall timeout for executing all the operations. This timeout should equal or exceed the total\n timeout for each operation listed.\n required: true\n abatement:\n type: boolean\n description: Whether an abatement event message will be expected for the automation composition from DCAE.\n required: true\n default: false\n trigger:\n type: string\n description: Initial operation to execute upon receiving an Onset event message for the Control Loop.\n required: true\n operations:\n type: list\n description: List of operations to be performed when Control Loop is triggered.\n required: true\n entry_schema:\n type: onap.datatype.acm.Operation\n onap.policies.acm.operational.common.Apex:\n derived_from: onap.policies.acm.operational.Common\n type_version: 1.0.0\n version: 1.0.0\n name: onap.policies.acm.operational.common.Apex\n description: Operational policies for Apex PDP\n properties:\n engineServiceParameters:\n type: string\n description: The engine parameters like name, instanceCount, policy implementation, parameters etc.\n required: true\n eventInputParameters:\n type: string\n description: The event input parameters.\n required: true\n eventOutputParameters:\n type: string\n description: The event output parameters.\n required: true\n javaProperties:\n type: string\n description: Name/value pairs of properties to be set for APEX if needed.\n required: false\nnode_types:\n org.onap.policy.clamp.acm.Participant:\n version: 1.0.1\n derived_from: tosca.nodetypes.Root\n properties:\n provider:\n type: string\n requred: false\n org.onap.policy.clamp.acm.ControlLoopElement:\n version: 1.0.1\n derived_from: tosca.nodetypes.Root\n properties:\n provider:\n type: string\n required: false\n metadata:\n common: true\n description: Specifies the organization that provides the automation composition element\n participantType:\n type: onap.datatypes.ToscaConceptIdentifier\n required: true\n metadata:\n common: true\n description: The identity of the participant type that hosts this type of Control Loop Element\n startPhase:\n type: integer\n required: false\n constraints:\n - greater-or-equal: 0\n metadata:\n common: true\n description: A value indicating the start phase in which this automation composition element will be started, the\n first start phase is zero. Control Loop Elements are started in their start_phase order and stopped\n in reverse start phase order. Control Loop Elements with the same start phase are started and\n stopped simultaneously\n uninitializedToPassiveTimeout:\n type: integer\n required: false\n constraints:\n - greater-or-equal: 0\n default: 60\n metadata:\n common: true\n description: The maximum time in seconds to wait for a state chage from uninitialized to passive\n passiveToRunningTimeout:\n type: integer\n required: false\n constraints:\n - greater-or-equal: 0\n default: 60\n metadata:\n common: true\n description: The maximum time in seconds to wait for a state chage from passive to running\n runningToPassiveTimeout:\n type: integer\n required: false\n constraints:\n - greater-or-equal: 0\n default: 60\n metadata:\n common: true\n description: The maximum time in seconds to wait for a state chage from running to passive\n passiveToUninitializedTimeout:\n type: integer\n required: false\n constraints:\n - greater-or-equal: 0\n default: 60\n metadata:\n common: true\n description: The maximum time in seconds to wait for a state chage from passive to uninitialized\n\n org.onap.policy.clamp.acm.ControlLoop:\n version: 1.0.1\n derived_from: tosca.nodetypes.Root\n properties:\n provider:\n type: string\n requred: false\n elements:\n type: list\n required: true\n entry_schema:\n type: onap.datatypes.ToscaConceptIdentifier\n org.onap.policy.clamp.acm.DCAEMicroserviceControlLoopElement:\n version: 1.0.1\n derived_from: org.onap.policy.clamp.acm.ControlLoopElement\n properties:\n dcae_blueprint_id:\n type: onap.datatypes.ToscaConceptIdentifier\n requred: false\n dcae_blueprint:\n type: onap.dcae.cloudify_blueprint\n requred: false\n consul_info:\n type: list\n required: false\n entry_schema:\n type: org.onap.datatypes.policy.clamp.acm.DCAEMicroserviceControlLoopElementConsulInfo\n org.onap.policy.clamp.acm.PolicyControlLoopElement:\n version: 1.0.1\n derived_from: org.onap.policy.clamp.acm.ControlLoopElement\n properties:\n policy_type_id:\n type: onap.datatypes.ToscaConceptIdentifier\n requred: true\n policy_id:\n type: onap.datatypes.ToscaConceptIdentifier\n requred: false\n org.onap.policy.clamp.acm.CDSControlLoopElement:\n version: 1.0.1\n derived_from: org.onap.policy.clamp.acm.ControlLoopElement\n properties:\n cds_blueprint_id:\n type: onap.datatypes.ToscaConceptIdentifier\n requred: true\ntopology_template:\n inputs:\n pmsh_monitoring_policy:\n type: onap.datatypes.ToscaConceptIdentifier\n description: The ID of the PMSH monitoring policy to use\n default:\n name: MICROSERVICE_vLoadBalancerMS_v1_0_dcae-pm-subscription-handler_1_0_0test\n version: 1.0.0\n pmsh_operational_policy:\n type: onap.datatypes.ToscaConceptIdentifier\n description: The ID of the PMSH operational policy to use\n default:\n name: operational.apex.pmcontrol\n version: 1.0.0\n node_templates:\n org.onap.dcae.acm.DCAEMicroserviceControlLoopParticipant:\n version: 2.3.4\n type: org.onap.policy.clamp.acm.Participant\n type_version: 1.0.1\n description: Participant for DCAE microservices\n properties:\n provider: ONAP\n org.onap.policy.acm.PolicyControlLoopParticipant:\n version: 2.3.1\n type: org.onap.policy.clamp.acm.Participant\n type_version: 1.0.1\n description: Participant for DCAE microservices\n properties:\n provider: ONAP\n org.onap.domain.pmsh.PMSH_DCAEMicroservice:\n version: 1.2.3\n type: org.onap.policy.clamp.acm.DCAEMicroserviceControlLoopElement\n type_version: 1.0.0\n description: Control loop element for the DCAE microservice for Performance Management Subscription Handling\n properties:\n provider: Ericsson\n participantType:\n name: org.onap.dcae.acm.DCAEMicroserviceControlLoopParticipant\n version: 2.3.4\n startPhase: 0\n dcae_blueprint:\n tosca_definitions_version: cloudify_dsl_1_3\n imports:\n - https://www.getcloudify.org/spec/cloudify/4.5.5/types.yaml\n - plugin:k8splugin?version=3.7.0\n - plugin:pgaas?version=1.3.0\n - plugin:clamppolicyplugin?version=1.1.0\n inputs:\n tag_version:\n type: string\n description: Docker image to be used\n default: nexus3.onap.org:10001/onap/org.onap.dcaegen2.services.pmsh:1.1.2\n replicas:\n type: integer\n description: Number of instances\n default: 1\n operational_policy_name:\n type: string\n default: operational.apex.pmcontrol\n control_loop_name:\n type: string\n default: pmsh-control-loop\n pmsh_publish_topic_name:\n type: string\n default: unauthenticated.DCAE_CL_OUTPUT\n policy_feedback_topic_name:\n type: string\n default: unauthenticated.PMSH_CL_INPUT\n aai_notification_topic_name:\n type: string\n default: AAI-EVENT\n publisher_client_role:\n type: string\n description: Client role to request secure access to topic\n default: org.onap.dcae.pmPublisher\n subscriber_client_role:\n type: string\n description: Client role to request secure access to topic\n default: org.onap.dcae.pmSubscriber\n dcae_location:\n type: string\n description: DCAE location for the subscriber, used to set up routing\n default: san-francisco\n cpu_limit:\n type: string\n default: 1000m\n cpu_request:\n type: string\n default: 1000m\n memory_limit:\n type: string\n default: 1024Mi\n memory_request:\n type: string\n default: 1024Mi\n pgaas_cluster_name:\n type: string\n default: dcae-pg-primary.onap\n enable_tls:\n type: boolean\n default: true\n protocol:\n type: string\n description: PMSH protocol. If enable_tls is false, set to http\n default: https\n policy_model_id:\n type: string\n default: onap.policies.monitoring.dcae-pm-subscription-handler\n policy_id:\n type: string\n default: MICROSERVICE_vLoadBalancerMS_v1_0_dcae-pm-subscription-handler_1_0_0test\n node_templates:\n pgaasvm:\n type: dcae.nodes.pgaas.database\n properties:\n writerfqdn:\n get_input: pgaas_cluster_name\n name: pmsh\n pmsh:\n type: dcae.nodes.ContainerizedServiceComponentUsingDmaap\n interfaces:\n cloudify.interfaces.lifecycle:\n create:\n inputs:\n ports:\n - '8443:0'\n envs:\n PMSH_PG_URL:\n get_attribute:\n - pgaasvm\n - admin\n - host\n PMSH_PG_PASSWORD:\n get_attribute:\n - pgaasvm\n - admin\n - password\n PMSH_PG_USERNAME:\n get_attribute:\n - pgaasvm\n - admin\n - user\n PMSH_DB_NAME:\n get_attribute:\n - pgaasvm\n - admin\n - database\n relationships:\n - target: pmsh-policy\n type: cloudify.relationships.depends_on\n properties:\n service_component_type: dcae-pmsh\n service_component_name_override: dcae-pmsh\n application_config:\n enable_tls:\n get_input: enable_tls\n aaf_identity: dcae@dcae.onap.org\n aaf_password: demo123456!\n operational_policy_name:\n get_input: operational_policy_name\n control_loop_name:\n get_input: control_loop_name\n cert_path: /opt/app/pmsh/etc/certs/cert.pem\n key_path: /opt/app/pmsh/etc/certs/key.pem\n ca_cert_path: /opt/app/pmsh/etc/certs/cacert.pem\n streams_publishes:\n policy_pm_publisher:\n type: message_router\n dmaap_info:\n topic_url:\n concat:\n - http://message-router:3904/events/\n - get_input: pmsh_publish_topic_name\n streams_subscribes:\n policy_pm_subscriber:\n type: message_router\n dmaap_info:\n topic_url:\n concat:\n - http://message-router:3904/events/\n - get_input: policy_feedback_topic_name\n aai_subscriber:\n type: message_router\n dmaap_info:\n topic_url:\n concat:\n - http://message-router:3904/events/\n - get_input: aai_notification_topic_name\n resource_config:\n limits:\n cpu:\n get_input: cpu_limit\n memory:\n get_input: memory_limit\n requests:\n cpu:\n get_input: cpu_request\n memory:\n get_input: memory_request\n docker_config:\n healthcheck:\n endpoint: /healthcheck\n interval: 15s\n timeout: 1s\n type:\n get_input: protocol\n image:\n get_input: tag_version\n replicas:\n get_input: replicas\n log_info:\n log_directory: /var/log/ONAP/dcaegen2/services/pmsh\n tls_info:\n cert_directory: /opt/app/pmsh/etc/certs\n use_tls:\n get_input: enable_tls\n pmsh-policy:\n type: clamp.nodes.policy\n properties:\n policy_model_id:\n get_input: policy_model_id\n policy_id:\n get_input: policy_id\n consul_info:\n - consulUrl: http://consul:31321/v1/kv/dcae-pmsh:policy\n consulBody:\n subscription:\n subscriptionName: subscriptiona\n administrativeState: UNLOCKED\n fileBasedGP: 15\n fileLocation: /pm/pm.xml\n nfFilter:\n nfNames:\n - ^pnf1.*\n modelInvariantIDs:\n - 5845y423-g654-6fju-po78-8n53154532k6\n - 7129e420-d396-4efb-af02-6b83499b12f8\n modelVersionIDs:\n - e80a6ae3-cafd-4d24-850d-e14c084a5ca9\n measurementGroups:\n - measurementGroup:\n measurementTypes:\n - measurementType: countera\n - measurementType: counterb\n managedObjectDNsBasic:\n - DN: dna\n - DN: dnb\n - measurementGroup:\n measurementTypes:\n - measurementType: counterc\n - measurementType: counterd\n managedObjectDNsBasic:\n - DN: dnc\n - DN: dnd\n org.onap.domain.pmsh.PMSH_MonitoringPolicyControlLoopElement:\n version: 1.2.3\n type: org.onap.policy.clamp.acm.PolicyControlLoopElement\n type_version: 1.0.0\n description: Control loop element for the monitoring policy for Performance Management Subscription Handling\n properties:\n provider: Ericsson\n participantType:\n name: org.onap.policy.acm.PolicyControlLoopParticipant\n version: 2.3.1\n startPhase: 0\n policy_type_id:\n name: onap.policies.monitoring.pm-subscription-handler\n version: 1.0.0\n policy_id:\n get_input: pmsh_monitoring_policy\n org.onap.domain.pmsh.PMSH_OperationalPolicyControlLoopElement:\n version: 1.2.3\n type: org.onap.policy.clamp.acm.PolicyControlLoopElement\n type_version: 1.0.0\n description: Control loop element for the operational policy for Performance Management Subscription Handling\n properties:\n provider: Ericsson\n participantType:\n name: org.onap.policy.acm.PolicyControlLoopParticipant\n version: 2.3.1\n startPhase: 0\n policy_type_id:\n name: onap.policies.operational.pm-subscription-handler\n version: 1.0.0\n policy_id:\n get_input: pmsh_operational_policy\n org.onap.domain.pmsh.PMSHControlLoopDefinition:\n version: 1.2.3\n type: org.onap.policy.clamp.acm.ControlLoop\n type_version: 1.0.0\n description: Control loop for Performance Management Subscription Handling\n properties:\n provider: Ericsson\n elements:\n - name: org.onap.domain.pmsh.PMSH_DCAEMicroservice\n version: 1.2.3\n - name: org.onap.domain.pmsh.PMSH_MonitoringPolicyControlLoopElement\n version: 1.2.3\n - name: org.onap.domain.pmsh.PMSH_OperationalPolicyControlLoopElement\n version: 1.2.3\n policies:\n - MICROSERVICE_vLoadBalancerMS_v1_0_dcae-pm-subscription-handler_1_0_0test:\n type: onap.policies.monitoring.dcae-pm-subscription-handler\n type_version: 1.0.0\n name: MICROSERVICE_vLoadBalancerMS_v1_0_dcae-pm-subscription-handler_1_0_0test\n version: 1.0.0\n metadata:\n policy-id: MICROSERVICE_vLoadBalancerMS_v1_0_dcae-pm-subscription-handler_1_0_0test\n policy-version: 1.0.0\n properties:\n pmsh_policy:\n fileBasedGP: 15\n fileLocation: /pm/pm.xml\n subscriptionName: subscriptiona\n administrativeState: UNLOCKED\n nfFilter:\n onap.datatypes.monitoring.nfFilter:\n modelVersionIDs:\n - e80a6ae3-cafd-4d24-850d-e14c084a5ca9\n modelInvariantIDs:\n - 5845y423-g654-6fju-po78-8n53154532k6\n - 7129e420-d396-4efb-af02-6b83499b12f8\n modelNames: []\n nfNames:\n - '\"^pnf1.*\"'\n measurementGroups:\n - measurementGroup:\n onap.datatypes.monitoring.measurementGroup:\n measurementTypes:\n - measurementType:\n onap.datatypes.monitoring.measurementType:\n measurementType: countera\n - measurementType:\n onap.datatypes.monitoring.measurementType:\n measurementType: counterb\n managedObjectDNsBasic:\n - managedObjectDNsBasic:\n onap.datatypes.monitoring.managedObjectDNsBasic:\n DN: dna\n - managedObjectDNsBasic:\n onap.datatypes.monitoring.managedObjectDNsBasic:\n DN: dnb\n - measurementGroup:\n onap.datatypes.monitoring.measurementGroup:\n measurementTypes:\n - measurementType:\n onap.datatypes.monitoring.measurementType:\n measurementType: counterc\n - measurementType:\n onap.datatypes.monitoring.measurementType:\n measurementType: counterd\n managedObjectDNsBasic:\n - managedObjectDNsBasic:\n onap.datatypes.monitoring.managedObjectDNsBasic:\n DN: dnc\n - managedObjectDNsBasic:\n onap.datatypes.monitoring.managedObjectDNsBasic:\n DN: dnd\n - operational.apex.pmcontrol:\n type: onap.policies.acm.operational.common.Apex\n type_version: 1.0.0\n version: 1.0.0\n metadata:\n policy-id: operational.apex.pmcontrol\n policy-version: 1\n properties:\n engineServiceParameters:\n name: MyApexEngine\n version: 0.0.1\n id: 45\n instanceCount: 2\n deploymentPort: 12561\n policy_type_impl:\n apexPolicyModel:\n key:\n name: PMControlPolicy\n version: 0.0.1\n keyInformation:\n key:\n name: PMControlPolicy_KeyInfo\n version: 0.0.1\n keyInfoMap:\n entry:\n - key:\n name: CDSActionIdentifiersType\n version: 0.0.1\n value:\n key:\n name: CDSActionIdentifiersType\n version: 0.0.1\n UUID: 6e5fa19b-14df-37e3-a4ae-8c537e861a82\n description: Generated description for concept referred to by key \"CDSActionIdentifiersType:0.0.1\"\n - key:\n name: CDSCreateResponseEvent\n version: 0.0.1\n value:\n key:\n name: CDSCreateResponseEvent\n version: 0.0.1\n UUID: 14b29e38-ac75-3273-aa4e-8583c0aa7dad\n description: Generated description for concept referred to by key \"CDSCreateResponseEvent:0.0.1\"\n - key:\n name: CDSCreateResponsePayloadType\n version: 0.0.1\n value:\n key:\n name: CDSCreateResponsePayloadType\n version: 0.0.1\n UUID: 04573f8f-e772-30a5-b1d9-d7318d4a1e13\n description: Generated description for concept referred to by key \"CDSCreateResponsePayloadType:0.0.1\"\n - key:\n name: CDSCreateResponsePolicy\n version: 0.0.1\n value:\n key:\n name: CDSCreateResponsePolicy\n version: 0.0.1\n UUID: e126c965-fc09-3bfe-8f55-70f380a4a49c\n description: Generated description for concept referred to by key \"CDSCreateResponsePolicy:0.0.1\"\n - key:\n name: CDSCreateResponseTask\n version: 0.0.1\n value:\n key:\n name: CDSCreateResponseTask\n version: 0.0.1\n UUID: 6165ee82-afd2-3aab-a517-f00b3f2461d2\n description: Generated description for concept referred to by key \"CDSCreateResponseTask:0.0.1\"\n - key:\n name: CDSCreateSubscriptionPayloadType\n version: 0.0.1\n value:\n key:\n name: CDSCreateSubscriptionPayloadType\n version: 0.0.1\n UUID: 8350ac5e-c157-38b9-9614-a0f93a830e60\n description: Generated description for concept referred to by key \"CDSCreateSubscriptionPayloadType:0.0.1\"\n - key:\n name: CDSCreateSubscriptionRequestEvent\n version: 0.0.1\n value:\n key:\n name: CDSCreateSubscriptionRequestEvent\n version: 0.0.1\n UUID: cfa325ba-226b-3a31-9183-ec43e2b6e9a2\n description: Generated description for concept referred to by key \"CDSCreateSubscriptionRequestEvent:0.0.1\"\n - key:\n name: CDSDeleteResponseEvent\n version: 0.0.1\n value:\n key:\n name: CDSDeleteResponseEvent\n version: 0.0.1\n UUID: 8be9c0fa-7437-3841-aff2-b3cec6ae3bd8\n description: Generated description for concept referred to by key \"CDSDeleteResponseEvent:0.0.1\"\n - key:\n name: CDSDeleteResponsePayloadType\n version: 0.0.1\n value:\n key:\n name: CDSDeleteResponsePayloadType\n version: 0.0.1\n UUID: 3fbfe0c9-152e-34d3-a504-09cd13c058d0\n description: Generated description for concept referred to by key \"CDSDeleteResponsePayloadType:0.0.1\"\n - key:\n name: CDSDeleteResponsePolicy\n version: 0.0.1\n value:\n key:\n name: CDSDeleteResponsePolicy\n version: 0.0.1\n UUID: a780251c-edd5-3132-b865-04313246b43c\n description: Generated description for concept referred to by key \"CDSDeleteResponsePolicy:0.0.1\"\n - key:\n name: CDSDeleteResponseTask\n version: 0.0.1\n value:\n key:\n name: CDSDeleteResponseTask\n version: 0.0.1\n UUID: afce4555-3aa3-3521-a7d8-ee8cdf0d3efc\n description: Generated description for concept referred to by key \"CDSDeleteResponseTask:0.0.1\"\n - key:\n name: CDSDeleteSubscriptionPayloadType\n version: 0.0.1\n value:\n key:\n name: CDSDeleteSubscriptionPayloadType\n version: 0.0.1\n UUID: 12658406-9147-3c9d-a38c-5ad5e30b092b\n description: Generated description for concept referred to by key \"CDSDeleteSubscriptionPayloadType:0.0.1\"\n - key:\n name: CDSDeleteSubscriptionRequestEvent\n version: 0.0.1\n value:\n key:\n name: CDSDeleteSubscriptionRequestEvent\n version: 0.0.1\n UUID: 24380c95-9289-36e6-8cbf-0edefa15ccd9\n description: Generated description for concept referred to by key \"CDSDeleteSubscriptionRequestEvent:0.0.1\"\n - key:\n name: CDSRequestCommonHeaderType\n version: 0.0.1\n value:\n key:\n name: CDSRequestCommonHeaderType\n version: 0.0.1\n UUID: 35590ac0-062c-39f1-8786-b4ff716e30b1\n description: Generated description for concept referred to by key \"CDSRequestCommonHeaderType:0.0.1\"\n - key:\n name: CDSResponseCommonHeaderType\n version: 0.0.1\n value:\n key:\n name: CDSResponseCommonHeaderType\n version: 0.0.1\n UUID: dd7e1805-885a-350b-aaf9-ed541321ae3c\n description: Generated description for concept referred to by key \"CDSResponseCommonHeaderType:0.0.1\"\n - key:\n name: CDSResponseStatusEvent\n version: 0.0.1\n value:\n key:\n name: CDSResponseStatusEvent\n version: 0.0.1\n UUID: 7986e21b-32f7-302e-9554-31f21b673493\n description: Generated description for concept referred to by key \"CDSResponseStatusEvent:0.0.1\"\n - key:\n name: CDSResponseStatusType\n version: 0.0.1\n value:\n key:\n name: CDSResponseStatusType\n version: 0.0.1\n UUID: 92b8a2cf-344e-3ce1-8cc0-2b7d3cb695fa\n description: Generated description for concept referred to by key \"CDSResponseStatusType:0.0.1\"\n - key:\n name: CreateSubscriptionPayloadEvent\n version: 0.0.1\n value:\n key:\n name: CreateSubscriptionPayloadEvent\n version: 0.0.1\n UUID: 92162397-1a8e-3a3f-a469-d2af7700af4a\n description: Generated description for concept referred to by key \"CreateSubscriptionPayloadEvent:0.0.1\"\n - key:\n name: CreateSubscriptionPayloadTask\n version: 0.0.1\n value:\n key:\n name: CreateSubscriptionPayloadTask\n version: 0.0.1\n UUID: bc0c69f0-52ed-38ea-b468-ae4a6fd1730d\n description: Generated description for concept referred to by key \"CreateSubscriptionPayloadTask:0.0.1\"\n - key:\n name: CreateSubscriptionRequestTask\n version: 0.0.1\n value:\n key:\n name: CreateSubscriptionRequestTask\n version: 0.0.1\n UUID: 89cb75e9-f06c-30d3-b4ff-698d45f63869\n description: Generated description for concept referred to by key \"CreateSubscriptionRequestTask:0.0.1\"\n - key:\n name: DeleteSubscriptionPayloadEvent\n version: 0.0.1\n value:\n key:\n name: DeleteSubscriptionPayloadEvent\n version: 0.0.1\n UUID: 994fa441-04ab-33bb-832d-1cd12ab5d074\n description: Generated description for concept referred to by key \"DeleteSubscriptionPayloadEvent:0.0.1\"\n - key:\n name: DeleteSubscriptionPayloadTask\n version: 0.0.1\n value:\n key:\n name: DeleteSubscriptionPayloadTask\n version: 0.0.1\n UUID: 0f519117-5fea-3e4b-941f-8f778100465f\n description: Generated description for concept referred to by key \"DeleteSubscriptionPayloadTask:0.0.1\"\n - key:\n name: DeleteSubscriptionRequestTask\n version: 0.0.1\n value:\n key:\n name: DeleteSubscriptionRequestTask\n version: 0.0.1\n UUID: acb772fe-d442-39e3-98f9-b1080caf4150\n description: Generated description for concept referred to by key \"DeleteSubscriptionRequestTask:0.0.1\"\n - key:\n name: MRResponseEvent\n version: 0.0.1\n value:\n key:\n name: MRResponseEvent\n version: 0.0.1\n UUID: 13c747a3-6bae-3bcf-9c80-b152e01dc194\n description: Generated description for concept referred to by key \"MRResponseEvent:0.0.1\"\n - key:\n name: PMControlPolicy\n version: 0.0.1\n value:\n key:\n name: PMControlPolicy\n version: 0.0.1\n UUID: acf1e55c-7bc5-3bd5-975a-0ca54afcd8a4\n description: Generated description for concept referred to by key \"PMControlPolicy:0.0.1\"\n - key:\n name: PMControlPolicy_Albums\n version: 0.0.1\n value:\n key:\n name: PMControlPolicy_Albums\n version: 0.0.1\n UUID: b38ad204-c2c8-32f4-9b5a-dda0aeb0145b\n description: Generated description for concept referred to by key \"PMControlPolicy_Albums:0.0.1\"\n - key:\n name: PMControlPolicy_Events\n version: 0.0.1\n value:\n key:\n name: PMControlPolicy_Events\n version: 0.0.1\n UUID: be3871a0-c42a-3113-a066-82d192840eca\n description: Generated description for concept referred to by key \"PMControlPolicy_Events:0.0.1\"\n - key:\n name: PMControlPolicy_KeyInfo\n version: 0.0.1\n value:\n key:\n name: PMControlPolicy_KeyInfo\n version: 0.0.1\n UUID: ced37634-28a4-3178-b7f6-2980794927b0\n description: Generated description for concept referred to by key \"PMControlPolicy_KeyInfo:0.0.1\"\n - key:\n name: PMControlPolicy_Policies\n version: 0.0.1\n value:\n key:\n name: PMControlPolicy_Policies\n version: 0.0.1\n UUID: be3d180d-ef9c-3a75-8e9c-84271a038bed\n description: Generated description for concept referred to by key \"PMControlPolicy_Policies:0.0.1\"\n - key:\n name: PMControlPolicy_Schemas\n version: 0.0.1\n value:\n key:\n name: PMControlPolicy_Schemas\n version: 0.0.1\n UUID: e61973f1-189c-39e5-82f6-0d3afe298a20\n description: Generated description for concept referred to by key \"PMControlPolicy_Schemas:0.0.1\"\n - key:\n name: PMControlPolicy_Tasks\n version: 0.0.1\n value:\n key:\n name: PMControlPolicy_Tasks\n version: 0.0.1\n UUID: 5658adb3-2962-30a3-a241-fae75bb8eb4a\n description: Generated description for concept referred to by key \"PMControlPolicy_Tasks:0.0.1\"\n - key:\n name: PMSubscriptionAlbum\n version: 0.0.1\n value:\n key:\n name: PMSubscriptionAlbum\n version: 0.0.1\n UUID: c2bd6f0d-6854-317a-9be2-97c08338428c\n description: Generated description for concept referred to by key \"PMSubscriptionAlbum:0.0.1\"\n - key:\n name: PMSubscriptionOutputEvent\n version: 0.0.1\n value:\n key:\n name: PMSubscriptionOutputEvent\n version: 0.0.1\n UUID: 992b7819-9f69-3aa0-bb0f-6e45ea15ce05\n description: Generated description for concept referred to by key \"PMSubscriptionOutputEvent:0.0.1\"\n - key:\n name: PMSubscriptionType\n version: 0.0.1\n value:\n key:\n name: PMSubscriptionType\n version: 0.0.1\n UUID: 73c1c397-4fc3-357f-93b6-a8ad707fbaae\n description: Generated description for concept referred to by key \"PMSubscriptionType:0.0.1\"\n - key:\n name: ReceiveEventPolicy\n version: 0.0.1\n value:\n key:\n name: ReceiveEventPolicy\n version: 0.0.1\n UUID: 568b7345-9de1-36d3-b6a3-9b857e6809a1\n description: Generated description for concept referred to by key \"ReceiveEventPolicy:0.0.1\"\n - key:\n name: ReceiveSubscriptionTask\n version: 0.0.1\n value:\n key:\n name: ReceiveSubscriptionTask\n version: 0.0.1\n UUID: f596afc8-100c-35eb-92c8-352355ea457d\n description: Generated description for concept referred to by key \"ReceiveSubscriptionTask:0.0.1\"\n - key:\n name: SimpleIntType\n version: 0.0.1\n value:\n key:\n name: SimpleIntType\n version: 0.0.1\n UUID: 153791fd-ae0a-36a7-88a5-309a7936415d\n description: Generated description for concept referred to by key \"SimpleIntType:0.0.1\"\n - key:\n name: SimpleStringType\n version: 0.0.1\n value:\n key:\n name: SimpleStringType\n version: 0.0.1\n UUID: 8a4957cf-9493-3a76-8c22-a208e23259af\n description: Generated description for concept referred to by key \"SimpleStringType:0.0.1\"\n - key:\n name: SubscriptionStatusType\n version: 0.0.1\n value:\n key:\n name: SubscriptionStatusType\n version: 0.0.1\n UUID: 597643b1-9db1-31ce-85d0-e1c63c43b30b\n description: Generated description for concept referred to by key \"SubscriptionStatusType:0.0.1\"\n - key:\n name: SubscriptionType\n version: 0.0.1\n value:\n key:\n name: SubscriptionType\n version: 0.0.1\n UUID: 184547bb-7d64-3cb2-a273-d7185102c5ce\n description: Generated description for concept referred to by key \"SubscriptionType:0.0.1\"\n - key:\n name: UUIDType\n version: 0.0.1\n value:\n key:\n name: UUIDType\n version: 0.0.1\n UUID: 6a8cc68e-dfc8-3403-9c6d-071c886b319c\n description: Generated description for concept referred to by key \"UUIDType:0.0.1\"\n - key:\n name: pmsh-operational-policy\n version: 0.0.1\n value:\n key:\n name: pmsh-operational-policy\n version: 0.0.1\n UUID: fdf2c9ff-6422-3ea6-b6b6-49b12116265d\n description: Generated description for concept referred to by key \"pmsh-operational-policy:0.0.1\"\n policies:\n key:\n name: PMControlPolicy_Policies\n version: 0.0.1\n policyMap:\n entry:\n - key:\n name: CDSCreateResponsePolicy\n version: 0.0.1\n value:\n policyKey:\n name: CDSCreateResponsePolicy\n version: 0.0.1\n template: Freestyle\n state:\n entry:\n - key: CDSCreateResponseState\n value:\n stateKey:\n parentKeyName: CDSCreateResponsePolicy\n parentKeyVersion: 0.0.1\n parentLocalName: 'NULL'\n localName: CDSCreateResponseState\n trigger:\n name: CDSCreateResponseEvent\n version: 0.0.1\n stateOutputs:\n entry:\n - key: ResponseOutput\n value:\n key:\n parentKeyName: CDSCreateResponsePolicy\n parentKeyVersion: 0.0.1\n parentLocalName: CDSCreateResponseState\n localName: ResponseOutput\n outgoingEvent:\n name: CDSResponseStatusEvent\n version: 0.0.1\n nextState:\n parentKeyName: 'NULL'\n parentKeyVersion: 0.0.0\n parentLocalName: 'NULL'\n localName: 'NULL'\n contextAlbumReference: []\n taskSelectionLogic:\n key: 'NULL'\n logicFlavour: UNDEFINED\n logic: ''\n stateFinalizerLogicMap:\n entry: []\n defaultTask:\n name: CDSCreateResponseTask\n version: 0.0.1\n taskReferences:\n entry:\n - key:\n name: CDSCreateResponseTask\n version: 0.0.1\n value:\n key:\n parentKeyName: CDSCreateResponsePolicy\n parentKeyVersion: 0.0.1\n parentLocalName: CDSCreateResponseState\n localName: CDSCreateResponsePolicy\n outputType: DIRECT\n output:\n parentKeyName: CDSCreateResponsePolicy\n parentKeyVersion: 0.0.1\n parentLocalName: CDSCreateResponseState\n localName: ResponseOutput\n firstState: CDSCreateResponseState\n - key:\n name: CDSDeleteResponsePolicy\n version: 0.0.1\n value:\n policyKey:\n name: CDSDeleteResponsePolicy\n version: 0.0.1\n template: Freestyle\n state:\n entry:\n - key: CDSDeleteResponseState\n value:\n stateKey:\n parentKeyName: CDSDeleteResponsePolicy\n parentKeyVersion: 0.0.1\n parentLocalName: 'NULL'\n localName: CDSDeleteResponseState\n trigger:\n name: CDSDeleteResponseEvent\n version: 0.0.1\n stateOutputs:\n entry:\n - key: ResponseOutput\n value:\n key:\n parentKeyName: CDSDeleteResponsePolicy\n parentKeyVersion: 0.0.1\n parentLocalName: CDSDeleteResponseState\n localName: ResponseOutput\n outgoingEvent:\n name: CDSResponseStatusEvent\n version: 0.0.1\n nextState:\n parentKeyName: 'NULL'\n parentKeyVersion: 0.0.0\n parentLocalName: 'NULL'\n localName: 'NULL'\n contextAlbumReference: []\n taskSelectionLogic:\n key: 'NULL'\n logicFlavour: UNDEFINED\n logic: ''\n stateFinalizerLogicMap:\n entry: []\n defaultTask:\n name: CDSDeleteResponseTask\n version: 0.0.1\n taskReferences:\n entry:\n - key:\n name: CDSDeleteResponseTask\n version: 0.0.1\n value:\n key:\n parentKeyName: CDSDeleteResponsePolicy\n parentKeyVersion: 0.0.1\n parentLocalName: CDSDeleteResponseState\n localName: CDSDeleteResponsePolicy\n outputType: DIRECT\n output:\n parentKeyName: CDSDeleteResponsePolicy\n parentKeyVersion: 0.0.1\n parentLocalName: CDSDeleteResponseState\n localName: ResponseOutput\n firstState: CDSDeleteResponseState\n - key:\n name: ReceiveEventPolicy\n version: 0.0.1\n value:\n policyKey:\n name: ReceiveEventPolicy\n version: 0.0.1\n template: Freestyle\n state:\n entry:\n - key: CreateOrDeleteState\n value:\n stateKey:\n parentKeyName: ReceiveEventPolicy\n parentKeyVersion: 0.0.1\n parentLocalName: 'NULL'\n localName: CreateOrDeleteState\n trigger:\n name: PMSubscriptionOutputEvent\n version: 0.0.1\n stateOutputs:\n entry:\n - key: CreateSubscriptionPayload\n value:\n key:\n parentKeyName: ReceiveEventPolicy\n parentKeyVersion: 0.0.1\n parentLocalName: CreateOrDeleteState\n localName: CreateSubscriptionPayload\n outgoingEvent:\n name: CreateSubscriptionPayloadEvent\n version: 0.0.1\n nextState:\n parentKeyName: ReceiveEventPolicy\n parentKeyVersion: 0.0.1\n parentLocalName: 'NULL'\n localName: CreateSubscription\n - key: DeleteSubscriptionPayload\n value:\n key:\n parentKeyName: ReceiveEventPolicy\n parentKeyVersion: 0.0.1\n parentLocalName: CreateOrDeleteState\n localName: DeleteSubscriptionPayload\n outgoingEvent:\n name: DeleteSubscriptionPayloadEvent\n version: 0.0.1\n nextState:\n parentKeyName: ReceiveEventPolicy\n parentKeyVersion: 0.0.1\n parentLocalName: 'NULL'\n localName: DeleteSubscription\n contextAlbumReference:\n - name: PMSubscriptionAlbum\n version: 0.0.1\n taskSelectionLogic:\n key: TaskSelectionLogic\n logicFlavour: JAVASCRIPT\n logic: |-\n /*\n * ============LICENSE_START=======================================================\n * Copyright (C) 2020 Nordix. All rights reserved.\n * ================================================================================\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n *\n * SPDX-License-Identifier: Apache-2.0\n * ============LICENSE_END=========================================================\n */\n\n executor.logger.info(executor.subject.id);\n\n var pmSubscriptionInfo = executor.getContextAlbum(\"PMSubscriptionAlbum\").get(executor.inFields.get(\"albumID\").toString())\n var changeType = pmSubscriptionInfo.get(\"changeType\").toString()\n\n executor.logger.info(\"Change Type is \" + changeType)\n\n if (\"CREATE\".equals(changeType)) {\n executor.logger.info(\"Choosing to create a subscription\")\n executor.subject.getTaskKey(\"CreateSubscriptionPayloadTask\").copyTo(executor.selectedTask);\n }\n else if (\"DELETE\".equals(changeType)) {\n executor.logger.info(\"Choosing to delete a subscription\")\n executor.subject.getTaskKey(\"DeleteSubscriptionPayloadTask\").copyTo(executor.selectedTask);\n }\n\n //var returnValue = executor.isTrue;\n true;\n stateFinalizerLogicMap:\n entry: []\n defaultTask:\n name: CreateSubscriptionPayloadTask\n version: 0.0.1\n taskReferences:\n entry:\n - key:\n name: CreateSubscriptionPayloadTask\n version: 0.0.1\n value:\n key:\n parentKeyName: ReceiveEventPolicy\n parentKeyVersion: 0.0.1\n parentLocalName: CreateOrDeleteState\n localName: ReceiveEventPolicy\n outputType: DIRECT\n output:\n parentKeyName: ReceiveEventPolicy\n parentKeyVersion: 0.0.1\n parentLocalName: CreateOrDeleteState\n localName: CreateSubscriptionPayload\n - key:\n name: DeleteSubscriptionPayloadTask\n version: 0.0.1\n value:\n key:\n parentKeyName: ReceiveEventPolicy\n parentKeyVersion: 0.0.1\n parentLocalName: CreateOrDeleteState\n localName: ReceiveEventPolicy\n outputType: DIRECT\n output:\n parentKeyName: ReceiveEventPolicy\n parentKeyVersion: 0.0.1\n parentLocalName: CreateOrDeleteState\n localName: DeleteSubscriptionPayload\n - key: CreateSubscription\n value:\n stateKey:\n parentKeyName: ReceiveEventPolicy\n parentKeyVersion: 0.0.1\n parentLocalName: 'NULL'\n localName: CreateSubscription\n trigger:\n name: CreateSubscriptionPayloadEvent\n version: 0.0.1\n stateOutputs:\n entry:\n - key: IssueCreateSubscriptionRequestOutput\n value:\n key:\n parentKeyName: ReceiveEventPolicy\n parentKeyVersion: 0.0.1\n parentLocalName: CreateSubscription\n localName: IssueCreateSubscriptionRequestOutput\n outgoingEvent:\n name: CDSCreateSubscriptionRequestEvent\n version: 0.0.1\n nextState:\n parentKeyName: 'NULL'\n parentKeyVersion: 0.0.0\n parentLocalName: 'NULL'\n localName: 'NULL'\n contextAlbumReference:\n - name: PMSubscriptionAlbum\n version: 0.0.1\n taskSelectionLogic:\n key: 'NULL'\n logicFlavour: UNDEFINED\n logic: ''\n stateFinalizerLogicMap:\n entry: []\n defaultTask:\n name: CreateSubscriptionRequestTask\n version: 0.0.1\n taskReferences:\n entry:\n - key:\n name: CreateSubscriptionRequestTask\n version: 0.0.1\n value:\n key:\n parentKeyName: ReceiveEventPolicy\n parentKeyVersion: 0.0.1\n parentLocalName: CreateSubscription\n localName: ReceiveEventPolicy\n outputType: DIRECT\n output:\n parentKeyName: ReceiveEventPolicy\n parentKeyVersion: 0.0.1\n parentLocalName: CreateSubscription\n localName: IssueCreateSubscriptionRequestOutput\n - key: DeleteSubscription\n value:\n stateKey:\n parentKeyName: ReceiveEventPolicy\n parentKeyVersion: 0.0.1\n parentLocalName: 'NULL'\n localName: DeleteSubscription\n trigger:\n name: DeleteSubscriptionPayloadEvent\n version: 0.0.1\n stateOutputs:\n entry:\n - key: IssueDeleteSubscriptionRequestOutput\n value:\n key:\n parentKeyName: ReceiveEventPolicy\n parentKeyVersion: 0.0.1\n parentLocalName: DeleteSubscription\n localName: IssueDeleteSubscriptionRequestOutput\n outgoingEvent:\n name: CDSDeleteSubscriptionRequestEvent\n version: 0.0.1\n nextState:\n parentKeyName: 'NULL'\n parentKeyVersion: 0.0.0\n parentLocalName: 'NULL'\n localName: 'NULL'\n contextAlbumReference:\n - name: PMSubscriptionAlbum\n version: 0.0.1\n taskSelectionLogic:\n key: 'NULL'\n logicFlavour: UNDEFINED\n logic: ''\n stateFinalizerLogicMap:\n entry: []\n defaultTask:\n name: DeleteSubscriptionRequestTask\n version: 0.0.1\n taskReferences:\n entry:\n - key:\n name: DeleteSubscriptionRequestTask\n version: 0.0.1\n value:\n key:\n parentKeyName: ReceiveEventPolicy\n parentKeyVersion: 0.0.1\n parentLocalName: DeleteSubscription\n localName: ReceiveEventPolicy\n outputType: DIRECT\n output:\n parentKeyName: ReceiveEventPolicy\n parentKeyVersion: 0.0.1\n parentLocalName: DeleteSubscription\n localName: IssueDeleteSubscriptionRequestOutput\n - key: ReceiveSubscriptionState\n value:\n stateKey:\n parentKeyName: ReceiveEventPolicy\n parentKeyVersion: 0.0.1\n parentLocalName: 'NULL'\n localName: ReceiveSubscriptionState\n trigger:\n name: pmsh-operational-policy\n version: 0.0.1\n stateOutputs:\n entry:\n - key: ReceivePMSubscriptionOutput\n value:\n key:\n parentKeyName: ReceiveEventPolicy\n parentKeyVersion: 0.0.1\n parentLocalName: ReceiveSubscriptionState\n localName: ReceivePMSubscriptionOutput\n outgoingEvent:\n name: PMSubscriptionOutputEvent\n version: 0.0.1\n nextState:\n parentKeyName: ReceiveEventPolicy\n parentKeyVersion: 0.0.1\n parentLocalName: 'NULL'\n localName: CreateOrDeleteState\n contextAlbumReference:\n - name: PMSubscriptionAlbum\n version: 0.0.1\n taskSelectionLogic:\n key: 'NULL'\n logicFlavour: UNDEFINED\n logic: ''\n stateFinalizerLogicMap:\n entry: []\n defaultTask:\n name: ReceiveSubscriptionTask\n version: 0.0.1\n taskReferences:\n entry:\n - key:\n name: ReceiveSubscriptionTask\n version: 0.0.1\n value:\n key:\n parentKeyName: ReceiveEventPolicy\n parentKeyVersion: 0.0.1\n parentLocalName: ReceiveSubscriptionState\n localName: ReceiveEventPolicy\n outputType: DIRECT\n output:\n parentKeyName: ReceiveEventPolicy\n parentKeyVersion: 0.0.1\n parentLocalName: ReceiveSubscriptionState\n localName: ReceivePMSubscriptionOutput\n firstState: ReceiveSubscriptionState\n tasks:\n key:\n name: PMControlPolicy_Tasks\n version: 0.0.1\n taskMap:\n entry:\n - key:\n name: CDSCreateResponseTask\n version: 0.0.1\n value:\n key:\n name: CDSCreateResponseTask\n version: 0.0.1\n inputFields:\n entry:\n - key: actionIdentifiers\n value:\n key: actionIdentifiers\n fieldSchemaKey:\n name: CDSActionIdentifiersType\n version: 0.0.1\n optional: false\n - key: commonHeader\n value:\n key: commonHeader\n fieldSchemaKey:\n name: CDSResponseCommonHeaderType\n version: 0.0.1\n optional: false\n - key: payload\n value:\n key: payload\n fieldSchemaKey:\n name: CDSCreateResponsePayloadType\n version: 0.0.1\n optional: false\n - key: status\n value:\n key: status\n fieldSchemaKey:\n name: CDSResponseStatusType\n version: 0.0.1\n optional: false\n outputFields:\n entry:\n - key: status\n value:\n key: status\n fieldSchemaKey:\n name: SubscriptionStatusType\n version: 0.0.1\n optional: false\n taskParameters:\n entry: []\n contextAlbumReference:\n - name: PMSubscriptionAlbum\n version: 0.0.1\n taskLogic:\n key: TaskLogic\n logicFlavour: JAVASCRIPT\n logic: |-\n /*\n * ============LICENSE_START=======================================================\n * Copyright (C) 2020 Nordix. All rights reserved.\n * ================================================================================\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n *\n * SPDX-License-Identifier: Apache-2.0\n * ============LICENSE_END=========================================================\n */\n\n executor.logger.info(executor.subject.id);\n\n var commonHeader = executor.inFields.get(\"commonHeader\")\n var response = executor.inFields.get(\"payload\")\n var albumID = commonHeader.get(\"requestId\")\n\n var pmSubscriptionInfo = executor.getContextAlbum(\"PMSubscriptionAlbum\").get(albumID.toString());\n var responseStatus = executor.subject.getOutFieldSchemaHelper(\"status\").createNewInstance();\n\n responseStatus.put(\"subscriptionName\", pmSubscriptionInfo.get(\"subscription\").get(\"subscriptionName\"))\n responseStatus.put(\"nfName\", pmSubscriptionInfo.get(\"nfName\"))\n responseStatus.put(\"changeType\", pmSubscriptionInfo.get(\"changeType\"))\n\n var status = response.get(pmSubscriptionInfo.get(\"changeType\").toLowerCase() + \"_DasH_subscription_DasH_response\").get(\"odl_DasH_response\").get(\"status\")\n\n executor.logger.info(\"RESPONSE STATUS = \" + status)\n\n if(status == \"success\") {\n responseStatus.put(\"message\", \"success\")\n } else {\n responseStatus.put(\"message\", \"failed\")\n }\n\n executor.outFields.put(\"status\", responseStatus)\n\n //var returnValue = executor.isTrue;\n true;\n - key:\n name: CDSDeleteResponseTask\n version: 0.0.1\n value:\n key:\n name: CDSDeleteResponseTask\n version: 0.0.1\n inputFields:\n entry:\n - key: actionIdentifiers\n value:\n key: actionIdentifiers\n fieldSchemaKey:\n name: CDSActionIdentifiersType\n version: 0.0.1\n optional: false\n - key: commonHeader\n value:\n key: commonHeader\n fieldSchemaKey:\n name: CDSResponseCommonHeaderType\n version: 0.0.1\n optional: false\n - key: payload\n value:\n key: payload\n fieldSchemaKey:\n name: CDSDeleteResponsePayloadType\n version: 0.0.1\n optional: false\n - key: status\n value:\n key: status\n fieldSchemaKey:\n name: CDSResponseStatusType\n version: 0.0.1\n optional: false\n outputFields:\n entry:\n - key: status\n value:\n key: status\n fieldSchemaKey:\n name: SubscriptionStatusType\n version: 0.0.1\n optional: false\n taskParameters:\n entry: []\n contextAlbumReference:\n - name: PMSubscriptionAlbum\n version: 0.0.1\n taskLogic:\n key: TaskLogic\n logicFlavour: JAVASCRIPT\n logic: |-\n /*\n * ============LICENSE_START=======================================================\n * Copyright (C) 2020 Nordix. All rights reserved.\n * ================================================================================\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n *\n * SPDX-License-Identifier: Apache-2.0\n * ============LICENSE_END=========================================================\n */\n\n executor.logger.info(executor.subject.id);\n\n var commonHeader = executor.inFields.get(\"commonHeader\")\n var response = executor.inFields.get(\"payload\")\n var albumID = commonHeader.get(\"requestId\")\n\n var pmSubscriptionInfo = executor.getContextAlbum(\"PMSubscriptionAlbum\").get(albumID.toString());\n var responseStatus = executor.subject.getOutFieldSchemaHelper(\"status\").createNewInstance();\n\n responseStatus.put(\"subscriptionName\", pmSubscriptionInfo.get(\"subscription\").get(\"subscriptionName\"))\n responseStatus.put(\"nfName\", pmSubscriptionInfo.get(\"nfName\"))\n responseStatus.put(\"changeType\", pmSubscriptionInfo.get(\"changeType\"))\n\n var status = response.get(pmSubscriptionInfo.get(\"changeType\").toLowerCase() + \"_DasH_subscription_DasH_response\").get(\"odl_DasH_response\").get(\"status\")\n\n executor.logger.info(\"RESPONSE STATUS = \" + status)\n\n if(status == \"success\") {\n responseStatus.put(\"message\", \"success\")\n } else {\n responseStatus.put(\"message\", \"failed\")\n }\n\n executor.outFields.put(\"status\", responseStatus)\n\n //var returnValue = executor.isTrue;\n true;\n - key:\n name: CreateSubscriptionPayloadTask\n version: 0.0.1\n value:\n key:\n name: CreateSubscriptionPayloadTask\n version: 0.0.1\n inputFields:\n entry:\n - key: albumID\n value:\n key: albumID\n fieldSchemaKey:\n name: UUIDType\n version: 0.0.1\n optional: false\n outputFields:\n entry:\n - key: albumID\n value:\n key: albumID\n fieldSchemaKey:\n name: UUIDType\n version: 0.0.1\n optional: false\n - key: payload\n value:\n key: payload\n fieldSchemaKey:\n name: CDSCreateSubscriptionPayloadType\n version: 0.0.1\n optional: false\n taskParameters:\n entry: []\n contextAlbumReference:\n - name: PMSubscriptionAlbum\n version: 0.0.1\n taskLogic:\n key: TaskLogic\n logicFlavour: JAVASCRIPT\n logic: |-\n /*\n * ============LICENSE_START=======================================================\n * Copyright (C) 2020 Nordix. All rights reserved.\n * ================================================================================\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n *\n * SPDX-License-Identifier: Apache-2.0\n * ============LICENSE_END=========================================================\n */\n\n executor.logger.info(executor.subject.id);\n\n var pmSubscriptionInfo = executor.getContextAlbum(\"PMSubscriptionAlbum\").get(executor.inFields.get(\"albumID\").toString())\n\n var changeType = pmSubscriptionInfo.get(\"changeType\").toLowerCase()\n\n var payloadProperties = executor.subject.getOutFieldSchemaHelper(\"payload\").createNewSubInstance(changeType + \"_DasH_subscription_DasH_properties_record\");\n\n payloadProperties.put(\"nfName\", pmSubscriptionInfo.get(\"nfName\"))\n payloadProperties.put(\"subscriptionName\", pmSubscriptionInfo.get(\"subscription\").get(\"subscriptionName\"))\n payloadProperties.put(\"administrativeState\", pmSubscriptionInfo.get(\"subscription\").get(\"administrativeState\"))\n payloadProperties.put(\"fileBasedGP\", pmSubscriptionInfo.get(\"subscription\").get(\"fileBasedGP\").toString())\n payloadProperties.put(\"fileLocation\", pmSubscriptionInfo.get(\"subscription\").get(\"fileLocation\"))\n payloadProperties.put(\"measurementGroups\", pmSubscriptionInfo.get(\"subscription\").get(\"measurementGroups\"))\n\n var payloadEntry = executor.subject.getOutFieldSchemaHelper(\"payload\").createNewSubInstance(\"CDSRequestPayloadEntry\");\n payloadEntry.put(changeType + \"_DasH_subscription_DasH_properties\", payloadProperties)\n\n var payload = executor.subject.getOutFieldSchemaHelper(\"payload\").createNewInstance();\n payload.put(changeType + \"_DasH_subscription_DasH_request\", payloadEntry);\n\n executor.outFields.put(\"albumID\", executor.inFields.get(\"albumID\"))\n executor.outFields.put(\"payload\", payload);\n\n //var returnValue = executor.isTrue;\n true;\n - key:\n name: CreateSubscriptionRequestTask\n version: 0.0.1\n value:\n key:\n name: CreateSubscriptionRequestTask\n version: 0.0.1\n inputFields:\n entry:\n - key: albumID\n value:\n key: albumID\n fieldSchemaKey:\n name: UUIDType\n version: 0.0.1\n optional: false\n - key: payload\n value:\n key: payload\n fieldSchemaKey:\n name: CDSCreateSubscriptionPayloadType\n version: 0.0.1\n optional: false\n outputFields:\n entry:\n - key: actionIdentifiers\n value:\n key: actionIdentifiers\n fieldSchemaKey:\n name: CDSActionIdentifiersType\n version: 0.0.1\n optional: false\n - key: commonHeader\n value:\n key: commonHeader\n fieldSchemaKey:\n name: CDSRequestCommonHeaderType\n version: 0.0.1\n optional: false\n - key: payload\n value:\n key: payload\n fieldSchemaKey:\n name: CDSCreateSubscriptionPayloadType\n version: 0.0.1\n optional: false\n taskParameters:\n entry: []\n contextAlbumReference:\n - name: PMSubscriptionAlbum\n version: 0.0.1\n taskLogic:\n key: TaskLogic\n logicFlavour: JAVASCRIPT\n logic: |-\n /*\n * ============LICENSE_START=======================================================\n * Copyright (C) 2020 Nordix. All rights reserved.\n * ================================================================================\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n *\n * SPDX-License-Identifier: Apache-2.0\n * ============LICENSE_END=========================================================\n */\n\n executor.logger.info(executor.subject.id);\n\n var pmSubscriptionInfo = executor.getContextAlbum(\"PMSubscriptionAlbum\").get(executor.inFields.get(\"albumID\").toString())\n\n var changeType = pmSubscriptionInfo.get(\"changeType\").toLowerCase()\n var blueprintName = pmSubscriptionInfo.get(\"blueprintName\").toLowerCase()\n var blueprintVersion = pmSubscriptionInfo.get(\"blueprintVersion\").toLowerCase()\n var payload = executor.inFields.get(\"payload\")\n var actionName = changeType + \"-subscription\"\n\n var commonHeader = executor.subject.getOutFieldSchemaHelper(\"commonHeader\").createNewInstance();\n commonHeader.put(\"originatorId\", \"sdnc\");\n commonHeader.put(\"requestId\", executor.inFields.get(\"albumID\").toString());\n commonHeader.put(\"subRequestId\", \"sub-123456-1000\");\n\n var actionIdentifiers = executor.subject.getOutFieldSchemaHelper(\"actionIdentifiers\").createNewInstance();\n actionIdentifiers.put(\"actionName\", actionName);\n actionIdentifiers.put(\"blueprintName\", blueprintName);\n actionIdentifiers.put(\"blueprintVersion\", blueprintVersion);\n actionIdentifiers.put(\"mode\", \"sync\");\n\n executor.outFields.put(\"commonHeader\", commonHeader);\n executor.outFields.put(\"actionIdentifiers\", actionIdentifiers);\n executor.outFields.put(\"payload\", payload);\n\n //var returnValue = executor.isTrue;\n true;\n - key:\n name: DeleteSubscriptionPayloadTask\n version: 0.0.1\n value:\n key:\n name: DeleteSubscriptionPayloadTask\n version: 0.0.1\n inputFields:\n entry:\n - key: albumID\n value:\n key: albumID\n fieldSchemaKey:\n name: UUIDType\n version: 0.0.1\n optional: false\n outputFields:\n entry:\n - key: albumID\n value:\n key: albumID\n fieldSchemaKey:\n name: UUIDType\n version: 0.0.1\n optional: false\n - key: payload\n value:\n key: payload\n fieldSchemaKey:\n name: CDSDeleteSubscriptionPayloadType\n version: 0.0.1\n optional: false\n taskParameters:\n entry: []\n contextAlbumReference:\n - name: PMSubscriptionAlbum\n version: 0.0.1\n taskLogic:\n key: TaskLogic\n logicFlavour: JAVASCRIPT\n logic: |-\n /*\n * ============LICENSE_START=======================================================\n * Copyright (C) 2020 Nordix. All rights reserved.\n * ================================================================================\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n *\n * SPDX-License-Identifier: Apache-2.0\n * ============LICENSE_END=========================================================\n */\n\n executor.logger.info(executor.subject.id);\n\n var pmSubscriptionInfo = executor.getContextAlbum(\"PMSubscriptionAlbum\").get(executor.inFields.get(\"albumID\").toString())\n\n var changeType = pmSubscriptionInfo.get(\"changeType\").toLowerCase()\n\n var payloadProperties = executor.subject.getOutFieldSchemaHelper(\"payload\").createNewSubInstance(changeType + \"_DasH_subscription_DasH_properties_record\");\n\n payloadProperties.put(\"nfName\", pmSubscriptionInfo.get(\"nfName\"))\n payloadProperties.put(\"subscriptionName\", pmSubscriptionInfo.get(\"subscription\").get(\"subscriptionName\"))\n payloadProperties.put(\"administrativeState\", pmSubscriptionInfo.get(\"subscription\").get(\"administrativeState\"))\n payloadProperties.put(\"fileBasedGP\", pmSubscriptionInfo.get(\"subscription\").get(\"fileBasedGP\").toString())\n payloadProperties.put(\"fileLocation\", pmSubscriptionInfo.get(\"subscription\").get(\"fileLocation\"))\n payloadProperties.put(\"measurementGroups\", pmSubscriptionInfo.get(\"subscription\").get(\"measurementGroups\"))\n\n var payloadEntry = executor.subject.getOutFieldSchemaHelper(\"payload\").createNewSubInstance(\"CDSRequestPayloadEntry\");\n payloadEntry.put(changeType + \"_DasH_subscription_DasH_properties\", payloadProperties)\n\n var payload = executor.subject.getOutFieldSchemaHelper(\"payload\").createNewInstance();\n payload.put(changeType + \"_DasH_subscription_DasH_request\", payloadEntry);\n\n executor.outFields.put(\"albumID\", executor.inFields.get(\"albumID\"))\n executor.outFields.put(\"payload\", payload);\n\n //var returnValue = executor.isTrue;\n true;\n - key:\n name: DeleteSubscriptionRequestTask\n version: 0.0.1\n value:\n key:\n name: DeleteSubscriptionRequestTask\n version: 0.0.1\n inputFields:\n entry:\n - key: albumID\n value:\n key: albumID\n fieldSchemaKey:\n name: UUIDType\n version: 0.0.1\n optional: false\n - key: payload\n value:\n key: payload\n fieldSchemaKey:\n name: CDSDeleteSubscriptionPayloadType\n version: 0.0.1\n optional: false\n outputFields:\n entry:\n - key: actionIdentifiers\n value:\n key: actionIdentifiers\n fieldSchemaKey:\n name: CDSActionIdentifiersType\n version: 0.0.1\n optional: false\n - key: commonHeader\n value:\n key: commonHeader\n fieldSchemaKey:\n name: CDSRequestCommonHeaderType\n version: 0.0.1\n optional: false\n - key: payload\n value:\n key: payload\n fieldSchemaKey:\n name: CDSDeleteSubscriptionPayloadType\n version: 0.0.1\n optional: false\n taskParameters:\n entry: []\n contextAlbumReference:\n - name: PMSubscriptionAlbum\n version: 0.0.1\n taskLogic:\n key: TaskLogic\n logicFlavour: JAVASCRIPT\n logic: |-\n /*\n * ============LICENSE_START=======================================================\n * Copyright (C) 2020 Nordix. All rights reserved.\n * ================================================================================\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n *\n * SPDX-License-Identifier: Apache-2.0\n * ============LICENSE_END=========================================================\n */\n\n executor.logger.info(executor.subject.id);\n\n var pmSubscriptionInfo = executor.getContextAlbum(\"PMSubscriptionAlbum\").get(executor.inFields.get(\"albumID\").toString())\n\n var changeType = pmSubscriptionInfo.get(\"changeType\").toLowerCase()\n var blueprintName = pmSubscriptionInfo.get(\"blueprintName\").toLowerCase()\n var blueprintVersion = pmSubscriptionInfo.get(\"blueprintVersion\").toLowerCase()\n var payload = executor.inFields.get(\"payload\")\n var actionName = changeType + \"-subscription\"\n\n var commonHeader = executor.subject.getOutFieldSchemaHelper(\"commonHeader\").createNewInstance();\n commonHeader.put(\"originatorId\", \"sdnc\");\n commonHeader.put(\"requestId\", executor.inFields.get(\"albumID\").toString());\n commonHeader.put(\"subRequestId\", \"sub-123456-1000\");\n\n var actionIdentifiers = executor.subject.getOutFieldSchemaHelper(\"actionIdentifiers\").createNewInstance();\n actionIdentifiers.put(\"actionName\", actionName);\n actionIdentifiers.put(\"blueprintName\", blueprintName);\n actionIdentifiers.put(\"blueprintVersion\", blueprintVersion);\n actionIdentifiers.put(\"mode\", \"sync\");\n\n executor.outFields.put(\"commonHeader\", commonHeader);\n executor.outFields.put(\"actionIdentifiers\", actionIdentifiers);\n executor.outFields.put(\"payload\", payload);\n\n //var returnValue = executor.isTrue;\n true;\n - key:\n name: ReceiveSubscriptionTask\n version: 0.0.1\n value:\n key:\n name: ReceiveSubscriptionTask\n version: 0.0.1\n inputFields:\n entry:\n - key: blueprintName\n value:\n key: blueprintName\n fieldSchemaKey:\n name: SimpleStringType\n version: 0.0.1\n optional: false\n - key: blueprintVersion\n value:\n key: blueprintVersion\n fieldSchemaKey:\n name: SimpleStringType\n version: 0.0.1\n optional: false\n - key: changeType\n value:\n key: changeType\n fieldSchemaKey:\n name: SimpleStringType\n version: 0.0.1\n optional: false\n - key: closedLoopControlName\n value:\n key: closedLoopControlName\n fieldSchemaKey:\n name: SimpleStringType\n version: 0.0.1\n optional: false\n - key: nfName\n value:\n key: nfName\n fieldSchemaKey:\n name: SimpleStringType\n version: 0.0.1\n optional: false\n - key: policyName\n value:\n key: policyName\n fieldSchemaKey:\n name: SimpleStringType\n version: 0.0.1\n optional: false\n - key: subscription\n value:\n key: subscription\n fieldSchemaKey:\n name: SubscriptionType\n version: 0.0.1\n optional: false\n outputFields:\n entry:\n - key: albumID\n value:\n key: albumID\n fieldSchemaKey:\n name: UUIDType\n version: 0.0.1\n optional: false\n taskParameters:\n entry: []\n contextAlbumReference:\n - name: PMSubscriptionAlbum\n version: 0.0.1\n taskLogic:\n key: TaskLogic\n logicFlavour: JAVASCRIPT\n logic: |-\n /*\n * ============LICENSE_START=======================================================\n * Copyright (C) 2020 Nordix. All rights reserved.\n * ================================================================================\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n *\n * SPDX-License-Identifier: Apache-2.0\n * ============LICENSE_END=========================================================\n */\n var uuidType = java.util.UUID;\n\n executor.logger.info(executor.subject.id);\n\n //albumID will be used to fetch info from our album later\n var albumID = uuidType.randomUUID();\n var pmSubscriptionInfo = executor.getContextAlbum(\"PMSubscriptionAlbum\").getSchemaHelper().createNewInstance();\n var returnValue = true;\n\n if(executor.inFields.get(\"policyName\") != null) {\n executor.logger.info(\"nfName in receive sub event \" + executor.inFields.get(\"nfName\"));\n\n var changeType = executor.inFields.get(\"changeType\")\n var nfName = executor.inFields.get(\"nfName\")\n var policyName = executor.inFields.get(\"policyName\")\n var closedLoopControlName = executor.inFields.get(\"closedLoopControlName\")\n var subscription = executor.inFields.get(\"subscription\")\n var blueprintName = executor.inFields.get(\"blueprintName\")\n var blueprintVersion = executor.inFields.get(\"blueprintVersion\")\n\n pmSubscriptionInfo.put(\"nfName\", executor.inFields.get(\"nfName\"));\n pmSubscriptionInfo.put(\"changeType\", executor.inFields.get(\"changeType\"))\n pmSubscriptionInfo.put(\"policyName\", executor.inFields.get(\"policyName\"))\n pmSubscriptionInfo.put(\"closedLoopControlName\", executor.inFields.get(\"closedLoopControlName\"))\n pmSubscriptionInfo.put(\"subscription\", subscription)\n pmSubscriptionInfo.put(\"blueprintName\", blueprintName)\n pmSubscriptionInfo.put(\"blueprintVersion\", blueprintVersion)\n\n\n executor.getContextAlbum(\"PMSubscriptionAlbum\").put(albumID.toString(), pmSubscriptionInfo);\n\n executor.outFields.put(\"albumID\", albumID)\n } else {\n executor.message = \"Received invalid event\"\n returnValue = false;\n }\n\n returnValue;\n events:\n key:\n name: PMControlPolicy_Events\n version: 0.0.1\n eventMap:\n entry:\n - key:\n name: CDSCreateResponseEvent\n version: 0.0.1\n value:\n key:\n name: CDSCreateResponseEvent\n version: 0.0.1\n nameSpace: org.onap.policy.apex.onap.pmcontrol\n source: CDS\n target: APEX\n parameter:\n entry:\n - key: actionIdentifiers\n value:\n key: actionIdentifiers\n fieldSchemaKey:\n name: CDSActionIdentifiersType\n version: 0.0.1\n optional: false\n - key: commonHeader\n value:\n key: commonHeader\n fieldSchemaKey:\n name: CDSResponseCommonHeaderType\n version: 0.0.1\n optional: false\n - key: payload\n value:\n key: payload\n fieldSchemaKey:\n name: CDSCreateResponsePayloadType\n version: 0.0.1\n optional: false\n - key: status\n value:\n key: status\n fieldSchemaKey:\n name: CDSResponseStatusType\n version: 0.0.1\n optional: false\n - key:\n name: CDSCreateSubscriptionRequestEvent\n version: 0.0.1\n value:\n key:\n name: CDSCreateSubscriptionRequestEvent\n version: 0.0.1\n nameSpace: org.onap.policy.apex.onap.pmcontrol\n source: APEX\n target: APEX\n parameter:\n entry:\n - key: actionIdentifiers\n value:\n key: actionIdentifiers\n fieldSchemaKey:\n name: CDSActionIdentifiersType\n version: 0.0.1\n optional: false\n - key: commonHeader\n value:\n key: commonHeader\n fieldSchemaKey:\n name: CDSRequestCommonHeaderType\n version: 0.0.1\n optional: false\n - key: payload\n value:\n key: payload\n fieldSchemaKey:\n name: CDSCreateSubscriptionPayloadType\n version: 0.0.1\n optional: false\n - key:\n name: CDSDeleteResponseEvent\n version: 0.0.1\n value:\n key:\n name: CDSDeleteResponseEvent\n version: 0.0.1\n nameSpace: org.onap.policy.apex.onap.pmcontrol\n source: CDS\n target: APEX\n parameter:\n entry:\n - key: actionIdentifiers\n value:\n key: actionIdentifiers\n fieldSchemaKey:\n name: CDSActionIdentifiersType\n version: 0.0.1\n optional: false\n - key: commonHeader\n value:\n key: commonHeader\n fieldSchemaKey:\n name: CDSResponseCommonHeaderType\n version: 0.0.1\n optional: false\n - key: payload\n value:\n key: payload\n fieldSchemaKey:\n name: CDSDeleteResponsePayloadType\n version: 0.0.1\n optional: false\n - key: status\n value:\n key: status\n fieldSchemaKey:\n name: CDSResponseStatusType\n version: 0.0.1\n optional: false\n - key:\n name: CDSDeleteSubscriptionRequestEvent\n version: 0.0.1\n value:\n key:\n name: CDSDeleteSubscriptionRequestEvent\n version: 0.0.1\n nameSpace: org.onap.policy.apex.onap.pmcontrol\n source: APEX\n target: APEX\n parameter:\n entry:\n - key: actionIdentifiers\n value:\n key: actionIdentifiers\n fieldSchemaKey:\n name: CDSActionIdentifiersType\n version: 0.0.1\n optional: false\n - key: commonHeader\n value:\n key: commonHeader\n fieldSchemaKey:\n name: CDSRequestCommonHeaderType\n version: 0.0.1\n optional: false\n - key: payload\n value:\n key: payload\n fieldSchemaKey:\n name: CDSDeleteSubscriptionPayloadType\n version: 0.0.1\n optional: false\n - key:\n name: CDSResponseStatusEvent\n version: 0.0.1\n value:\n key:\n name: CDSResponseStatusEvent\n version: 0.0.1\n nameSpace: org.onap.policy.apex.onap.pmcontrol\n source: APEX\n target: DCAE\n parameter:\n entry:\n - key: status\n value:\n key: status\n fieldSchemaKey:\n name: SubscriptionStatusType\n version: 0.0.1\n optional: false\n - key:\n name: CreateSubscriptionPayloadEvent\n version: 0.0.1\n value:\n key:\n name: CreateSubscriptionPayloadEvent\n version: 0.0.1\n nameSpace: org.onap.policy.apex.onap.pmcontrol\n source: APEX\n target: APEX\n parameter:\n entry:\n - key: albumID\n value:\n key: albumID\n fieldSchemaKey:\n name: UUIDType\n version: 0.0.1\n optional: false\n - key: payload\n value:\n key: payload\n fieldSchemaKey:\n name: CDSCreateSubscriptionPayloadType\n version: 0.0.1\n optional: false\n - key:\n name: DeleteSubscriptionPayloadEvent\n version: 0.0.1\n value:\n key:\n name: DeleteSubscriptionPayloadEvent\n version: 0.0.1\n nameSpace: org.onap.policy.apex.onap.pmcontrol\n source: APEX\n target: APEX\n parameter:\n entry:\n - key: albumID\n value:\n key: albumID\n fieldSchemaKey:\n name: UUIDType\n version: 0.0.1\n optional: false\n - key: payload\n value:\n key: payload\n fieldSchemaKey:\n name: CDSDeleteSubscriptionPayloadType\n version: 0.0.1\n optional: false\n - key:\n name: MRResponseEvent\n version: 0.0.1\n value:\n key:\n name: MRResponseEvent\n version: 0.0.1\n nameSpace: org.onap.policy.apex.onap.pmcontrol\n source: DCAE\n target: APEX\n parameter:\n entry:\n - key: count\n value:\n key: count\n fieldSchemaKey:\n name: SimpleIntType\n version: 0.0.1\n optional: false\n - key: serverTimeMs\n value:\n key: serverTimeMs\n fieldSchemaKey:\n name: SimpleIntType\n version: 0.0.1\n optional: false\n - key:\n name: PMSubscriptionOutputEvent\n version: 0.0.1\n value:\n key:\n name: PMSubscriptionOutputEvent\n version: 0.0.1\n nameSpace: org.onap.policy.apex.onap.pmcontrol\n source: APEX\n target: APEX\n parameter:\n entry:\n - key: albumID\n value:\n key: albumID\n fieldSchemaKey:\n name: UUIDType\n version: 0.0.1\n optional: false\n - key:\n name: pmsh-operational-policy\n version: 0.0.1\n value:\n key:\n name: pmsh-operational-policy\n version: 0.0.1\n nameSpace: org.onap.policy.apex.onap.pmcontrol\n source: DCAE\n target: APEX\n parameter:\n entry:\n - key: blueprintName\n value:\n key: blueprintName\n fieldSchemaKey:\n name: SimpleStringType\n version: 0.0.1\n optional: false\n - key: blueprintVersion\n value:\n key: blueprintVersion\n fieldSchemaKey:\n name: SimpleStringType\n version: 0.0.1\n optional: false\n - key: changeType\n value:\n key: changeType\n fieldSchemaKey:\n name: SimpleStringType\n version: 0.0.1\n optional: false\n - key: closedLoopControlName\n value:\n key: closedLoopControlName\n fieldSchemaKey:\n name: SimpleStringType\n version: 0.0.1\n optional: false\n - key: nfName\n value:\n key: nfName\n fieldSchemaKey:\n name: SimpleStringType\n version: 0.0.1\n optional: false\n - key: policyName\n value:\n key: policyName\n fieldSchemaKey:\n name: SimpleStringType\n version: 0.0.1\n optional: false\n - key: subscription\n value:\n key: subscription\n fieldSchemaKey:\n name: SubscriptionType\n version: 0.0.1\n optional: false\n albums:\n key:\n name: PMControlPolicy_Albums\n version: 0.0.1\n albums:\n entry:\n - key:\n name: PMSubscriptionAlbum\n version: 0.0.1\n value:\n key:\n name: PMSubscriptionAlbum\n version: 0.0.1\n scope: policy\n isWritable: true\n itemSchema:\n name: PMSubscriptionType\n version: 0.0.1\n schemas:\n key:\n name: PMControlPolicy_Schemas\n version: 0.0.1\n schemas:\n entry:\n - key:\n name: CDSActionIdentifiersType\n version: 0.0.1\n value:\n key:\n name: CDSActionIdentifiersType\n version: 0.0.1\n schemaFlavour: Avro\n schemaDefinition: |-\n {\n \"type\": \"record\",\n \"name\": \"ActionIdentifiers_Type\",\n \"namespace\": \"org.onap.policy.apex.onap.helloworld\",\n \"fields\": [\n {\n \"name\": \"actionName\",\n \"type\": \"string\"\n },\n {\n \"name\": \"blueprintName\",\n \"type\": \"string\"\n },\n {\n \"name\": \"blueprintVersion\",\n \"type\": \"string\"\n },\n {\n \"name\": \"mode\",\n \"type\": \"string\"\n }\n ]\n }\n - key:\n name: CDSCreateResponsePayloadType\n version: 0.0.1\n value:\n key:\n name: CDSCreateResponsePayloadType\n version: 0.0.1\n schemaFlavour: Avro\n schemaDefinition: |-\n {\n \"name\": \"CreateResponsePayloadEntry\",\n \"type\": \"record\",\n \"namespace\": \"org.onap.policy.apex.onap.helloworld\",\n \"fields\": [\n {\n \"name\": \"create_DasH_subscription_DasH_response\",\n \"type\": {\n \"name\": \"create_DasH_subscription_DasH_response\",\n \"type\": \"record\",\n \"fields\": [\n {\n \"name\": \"odl_DasH_response\",\n \"type\": {\n \"name\": \"odl_DasH_response\",\n \"type\": \"record\",\n \"fields\": [\n {\n \"name\": \"status\",\n \"type\": \"string\"\n }\n ]\n }\n }\n ]\n }\n }\n ]\n }\n - key:\n name: CDSCreateSubscriptionPayloadType\n version: 0.0.1\n value:\n key:\n name: CDSCreateSubscriptionPayloadType\n version: 0.0.1\n schemaFlavour: Avro\n schemaDefinition: |-\n {\n \"type\": \"map\",\n \"values\": {\n \"type\": \"record\",\n \"name\": \"CDSRequestPayloadEntry\",\n \"fields\": [\n {\n \"name\": \"create_DasH_subscription_DasH_properties\",\n \"type\": {\n \"name\": \"create_DasH_subscription_DasH_properties_record\",\n \"type\": \"record\",\n \"fields\": [\n {\n \"name\": \"nfName\",\n \"type\": \"string\"\n },\n {\n \"name\": \"subscriptionName\",\n \"type\": \"string\"\n },\n {\n \"name\": \"administrativeState\",\n \"type\": \"string\"\n },\n {\n \"name\": \"fileBasedGP\",\n \"type\": \"string\"\n },\n {\n \"name\": \"fileLocation\",\n \"type\": \"string\"\n },\n {\n \"name\": \"measurementGroups\",\n \"type\": {\n \"type\": \"array\",\n \"items\": {\n \"name\": \"measurementGroups_record\",\n \"type\": \"record\",\n \"fields\": [\n {\n \"name\": \"measurementGroup\",\n \"type\": {\n \"name\": \"measurementGroup\",\n \"type\": \"record\",\n \"fields\": [\n {\n \"name\": \"measurementTypes\",\n \"type\": {\n \"type\": \"array\",\n \"items\": {\n \"name\": \"measurementTypes_record\",\n \"type\": \"record\",\n \"fields\": [\n {\n \"name\": \"measurementType\",\n \"type\": \"string\"\n }\n ]\n }\n }\n },\n {\n \"name\": \"managedObjectDNsBasic\",\n \"type\": {\n \"type\": \"array\",\n \"items\": {\n \"name\": \"managedObjectDNsBasic_record\",\n \"type\": \"record\",\n \"fields\": [\n {\n \"name\": \"DN\",\n \"type\": \"string\"\n }\n ]\n }\n }\n }\n ]\n }\n }\n ]\n }\n }\n }\n ]\n }\n }\n ]\n }\n }\n - key:\n name: CDSDeleteResponsePayloadType\n version: 0.0.1\n value:\n key:\n name: CDSDeleteResponsePayloadType\n version: 0.0.1\n schemaFlavour: Avro\n schemaDefinition: |-\n {\n \"name\": \"DeleteResponsePayloadEntry\",\n \"type\": \"record\",\n \"namespace\": \"com.acme.avro\",\n \"fields\": [\n {\n \"name\": \"delete_DasH_subscription_DasH_response\",\n \"type\": {\n \"name\": \"delete_DasH_subscription_DasH_response\",\n \"type\": \"record\",\n \"fields\": [\n {\n \"name\": \"odl_DasH_response\",\n \"type\": {\n \"name\": \"odl_DasH_response\",\n \"type\": \"record\",\n \"fields\": [\n {\n \"name\": \"status\",\n \"type\": \"string\"\n }\n ]\n }\n }\n ]\n }\n }\n ]\n }\n - key:\n name: CDSDeleteSubscriptionPayloadType\n version: 0.0.1\n value:\n key:\n name: CDSDeleteSubscriptionPayloadType\n version: 0.0.1\n schemaFlavour: Avro\n schemaDefinition: |-\n {\n \"type\": \"map\",\n \"values\": {\n \"type\": \"record\",\n \"name\": \"CDSRequestPayloadEntry\",\n \"fields\": [\n {\n \"name\": \"delete_DasH_subscription_DasH_properties\",\n \"type\": {\n \"name\": \"delete_DasH_subscription_DasH_properties_record\",\n \"type\": \"record\",\n \"fields\": [\n {\n \"name\": \"nfName\",\n \"type\": \"string\"\n },\n {\n \"name\": \"subscriptionName\",\n \"type\": \"string\"\n },\n {\n \"name\": \"administrativeState\",\n \"type\": \"string\"\n },\n {\n \"name\": \"fileBasedGP\",\n \"type\": \"string\"\n },\n {\n \"name\": \"fileLocation\",\n \"type\": \"string\"\n },\n {\n \"name\": \"measurementGroups\",\n \"type\": {\n \"type\": \"array\",\n \"items\": {\n \"name\": \"measurementGroups_record\",\n \"type\": \"record\",\n \"fields\": [\n {\n \"name\": \"measurementGroup\",\n \"type\": {\n \"name\": \"measurementGroup\",\n \"type\": \"record\",\n \"fields\": [\n {\n \"name\": \"measurementTypes\",\n \"type\": {\n \"type\": \"array\",\n \"items\": {\n \"name\": \"measurementTypes_record\",\n \"type\": \"record\",\n \"fields\": [\n {\n \"name\": \"measurementType\",\n \"type\": \"string\"\n }\n ]\n }\n }\n },\n {\n \"name\": \"managedObjectDNsBasic\",\n \"type\": {\n \"type\": \"array\",\n \"items\": {\n \"name\": \"managedObjectDNsBasic_record\",\n \"type\": \"record\",\n \"fields\": [\n {\n \"name\": \"DN\",\n \"type\": \"string\"\n }\n ]\n }\n }\n }\n ]\n }\n }\n ]\n }\n }\n }\n ]\n }\n }\n ]\n }\n }\n - key:\n name: CDSRequestCommonHeaderType\n version: 0.0.1\n value:\n key:\n name: CDSRequestCommonHeaderType\n version: 0.0.1\n schemaFlavour: Avro\n schemaDefinition: |-\n {\n \"type\": \"record\",\n \"name\": \"RequestCommonHeader_Type\",\n \"namespace\": \"org.onap.policy.apex.onap.helloworld\",\n \"fields\": [\n {\n \"name\": \"originatorId\",\n \"type\": \"string\"\n },\n {\n \"name\": \"requestId\",\n \"type\": \"string\"\n },\n {\n \"name\": \"subRequestId\",\n \"type\": \"string\"\n }\n ]\n }\n - key:\n name: CDSResponseCommonHeaderType\n version: 0.0.1\n value:\n key:\n name: CDSResponseCommonHeaderType\n version: 0.0.1\n schemaFlavour: Avro\n schemaDefinition: |-\n {\n \"type\": \"record\",\n \"name\": \"ResponseCommonHeader_Type\",\n \"namespace\": \"org.onap.policy.apex.onap.helloworld\",\n \"fields\": [\n {\n \"name\": \"originatorId\",\n \"type\": \"string\"\n },\n {\n \"name\": \"requestId\",\n \"type\": \"string\"\n },\n {\n \"name\": \"subRequestId\",\n \"type\": \"string\"\n },\n {\n \"name\": \"timestamp\",\n \"type\": \"string\"\n },\n {\n \"name\": \"flags\",\n \"type\": [\"null\", \"string\"]\n }\n ]\n }\n - key:\n name: CDSResponseStatusType\n version: 0.0.1\n value:\n key:\n name: CDSResponseStatusType\n version: 0.0.1\n schemaFlavour: Avro\n schemaDefinition: |-\n {\n \"type\": \"record\",\n \"name\": \"ResponseStatus_Type\",\n \"namespace\": \"org.onap.policy.apex.onap.helloworld\",\n \"fields\": [\n {\n \"name\": \"code\",\n \"type\": \"int\"\n },\n {\n \"name\": \"eventType\",\n \"type\": \"string\"\n },\n {\n \"name\": \"timestamp\",\n \"type\": \"string\"\n },\n {\n \"name\": \"message\",\n \"type\": \"string\"\n }\n ]\n }\n - key:\n name: PMSubscriptionType\n version: 0.0.1\n value:\n key:\n name: PMSubscriptionType\n version: 0.0.1\n schemaFlavour: Avro\n schemaDefinition: \"{\\n\\t\\\"name\\\": \\\"PMSubscription\\\",\\n\\t\\\"type\\\": \\\"record\\\",\\n\\t\\\"namespace\\\": \\\"\\\n org.onap.policy.apex.onap.pmcontrol\\\",\\n\\t\\\"fields\\\": [\\n {\\n \\\"name\\\": \\\"nfName\\\"\\\n ,\\n \\\"type\\\": \\\"string\\\"\\n },\\n\\t {\\n\\t\\t\\t\\\"name\\\": \\\"changeType\\\",\\n\\t\\t\\t\\\"\\\n type\\\": \\\"string\\\"\\n\\t\\t},\\n\\t\\t{\\n\\t\\t\\t\\\"name\\\": \\\"closedLoopControlName\\\",\\n\\t\\t\\t\\\"type\\\": \\\"\\\n string\\\"\\n\\t\\t},\\n\\t\\t{\\n\\t\\t\\t\\\"name\\\": \\\"policyName\\\",\\n\\t\\t\\t\\\"type\\\": \\\"string\\\"\\n\\t\\t},\\n\\t\\t\\\n {\\n\\t\\t \\\"name\\\": \\\"blueprintName\\\",\\n\\t\\t \\\"type\\\": \\\"string\\\"\\n\\t\\t},\\n\\t\\t{\\n\\t\\t \\\"name\\\"\\\n : \\\"blueprintVersion\\\",\\n\\t\\t \\\"type\\\": \\\"string\\\"\\n\\t\\t},\\n\\t\\t{\\n\\t\\t\\t\\\"name\\\": \\\"subscription\\\"\\\n ,\\n\\t\\t\\t\\\"type\\\": {\\n\\t\\t\\t\\t\\\"name\\\": \\\"subscription\\\",\\n\\t\\t\\t\\t\\\"type\\\": \\\"record\\\",\\n\\t\\t\\t\\t\\\n \\\"fields\\\": [{\\n\\t\\t\\t\\t\\t\\t\\\"name\\\": \\\"subscriptionName\\\",\\n\\t\\t\\t\\t\\t\\t\\\"type\\\": \\\"string\\\"\\n\\t\\t\\\n \\t\\t\\t},\\n\\t\\t\\t\\t\\t{\\n\\t\\t\\t\\t\\t\\t\\\"name\\\": \\\"administrativeState\\\",\\n\\t\\t\\t\\t\\t\\t\\\"type\\\": \\\"string\\\"\\\n \\n\\t\\t\\t\\t\\t},\\n\\t\\t\\t\\t\\t{\\n\\t\\t\\t\\t\\t\\t\\\"name\\\": \\\"fileBasedGP\\\",\\n\\t\\t\\t\\t\\t\\t\\\"type\\\": \\\"int\\\"\\\n \\n\\t\\t\\t\\t\\t},\\n\\t\\t\\t\\t\\t{\\n\\t\\t\\t\\t\\t\\t\\\"name\\\": \\\"fileLocation\\\",\\n\\t\\t\\t\\t\\t\\t\\\"type\\\": \\\"string\\\"\\\n \\n\\t\\t\\t\\t\\t},\\n\\t\\t\\t\\t\\t{\\n\\t\\t\\t\\t\\t\\t\\\"name\\\": \\\"measurementGroups\\\",\\n\\t\\t\\t\\t\\t\\t\\\"type\\\": {\\n\\\n \\t\\t\\t\\t\\t\\t\\t\\\"type\\\": \\\"array\\\",\\n\\t\\t\\t\\t\\t\\t\\t\\\"items\\\": {\\n\\t\\t\\t\\t\\t\\t\\t\\t\\\"name\\\": \\\"Measurement_Groups_Type\\\"\\\n ,\\n\\t\\t\\t\\t\\t\\t\\t\\t\\\"type\\\": \\\"record\\\",\\n\\t\\t\\t\\t\\t\\t\\t\\t\\\"fields\\\": [{\\n\\t\\t\\t\\t\\t\\t\\t\\t\\t\\\"name\\\"\\\n : \\\"measurementGroup\\\",\\n\\t\\t\\t\\t\\t\\t\\t\\t\\t\\\"type\\\": {\\n\\t\\t\\t\\t\\t\\t\\t\\t\\t\\t\\\"name\\\": \\\"Measurement_Group_Type\\\"\\\n ,\\n\\t\\t\\t\\t\\t\\t\\t\\t\\t\\t\\\"type\\\": \\\"record\\\",\\n\\t\\t\\t\\t\\t\\t\\t\\t\\t\\t\\\"fields\\\": [{\\n\\t\\t\\t\\t\\t\\t\\t\\t\\\n \\t\\t\\t\\t\\\"name\\\": \\\"measurementTypes\\\",\\n\\t\\t\\t\\t\\t\\t\\t\\t\\t\\t\\t\\t\\\"type\\\": {\\n\\t\\t\\t\\t\\t\\t\\t\\t\\t\\t\\\n \\t\\t\\t\\\"type\\\": \\\"array\\\",\\n\\t\\t\\t\\t\\t\\t\\t\\t\\t\\t\\t\\t\\t\\\"items\\\": {\\n\\t\\t\\t\\t\\t\\t\\t\\t\\t\\t\\t\\t\\t\\t\\\"\\\n name\\\": \\\"Measurement_Types_Type\\\",\\n\\t\\t\\t\\t\\t\\t\\t\\t\\t\\t\\t\\t\\t\\t\\\"type\\\": \\\"record\\\",\\n\\t\\t\\t\\t\\t\\\n \\t\\t\\t\\t\\t\\t\\t\\t\\t\\\"fields\\\": [{\\n\\t\\t\\t\\t\\t\\t\\t\\t\\t\\t\\t\\t\\t\\t\\t\\\"name\\\": \\\"measurementType\\\",\\n\\t\\\n \\t\\t\\t\\t\\t\\t\\t\\t\\t\\t\\t\\t\\t\\t\\\"type\\\": \\\"string\\\"\\n\\t\\t\\t\\t\\t\\t\\t\\t\\t\\t\\t\\t\\t\\t}]\\n\\t\\t\\t\\t\\t\\t\\t\\t\\\n \\t\\t\\t\\t\\t}\\n\\t\\t\\t\\t\\t\\t\\t\\t\\t\\t\\t\\t}\\n\\t\\t\\t\\t\\t\\t\\t\\t\\t\\t\\t},\\n\\t\\t\\t\\t\\t\\t\\t\\t\\t\\t\\t{\\n\\t\\t\\t\\t\\\n \\t\\t\\t\\t\\t\\t\\t\\t\\\"name\\\": \\\"managedObjectDNsBasic\\\",\\n\\t\\t\\t\\t\\t\\t\\t\\t\\t\\t\\t\\t\\\"type\\\": {\\n\\t\\t\\t\\t\\\n \\t\\t\\t\\t\\t\\t\\t\\t\\t\\\"type\\\": \\\"array\\\",\\n\\t\\t\\t\\t\\t\\t\\t\\t\\t\\t\\t\\t\\t\\\"items\\\": {\\n\\t\\t\\t\\t\\t\\t\\t\\t\\t\\\n \\t\\t\\t\\t\\t\\\"name\\\": \\\"Managed_Object_Dns_Basic_Type\\\",\\n\\t\\t\\t\\t\\t\\t\\t\\t\\t\\t\\t\\t\\t\\t\\\"type\\\": \\\"record\\\"\\\n ,\\n\\t\\t\\t\\t\\t\\t\\t\\t\\t\\t\\t\\t\\t\\t\\\"fields\\\": [{\\n\\t\\t\\t\\t\\t\\t\\t\\t\\t\\t\\t\\t\\t\\t\\t\\\"name\\\": \\\"DN\\\",\\n\\t\\\n \\t\\t\\t\\t\\t\\t\\t\\t\\t\\t\\t\\t\\t\\t\\\"type\\\": \\\"string\\\"\\n\\t\\t\\t\\t\\t\\t\\t\\t\\t\\t\\t\\t\\t\\t}]\\n\\t\\t\\t\\t\\t\\t\\t\\t\\\n \\t\\t\\t\\t\\t}\\n\\t\\t\\t\\t\\t\\t\\t\\t\\t\\t\\t\\t}\\n\\t\\t\\t\\t\\t\\t\\t\\t\\t\\t\\t}\\n\\t\\t\\t\\t\\t\\t\\t\\t\\t\\t]\\n\\t\\t\\t\\t\\t\\\n \\t\\t\\t\\t}\\n\\t\\t\\t\\t\\t\\t\\t\\t}]\\n\\t\\t\\t\\t\\t\\t\\t}\\n\\t\\t\\t\\t\\t\\t}\\n\\t\\t\\t\\t\\t}\\n\\t\\t\\t\\t]\\n\\t\\t\\t}\\n\\t\\\n \\t}\\n\\t]\\n}\"\n - key:\n name: SimpleIntType\n version: 0.0.1\n value:\n key:\n name: SimpleIntType\n version: 0.0.1\n schemaFlavour: Java\n schemaDefinition: java.lang.Integer\n - key:\n name: SimpleStringType\n version: 0.0.1\n value:\n key:\n name: SimpleStringType\n version: 0.0.1\n schemaFlavour: Java\n schemaDefinition: java.lang.String\n - key:\n name: SubscriptionStatusType\n version: 0.0.1\n value:\n key:\n name: SubscriptionStatusType\n version: 0.0.1\n schemaFlavour: Avro\n schemaDefinition: |-\n {\n \"type\": \"record\",\n \"name\": \"ActivateSubscriptionStatus_Type\",\n \"namespace\": \"org.onap.policy.apex.onap.helloworld\",\n \"fields\": [\n {\n \"name\": \"subscriptionName\",\n \"type\": \"string\"\n },\n {\n \"name\": \"nfName\",\n \"type\": \"string\"\n },\n {\n \"name\": \"changeType\",\n \"type\": \"string\"\n },\n {\n \"name\": \"message\",\n \"type\": \"string\"\n }\n ]\n }\n - key:\n name: SubscriptionType\n version: 0.0.1\n value:\n key:\n name: SubscriptionType\n version: 0.0.1\n schemaFlavour: Avro\n schemaDefinition: \"{\\n\\t\\\"name\\\": \\\"subscription\\\",\\n\\t\\\"type\\\": \\\"record\\\",\\n\\t\\\"fields\\\": [{\\n\\t\\t\\\n \\t\\\"name\\\": \\\"subscriptionName\\\",\\n\\t\\t\\t\\\"type\\\": \\\"string\\\"\\n\\t\\t},\\n\\t\\t{\\n\\t\\t\\t\\\"name\\\": \\\"administrativeState\\\"\\\n ,\\n\\t\\t\\t\\\"type\\\": \\\"string\\\"\\n\\t\\t},\\n\\t\\t{\\n\\t\\t\\t\\\"name\\\": \\\"fileBasedGP\\\",\\n\\t\\t\\t\\\"type\\\": \\\"\\\n int\\\"\\n\\t\\t},\\n\\t\\t{\\n\\t\\t\\t\\\"name\\\": \\\"fileLocation\\\",\\n\\t\\t\\t\\\"type\\\": \\\"string\\\"\\n\\t\\t},\\n\\t\\t\\\n {\\n\\t\\t\\t\\\"name\\\": \\\"measurementGroups\\\",\\n\\t\\t\\t\\\"type\\\": {\\n\\t\\t\\t\\t\\\"type\\\": \\\"array\\\",\\n\\t\\t\\t\\\n \\t\\\"items\\\": {\\n\\t\\t\\t\\t\\t\\\"name\\\": \\\"Measurement_Groups_Type\\\",\\n\\t\\t\\t\\t\\t\\\"type\\\": \\\"record\\\",\\n\\\n \\t\\t\\t\\t\\t\\\"fields\\\": [{\\n\\t\\t\\t\\t\\t\\t\\\"name\\\": \\\"measurementGroup\\\",\\n\\t\\t\\t\\t\\t\\t\\\"type\\\": {\\n\\t\\\n \\t\\t\\t\\t\\t\\t\\\"name\\\": \\\"Measurement_Group_Type\\\",\\n\\t\\t\\t\\t\\t\\t\\t\\\"type\\\": \\\"record\\\",\\n\\t\\t\\t\\t\\t\\\n \\t\\t\\\"fields\\\": [{\\n\\t\\t\\t\\t\\t\\t\\t\\t\\t\\\"name\\\": \\\"measurementTypes\\\",\\n\\t\\t\\t\\t\\t\\t\\t\\t\\t\\\"type\\\"\\\n : {\\n\\t\\t\\t\\t\\t\\t\\t\\t\\t\\t\\\"type\\\": \\\"array\\\",\\n\\t\\t\\t\\t\\t\\t\\t\\t\\t\\t\\\"items\\\": {\\n\\t\\t\\t\\t\\t\\t\\t\\t\\t\\\n \\t\\t\\\"name\\\": \\\"Measurement_Types_Type\\\",\\n\\t\\t\\t\\t\\t\\t\\t\\t\\t\\t\\t\\\"type\\\": \\\"record\\\",\\n\\t\\t\\t\\t\\t\\\n \\t\\t\\t\\t\\t\\t\\\"fields\\\": [{\\n\\t\\t\\t\\t\\t\\t\\t\\t\\t\\t\\t\\t\\\"name\\\": \\\"measurementType\\\",\\n\\t\\t\\t\\t\\t\\t\\t\\\n \\t\\t\\t\\t\\t\\\"type\\\": \\\"string\\\"\\n\\t\\t\\t\\t\\t\\t\\t\\t\\t\\t\\t}]\\n\\t\\t\\t\\t\\t\\t\\t\\t\\t\\t}\\n\\t\\t\\t\\t\\t\\t\\t\\t\\t\\\n }\\n\\t\\t\\t\\t\\t\\t\\t\\t},\\n\\t\\t\\t\\t\\t\\t\\t\\t{\\n\\t\\t\\t\\t\\t\\t\\t\\t\\t\\\"name\\\": \\\"managedObjectDNsBasic\\\",\\n\\\n \\t\\t\\t\\t\\t\\t\\t\\t\\t\\\"type\\\": {\\n\\t\\t\\t\\t\\t\\t\\t\\t\\t\\t\\\"type\\\": \\\"array\\\",\\n\\t\\t\\t\\t\\t\\t\\t\\t\\t\\t\\\"items\\\"\\\n : {\\n\\t\\t\\t\\t\\t\\t\\t\\t\\t\\t\\t\\\"name\\\": \\\"Managed_Object_Dns_Basic_Type\\\",\\n\\t\\t\\t\\t\\t\\t\\t\\t\\t\\t\\t\\\"\\\n type\\\": \\\"record\\\",\\n\\t\\t\\t\\t\\t\\t\\t\\t\\t\\t\\t\\\"fields\\\": [{\\n\\t\\t\\t\\t\\t\\t\\t\\t\\t\\t\\t\\t\\\"name\\\": \\\"DN\\\"\\\n ,\\n\\t\\t\\t\\t\\t\\t\\t\\t\\t\\t\\t\\t\\\"type\\\": \\\"string\\\"\\n\\t\\t\\t\\t\\t\\t\\t\\t\\t\\t\\t}]\\n\\t\\t\\t\\t\\t\\t\\t\\t\\t\\t}\\n\\\n \\t\\t\\t\\t\\t\\t\\t\\t\\t}\\n\\t\\t\\t\\t\\t\\t\\t\\t}\\n\\t\\t\\t\\t\\t\\t\\t]\\n\\t\\t\\t\\t\\t\\t}\\n\\t\\t\\t\\t\\t}]\\n\\t\\t\\t\\t}\\n\\t\\\n \\t\\t}\\n\\t\\t}\\n\\t]\\n}\"\n - key:\n name: UUIDType\n version: 0.0.1\n value:\n key:\n name: UUIDType\n version: 0.0.1\n schemaFlavour: Java\n schemaDefinition: java.util.UUID\n engineParameters:\n executorParameters:\n JAVASCRIPT:\n parameterClassName: org.onap.policy.apex.plugins.executor.javascript.JavascriptExecutorParameters\n contextParameters:\n parameterClassName: org.onap.policy.apex.context.parameters.ContextParameters\n schemaParameters:\n Avro:\n parameterClassName: org.onap.policy.apex.plugins.context.schema.avro.AvroSchemaHelperParameters\n Java:\n parameterClassName: org.onap.policy.apex.context.impl.schema.java.JavaSchemaHelperParameters\n jsonAdapters:\n Instant:\n adaptedClass: java.time.Instant\n adaptorClass: org.onap.policy.acm.util.Serialization$GsonInstantAdapter\n eventInputParameters:\n DCAEConsumer:\n carrierTechnologyParameters:\n carrierTechnology: RESTCLIENT\n parameterClassName: org.onap.policy.apex.plugins.event.carrier.restclient.RestClientCarrierTechnologyParameters\n parameters:\n consumerPollTime: '50'\n url: https://message-router:3905/events/unauthenticated.DCAE_CL_OUTPUT/cg1/sg1\n eventProtocolParameters:\n eventProtocol: JSON\n parameters:\n nameAlias: policyName\n eventName: pmsh-operational-policy\n eventNameFilter: pmsh-operational-policy\n CDSRequestConsumer:\n carrierTechnologyParameters:\n carrierTechnology: RESTREQUESTOR\n parameterClassName: org.onap.policy.apex.plugins.event.carrier.restrequestor.RestRequestorCarrierTechnologyParameters\n parameters:\n url: http://10.10.10.184:30254/api/v1/execution-service/process\n httpMethod: POST\n restRequestTimeout: 2000\n httpHeaders:\n - - Authorization\n - Basic Y2NzZGthcHBzOmNjc2RrYXBwcw==\n eventProtocolParameters:\n eventProtocol: JSON\n eventName: CDSCreateResponseEvent\n eventNameFilter: CDSCreateResponseEvent\n requestorMode: true\n requestorPeer: CDSRequestProducer\n requestorTimeout: 500\n CDSDeleteRequestConsumer:\n carrierTechnologyParameters:\n carrierTechnology: RESTREQUESTOR\n parameterClassName: org.onap.policy.apex.plugins.event.carrier.restrequestor.RestRequestorCarrierTechnologyParameters\n parameters:\n url: http://10.10.10.184:30254/api/v1/execution-service/process\n httpMethod: POST\n restRequestTimeout: 2000\n httpHeaders:\n - - Authorization\n - Basic Y2NzZGthcHBzOmNjc2RrYXBwcw==\n eventProtocolParameters:\n eventProtocol: JSON\n eventName: CDSDeleteResponseEvent\n eventNameFilter: CDSDeleteResponseEvent\n requestorMode: true\n requestorPeer: CDSDeleteRequestProducer\n requestorTimeout: 500\n CDSReplyConsumer:\n carrierTechnologyParameters:\n carrierTechnology: RESTREQUESTOR\n parameterClassName: org.onap.policy.apex.plugins.event.carrier.restrequestor.RestRequestorCarrierTechnologyParameters\n parameters:\n url: https://message-router:3905/events/unauthenticated.PMSH_CL_INPUT\n httpMethod: POST\n restRequestTimeout: 2000\n eventProtocolParameters:\n eventProtocol: JSON\n eventName: MRResponseEvent\n eventNameFilter: MRResponseEvent\n requestorMode: true\n requestorPeer: CDSReplyProducer\n requestorTimeout: 500\n eventOutputParameters:\n logOutputter:\n carrierTechnologyParameters:\n carrierTechnology: FILE\n parameters:\n fileName: /tmp/outputevents.log\n eventProtocolParameters:\n eventProtocol: JSON\n StdOutOutputter:\n carrierTechnologyParameters:\n carrierTechnology: FILE\n parameters:\n standardIo: true\n eventProtocolParameters:\n eventProtocol: JSON\n CDSRequestProducer:\n carrierTechnologyParameters:\n carrierTechnology: RESTREQUESTOR\n parameterClassName: org.onap.policy.apex.plugins.event.carrier.restrequestor.RestRequestorCarrierTechnologyParameters\n eventProtocolParameters:\n eventProtocol: JSON\n eventNameFilter: CDSCreateSubscriptionRequestEvent\n requestorMode: true\n requestorPeer: CDSRequestConsumer\n requestorTimeout: 500\n CDSDeleteRequestProducer:\n carrierTechnologyParameters:\n carrierTechnology: RESTREQUESTOR\n parameterClassName: org.onap.policy.apex.plugins.event.carrier.restrequestor.RestRequestorCarrierTechnologyParameters\n eventProtocolParameters:\n eventProtocol: JSON\n eventNameFilter: CDSDeleteSubscriptionRequestEvent\n requestorMode: true\n requestorPeer: CDSDeleteRequestConsumer\n requestorTimeout: 500\n CDSReplyProducer:\n carrierTechnologyParameters:\n carrierTechnology: RESTREQUESTOR\n parameterClassName: org.onap.policy.apex.plugins.event.carrier.restrequestor.RestRequestorCarrierTechnologyParameters\n eventProtocolParameters:\n eventProtocol: JSON\n eventNameFilter: CDSResponseStatusEvent\n requestorMode: true\n requestorPeer: CDSReplyConsumer\n requestorTimeout: 500", "options": { "raw": { "language": "text" @@ -51,14 +51,14 @@ } }, "url": { - "raw": "localhost:6969/onap/controlloop/v2/commission", + "raw": "localhost:6969/onap.acm.v2/commission", "host": [ "localhost" ], "port": "6969", "path": [ "onap", - "controlloop", + "acm", "v2", "commission" ] @@ -67,7 +67,7 @@ "response": [] }, { - "name": "Demo: Instantiation control loop definition (Full tosca try)", + "name": "Demo: Instantiation automation composition definition (Full tosca try)", "protocolProfileBehavior": { "disabledSystemHeaders": { "content-type": true @@ -104,7 +104,7 @@ ], "body": { "mode": "raw", - "raw": "{\n \"controlLoopList\": [\n {\n \"name\": \"PMSHInstance0\",\n \"version\": \"1.0.1\",\n \"definition\": {\n \"name\": \"org.onap.domain.pmsh.PMSHControlLoopDefinition\",\n \"version\": \"1.2.3\"\n },\n \"state\": \"UNINITIALISED\",\n \"orderedState\": \"UNINITIALISED\",\n \"description\": \"PMSH control loop instance 0\",\n \"elements\": {\n \"709c62b3-8918-41b9-a747-d21eb79c6c20\": {\n \"id\": \"709c62b3-8918-41b9-a747-d21eb79c6c20\",\n \"definition\": {\n \"name\": \"org.onap.domain.pmsh.PMSH_DCAEMicroservice\",\n \"version\": \"1.2.3\"\n },\n \"participantType\": {\n \"name\": \"org.onap.dcae.controlloop.DCAEMicroserviceControlLoopParticipant\",\n \"version\": \"2.3.4\"\n },\n \"state\": \"UNINITIALISED\",\n \"orderedState\": \"UNINITIALISED\",\n \"description\": \"DCAE Control Loop Element for the PMSH instance 0 control loop\"\n },\n \"709c62b3-8918-41b9-a747-d21eb79c6c21\": {\n \"id\": \"709c62b3-8918-41b9-a747-d21eb79c6c21\",\n \"definition\": {\n \"name\": \"org.onap.domain.pmsh.PMSH_MonitoringPolicyControlLoopElement\",\n \"version\": \"1.2.3\"\n },\n \"participantType\": {\n \"name\": \"org.onap.policy.controlloop.PolicyControlLoopParticipant\",\n \"version\": \"2.3.1\"\n },\n \"state\": \"UNINITIALISED\",\n \"orderedState\": \"UNINITIALISED\",\n \"description\": \"Monitoring Policy Control Loop Element for the PMSH instance 0 control loop\"\n },\n \"709c62b3-8918-41b9-a747-d21eb79c6c22\": {\n \"id\": \"709c62b3-8918-41b9-a747-d21eb79c6c22\",\n \"definition\": {\n \"name\": \"org.onap.domain.pmsh.PMSH_OperationalPolicyControlLoopElement\",\n \"version\": \"1.2.3\"\n },\n \"participantType\": {\n \"name\": \"org.onap.policy.controlloop.PolicyControlLoopParticipant\",\n \"version\": \"2.3.1\"\n },\n \"state\": \"UNINITIALISED\",\n \"orderedState\": \"UNINITIALISED\",\n \"description\": \"Operational Policy Control Loop Element for the PMSH instance 0 control loop\"\n }\n }\n }\n ]\n}", + "raw": "{\n \"controlLoopList\": [\n {\n \"name\": \"PMSHInstance0\",\n \"version\": \"1.0.1\",\n \"definition\": {\n \"name\": \"org.onap.domain.pmsh.PMSHControlLoopDefinition\",\n \"version\": \"1.2.3\"\n },\n \"state\": \"UNINITIALISED\",\n \"orderedState\": \"UNINITIALISED\",\n \"description\": \"PMSH automation composition instance 0\",\n \"elements\": {\n \"709c62b3-8918-41b9-a747-d21eb79c6c20\": {\n \"id\": \"709c62b3-8918-41b9-a747-d21eb79c6c20\",\n \"definition\": {\n \"name\": \"org.onap.domain.pmsh.PMSH_DCAEMicroservice\",\n \"version\": \"1.2.3\"\n },\n \"participantType\": {\n \"name\": \"org.onap.dcae.acm.DCAEMicroserviceControlLoopParticipant\",\n \"version\": \"2.3.4\"\n },\n \"state\": \"UNINITIALISED\",\n \"orderedState\": \"UNINITIALISED\",\n \"description\": \"DCAE Control Loop Element for the PMSH instance 0 automation composition\"\n },\n \"709c62b3-8918-41b9-a747-d21eb79c6c21\": {\n \"id\": \"709c62b3-8918-41b9-a747-d21eb79c6c21\",\n \"definition\": {\n \"name\": \"org.onap.domain.pmsh.PMSH_MonitoringPolicyControlLoopElement\",\n \"version\": \"1.2.3\"\n },\n \"participantType\": {\n \"name\": \"org.onap.policy.acm.PolicyControlLoopParticipant\",\n \"version\": \"2.3.1\"\n },\n \"state\": \"UNINITIALISED\",\n \"orderedState\": \"UNINITIALISED\",\n \"description\": \"Monitoring Policy Control Loop Element for the PMSH instance 0 automation composition\"\n },\n \"709c62b3-8918-41b9-a747-d21eb79c6c22\": {\n \"id\": \"709c62b3-8918-41b9-a747-d21eb79c6c22\",\n \"definition\": {\n \"name\": \"org.onap.domain.pmsh.PMSH_OperationalPolicyControlLoopElement\",\n \"version\": \"1.2.3\"\n },\n \"participantType\": {\n \"name\": \"org.onap.policy.acm.PolicyControlLoopParticipant\",\n \"version\": \"2.3.1\"\n },\n \"state\": \"UNINITIALISED\",\n \"orderedState\": \"UNINITIALISED\",\n \"description\": \"Operational Policy Control Loop Element for the PMSH instance 0 automation composition\"\n }\n }\n }\n ]\n}", "options": { "raw": { "language": "json" @@ -112,14 +112,14 @@ } }, "url": { - "raw": "localhost:6969/onap/controlloop/v2/instantiation", + "raw": "localhost:6969/onap.acm.v2/instantiation", "host": [ "localhost" ], "port": "6969", "path": [ "onap", - "controlloop", + "acm", "v2", "instantiation" ] @@ -128,7 +128,7 @@ "response": [] }, { - "name": "Demo: Instantiation control loop definition Command", + "name": "Demo: Instantiation automation composition definition Command", "protocolProfileBehavior": { "disabledSystemHeaders": { "content-type": true @@ -173,14 +173,14 @@ } }, "url": { - "raw": "localhost:6969/onap/controlloop/v2/instantiation/command", + "raw": "localhost:6969/onap.acm.v2/instantiation/command", "host": [ "localhost" ], "port": "6969", "path": [ "onap", - "controlloop", + "acm", "v2", "instantiation", "command" @@ -263,7 +263,7 @@ "response": [] }, { - "name": "Demo: Get instantiated control loops", + "name": "Demo: Get instantiated automation compositions", "request": { "auth": { "type": "basic", @@ -283,14 +283,14 @@ "method": "GET", "header": [], "url": { - "raw": "localhost:6969/onap/controlloop/v2/instantiation", + "raw": "localhost:6969/onap.acm.v2/instantiation", "host": [ "localhost" ], "port": "6969", "path": [ "onap", - "controlloop", + "acm", "v2", "instantiation" ] diff --git a/common/src/test/resources/demo/config/PolicyParticipantConfig.json b/common/src/test/resources/demo/config/PolicyParticipantConfig.json index f02fbdd23..12b261fcd 100644 --- a/common/src/test/resources/demo/config/PolicyParticipantConfig.json +++ b/common/src/test/resources/demo/config/PolicyParticipantConfig.json @@ -1,21 +1,21 @@ { - "name": "ControlLoopParticipantGroup", + "name": "AutomationCompositionParticipantGroup", "intermediaryParameters": { "name": "Participant parameters", "reportingTimeInterval": 120000, "description": "Participant Description", "participantType":{ - "name": "org.onap.policy.controlloop.PolicyControlLoopParticipant", + "name": "org.onap.policy.acm.PolicyAutomationCompositionParticipant", "version":"2.3.1" }, "participantId": { "name": "org.onap.PM_Policy", "version": "1.0.0" }, - "clampControlLoopTopics": { + "automationCompositionTopics": { "topicSources": [ { - "topic": "POLICY-CLRUNTIME-PARTICIPANT", + "topic": "POLICY-ACRUNTIME-PARTICIPANT", "servers": [ "localhost" ], @@ -25,7 +25,7 @@ ], "topicSinks": [ { - "topic": "POLICY-CLRUNTIME-PARTICIPANT", + "topic": "POLICY-ACRUNTIME-PARTICIPANT", "servers": [ "localhost" ], diff --git a/common/src/test/resources/demo/config/RuntimeConfig.json b/common/src/test/resources/demo/config/RuntimeConfig.json index fd8948ab7..7424568cc 100644 --- a/common/src/test/resources/demo/config/RuntimeConfig.json +++ b/common/src/test/resources/demo/config/RuntimeConfig.json @@ -1,5 +1,5 @@ { - "name": "ControlLoopRuntimeGroup", + "name": "AutomationCompositionRuntimeGroup", "restServerParameters": { "host": "0.0.0.0", "port": 6969, @@ -23,7 +23,7 @@ "name": "PolicyProviderParameterGroup", "implementation": "org.onap.policy.models.provider.impl.DatabasePolicyModelsProviderImpl", "databaseDriver": "org.mariadb.jdbc.Driver", - "databaseUrl": "jdbc:mariadb://localhost:3306/controlloop", + "databaseUrl": "jdbc:mariadb://localhost:3306/acm", "databaseUser": "policy", "databasePassword": "P01icY", "persistenceUnit": "CommissioningMariaDb" @@ -31,7 +31,7 @@ "topicParameterGroup": { "topicSources": [ { - "topic": "POLICY-CLRUNTIME-PARTICIPANT", + "topic": "POLICY-ACRUNTIME-PARTICIPANT", "servers": [ "localhost" ], @@ -41,7 +41,7 @@ ], "topicSinks": [ { - "topic": "POLICY-CLRUNTIME-PARTICIPANT", + "topic": "POLICY-ACRUNTIME-PARTICIPANT", "servers": [ "localhost" ], diff --git a/common/src/test/resources/examples/acm/KubernetesHelm.yaml b/common/src/test/resources/examples/acm/KubernetesHelm.yaml new file mode 100644 index 000000000..9b0f449d3 --- /dev/null +++ b/common/src/test/resources/examples/acm/KubernetesHelm.yaml @@ -0,0 +1,182 @@ +# ============LICENSE_START======================================================= +# Copyright (C) 2021 Nordix Foundation. +# ================================================================================ +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# SPDX-License-Identifier: Apache-2.0 +# ============LICENSE_END========================================================= + +tosca_definitions_version: tosca_simple_yaml_1_3 +data_types: + onap.datatypes.ToscaConceptIdentifier: + derived_from: tosca.datatypes.Root + properties: + name: + type: string + required: true + version: + type: string + required: true +node_types: + org.onap.policy.clamp.controlloop.Participant: + version: 1.0.1 + derived_from: tosca.nodetypes.Root + properties: + provider: + type: string + requred: false + org.onap.policy.clamp.controlloop.ControlLoopElement: + version: 1.0.1 + derived_from: tosca.nodetypes.Root + properties: + provider: + type: string + requred: false + participantType: + type: onap.datatypes.ToscaConceptIdentifier + requred: true + startPhase: + type: integer + required: false + constraints: + - greater-or-equal: 0 + metadata: + common: true + description: A value indicating the start phase in which this control loop element will be started, the + first start phase is zero. Control Loop Elements are started in their start_phase order and stopped + in reverse start phase order. Control Loop Elements with the same start phase are started and + stopped simultaneously + org.onap.policy.clamp.controlloop.ControlLoop: + version: 1.0.1 + derived_from: tosca.nodetypes.Root + properties: + provider: + type: string + requred: false + elements: + type: list + required: true + entry_schema: + type: onap.datatypes.ToscaConceptIdentifier + org.onap.policy.clamp.controlloop.K8SMicroserviceControlLoopElement: + version: 1.0.1 + derived_from: org.onap.policy.clamp.controlloop.ControlLoopElement + properties: + chart: + type: string + requred: true + configs: + type: list + required: false + requirements: + type: string + requred: false + templates: + type: list + required: false + entry_schema: + values: + type: string + requred: true +topology_template: + node_templates: + org.onap.k8s.controlloop.K8SControlLoopParticipant: + version: 2.3.4 + type: org.onap.policy.clamp.controlloop.Participant + type_version: 1.0.1 + description: Participant for K8S + properties: + provider: ONAP + org.onap.domain.database.Postgres_K8SMicroserviceControlLoopElement: + # See https://github.com/onap/oom/tree/master/kubernetes/common/postgres + version: 1.2.3 + type: org.onap.policy.clamp.controlloop.K8SMicroserviceControlLoopElement + type_version: 1.0.0 + description: Control loop element for the K8S microservice for Postgres + properties: + provider: ONAP + participantType: + name: org.onap.k8s.controlloop.K8SControlLoopParticipant + version: 2.3.4 + startPhase: 2 + chart: + apiVersion: v1 + description: ONAP Postgres Server + name: postgres + version: 7.0.0 + configs: + - name: pg_hba.conf + value: + - name: setup.sql + value: + requirements: + dependencies: + - name: common + version: ~7.x-0 + repository: 'file://../common' + - name: repositoryGenerator + version: ~7.x-0 + repository: 'file://../repositoryGenerator' + templates: + - name: first_template_file + value: + - name: And so on + values: + + org.onap.domain.database.HelloWorld_K8SMicroserviceControlLoopElement: + # See https://github.com/stakater-charts/helloworld/tree/master/helloworld + version: 1.2.3 + type: org.onap.policy.clamp.controlloop.K8SMicroserviceControlLoopElement + type_version: 1.0.0 + description: Control loop element for the K8S microservice for Hello World + properties: + provider: ONAP + participantType: + name: org.onap.k8s.controlloop.K8SControlLoopParticipant + version: 2.3.4 + startPhase: 2 + chart: + apiVersion: v1 + name: helloworld + description: helloworld chart that runs on kubernetes + version: 1.0.0 + keywords: + - helloworld + - kubernetes + home: https://github.com/stakater-charts/helloworld + maintainers: + - name: Stakater + email: stakater@aurorasolutions.io + values: + kubernetes: + host: https://kubernetes.default + helloworld: + namespace: default + image: + name: tutum/hello-world + tag: latest + pullPolicy: IfNotPresent + service: + ingressClass: internal-ingress + org.onap.domain.sample.Postgres_HelloWorld_ControlLoopDefinition: + version: 1.2.3 + type: org.onap.policy.clamp.controlloop.ControlLoop + type_version: 1.0.0 + description: Control loop for Postgres and Hello World + properties: + provider: ONAP + elements: + - name: org.onap.domain.database.Postgres_K8SMicroserviceControlLoopElement + version: 1.2.3 + - name: org.onap.domain.database.HelloWorld_K8SMicroserviceControlLoopElement + version: 1.2.3 diff --git a/common/src/test/resources/examples/acm/PMSH/consul_call_body.json b/common/src/test/resources/examples/acm/PMSH/consul_call_body.json new file mode 100644 index 000000000..9118e9a6f --- /dev/null +++ b/common/src/test/resources/examples/acm/PMSH/consul_call_body.json @@ -0,0 +1,62 @@ +{ + "subscription": { + "subscriptionName": "subscriptiona", + "administrativeState": "UNLOCKED", + "fileBasedGP": 15, + "fileLocation": "/pm/pm.xml", + "nfFilter": { + "nfNames": [ + "^pnf1.*" + ], + "modelInvariantIDs": [ + "5845y423-g654-6fju-po78-8n53154532k6", + "7129e420-d396-4efb-af02-6b83499b12f8" + ], + "modelVersionIDs": [ + "e80a6ae3-cafd-4d24-850d-e14c084a5ca9" + ] + }, + "measurementGroups": [ + { + "measurementGroup": { + "measurementTypes": [ + { + "measurementType": "countera" + }, + { + "measurementType": "counterb" + } + ], + "managedObjectDNsBasic": [ + { + "DN": "dna" + }, + { + "DN": "dnb" + } + ] + } + }, + { + "measurementGroup": { + "measurementTypes": [ + { + "measurementType": "counterc" + }, + { + "measurementType": "counterd" + } + ], + "managedObjectDNsBasic": [ + { + "DN": "dnc" + }, + { + "DN": "dnd" + } + ] + } + } + ] + } +} diff --git a/common/src/test/resources/examples/acm/PMSH/consul_url.txt b/common/src/test/resources/examples/acm/PMSH/consul_url.txt new file mode 100644 index 000000000..2a2e77e86 --- /dev/null +++ b/common/src/test/resources/examples/acm/PMSH/consul_url.txt @@ -0,0 +1 @@ +http://consul:31321/v1/kv/dcae-pmsh:policy diff --git a/common/src/test/resources/examples/acm/PMSH/pmsh.postman2.0_collection.json b/common/src/test/resources/examples/acm/PMSH/pmsh.postman2.0_collection.json new file mode 100644 index 000000000..6efddc256 --- /dev/null +++ b/common/src/test/resources/examples/acm/PMSH/pmsh.postman2.0_collection.json @@ -0,0 +1,254 @@ +{ + "info": { + "name": "CL-PMSH usecase", + "_postman_id": "5fb85996-3b5b-40fb-9564-bd44eff287d4", + "description": "", + "schema": "https://schema.getpostman.com/json/collection/v2.0.0/collection.json" + }, + "item": [ + { + "id": "b436e642-10a0-40d7-a37f-9979693cdb02", + "name": "Get Instantiated Control loops", + "request": { + "url": { + "protocol": "https", + "host": "localhost", + "path": [ + "onap", + "controlloop", + "v2", + "instantiation" + ], + "port": "6969" + }, + "method": "GET", + "header": [ + { + "key": "Accept", + "value": "*/*", + "disabled": false + } + ], + "body": { + "mode": "raw", + "disabled": false + }, + "description": "" + }, + "response": [ + { + "header": [], + "code": 200, + "name": "Response_200", + "id": "d9328b54-71fa-43aa-96cd-0d002e958da9" + } + ] + }, + { + "id": "021d7ff6-5cad-4967-afe2-f68317cba1f1", + "name": "Update a Control loop", + "request": { + "url": { + "protocol": "https", + "host": "localhost", + "path": [ + "onap", + "controlloop", + "v2", + "instantiation/command" + ], + "port": "6969" + }, + "method": "PUT", + "header": [ + { + "key": "Content-Type", + "value": "application/json", + "description": "", + "disabled": false + }, + { + "key": "X-ONAP-RequestID", + "value": "709c62b3-8918-41b9-a747-d21eb79c6c20", + "description": "", + "disabled": false + }, + { + "key": "Accept", + "value": "*/*", + "disabled": false + } + ], + "body": { + "mode": "raw", + "raw": "{\r\n \"orderedState\": \"PASSIVE\",\r\n \"controlLoopIdentifierList\": [\r\n {\r\n \"name\": \"PmshInstance0\",\r\n \"version\": \"1.0.1\"\r\n }\r\n ]\r\n}", + "disabled": false + }, + "description": "" + }, + "response": [ + { + "header": [], + "code": 200, + "name": "Response_200", + "id": "15718e82-6647-4102-9c1e-7e5c0cc48261" + } + ] + }, + { + "id": "96d15818-1f95-41bd-ac18-37a96f99a0d8", + "name": "UnInitialise a Control loop", + "request": { + "url": { + "protocol": "https", + "host": "localhost", + "path": [ + "onap", + "controlloop", + "v2", + "instantiation/command" + ], + "port": "6969" + }, + "method": "PUT", + "header": [ + { + "key": "Content-Type", + "value": "application/json", + "description": "", + "disabled": false + }, + { + "key": "Accept", + "value": "*/*", + "disabled": false + } + ], + "body": { + "mode": "raw", + "raw": "{\r\n \"orderedState\": \"UNINTIALISED\",\r\n \"controlLoopIdentifierList\": [\r\n {\r\n \"name\": \"PmshInstance0\",\r\n \"version\": \"1.0.1\"\r\n }\r\n ]\r\n}", + "disabled": false + }, + "description": "" + }, + "response": [ + { + "header": [], + "code": 200, + "name": "Response_200", + "id": "a02ccea0-d357-4ced-9f19-82bd5712d318" + } + ] + }, + { + "id": "43776ab0-4851-41bb-8c43-407d0b807696", + "name": "Instantiate a Control loop", + "request": { + "url": { + "protocol": "https", + "host": "localhost", + "path": [ + "onap", + "controlloop", + "v2", + "instantiation" + ], + "port": "6969" + }, + "method": "POST", + "header": [ + { + "key": "X-ONAP-RequestID", + "value": "709c62b3-8918-41b9-a747-d21eb79c6c20", + "description": "", + "disabled": false + }, + { + "key": "Content-Type", + "value": "application/json", + "description": "", + "disabled": false + }, + { + "key": "Accept", + "value": "*/*", + "disabled": false + } + ], + "body": { + "mode": "raw", + "raw": "{\r\n \"controlLoopList\": [\r\n {\r\n \"name\": \"PmshInstance0\",\r\n \"version\": \"1.0.1\",\r\n \"definition\": {\r\n \"name\": \"org.onap.domain.sample.GenericK8s_ControlLoopDefinition\",\r\n \"version\": \"1.2.3\"\r\n },\r\n \"state\": \"UNINITIALISED\",\r\n \"orderedState\": \"UNINITIALISED\",\r\n \"description\": \"K8s control loop instance 0\",\r\n \"elements\": {\r\n \"709c62b3-8918-41b9-a747-d21eb79c6c21\": {\r\n \"id\": \"709c62b3-8918-41b9-a747-d21eb79c6c21\",\r\n \"definition\": {\r\n \"name\": \"org.onap.domain.database.PMSH_K8SMicroserviceControlLoopElement\",\r\n \"version\": \"1.2.3\"\r\n },\r\n \"participantId\": {\r\n \"name\": \"org.onap.k8s.controlloop.K8SControlLoopParticipant\",\r\n \"version\": \"2.3.4\"\r\n },\r\n \"participantType\": {\r\n \"name\": \"org.onap.k8s.controlloop.K8SControlLoopParticipant\",\r\n \"version\": \"2.3.4\"\r\n },\r\n \"state\": \"UNINITIALISED\",\r\n \"orderedState\": \"UNINITIALISED\",\r\n \"description\": \"K8s Control Loop Element for the PMSH instance 0 control loop\"\r\n },\r\n \"709c62b3-8918-41b9-a747-d21eb79c6c22\": {\r\n \"id\": \"709c62b3-8918-41b9-a747-d21eb79c6c22\",\r\n \"definition\": {\r\n \"name\": \"org.onap.domain.database.Local_K8SMicroserviceControlLoopElement\",\r\n \"version\": \"1.2.3\"\r\n },\r\n \"participantId\": {\r\n \"name\": \"org.onap.k8s.controlloop.K8SControlLoopParticipant\",\r\n \"version\": \"2.3.4\"\r\n },\r\n \"participantType\": {\r\n \"name\": \"org.onap.k8s.controlloop.K8SControlLoopParticipant\",\r\n \"version\": \"2.3.4\"\r\n },\r\n \"state\": \"UNINITIALISED\",\r\n \"orderedState\": \"UNINITIALISED\",\r\n \"description\": \"K8s Control Loop Element for the local instance 0 control loop\"\r\n },\r\n \"709c62b3-8918-41b9-a747-d21eb79c6c25\": {\r\n \"id\": \"709c62b3-8918-41b9-a747-d21eb79c6c25\",\r\n \"definition\": {\r\n \"name\": \"org.onap.domain.database.Http_PMSHMicroserviceControlLoopElement\",\r\n \"version\": \"1.2.3\"\r\n },\r\n \"participantId\": {\r\n \"name\": \"org.onap.controlloop.HttpControlLoopParticipant\",\r\n \"version\": \"2.3.4\"\r\n },\r\n \"participantType\": {\r\n \"name\": \"org.onap.controlloop.HttpControlLoopParticipant\",\r\n \"version\": \"2.3.4\"\r\n },\r\n \"state\": \"UNINITIALISED\",\r\n \"orderedState\": \"UNINITIALISED\",\r\n \"description\": \"DCAE Control Loop Element for the PMSH instance 0 control loop\"\r\n }\r\n }\r\n }\r\n ]\r\n}", + "disabled": false + }, + "description": "" + }, + "response": [ + { + "header": [], + "code": 200, + "name": "Response_200", + "id": "855ec245-13ef-48ab-a0e0-3de6e11090a4" + } + ] + }, + { + "id": "3f6d5d18-8a29-46c3-8fec-d6645e7f7c2b", + "name": "Commission a Control loop", + "request": { + "url": { + "protocol": "https", + "host": "localhost", + "path": [ + "onap", + "controlloop", + "v2", + "commission" + ], + "port": "6969" + }, + "method": "POST", + "header": [ + { + "key": "Content-Type", + "value": "application/yaml", + "description": "", + "disabled": false + }, + { + "key": "X-ONAP-RequestID", + "value": "709c62b3-8918-41b9-a747-d21eb79c6c20", + "description": "", + "disabled": false + }, + { + "key": "Accept", + "value": "*/*", + "disabled": false + } + ], + "body": { + "mode": "raw", + "raw": "tosca_definitions_version: tosca_simple_yaml_1_3\ndata_types:\n onap.datatypes.ToscaConceptIdentifier:\n derived_from: tosca.datatypes.Root\n properties:\n name:\n type: string\n required: true\n version:\n type: string\n required: true\n \n org.onap.datatypes.policy.clamp.controlloop.httpControlLoopElement.RestRequest:\n version: 1.0.0\n derived_from: tosca.datatypes.Root\n properties:\n restRequestId:\n type: onap.datatypes.ToscaConceptIdentifier\n typeVersion: 1.0.0\n required: true\n description: The name and version of a REST request to be sent to a REST endpoint\n httpMethod:\n type: string\n required: true\n constraints:\n - valid_values: [POST, PUT, GET, DELETE]\n description: The REST method to use\n path:\n type: string\n required: true\n description: The path of the REST request relative to the base URL\n body:\n type: string\n required: false\n description: The body of the REST request for PUT and POST requests\n expectedResponse:\n type: integer\n required: true\n constraints:\n - in_range: [100, 599]\n description: THe expected HTTP status code for the REST request\n org.onap.datatypes.policy.clamp.controlloop.httpControlLoopElement.ConfigurationEntity:\n version: 1.0.0\n derived_from: tosca.datatypes.Root\n properties:\n configurationEntityId:\n type: onap.datatypes.ToscaConceptIdentifier\n typeVersion: 1.0.0\n required: true\n description: The name and version of a Configuration Entity to be handled by the HTTP Control Loop Element\n restSequence:\n type: list\n entry_schema:\n type: org.onap.datatypes.policy.clamp.controlloop.httpControlLoopElement.RestRequest\n typeVersion: 1.0.0\n description: A sequence of REST commands to send to the REST endpoint \nnode_types:\n org.onap.policy.clamp.controlloop.Participant:\n version: 1.0.1\n derived_from: tosca.nodetypes.Root\n properties:\n provider:\n type: string\n requred: false\n org.onap.policy.clamp.controlloop.ControlLoopElement:\n version: 1.0.1\n derived_from: tosca.nodetypes.Root\n properties:\n provider:\n type: string\n requred: false\n participant_id:\n type: onap.datatypes.ToscaConceptIdentifier\n requred: true\n org.onap.policy.clamp.controlloop.ControlLoop:\n version: 1.0.1\n derived_from: tosca.nodetypes.Root\n properties:\n provider:\n type: string\n requred: false\n elements:\n type: list\n required: true\n entry_schema:\n type: onap.datatypes.ToscaConceptIdentifier\n org.onap.policy.clamp.controlloop.K8SMicroserviceControlLoopElement:\n version: 1.0.1\n derived_from: org.onap.policy.clamp.controlloop.ControlLoopElement\n properties:\n chart:\n type: string\n required: true\n configs:\n type: list\n required: false\n requirements:\n type: string\n requred: false\n templates:\n type: list\n required: false\n entry_schema:\n values:\n type: string\n requred: true\n \n org.onap.policy.clamp.controlloop.HttpControlLoopElement:\n version: 1.0.1\n derived_from: org.onap.policy.clamp.controlloop.ControlLoopElement\n properties:\n baseUrl:\n type: string\n required: true\n description: The base URL to be prepended to each path, identifies the host for the REST endpoints.\n httpHeaders:\n type: map\n required: false\n entry_schema:\n type: string\n description: HTTP headers to send on REST requests\n configurationEntities:\n type: map\n required: true\n entry_schema:\n type: org.onap.datatypes.policy.clamp.controlloop.httpControlLoopElement.ConfigurationEntity\n typeVersion: 1.0.0\n description: The connfiguration entities the Control Loop Element is managing and their associated REST requests \n \n \ntopology_template:\n node_templates:\n org.onap.k8s.controlloop.K8SControlLoopParticipant:\n version: 2.3.4\n type: org.onap.policy.clamp.controlloop.Participant\n type_version: 1.0.1\n description: Participant for K8S\n properties:\n provider: ONAP \n\n org.onap.domain.database.PMSH_K8SMicroserviceControlLoopElement: \n # Chart from new repository \n version: 1.2.3\n type: org.onap.policy.clamp.controlloop.K8SMicroserviceControlLoopElement\n type_version: 1.0.0\n description: Control loop element for the K8S microservice for PMSH\n properties:\n provider: ONAP\n participant_id:\n name: org.onap.k8s.controlloop.K8SControlLoopParticipant\n version: 2.3.4\n chart: \n chartId: \n name: dcae-pmsh \n version: 8.0.0\n namespace: onap \n releaseName: pmshms\n repository:\n repoName: chartmuseum\n protocol: http\n address: 10.152.183.120\n port: 80\n userName: onapinitializer\n password: demo123456!\n overrideParams:\n global.masterPassword: test\n \n \n\n org.onap.domain.database.Local_K8SMicroserviceControlLoopElement: \n # Chart installation without passing repository info \n version: 1.2.3\n type: org.onap.policy.clamp.controlloop.K8SMicroserviceControlLoopElement\n type_version: 1.0.0\n description: Control loop element for the K8S microservice for local chart\n properties:\n provider: ONAP\n participant_id:\n name: org.onap.k8s.controlloop.K8SControlLoopParticipant\n version: 2.3.4\n chart:\n chartId: \n name: nginx-ingress\n version: 0.9.1 \n releaseName: nginxms\n namespace: test \n \n org.onap.controlloop.HttpControlLoopParticipant:\n version: 2.3.4\n type: org.onap.policy.clamp.controlloop.Participant\n type_version: 1.0.1\n description: Participant for Http requests\n properties:\n provider: ONAP\n\n org.onap.domain.database.Http_PMSHMicroserviceControlLoopElement:\n # Consul http config for PMSH.\n version: 1.2.3\n type: org.onap.policy.clamp.controlloop.HttpControlLoopElement\n type_version: 1.0.1\n description: Control loop element for the http requests of PMSH microservice\n properties:\n provider: ONAP\n participant_id:\n name: org.onap.controlloop.HttpControlLoopParticipant\n version: 2.3.4\n uninitializedToPassiveTimeout: 180\n baseUrl: http://10.152.183.51:8500\n httpHeaders:\n Content-Type: application/json\n configurationEntities:\n - configurationEntityId:\n name: entity1\n version: 1.0.1\n restSequence:\n - restRequestId:\n name: request1\n version: 1.0.1\n httpMethod: PUT\n path: v1/kv/dcae-pmsh2\n body: '{\n \"control_loop_name\":\"pmsh-control-loop\",\n \"operational_policy_name\":\"pmsh-operational-policy\",\n \"aaf_password\":\"demo123456!\",\n \"aaf_identity\":\"dcae@dcae.onap.org\",\n \"cert_path\":\"/opt/app/pmsh/etc/certs/cert.pem\",\n \"key_path\":\"/opt/app/pmsh/etc/certs/key.pem\",\n \"ca_cert_path\":\"/opt/app/pmsh/etc/certs/cacert.pem\",\n \"enable_tls\":\"true\",\n \"pmsh_policy\":{\n \"subscription\":{\n \"subscriptionName\":\"ExtraPM-All-gNB-R2B\",\n \"administrativeState\":\"UNLOCKED\",\n \"fileBasedGP\":15,\n \"fileLocation\":\"\\/pm\\/pm.xml\",\n \"nfFilter\":{\n \"nfNames\":[\n \"^pnf.*\",\n \"^vnf.*\"\n ],\n \"modelInvariantIDs\":[\n ],\n \"modelVersionIDs\":[\n ],\n \"modelNames\":[\n ]\n },\n \"measurementGroups\":[\n {\n \"measurementGroup\":{\n \"measurementTypes\":[\n {\n \"measurementType\":\"countera\"\n },\n {\n \"measurementType\":\"counterb\"\n }\n ],\n \"managedObjectDNsBasic\":[\n {\n \"DN\":\"dna\"\n },\n {\n \"DN\":\"dnb\"\n }\n ]\n }\n },\n {\n \"measurementGroup\":{\n \"measurementTypes\":[\n {\n \"measurementType\":\"counterc\"\n },\n {\n \"measurementType\":\"counterd\"\n }\n ],\n \"managedObjectDNsBasic\":[\n {\n \"DN\":\"dnc\"\n },\n {\n \"DN\":\"dnd\"\n }\n ]\n }\n }\n ]\n }\n },\n \"streams_subscribes\":{\n \"aai_subscriber\":{\n \"type\":\"message_router\",\n \"dmaap_info\":{\n \"topic_url\":\"https://10.152.183.151:3905/events/AAI_EVENT\",\n \"client_role\":\"org.onap.dcae.aaiSub\",\n \"location\":\"san-francisco\",\n \"client_id\":\"1575976809466\"\n }\n },\n \"policy_pm_subscriber\":{\n \"type\":\"message_router\",\n \"dmaap_info\":{\n \"topic_url\":\"https://10.152.183.151:3905/events/org.onap.dmaap.mr.PM_SUBSCRIPTIONS\",\n \"client_role\":\"org.onap.dcae.pmSubscriber\",\n \"location\":\"san-francisco\",\n \"client_id\":\"1575876809456\"\n }\n }\n },\n \"streams_publishes\":{\n \"policy_pm_publisher\":{\n \"type\":\"message_router\",\n \"dmaap_info\":{\n \"topic_url\":\"https://10.152.183.151:3905/events/org.onap.dmaap.mr.PM_SUBSCRIPTIONS\",\n \"client_role\":\"org.onap.dcae.pmPublisher\",\n \"location\":\"san-francisco\",\n \"client_id\":\"1475976809466\"\n }\n },\n \"other_publisher\":{\n \"type\":\"message_router\",\n \"dmaap_info\":{\n \"topic_url\":\"https://10.152.183.151:3905/events/org.onap.dmaap.mr.SOME_OTHER_TOPIC\",\n \"client_role\":\"org.onap.dcae.pmControlPub\",\n \"location\":\"san-francisco\",\n \"client_id\":\"1875976809466\"\n }\n }\n }\n }'\n expectedResponse: 200\n \n\n org.onap.domain.sample.GenericK8s_ControlLoopDefinition:\n version: 1.2.3\n type: org.onap.policy.clamp.controlloop.ControlLoop\n type_version: 1.0.0\n description: Control loop for Hello World\n properties:\n provider: ONAP\n elements: \n - name: org.onap.domain.database.PMSH_K8SMicroserviceControlLoopElement\n version: 1.2.3 \n - name: org.onap.domain.database.Local_K8SMicroserviceControlLoopElement\n version: 1.2.3 \n - name: org.onap.domain.database.Http_PMSHMicroserviceControlLoopElement\n version: 1.2.3\n ", + "disabled": false + }, + "description": "" + }, + "response": [ + { + "header": [], + "code": 200, + "name": "Response_200", + "id": "d120b824-7fb5-478b-92a3-4d06b92bd00f" + } + ] + } + ], + "variable": [], + "auth": { + "type": "basic", + "basic": { + "username": "runtimeUser", + "password": "zb!XztG34" + } + } +} \ No newline at end of file diff --git a/common/src/test/resources/examples/acm/PMSH/pmsh_cloudify_blueprint.yaml b/common/src/test/resources/examples/acm/PMSH/pmsh_cloudify_blueprint.yaml new file mode 100644 index 000000000..7cdc6d5b9 --- /dev/null +++ b/common/src/test/resources/examples/acm/PMSH/pmsh_cloudify_blueprint.yaml @@ -0,0 +1,176 @@ +# +# ============LICENSE_START======================================================= +# Copyright (C) 2020 Nordix Foundation. +# ================================================================================ +# Licensed under the Apache License, Version 2.0 (the 'License'); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an 'AS IS' BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# SPDX-License-Identifier: Apache-2.0 +# ============LICENSE_END========================================================= +# + +tosca_definitions_version: cloudify_dsl_1_3 + +imports: + - https://www.getcloudify.org/spec/cloudify/4.5.5/types.yaml + # - plugin:k8splugin?version=>=3.4.3,<4.0.0 + - plugin:k8splugin?version=3.7.0 + - plugin:pgaas?version=1.3.0 + - plugin:clamppolicyplugin?version=1.1.0 +inputs: + tag_version: + type: string + description: Docker image to be used + default: 'nexus3.onap.org:10001/onap/org.onap.dcaegen2.services.pmsh:1.1.2' + replicas: + type: integer + description: Number of instances + default: 1 + operational_policy_name: + type: string + default: 'pmsh-operational-policy' + control_loop_name: + type: string + default: 'pmsh-control-loop' + pmsh_publish_topic_name: + type: string + default: 'unauthenticated.DCAE_CL_OUTPUT' + policy_feedback_topic_name: + type: string + default: 'unauthenticated.PMSH_CL_INPUT' + aai_notification_topic_name: + type: string + default: 'AAI-EVENT' + publisher_client_role: + type: string + description: Client role to request secure access to topic + default: 'org.onap.dcae.pmPublisher' + subscriber_client_role: + type: string + description: Client role to request secure access to topic + default: 'org.onap.dcae.pmSubscriber' + dcae_location: + type: string + description: DCAE location for the subscriber, used to set up routing + default: 'san-francisco' + cpu_limit: + type: string + default: '1000m' + cpu_request: + type: string + default: '1000m' + memory_limit: + type: string + default: '1024Mi' + memory_request: + type: string + default: '1024Mi' + pgaas_cluster_name: + type: string + default: 'dcae-pg-primary.onap' + enable_tls: + type: boolean + default: true + protocol: + type: string + description: PMSH protocol. If enable_tls is false, set to http + default: 'https' + policy_model_id: + type: 'string' + default: 'onap.policies.monitoring.dcae-pm-subscription-handler' + policy_id: + type: 'string' + default: 'onap.policies.monitoring.dcae-pm-subscription-handler' +node_templates: + pgaasvm: + type: dcae.nodes.pgaas.database + properties: + writerfqdn: { get_input: pgaas_cluster_name } + name: 'pmsh' + pmsh: + type: dcae.nodes.ContainerizedServiceComponentUsingDmaap + interfaces: + cloudify.interfaces.lifecycle: + create: + inputs: + ports: + - '8443:0' + envs: + PMSH_PG_URL: + { get_attribute: [ pgaasvm, admin, host ] } + PMSH_PG_PASSWORD: + { get_attribute: [ pgaasvm, admin, password ] } + PMSH_PG_USERNAME: + { get_attribute: [ pgaasvm, admin, user ] } + PMSH_DB_NAME: + { get_attribute: [ pgaasvm, admin, database ] } + + relationships: + - target: pmsh-policy + type: cloudify.relationships.depends_on + + properties: + service_component_type: 'dcae-pmsh' + service_component_name_override: 'dcae-pmsh' + application_config: + enable_tls: { get_input: enable_tls } + aaf_identity: 'dcae@dcae.onap.org' + aaf_password: 'demo123456!' + operational_policy_name: { get_input: operational_policy_name } + control_loop_name: { get_input: control_loop_name } + cert_path: '/opt/app/pmsh/etc/certs/cert.pem' + key_path: '/opt/app/pmsh/etc/certs/key.pem' + ca_cert_path: '/opt/app/pmsh/etc/certs/cacert.pem' + streams_publishes: + policy_pm_publisher: + type: message_router + dmaap_info: + #topic_url: {concat: ["https://message-router:3905/events/", { get_input: pmsh_publish_topic_name }]} + topic_url: { concat: [ "http://message-router:3904/events/", { get_input: pmsh_publish_topic_name } ] } + streams_subscribes: + policy_pm_subscriber: + type: message_router + dmaap_info: + #topic_url: {concat: ["https://message-router:3905/events/", { get_input: policy_feedback_topic_name }]} + topic_url: {concat: ["http://message-router:3904/events/", { get_input: policy_feedback_topic_name }]} + aai_subscriber: + type: message_router + dmaap_info: + #topic_url: {concat: ["https://message-router:3905/events/", { get_input: aai_notification_topic_name }]} + topic_url: {concat: ["http://message-router:3904/events/", { get_input: aai_notification_topic_name }]} + resource_config: + limits: + cpu: { get_input: cpu_limit } + memory: { get_input: memory_limit } + requests: + cpu: { get_input: cpu_request } + memory: { get_input: memory_request } + docker_config: + healthcheck: + endpoint: /healthcheck + interval: 15s + timeout: 1s + type: { get_input: protocol } + image: { get_input: tag_version } + replicas: { get_input: replicas } + log_info: + log_directory: '/var/log/ONAP/dcaegen2/services/pmsh' + tls_info: + cert_directory: '/opt/app/pmsh/etc/certs' + use_tls: { get_input: enable_tls } + pmsh-policy: + type: clamp.nodes.policy + properties: + policy_model_id: + get_input: policy_model_id + policy_id: + get_input: policy_id diff --git a/common/src/test/resources/examples/acm/PMSH/pmsh_monitoring_policy.json b/common/src/test/resources/examples/acm/PMSH/pmsh_monitoring_policy.json new file mode 100644 index 000000000..5b64b5b6f --- /dev/null +++ b/common/src/test/resources/examples/acm/PMSH/pmsh_monitoring_policy.json @@ -0,0 +1,123 @@ +{ + "tosca_definitions_version": "tosca_simple_yaml_1_1_0", + "topology_template": { + "policies": [ + { + "MICROSERVICE_vLoadBalancerMS_v1_0_dcae-pm-subscription-handler_1_0_0test": { + "type": "onap.policies.monitoring.dcae-pm-subscription-handler", + "type_version": "1.0.0", + "properties": { + "pmsh_policy": { + "measurementGroups": [ + { + "measurementGroup": { + "onap.datatypes.monitoring.measurementGroup": { + "measurementTypes": [ + { + "measurementType": { + "onap.datatypes.monitoring.measurementType": { + "measurementType": "countera" + } + } + }, + { + "measurementType": { + "onap.datatypes.monitoring.measurementType": { + "measurementType": "counterb" + } + } + } + ], + "managedObjectDNsBasic": [ + { + "managedObjectDNsBasic": { + "onap.datatypes.monitoring.managedObjectDNsBasic": { + "DN": "dna" + } + } + }, + { + "managedObjectDNsBasic": { + "onap.datatypes.monitoring.managedObjectDNsBasic": { + "DN": "dnb" + } + } + } + ] + } + } + }, + { + "measurementGroup": { + "onap.datatypes.monitoring.measurementGroup": { + "measurementTypes": [ + { + "measurementType": { + "onap.datatypes.monitoring.measurementType": { + "measurementType": "counterc" + } + } + }, + { + "measurementType": { + "onap.datatypes.monitoring.measurementType": { + "measurementType": "counterd" + } + } + } + ], + "managedObjectDNsBasic": [ + { + "managedObjectDNsBasic": { + "onap.datatypes.monitoring.managedObjectDNsBasic": { + "DN": "dnc" + } + } + }, + { + "managedObjectDNsBasic": { + "onap.datatypes.monitoring.managedObjectDNsBasic": { + "DN": "dnd" + } + } + } + ] + } + } + } + ], + "fileBasedGP": 15, + "fileLocation": "/pm/pm.xml", + "subscriptionName": "subscriptiona", + "administrativeState": "UNLOCKED", + "nfFilter": { + "onap.datatypes.monitoring.nfFilter": { + "modelVersionIDs": [ + "e80a6ae3-cafd-4d24-850d-e14c084a5ca9" + ], + "modelInvariantIDs": [ + "5845y423-g654-6fju-po78-8n53154532k6", + "7129e420-d396-4efb-af02-6b83499b12f8" + ], + "modelNames": [], + "nfNames": [ + "\"^pnf1.*\"" + ] + } + } + } + }, + "name": "MICROSERVICE_vLoadBalancerMS_v1_0_dcae-pm-subscription-handler_1_0_0test", + "version": "1.0.0", + "metadata": { + "policy-id": "MICROSERVICE_vLoadBalancerMS_v1_0_dcae-pm-subscription-handler_1_0_0test", + "policy-version": "1.0.0" + } + } + } + ] + }, + "name": "ToscaServiceTemplateSimple", + "version": "1.0.0", + "metadata": {} +} diff --git a/common/src/test/resources/examples/acm/PMSH/pmsh_monitoring_policy.yaml b/common/src/test/resources/examples/acm/PMSH/pmsh_monitoring_policy.yaml new file mode 100644 index 000000000..6021f36bc --- /dev/null +++ b/common/src/test/resources/examples/acm/PMSH/pmsh_monitoring_policy.yaml @@ -0,0 +1,64 @@ +--- +tosca_definitions_version: tosca_simple_yaml_1_1_0 +name: ToscaServiceTemplateSimple +version: 1.0.0 +metadata: {} +topology_template: + policies: + - MICROSERVICE_vLoadBalancerMS_v1_0_dcae-pm-subscription-handler_1_0_0test: + type: onap.policies.monitoring.dcae-pm-subscription-handler + type_version: 1.0.0 + name: MICROSERVICE_vLoadBalancerMS_v1_0_dcae-pm-subscription-handler_1_0_0test + version: 1.0.0 + metadata: + policy-id: MICROSERVICE_vLoadBalancerMS_v1_0_dcae-pm-subscription-handler_1_0_0test + policy-version: 1.0.0 + properties: + pmsh_policy: + fileBasedGP: 15 + fileLocation: "/pm/pm.xml" + subscriptionName: subscriptiona + administrativeState: UNLOCKED + nfFilter: + onap.datatypes.monitoring.nfFilter: + modelVersionIDs: + - e80a6ae3-cafd-4d24-850d-e14c084a5ca9 + modelInvariantIDs: + - 5845y423-g654-6fju-po78-8n53154532k6 + - 7129e420-d396-4efb-af02-6b83499b12f8 + modelNames: [] + nfNames: + - '"^pnf1.*"' + measurementGroups: + - measurementGroup: + onap.datatypes.monitoring.measurementGroup: + measurementTypes: + - measurementType: + onap.datatypes.monitoring.measurementType: + measurementType: countera + - measurementType: + onap.datatypes.monitoring.measurementType: + measurementType: counterb + managedObjectDNsBasic: + - managedObjectDNsBasic: + onap.datatypes.monitoring.managedObjectDNsBasic: + DN: dna + - managedObjectDNsBasic: + onap.datatypes.monitoring.managedObjectDNsBasic: + DN: dnb + - measurementGroup: + onap.datatypes.monitoring.measurementGroup: + measurementTypes: + - measurementType: + onap.datatypes.monitoring.measurementType: + measurementType: counterc + - measurementType: + onap.datatypes.monitoring.measurementType: + measurementType: counterd + managedObjectDNsBasic: + - managedObjectDNsBasic: + onap.datatypes.monitoring.managedObjectDNsBasic: + DN: dnc + - managedObjectDNsBasic: + onap.datatypes.monitoring.managedObjectDNsBasic: + DN: dnd diff --git a/common/src/test/resources/examples/acm/PMSH/pmsh_monitoring_policy_type.yaml b/common/src/test/resources/examples/acm/PMSH/pmsh_monitoring_policy_type.yaml new file mode 100644 index 000000000..e282bf5ba --- /dev/null +++ b/common/src/test/resources/examples/acm/PMSH/pmsh_monitoring_policy_type.yaml @@ -0,0 +1,264 @@ +tosca_definitions_version: tosca_simple_yaml_1_1_0 +name: ToscaServiceTemplateSimple +version: 1.0.0 +metadata: {} +policy_types: + onap.policies.Monitoring: + derived_from: tosca.policies.Root + description: a base policy type for all policies that govern monitoring provisioning + version: 1.0.0 + name: onap.policies.Monitoring + onap.policies.monitoring.dcae-pm-subscription-handler: + name: onap.policies.monitoring.dcae-pm-subscription-handler + version: 1.0.0 + derived_from: onap.policies.Monitoring + metadata: {} + properties: + pmsh_policy: + name: pmsh_policy + type: onap.datatypes.monitoring.subscription + typeVersion: 0.0.0 + description: PMSH Policy JSON + required: false + constraints: [] + metadata: {} +data_types: + onap.datatypes.monitoring.managedObjectDNsBasic: + name: onap.datatypes.monitoring.managedObjectDNsBasic + version: 0.0.0 + derived_from: tosca.datatypes.Root + metadata: {} + constraints: [] + properties: + DN: + name: DN + type: string + typeVersion: 0.0.0 + description: Managed object distinguished name + required: true + constraints: [] + metadata: {} + onap.datatypes.monitoring.managedObjectDNsBasics: + name: onap.datatypes.monitoring.managedObjectDNsBasics + version: 0.0.0 + derived_from: tosca.datatypes.Root + metadata: {} + constraints: [] + properties: + managedObjectDNsBasic: + name: managedObjectDNsBasic + type: map + typeVersion: 0.0.0 + description: Managed object distinguished name object + required: true + constraints: [] + entry_schema: + type: onap.datatypes.monitoring.managedObjectDNsBasic + typeVersion: 0.0.0 + constraints: [] + metadata: {} + onap.datatypes.monitoring.measurementGroup: + name: onap.datatypes.monitoring.measurementGroup + version: 0.0.0 + derived_from: tosca.datatypes.Root + metadata: {} + constraints: [] + properties: + measurementTypes: + name: measurementTypes + type: list + typeVersion: 0.0.0 + description: List of measurement types + required: true + constraints: [] + entry_schema: + type: onap.datatypes.monitoring.measurementTypes + typeVersion: 0.0.0 + constraints: [] + metadata: {} + managedObjectDNsBasic: + name: managedObjectDNsBasic + type: list + typeVersion: 0.0.0 + description: List of managed object distinguished names + required: true + constraints: [] + entry_schema: + type: onap.datatypes.monitoring.managedObjectDNsBasics + typeVersion: 0.0.0 + constraints: [] + metadata: {} + onap.datatypes.monitoring.measurementGroups: + name: onap.datatypes.monitoring.measurementGroups + version: 0.0.0 + derived_from: tosca.datatypes.Root + metadata: {} + constraints: [] + properties: + measurementGroup: + name: measurementGroup + type: map + typeVersion: 0.0.0 + description: Measurement Group + required: true + constraints: [] + entry_schema: + type: onap.datatypes.monitoring.measurementGroup + typeVersion: 0.0.0 + constraints: [] + metadata: {} + onap.datatypes.monitoring.measurementType: + name: onap.datatypes.monitoring.measurementType + version: 0.0.0 + derived_from: tosca.datatypes.Root + metadata: {} + constraints: [] + properties: + measurementType: + name: measurementType + type: string + typeVersion: 0.0.0 + description: Measurement type + required: true + constraints: [] + metadata: {} + onap.datatypes.monitoring.measurementTypes: + name: onap.datatypes.monitoring.measurementTypes + version: 0.0.0 + derived_from: tosca.datatypes.Root + metadata: {} + constraints: [] + properties: + measurementType: + name: measurementType + type: map + typeVersion: 0.0.0 + description: Measurement type object + required: true + constraints: [] + entry_schema: + type: onap.datatypes.monitoring.measurementType + typeVersion: 0.0.0 + constraints: [] + metadata: {} + onap.datatypes.monitoring.nfFilter: + name: onap.datatypes.monitoring.nfFilter + version: 0.0.0 + derived_from: tosca.datatypes.Root + metadata: {} + constraints: [] + properties: + modelNames: + name: modelNames + type: list + typeVersion: 0.0.0 + description: List of model names + required: true + constraints: [] + entry_schema: + type: string + typeVersion: 0.0.0 + constraints: [] + metadata: {} + modelInvariantIDs: + name: modelInvariantIDs + type: list + typeVersion: 0.0.0 + description: List of model invariant IDs + required: true + constraints: [] + entry_schema: + type: string + typeVersion: 0.0.0 + constraints: [] + metadata: {} + modelVersionIDs: + name: modelVersionIDs + type: list + typeVersion: 0.0.0 + description: List of model version IDs + required: true + constraints: [] + entry_schema: + type: string + typeVersion: 0.0.0 + constraints: [] + metadata: {} + nfNames: + name: nfNames + type: list + typeVersion: 0.0.0 + description: List of network functions + required: true + constraints: [] + entry_schema: + type: string + typeVersion: 0.0.0 + constraints: [] + metadata: {} + onap.datatypes.monitoring.subscription: + name: onap.datatypes.monitoring.subscription + version: 0.0.0 + derived_from: tosca.datatypes.Root + metadata: {} + constraints: [] + properties: + measurementGroups: + name: measurementGroups + type: list + typeVersion: 0.0.0 + description: Measurement Groups + required: true + constraints: [] + entry_schema: + type: onap.datatypes.monitoring.measurementGroups + typeVersion: 0.0.0 + constraints: [] + metadata: {} + fileBasedGP: + name: fileBasedGP + type: integer + typeVersion: 0.0.0 + description: File based granularity period + required: true + constraints: [] + metadata: {} + fileLocation: + name: fileLocation + type: string + typeVersion: 0.0.0 + description: ROP file location + required: true + constraints: [] + metadata: {} + subscriptionName: + name: subscriptionName + type: string + typeVersion: 0.0.0 + description: Name of the subscription + required: true + constraints: [] + metadata: {} + administrativeState: + name: administrativeState + type: string + typeVersion: 0.0.0 + description: State of the subscription + required: true + constraints: + - valid_values: + - LOCKED + - UNLOCKED + metadata: {} + nfFilter: + name: nfFilter + type: map + typeVersion: 0.0.0 + description: Network function filter + required: true + constraints: [] + entry_schema: + type: onap.datatypes.monitoring.nfFilter + typeVersion: 0.0.0 + constraints: [] + metadata: {} diff --git a/common/src/test/resources/examples/acm/PMSH/pmsh_operational_policy.json b/common/src/test/resources/examples/acm/PMSH/pmsh_operational_policy.json new file mode 100644 index 000000000..6bd681d71 --- /dev/null +++ b/common/src/test/resources/examples/acm/PMSH/pmsh_operational_policy.json @@ -0,0 +1,2808 @@ +{ + "tosca_definitions_version":"tosca_simple_yaml_1_1_0", + "topology_template":{ + "policies":[ + { + "operational.apex.pmcontrol":{ + "type":"onap.policies.controlloop.operational.Apex", + "type_version":"1.0.0", + "version":"1.0.0", + "metadata":{ + "policy-id":"operational.apex.pmcontrol", + "policy-version":1 + }, + "properties":{ + "engineServiceParameters":{ + "name":"MyApexEngine", + "version":"0.0.1", + "id":45, + "instanceCount":2, + "deploymentPort":12561, + "policy_type_impl":{ + "apexPolicyModel":{ + "key":{ + "name":"PMControlPolicy", + "version":"0.0.1" + }, + "keyInformation":{ + "key":{ + "name":"PMControlPolicy_KeyInfo", + "version":"0.0.1" + }, + "keyInfoMap":{ + "entry":[ + { + "key":{ + "name":"CDSActionIdentifiersType", + "version":"0.0.1" + }, + "value":{ + "key":{ + "name":"CDSActionIdentifiersType", + "version":"0.0.1" + }, + "UUID":"6e5fa19b-14df-37e3-a4ae-8c537e861a82", + "description":"Generated description for concept referred to by key \"CDSActionIdentifiersType:0.0.1\"" + } + }, + { + "key":{ + "name":"CDSCreateResponseEvent", + "version":"0.0.1" + }, + "value":{ + "key":{ + "name":"CDSCreateResponseEvent", + "version":"0.0.1" + }, + "UUID":"14b29e38-ac75-3273-aa4e-8583c0aa7dad", + "description":"Generated description for concept referred to by key \"CDSCreateResponseEvent:0.0.1\"" + } + }, + { + "key":{ + "name":"CDSCreateResponsePayloadType", + "version":"0.0.1" + }, + "value":{ + "key":{ + "name":"CDSCreateResponsePayloadType", + "version":"0.0.1" + }, + "UUID":"04573f8f-e772-30a5-b1d9-d7318d4a1e13", + "description":"Generated description for concept referred to by key \"CDSCreateResponsePayloadType:0.0.1\"" + } + }, + { + "key":{ + "name":"CDSCreateResponsePolicy", + "version":"0.0.1" + }, + "value":{ + "key":{ + "name":"CDSCreateResponsePolicy", + "version":"0.0.1" + }, + "UUID":"e126c965-fc09-3bfe-8f55-70f380a4a49c", + "description":"Generated description for concept referred to by key \"CDSCreateResponsePolicy:0.0.1\"" + } + }, + { + "key":{ + "name":"CDSCreateResponseTask", + "version":"0.0.1" + }, + "value":{ + "key":{ + "name":"CDSCreateResponseTask", + "version":"0.0.1" + }, + "UUID":"6165ee82-afd2-3aab-a517-f00b3f2461d2", + "description":"Generated description for concept referred to by key \"CDSCreateResponseTask:0.0.1\"" + } + }, + { + "key":{ + "name":"CDSCreateSubscriptionPayloadType", + "version":"0.0.1" + }, + "value":{ + "key":{ + "name":"CDSCreateSubscriptionPayloadType", + "version":"0.0.1" + }, + "UUID":"8350ac5e-c157-38b9-9614-a0f93a830e60", + "description":"Generated description for concept referred to by key \"CDSCreateSubscriptionPayloadType:0.0.1\"" + } + }, + { + "key":{ + "name":"CDSCreateSubscriptionRequestEvent", + "version":"0.0.1" + }, + "value":{ + "key":{ + "name":"CDSCreateSubscriptionRequestEvent", + "version":"0.0.1" + }, + "UUID":"cfa325ba-226b-3a31-9183-ec43e2b6e9a2", + "description":"Generated description for concept referred to by key \"CDSCreateSubscriptionRequestEvent:0.0.1\"" + } + }, + { + "key":{ + "name":"CDSDeleteResponseEvent", + "version":"0.0.1" + }, + "value":{ + "key":{ + "name":"CDSDeleteResponseEvent", + "version":"0.0.1" + }, + "UUID":"8be9c0fa-7437-3841-aff2-b3cec6ae3bd8", + "description":"Generated description for concept referred to by key \"CDSDeleteResponseEvent:0.0.1\"" + } + }, + { + "key":{ + "name":"CDSDeleteResponsePayloadType", + "version":"0.0.1" + }, + "value":{ + "key":{ + "name":"CDSDeleteResponsePayloadType", + "version":"0.0.1" + }, + "UUID":"3fbfe0c9-152e-34d3-a504-09cd13c058d0", + "description":"Generated description for concept referred to by key \"CDSDeleteResponsePayloadType:0.0.1\"" + } + }, + { + "key":{ + "name":"CDSDeleteResponsePolicy", + "version":"0.0.1" + }, + "value":{ + "key":{ + "name":"CDSDeleteResponsePolicy", + "version":"0.0.1" + }, + "UUID":"a780251c-edd5-3132-b865-04313246b43c", + "description":"Generated description for concept referred to by key \"CDSDeleteResponsePolicy:0.0.1\"" + } + }, + { + "key":{ + "name":"CDSDeleteResponseTask", + "version":"0.0.1" + }, + "value":{ + "key":{ + "name":"CDSDeleteResponseTask", + "version":"0.0.1" + }, + "UUID":"afce4555-3aa3-3521-a7d8-ee8cdf0d3efc", + "description":"Generated description for concept referred to by key \"CDSDeleteResponseTask:0.0.1\"" + } + }, + { + "key":{ + "name":"CDSDeleteSubscriptionPayloadType", + "version":"0.0.1" + }, + "value":{ + "key":{ + "name":"CDSDeleteSubscriptionPayloadType", + "version":"0.0.1" + }, + "UUID":"12658406-9147-3c9d-a38c-5ad5e30b092b", + "description":"Generated description for concept referred to by key \"CDSDeleteSubscriptionPayloadType:0.0.1\"" + } + }, + { + "key":{ + "name":"CDSDeleteSubscriptionRequestEvent", + "version":"0.0.1" + }, + "value":{ + "key":{ + "name":"CDSDeleteSubscriptionRequestEvent", + "version":"0.0.1" + }, + "UUID":"24380c95-9289-36e6-8cbf-0edefa15ccd9", + "description":"Generated description for concept referred to by key \"CDSDeleteSubscriptionRequestEvent:0.0.1\"" + } + }, + { + "key":{ + "name":"CDSRequestCommonHeaderType", + "version":"0.0.1" + }, + "value":{ + "key":{ + "name":"CDSRequestCommonHeaderType", + "version":"0.0.1" + }, + "UUID":"35590ac0-062c-39f1-8786-b4ff716e30b1", + "description":"Generated description for concept referred to by key \"CDSRequestCommonHeaderType:0.0.1\"" + } + }, + { + "key":{ + "name":"CDSResponseCommonHeaderType", + "version":"0.0.1" + }, + "value":{ + "key":{ + "name":"CDSResponseCommonHeaderType", + "version":"0.0.1" + }, + "UUID":"dd7e1805-885a-350b-aaf9-ed541321ae3c", + "description":"Generated description for concept referred to by key \"CDSResponseCommonHeaderType:0.0.1\"" + } + }, + { + "key":{ + "name":"CDSResponseStatusEvent", + "version":"0.0.1" + }, + "value":{ + "key":{ + "name":"CDSResponseStatusEvent", + "version":"0.0.1" + }, + "UUID":"7986e21b-32f7-302e-9554-31f21b673493", + "description":"Generated description for concept referred to by key \"CDSResponseStatusEvent:0.0.1\"" + } + }, + { + "key":{ + "name":"CDSResponseStatusType", + "version":"0.0.1" + }, + "value":{ + "key":{ + "name":"CDSResponseStatusType", + "version":"0.0.1" + }, + "UUID":"92b8a2cf-344e-3ce1-8cc0-2b7d3cb695fa", + "description":"Generated description for concept referred to by key \"CDSResponseStatusType:0.0.1\"" + } + }, + { + "key":{ + "name":"CreateSubscriptionPayloadEvent", + "version":"0.0.1" + }, + "value":{ + "key":{ + "name":"CreateSubscriptionPayloadEvent", + "version":"0.0.1" + }, + "UUID":"92162397-1a8e-3a3f-a469-d2af7700af4a", + "description":"Generated description for concept referred to by key \"CreateSubscriptionPayloadEvent:0.0.1\"" + } + }, + { + "key":{ + "name":"CreateSubscriptionPayloadTask", + "version":"0.0.1" + }, + "value":{ + "key":{ + "name":"CreateSubscriptionPayloadTask", + "version":"0.0.1" + }, + "UUID":"bc0c69f0-52ed-38ea-b468-ae4a6fd1730d", + "description":"Generated description for concept referred to by key \"CreateSubscriptionPayloadTask:0.0.1\"" + } + }, + { + "key":{ + "name":"CreateSubscriptionRequestTask", + "version":"0.0.1" + }, + "value":{ + "key":{ + "name":"CreateSubscriptionRequestTask", + "version":"0.0.1" + }, + "UUID":"89cb75e9-f06c-30d3-b4ff-698d45f63869", + "description":"Generated description for concept referred to by key \"CreateSubscriptionRequestTask:0.0.1\"" + } + }, + { + "key":{ + "name":"DeleteSubscriptionPayloadEvent", + "version":"0.0.1" + }, + "value":{ + "key":{ + "name":"DeleteSubscriptionPayloadEvent", + "version":"0.0.1" + }, + "UUID":"994fa441-04ab-33bb-832d-1cd12ab5d074", + "description":"Generated description for concept referred to by key \"DeleteSubscriptionPayloadEvent:0.0.1\"" + } + }, + { + "key":{ + "name":"DeleteSubscriptionPayloadTask", + "version":"0.0.1" + }, + "value":{ + "key":{ + "name":"DeleteSubscriptionPayloadTask", + "version":"0.0.1" + }, + "UUID":"0f519117-5fea-3e4b-941f-8f778100465f", + "description":"Generated description for concept referred to by key \"DeleteSubscriptionPayloadTask:0.0.1\"" + } + }, + { + "key":{ + "name":"DeleteSubscriptionRequestTask", + "version":"0.0.1" + }, + "value":{ + "key":{ + "name":"DeleteSubscriptionRequestTask", + "version":"0.0.1" + }, + "UUID":"acb772fe-d442-39e3-98f9-b1080caf4150", + "description":"Generated description for concept referred to by key \"DeleteSubscriptionRequestTask:0.0.1\"" + } + }, + { + "key":{ + "name":"MRResponseEvent", + "version":"0.0.1" + }, + "value":{ + "key":{ + "name":"MRResponseEvent", + "version":"0.0.1" + }, + "UUID":"13c747a3-6bae-3bcf-9c80-b152e01dc194", + "description":"Generated description for concept referred to by key \"MRResponseEvent:0.0.1\"" + } + }, + { + "key":{ + "name":"PMControlPolicy", + "version":"0.0.1" + }, + "value":{ + "key":{ + "name":"PMControlPolicy", + "version":"0.0.1" + }, + "UUID":"acf1e55c-7bc5-3bd5-975a-0ca54afcd8a4", + "description":"Generated description for concept referred to by key \"PMControlPolicy:0.0.1\"" + } + }, + { + "key":{ + "name":"PMControlPolicy_Albums", + "version":"0.0.1" + }, + "value":{ + "key":{ + "name":"PMControlPolicy_Albums", + "version":"0.0.1" + }, + "UUID":"b38ad204-c2c8-32f4-9b5a-dda0aeb0145b", + "description":"Generated description for concept referred to by key \"PMControlPolicy_Albums:0.0.1\"" + } + }, + { + "key":{ + "name":"PMControlPolicy_Events", + "version":"0.0.1" + }, + "value":{ + "key":{ + "name":"PMControlPolicy_Events", + "version":"0.0.1" + }, + "UUID":"be3871a0-c42a-3113-a066-82d192840eca", + "description":"Generated description for concept referred to by key \"PMControlPolicy_Events:0.0.1\"" + } + }, + { + "key":{ + "name":"PMControlPolicy_KeyInfo", + "version":"0.0.1" + }, + "value":{ + "key":{ + "name":"PMControlPolicy_KeyInfo", + "version":"0.0.1" + }, + "UUID":"ced37634-28a4-3178-b7f6-2980794927b0", + "description":"Generated description for concept referred to by key \"PMControlPolicy_KeyInfo:0.0.1\"" + } + }, + { + "key":{ + "name":"PMControlPolicy_Policies", + "version":"0.0.1" + }, + "value":{ + "key":{ + "name":"PMControlPolicy_Policies", + "version":"0.0.1" + }, + "UUID":"be3d180d-ef9c-3a75-8e9c-84271a038bed", + "description":"Generated description for concept referred to by key \"PMControlPolicy_Policies:0.0.1\"" + } + }, + { + "key":{ + "name":"PMControlPolicy_Schemas", + "version":"0.0.1" + }, + "value":{ + "key":{ + "name":"PMControlPolicy_Schemas", + "version":"0.0.1" + }, + "UUID":"e61973f1-189c-39e5-82f6-0d3afe298a20", + "description":"Generated description for concept referred to by key \"PMControlPolicy_Schemas:0.0.1\"" + } + }, + { + "key":{ + "name":"PMControlPolicy_Tasks", + "version":"0.0.1" + }, + "value":{ + "key":{ + "name":"PMControlPolicy_Tasks", + "version":"0.0.1" + }, + "UUID":"5658adb3-2962-30a3-a241-fae75bb8eb4a", + "description":"Generated description for concept referred to by key \"PMControlPolicy_Tasks:0.0.1\"" + } + }, + { + "key":{ + "name":"PMSubscriptionAlbum", + "version":"0.0.1" + }, + "value":{ + "key":{ + "name":"PMSubscriptionAlbum", + "version":"0.0.1" + }, + "UUID":"c2bd6f0d-6854-317a-9be2-97c08338428c", + "description":"Generated description for concept referred to by key \"PMSubscriptionAlbum:0.0.1\"" + } + }, + { + "key":{ + "name":"PMSubscriptionOutputEvent", + "version":"0.0.1" + }, + "value":{ + "key":{ + "name":"PMSubscriptionOutputEvent", + "version":"0.0.1" + }, + "UUID":"992b7819-9f69-3aa0-bb0f-6e45ea15ce05", + "description":"Generated description for concept referred to by key \"PMSubscriptionOutputEvent:0.0.1\"" + } + }, + { + "key":{ + "name":"PMSubscriptionType", + "version":"0.0.1" + }, + "value":{ + "key":{ + "name":"PMSubscriptionType", + "version":"0.0.1" + }, + "UUID":"73c1c397-4fc3-357f-93b6-a8ad707fbaae", + "description":"Generated description for concept referred to by key \"PMSubscriptionType:0.0.1\"" + } + }, + { + "key":{ + "name":"ReceiveEventPolicy", + "version":"0.0.1" + }, + "value":{ + "key":{ + "name":"ReceiveEventPolicy", + "version":"0.0.1" + }, + "UUID":"568b7345-9de1-36d3-b6a3-9b857e6809a1", + "description":"Generated description for concept referred to by key \"ReceiveEventPolicy:0.0.1\"" + } + }, + { + "key":{ + "name":"ReceiveSubscriptionTask", + "version":"0.0.1" + }, + "value":{ + "key":{ + "name":"ReceiveSubscriptionTask", + "version":"0.0.1" + }, + "UUID":"f596afc8-100c-35eb-92c8-352355ea457d", + "description":"Generated description for concept referred to by key \"ReceiveSubscriptionTask:0.0.1\"" + } + }, + { + "key":{ + "name":"SimpleIntType", + "version":"0.0.1" + }, + "value":{ + "key":{ + "name":"SimpleIntType", + "version":"0.0.1" + }, + "UUID":"153791fd-ae0a-36a7-88a5-309a7936415d", + "description":"Generated description for concept referred to by key \"SimpleIntType:0.0.1\"" + } + }, + { + "key":{ + "name":"SimpleStringType", + "version":"0.0.1" + }, + "value":{ + "key":{ + "name":"SimpleStringType", + "version":"0.0.1" + }, + "UUID":"8a4957cf-9493-3a76-8c22-a208e23259af", + "description":"Generated description for concept referred to by key \"SimpleStringType:0.0.1\"" + } + }, + { + "key":{ + "name":"SubscriptionStatusType", + "version":"0.0.1" + }, + "value":{ + "key":{ + "name":"SubscriptionStatusType", + "version":"0.0.1" + }, + "UUID":"597643b1-9db1-31ce-85d0-e1c63c43b30b", + "description":"Generated description for concept referred to by key \"SubscriptionStatusType:0.0.1\"" + } + }, + { + "key":{ + "name":"SubscriptionType", + "version":"0.0.1" + }, + "value":{ + "key":{ + "name":"SubscriptionType", + "version":"0.0.1" + }, + "UUID":"184547bb-7d64-3cb2-a273-d7185102c5ce", + "description":"Generated description for concept referred to by key \"SubscriptionType:0.0.1\"" + } + }, + { + "key":{ + "name":"UUIDType", + "version":"0.0.1" + }, + "value":{ + "key":{ + "name":"UUIDType", + "version":"0.0.1" + }, + "UUID":"6a8cc68e-dfc8-3403-9c6d-071c886b319c", + "description":"Generated description for concept referred to by key \"UUIDType:0.0.1\"" + } + }, + { + "key":{ + "name":"pmsh-operational-policy", + "version":"0.0.1" + }, + "value":{ + "key":{ + "name":"pmsh-operational-policy", + "version":"0.0.1" + }, + "UUID":"fdf2c9ff-6422-3ea6-b6b6-49b12116265d", + "description":"Generated description for concept referred to by key \"pmsh-operational-policy:0.0.1\"" + } + } + ] + } + }, + "policies":{ + "key":{ + "name":"PMControlPolicy_Policies", + "version":"0.0.1" + }, + "policyMap":{ + "entry":[ + { + "key":{ + "name":"CDSCreateResponsePolicy", + "version":"0.0.1" + }, + "value":{ + "policyKey":{ + "name":"CDSCreateResponsePolicy", + "version":"0.0.1" + }, + "template":"Freestyle", + "state":{ + "entry":[ + { + "key":"CDSCreateResponseState", + "value":{ + "stateKey":{ + "parentKeyName":"CDSCreateResponsePolicy", + "parentKeyVersion":"0.0.1", + "parentLocalName":"NULL", + "localName":"CDSCreateResponseState" + }, + "trigger":{ + "name":"CDSCreateResponseEvent", + "version":"0.0.1" + }, + "stateOutputs":{ + "entry":[ + { + "key":"ResponseOutput", + "value":{ + "key":{ + "parentKeyName":"CDSCreateResponsePolicy", + "parentKeyVersion":"0.0.1", + "parentLocalName":"CDSCreateResponseState", + "localName":"ResponseOutput" + }, + "outgoingEvent":{ + "name":"CDSResponseStatusEvent", + "version":"0.0.1" + }, + "nextState":{ + "parentKeyName":"NULL", + "parentKeyVersion":"0.0.0", + "parentLocalName":"NULL", + "localName":"NULL" + } + } + } + ] + }, + "contextAlbumReference":[ + + ], + "taskSelectionLogic":{ + "key":"NULL", + "logicFlavour":"UNDEFINED", + "logic":"" + }, + "stateFinalizerLogicMap":{ + "entry":[ + + ] + }, + "defaultTask":{ + "name":"CDSCreateResponseTask", + "version":"0.0.1" + }, + "taskReferences":{ + "entry":[ + { + "key":{ + "name":"CDSCreateResponseTask", + "version":"0.0.1" + }, + "value":{ + "key":{ + "parentKeyName":"CDSCreateResponsePolicy", + "parentKeyVersion":"0.0.1", + "parentLocalName":"CDSCreateResponseState", + "localName":"CDSCreateResponsePolicy" + }, + "outputType":"DIRECT", + "output":{ + "parentKeyName":"CDSCreateResponsePolicy", + "parentKeyVersion":"0.0.1", + "parentLocalName":"CDSCreateResponseState", + "localName":"ResponseOutput" + } + } + } + ] + } + } + } + ] + }, + "firstState":"CDSCreateResponseState" + } + }, + { + "key":{ + "name":"CDSDeleteResponsePolicy", + "version":"0.0.1" + }, + "value":{ + "policyKey":{ + "name":"CDSDeleteResponsePolicy", + "version":"0.0.1" + }, + "template":"Freestyle", + "state":{ + "entry":[ + { + "key":"CDSDeleteResponseState", + "value":{ + "stateKey":{ + "parentKeyName":"CDSDeleteResponsePolicy", + "parentKeyVersion":"0.0.1", + "parentLocalName":"NULL", + "localName":"CDSDeleteResponseState" + }, + "trigger":{ + "name":"CDSDeleteResponseEvent", + "version":"0.0.1" + }, + "stateOutputs":{ + "entry":[ + { + "key":"ResponseOutput", + "value":{ + "key":{ + "parentKeyName":"CDSDeleteResponsePolicy", + "parentKeyVersion":"0.0.1", + "parentLocalName":"CDSDeleteResponseState", + "localName":"ResponseOutput" + }, + "outgoingEvent":{ + "name":"CDSResponseStatusEvent", + "version":"0.0.1" + }, + "nextState":{ + "parentKeyName":"NULL", + "parentKeyVersion":"0.0.0", + "parentLocalName":"NULL", + "localName":"NULL" + } + } + } + ] + }, + "contextAlbumReference":[ + + ], + "taskSelectionLogic":{ + "key":"NULL", + "logicFlavour":"UNDEFINED", + "logic":"" + }, + "stateFinalizerLogicMap":{ + "entry":[ + + ] + }, + "defaultTask":{ + "name":"CDSDeleteResponseTask", + "version":"0.0.1" + }, + "taskReferences":{ + "entry":[ + { + "key":{ + "name":"CDSDeleteResponseTask", + "version":"0.0.1" + }, + "value":{ + "key":{ + "parentKeyName":"CDSDeleteResponsePolicy", + "parentKeyVersion":"0.0.1", + "parentLocalName":"CDSDeleteResponseState", + "localName":"CDSDeleteResponsePolicy" + }, + "outputType":"DIRECT", + "output":{ + "parentKeyName":"CDSDeleteResponsePolicy", + "parentKeyVersion":"0.0.1", + "parentLocalName":"CDSDeleteResponseState", + "localName":"ResponseOutput" + } + } + } + ] + } + } + } + ] + }, + "firstState":"CDSDeleteResponseState" + } + }, + { + "key":{ + "name":"ReceiveEventPolicy", + "version":"0.0.1" + }, + "value":{ + "policyKey":{ + "name":"ReceiveEventPolicy", + "version":"0.0.1" + }, + "template":"Freestyle", + "state":{ + "entry":[ + { + "key":"CreateOrDeleteState", + "value":{ + "stateKey":{ + "parentKeyName":"ReceiveEventPolicy", + "parentKeyVersion":"0.0.1", + "parentLocalName":"NULL", + "localName":"CreateOrDeleteState" + }, + "trigger":{ + "name":"PMSubscriptionOutputEvent", + "version":"0.0.1" + }, + "stateOutputs":{ + "entry":[ + { + "key":"CreateSubscriptionPayload", + "value":{ + "key":{ + "parentKeyName":"ReceiveEventPolicy", + "parentKeyVersion":"0.0.1", + "parentLocalName":"CreateOrDeleteState", + "localName":"CreateSubscriptionPayload" + }, + "outgoingEvent":{ + "name":"CreateSubscriptionPayloadEvent", + "version":"0.0.1" + }, + "nextState":{ + "parentKeyName":"ReceiveEventPolicy", + "parentKeyVersion":"0.0.1", + "parentLocalName":"NULL", + "localName":"CreateSubscription" + } + } + }, + { + "key":"DeleteSubscriptionPayload", + "value":{ + "key":{ + "parentKeyName":"ReceiveEventPolicy", + "parentKeyVersion":"0.0.1", + "parentLocalName":"CreateOrDeleteState", + "localName":"DeleteSubscriptionPayload" + }, + "outgoingEvent":{ + "name":"DeleteSubscriptionPayloadEvent", + "version":"0.0.1" + }, + "nextState":{ + "parentKeyName":"ReceiveEventPolicy", + "parentKeyVersion":"0.0.1", + "parentLocalName":"NULL", + "localName":"DeleteSubscription" + } + } + } + ] + }, + "contextAlbumReference":[ + { + "name":"PMSubscriptionAlbum", + "version":"0.0.1" + } + ], + "taskSelectionLogic":{ + "key":"TaskSelectionLogic", + "logicFlavour":"JAVASCRIPT", + "logic":"/*\n * ============LICENSE_START=======================================================\n * Copyright (C) 2020 Nordix. All rights reserved.\n * ================================================================================\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n *\n * SPDX-License-Identifier: Apache-2.0\n * ============LICENSE_END=========================================================\n */\n\nexecutor.logger.info(executor.subject.id);\n\nvar pmSubscriptionInfo = executor.getContextAlbum(\"PMSubscriptionAlbum\").get(executor.inFields.get(\"albumID\").toString())\nvar changeType = pmSubscriptionInfo.get(\"changeType\").toString()\n\nexecutor.logger.info(\"Change Type is \" + changeType)\n\nif (\"CREATE\".equals(changeType)) {\n executor.logger.info(\"Choosing to create a subscription\")\n executor.subject.getTaskKey(\"CreateSubscriptionPayloadTask\").copyTo(executor.selectedTask);\n}\nelse if (\"DELETE\".equals(changeType)) {\n executor.logger.info(\"Choosing to delete a subscription\")\n executor.subject.getTaskKey(\"DeleteSubscriptionPayloadTask\").copyTo(executor.selectedTask);\n}\n\n//var returnValue = executor.isTrue;\ntrue;" + }, + "stateFinalizerLogicMap":{ + "entry":[ + + ] + }, + "defaultTask":{ + "name":"CreateSubscriptionPayloadTask", + "version":"0.0.1" + }, + "taskReferences":{ + "entry":[ + { + "key":{ + "name":"CreateSubscriptionPayloadTask", + "version":"0.0.1" + }, + "value":{ + "key":{ + "parentKeyName":"ReceiveEventPolicy", + "parentKeyVersion":"0.0.1", + "parentLocalName":"CreateOrDeleteState", + "localName":"ReceiveEventPolicy" + }, + "outputType":"DIRECT", + "output":{ + "parentKeyName":"ReceiveEventPolicy", + "parentKeyVersion":"0.0.1", + "parentLocalName":"CreateOrDeleteState", + "localName":"CreateSubscriptionPayload" + } + } + }, + { + "key":{ + "name":"DeleteSubscriptionPayloadTask", + "version":"0.0.1" + }, + "value":{ + "key":{ + "parentKeyName":"ReceiveEventPolicy", + "parentKeyVersion":"0.0.1", + "parentLocalName":"CreateOrDeleteState", + "localName":"ReceiveEventPolicy" + }, + "outputType":"DIRECT", + "output":{ + "parentKeyName":"ReceiveEventPolicy", + "parentKeyVersion":"0.0.1", + "parentLocalName":"CreateOrDeleteState", + "localName":"DeleteSubscriptionPayload" + } + } + } + ] + } + } + }, + { + "key":"CreateSubscription", + "value":{ + "stateKey":{ + "parentKeyName":"ReceiveEventPolicy", + "parentKeyVersion":"0.0.1", + "parentLocalName":"NULL", + "localName":"CreateSubscription" + }, + "trigger":{ + "name":"CreateSubscriptionPayloadEvent", + "version":"0.0.1" + }, + "stateOutputs":{ + "entry":[ + { + "key":"IssueCreateSubscriptionRequestOutput", + "value":{ + "key":{ + "parentKeyName":"ReceiveEventPolicy", + "parentKeyVersion":"0.0.1", + "parentLocalName":"CreateSubscription", + "localName":"IssueCreateSubscriptionRequestOutput" + }, + "outgoingEvent":{ + "name":"CDSCreateSubscriptionRequestEvent", + "version":"0.0.1" + }, + "nextState":{ + "parentKeyName":"NULL", + "parentKeyVersion":"0.0.0", + "parentLocalName":"NULL", + "localName":"NULL" + } + } + } + ] + }, + "contextAlbumReference":[ + { + "name":"PMSubscriptionAlbum", + "version":"0.0.1" + } + ], + "taskSelectionLogic":{ + "key":"NULL", + "logicFlavour":"UNDEFINED", + "logic":"" + }, + "stateFinalizerLogicMap":{ + "entry":[ + + ] + }, + "defaultTask":{ + "name":"CreateSubscriptionRequestTask", + "version":"0.0.1" + }, + "taskReferences":{ + "entry":[ + { + "key":{ + "name":"CreateSubscriptionRequestTask", + "version":"0.0.1" + }, + "value":{ + "key":{ + "parentKeyName":"ReceiveEventPolicy", + "parentKeyVersion":"0.0.1", + "parentLocalName":"CreateSubscription", + "localName":"ReceiveEventPolicy" + }, + "outputType":"DIRECT", + "output":{ + "parentKeyName":"ReceiveEventPolicy", + "parentKeyVersion":"0.0.1", + "parentLocalName":"CreateSubscription", + "localName":"IssueCreateSubscriptionRequestOutput" + } + } + } + ] + } + } + }, + { + "key":"DeleteSubscription", + "value":{ + "stateKey":{ + "parentKeyName":"ReceiveEventPolicy", + "parentKeyVersion":"0.0.1", + "parentLocalName":"NULL", + "localName":"DeleteSubscription" + }, + "trigger":{ + "name":"DeleteSubscriptionPayloadEvent", + "version":"0.0.1" + }, + "stateOutputs":{ + "entry":[ + { + "key":"IssueDeleteSubscriptionRequestOutput", + "value":{ + "key":{ + "parentKeyName":"ReceiveEventPolicy", + "parentKeyVersion":"0.0.1", + "parentLocalName":"DeleteSubscription", + "localName":"IssueDeleteSubscriptionRequestOutput" + }, + "outgoingEvent":{ + "name":"CDSDeleteSubscriptionRequestEvent", + "version":"0.0.1" + }, + "nextState":{ + "parentKeyName":"NULL", + "parentKeyVersion":"0.0.0", + "parentLocalName":"NULL", + "localName":"NULL" + } + } + } + ] + }, + "contextAlbumReference":[ + { + "name":"PMSubscriptionAlbum", + "version":"0.0.1" + } + ], + "taskSelectionLogic":{ + "key":"NULL", + "logicFlavour":"UNDEFINED", + "logic":"" + }, + "stateFinalizerLogicMap":{ + "entry":[ + + ] + }, + "defaultTask":{ + "name":"DeleteSubscriptionRequestTask", + "version":"0.0.1" + }, + "taskReferences":{ + "entry":[ + { + "key":{ + "name":"DeleteSubscriptionRequestTask", + "version":"0.0.1" + }, + "value":{ + "key":{ + "parentKeyName":"ReceiveEventPolicy", + "parentKeyVersion":"0.0.1", + "parentLocalName":"DeleteSubscription", + "localName":"ReceiveEventPolicy" + }, + "outputType":"DIRECT", + "output":{ + "parentKeyName":"ReceiveEventPolicy", + "parentKeyVersion":"0.0.1", + "parentLocalName":"DeleteSubscription", + "localName":"IssueDeleteSubscriptionRequestOutput" + } + } + } + ] + } + } + }, + { + "key":"ReceiveSubscriptionState", + "value":{ + "stateKey":{ + "parentKeyName":"ReceiveEventPolicy", + "parentKeyVersion":"0.0.1", + "parentLocalName":"NULL", + "localName":"ReceiveSubscriptionState" + }, + "trigger":{ + "name":"pmsh-operational-policy", + "version":"0.0.1" + }, + "stateOutputs":{ + "entry":[ + { + "key":"ReceivePMSubscriptionOutput", + "value":{ + "key":{ + "parentKeyName":"ReceiveEventPolicy", + "parentKeyVersion":"0.0.1", + "parentLocalName":"ReceiveSubscriptionState", + "localName":"ReceivePMSubscriptionOutput" + }, + "outgoingEvent":{ + "name":"PMSubscriptionOutputEvent", + "version":"0.0.1" + }, + "nextState":{ + "parentKeyName":"ReceiveEventPolicy", + "parentKeyVersion":"0.0.1", + "parentLocalName":"NULL", + "localName":"CreateOrDeleteState" + } + } + } + ] + }, + "contextAlbumReference":[ + { + "name":"PMSubscriptionAlbum", + "version":"0.0.1" + } + ], + "taskSelectionLogic":{ + "key":"NULL", + "logicFlavour":"UNDEFINED", + "logic":"" + }, + "stateFinalizerLogicMap":{ + "entry":[ + + ] + }, + "defaultTask":{ + "name":"ReceiveSubscriptionTask", + "version":"0.0.1" + }, + "taskReferences":{ + "entry":[ + { + "key":{ + "name":"ReceiveSubscriptionTask", + "version":"0.0.1" + }, + "value":{ + "key":{ + "parentKeyName":"ReceiveEventPolicy", + "parentKeyVersion":"0.0.1", + "parentLocalName":"ReceiveSubscriptionState", + "localName":"ReceiveEventPolicy" + }, + "outputType":"DIRECT", + "output":{ + "parentKeyName":"ReceiveEventPolicy", + "parentKeyVersion":"0.0.1", + "parentLocalName":"ReceiveSubscriptionState", + "localName":"ReceivePMSubscriptionOutput" + } + } + } + ] + } + } + } + ] + }, + "firstState":"ReceiveSubscriptionState" + } + } + ] + } + }, + "tasks":{ + "key":{ + "name":"PMControlPolicy_Tasks", + "version":"0.0.1" + }, + "taskMap":{ + "entry":[ + { + "key":{ + "name":"CDSCreateResponseTask", + "version":"0.0.1" + }, + "value":{ + "key":{ + "name":"CDSCreateResponseTask", + "version":"0.0.1" + }, + "inputFields":{ + "entry":[ + { + "key":"actionIdentifiers", + "value":{ + "key":"actionIdentifiers", + "fieldSchemaKey":{ + "name":"CDSActionIdentifiersType", + "version":"0.0.1" + }, + "optional":false + } + }, + { + "key":"commonHeader", + "value":{ + "key":"commonHeader", + "fieldSchemaKey":{ + "name":"CDSResponseCommonHeaderType", + "version":"0.0.1" + }, + "optional":false + } + }, + { + "key":"payload", + "value":{ + "key":"payload", + "fieldSchemaKey":{ + "name":"CDSCreateResponsePayloadType", + "version":"0.0.1" + }, + "optional":false + } + }, + { + "key":"status", + "value":{ + "key":"status", + "fieldSchemaKey":{ + "name":"CDSResponseStatusType", + "version":"0.0.1" + }, + "optional":false + } + } + ] + }, + "outputFields":{ + "entry":[ + { + "key":"status", + "value":{ + "key":"status", + "fieldSchemaKey":{ + "name":"SubscriptionStatusType", + "version":"0.0.1" + }, + "optional":false + } + } + ] + }, + "taskParameters":{ + "entry":[ + + ] + }, + "contextAlbumReference":[ + { + "name":"PMSubscriptionAlbum", + "version":"0.0.1" + } + ], + "taskLogic":{ + "key":"TaskLogic", + "logicFlavour":"JAVASCRIPT", + "logic":"/*\n * ============LICENSE_START=======================================================\n * Copyright (C) 2020 Nordix. All rights reserved.\n * ================================================================================\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n *\n * SPDX-License-Identifier: Apache-2.0\n * ============LICENSE_END=========================================================\n */\n\nexecutor.logger.info(executor.subject.id);\n\nvar commonHeader = executor.inFields.get(\"commonHeader\")\nvar response = executor.inFields.get(\"payload\")\nvar albumID = commonHeader.get(\"requestId\")\n\nvar pmSubscriptionInfo = executor.getContextAlbum(\"PMSubscriptionAlbum\").get(albumID.toString());\nvar responseStatus = executor.subject.getOutFieldSchemaHelper(\"status\").createNewInstance();\n\nresponseStatus.put(\"subscriptionName\", pmSubscriptionInfo.get(\"subscription\").get(\"subscriptionName\"))\nresponseStatus.put(\"nfName\", pmSubscriptionInfo.get(\"nfName\"))\nresponseStatus.put(\"changeType\", pmSubscriptionInfo.get(\"changeType\"))\n\nvar status = response.get(pmSubscriptionInfo.get(\"changeType\").toLowerCase() + \"_DasH_subscription_DasH_response\").get(\"odl_DasH_response\").get(\"status\")\n\nexecutor.logger.info(\"RESPONSE STATUS = \" + status)\n\nif(status == \"success\") {\n responseStatus.put(\"message\", \"success\")\n} else {\n responseStatus.put(\"message\", \"failed\")\n}\n\nexecutor.outFields.put(\"status\", responseStatus)\n\n//var returnValue = executor.isTrue;\ntrue;" + } + } + }, + { + "key":{ + "name":"CDSDeleteResponseTask", + "version":"0.0.1" + }, + "value":{ + "key":{ + "name":"CDSDeleteResponseTask", + "version":"0.0.1" + }, + "inputFields":{ + "entry":[ + { + "key":"actionIdentifiers", + "value":{ + "key":"actionIdentifiers", + "fieldSchemaKey":{ + "name":"CDSActionIdentifiersType", + "version":"0.0.1" + }, + "optional":false + } + }, + { + "key":"commonHeader", + "value":{ + "key":"commonHeader", + "fieldSchemaKey":{ + "name":"CDSResponseCommonHeaderType", + "version":"0.0.1" + }, + "optional":false + } + }, + { + "key":"payload", + "value":{ + "key":"payload", + "fieldSchemaKey":{ + "name":"CDSDeleteResponsePayloadType", + "version":"0.0.1" + }, + "optional":false + } + }, + { + "key":"status", + "value":{ + "key":"status", + "fieldSchemaKey":{ + "name":"CDSResponseStatusType", + "version":"0.0.1" + }, + "optional":false + } + } + ] + }, + "outputFields":{ + "entry":[ + { + "key":"status", + "value":{ + "key":"status", + "fieldSchemaKey":{ + "name":"SubscriptionStatusType", + "version":"0.0.1" + }, + "optional":false + } + } + ] + }, + "taskParameters":{ + "entry":[ + + ] + }, + "contextAlbumReference":[ + { + "name":"PMSubscriptionAlbum", + "version":"0.0.1" + } + ], + "taskLogic":{ + "key":"TaskLogic", + "logicFlavour":"JAVASCRIPT", + "logic":"/*\n * ============LICENSE_START=======================================================\n * Copyright (C) 2020 Nordix. All rights reserved.\n * ================================================================================\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n *\n * SPDX-License-Identifier: Apache-2.0\n * ============LICENSE_END=========================================================\n */\n\nexecutor.logger.info(executor.subject.id);\n\nvar commonHeader = executor.inFields.get(\"commonHeader\")\nvar response = executor.inFields.get(\"payload\")\nvar albumID = commonHeader.get(\"requestId\")\n\nvar pmSubscriptionInfo = executor.getContextAlbum(\"PMSubscriptionAlbum\").get(albumID.toString());\nvar responseStatus = executor.subject.getOutFieldSchemaHelper(\"status\").createNewInstance();\n\nresponseStatus.put(\"subscriptionName\", pmSubscriptionInfo.get(\"subscription\").get(\"subscriptionName\"))\nresponseStatus.put(\"nfName\", pmSubscriptionInfo.get(\"nfName\"))\nresponseStatus.put(\"changeType\", pmSubscriptionInfo.get(\"changeType\"))\n\nvar status = response.get(pmSubscriptionInfo.get(\"changeType\").toLowerCase() + \"_DasH_subscription_DasH_response\").get(\"odl_DasH_response\").get(\"status\")\n\nexecutor.logger.info(\"RESPONSE STATUS = \" + status)\n\nif(status == \"success\") {\n responseStatus.put(\"message\", \"success\")\n} else {\n responseStatus.put(\"message\", \"failed\")\n}\n\nexecutor.outFields.put(\"status\", responseStatus)\n\n//var returnValue = executor.isTrue;\ntrue;" + } + } + }, + { + "key":{ + "name":"CreateSubscriptionPayloadTask", + "version":"0.0.1" + }, + "value":{ + "key":{ + "name":"CreateSubscriptionPayloadTask", + "version":"0.0.1" + }, + "inputFields":{ + "entry":[ + { + "key":"albumID", + "value":{ + "key":"albumID", + "fieldSchemaKey":{ + "name":"UUIDType", + "version":"0.0.1" + }, + "optional":false + } + } + ] + }, + "outputFields":{ + "entry":[ + { + "key":"albumID", + "value":{ + "key":"albumID", + "fieldSchemaKey":{ + "name":"UUIDType", + "version":"0.0.1" + }, + "optional":false + } + }, + { + "key":"payload", + "value":{ + "key":"payload", + "fieldSchemaKey":{ + "name":"CDSCreateSubscriptionPayloadType", + "version":"0.0.1" + }, + "optional":false + } + } + ] + }, + "taskParameters":{ + "entry":[ + + ] + }, + "contextAlbumReference":[ + { + "name":"PMSubscriptionAlbum", + "version":"0.0.1" + } + ], + "taskLogic":{ + "key":"TaskLogic", + "logicFlavour":"JAVASCRIPT", + "logic":"/*\n * ============LICENSE_START=======================================================\n * Copyright (C) 2020 Nordix. All rights reserved.\n * ================================================================================\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n *\n * SPDX-License-Identifier: Apache-2.0\n * ============LICENSE_END=========================================================\n */\n\nexecutor.logger.info(executor.subject.id);\n\nvar pmSubscriptionInfo = executor.getContextAlbum(\"PMSubscriptionAlbum\").get(executor.inFields.get(\"albumID\").toString())\n\nvar changeType = pmSubscriptionInfo.get(\"changeType\").toLowerCase()\n\nvar payloadProperties = executor.subject.getOutFieldSchemaHelper(\"payload\").createNewSubInstance(changeType + \"_DasH_subscription_DasH_properties_record\");\n\npayloadProperties.put(\"nfName\", pmSubscriptionInfo.get(\"nfName\"))\npayloadProperties.put(\"subscriptionName\", pmSubscriptionInfo.get(\"subscription\").get(\"subscriptionName\"))\npayloadProperties.put(\"administrativeState\", pmSubscriptionInfo.get(\"subscription\").get(\"administrativeState\"))\npayloadProperties.put(\"fileBasedGP\", pmSubscriptionInfo.get(\"subscription\").get(\"fileBasedGP\").toString())\npayloadProperties.put(\"fileLocation\", pmSubscriptionInfo.get(\"subscription\").get(\"fileLocation\"))\npayloadProperties.put(\"measurementGroups\", pmSubscriptionInfo.get(\"subscription\").get(\"measurementGroups\"))\n\nvar payloadEntry = executor.subject.getOutFieldSchemaHelper(\"payload\").createNewSubInstance(\"CDSRequestPayloadEntry\");\npayloadEntry.put(changeType + \"_DasH_subscription_DasH_properties\", payloadProperties)\n\nvar payload = executor.subject.getOutFieldSchemaHelper(\"payload\").createNewInstance();\npayload.put(changeType + \"_DasH_subscription_DasH_request\", payloadEntry);\n\nexecutor.outFields.put(\"albumID\", executor.inFields.get(\"albumID\"))\nexecutor.outFields.put(\"payload\", payload);\n\n//var returnValue = executor.isTrue;\ntrue;" + } + } + }, + { + "key":{ + "name":"CreateSubscriptionRequestTask", + "version":"0.0.1" + }, + "value":{ + "key":{ + "name":"CreateSubscriptionRequestTask", + "version":"0.0.1" + }, + "inputFields":{ + "entry":[ + { + "key":"albumID", + "value":{ + "key":"albumID", + "fieldSchemaKey":{ + "name":"UUIDType", + "version":"0.0.1" + }, + "optional":false + } + }, + { + "key":"payload", + "value":{ + "key":"payload", + "fieldSchemaKey":{ + "name":"CDSCreateSubscriptionPayloadType", + "version":"0.0.1" + }, + "optional":false + } + } + ] + }, + "outputFields":{ + "entry":[ + { + "key":"actionIdentifiers", + "value":{ + "key":"actionIdentifiers", + "fieldSchemaKey":{ + "name":"CDSActionIdentifiersType", + "version":"0.0.1" + }, + "optional":false + } + }, + { + "key":"commonHeader", + "value":{ + "key":"commonHeader", + "fieldSchemaKey":{ + "name":"CDSRequestCommonHeaderType", + "version":"0.0.1" + }, + "optional":false + } + }, + { + "key":"payload", + "value":{ + "key":"payload", + "fieldSchemaKey":{ + "name":"CDSCreateSubscriptionPayloadType", + "version":"0.0.1" + }, + "optional":false + } + } + ] + }, + "taskParameters":{ + "entry":[ + + ] + }, + "contextAlbumReference":[ + { + "name":"PMSubscriptionAlbum", + "version":"0.0.1" + } + ], + "taskLogic":{ + "key":"TaskLogic", + "logicFlavour":"JAVASCRIPT", + "logic":"/*\n * ============LICENSE_START=======================================================\n * Copyright (C) 2020 Nordix. All rights reserved.\n * ================================================================================\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n *\n * SPDX-License-Identifier: Apache-2.0\n * ============LICENSE_END=========================================================\n */\n\nexecutor.logger.info(executor.subject.id);\n\nvar pmSubscriptionInfo = executor.getContextAlbum(\"PMSubscriptionAlbum\").get(executor.inFields.get(\"albumID\").toString())\n\nvar changeType = pmSubscriptionInfo.get(\"changeType\").toLowerCase()\nvar blueprintName = pmSubscriptionInfo.get(\"blueprintName\").toLowerCase()\nvar blueprintVersion = pmSubscriptionInfo.get(\"blueprintVersion\").toLowerCase()\nvar payload = executor.inFields.get(\"payload\")\nvar actionName = changeType + \"-subscription\"\n\nvar commonHeader = executor.subject.getOutFieldSchemaHelper(\"commonHeader\").createNewInstance();\ncommonHeader.put(\"originatorId\", \"sdnc\");\ncommonHeader.put(\"requestId\", executor.inFields.get(\"albumID\").toString());\ncommonHeader.put(\"subRequestId\", \"sub-123456-1000\");\n\nvar actionIdentifiers = executor.subject.getOutFieldSchemaHelper(\"actionIdentifiers\").createNewInstance();\nactionIdentifiers.put(\"actionName\", actionName);\nactionIdentifiers.put(\"blueprintName\", blueprintName);\nactionIdentifiers.put(\"blueprintVersion\", blueprintVersion);\nactionIdentifiers.put(\"mode\", \"sync\");\n\nexecutor.outFields.put(\"commonHeader\", commonHeader);\nexecutor.outFields.put(\"actionIdentifiers\", actionIdentifiers);\nexecutor.outFields.put(\"payload\", payload);\n\n//var returnValue = executor.isTrue;\ntrue;" + } + } + }, + { + "key":{ + "name":"DeleteSubscriptionPayloadTask", + "version":"0.0.1" + }, + "value":{ + "key":{ + "name":"DeleteSubscriptionPayloadTask", + "version":"0.0.1" + }, + "inputFields":{ + "entry":[ + { + "key":"albumID", + "value":{ + "key":"albumID", + "fieldSchemaKey":{ + "name":"UUIDType", + "version":"0.0.1" + }, + "optional":false + } + } + ] + }, + "outputFields":{ + "entry":[ + { + "key":"albumID", + "value":{ + "key":"albumID", + "fieldSchemaKey":{ + "name":"UUIDType", + "version":"0.0.1" + }, + "optional":false + } + }, + { + "key":"payload", + "value":{ + "key":"payload", + "fieldSchemaKey":{ + "name":"CDSDeleteSubscriptionPayloadType", + "version":"0.0.1" + }, + "optional":false + } + } + ] + }, + "taskParameters":{ + "entry":[ + + ] + }, + "contextAlbumReference":[ + { + "name":"PMSubscriptionAlbum", + "version":"0.0.1" + } + ], + "taskLogic":{ + "key":"TaskLogic", + "logicFlavour":"JAVASCRIPT", + "logic":"/*\n * ============LICENSE_START=======================================================\n * Copyright (C) 2020 Nordix. All rights reserved.\n * ================================================================================\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n *\n * SPDX-License-Identifier: Apache-2.0\n * ============LICENSE_END=========================================================\n */\n\nexecutor.logger.info(executor.subject.id);\n\nvar pmSubscriptionInfo = executor.getContextAlbum(\"PMSubscriptionAlbum\").get(executor.inFields.get(\"albumID\").toString())\n\nvar changeType = pmSubscriptionInfo.get(\"changeType\").toLowerCase()\n\nvar payloadProperties = executor.subject.getOutFieldSchemaHelper(\"payload\").createNewSubInstance(changeType + \"_DasH_subscription_DasH_properties_record\");\n\npayloadProperties.put(\"nfName\", pmSubscriptionInfo.get(\"nfName\"))\npayloadProperties.put(\"subscriptionName\", pmSubscriptionInfo.get(\"subscription\").get(\"subscriptionName\"))\npayloadProperties.put(\"administrativeState\", pmSubscriptionInfo.get(\"subscription\").get(\"administrativeState\"))\npayloadProperties.put(\"fileBasedGP\", pmSubscriptionInfo.get(\"subscription\").get(\"fileBasedGP\").toString())\npayloadProperties.put(\"fileLocation\", pmSubscriptionInfo.get(\"subscription\").get(\"fileLocation\"))\npayloadProperties.put(\"measurementGroups\", pmSubscriptionInfo.get(\"subscription\").get(\"measurementGroups\"))\n\nvar payloadEntry = executor.subject.getOutFieldSchemaHelper(\"payload\").createNewSubInstance(\"CDSRequestPayloadEntry\");\npayloadEntry.put(changeType + \"_DasH_subscription_DasH_properties\", payloadProperties)\n\nvar payload = executor.subject.getOutFieldSchemaHelper(\"payload\").createNewInstance();\npayload.put(changeType + \"_DasH_subscription_DasH_request\", payloadEntry);\n\nexecutor.outFields.put(\"albumID\", executor.inFields.get(\"albumID\"))\nexecutor.outFields.put(\"payload\", payload);\n\n//var returnValue = executor.isTrue;\ntrue;" + } + } + }, + { + "key":{ + "name":"DeleteSubscriptionRequestTask", + "version":"0.0.1" + }, + "value":{ + "key":{ + "name":"DeleteSubscriptionRequestTask", + "version":"0.0.1" + }, + "inputFields":{ + "entry":[ + { + "key":"albumID", + "value":{ + "key":"albumID", + "fieldSchemaKey":{ + "name":"UUIDType", + "version":"0.0.1" + }, + "optional":false + } + }, + { + "key":"payload", + "value":{ + "key":"payload", + "fieldSchemaKey":{ + "name":"CDSDeleteSubscriptionPayloadType", + "version":"0.0.1" + }, + "optional":false + } + } + ] + }, + "outputFields":{ + "entry":[ + { + "key":"actionIdentifiers", + "value":{ + "key":"actionIdentifiers", + "fieldSchemaKey":{ + "name":"CDSActionIdentifiersType", + "version":"0.0.1" + }, + "optional":false + } + }, + { + "key":"commonHeader", + "value":{ + "key":"commonHeader", + "fieldSchemaKey":{ + "name":"CDSRequestCommonHeaderType", + "version":"0.0.1" + }, + "optional":false + } + }, + { + "key":"payload", + "value":{ + "key":"payload", + "fieldSchemaKey":{ + "name":"CDSDeleteSubscriptionPayloadType", + "version":"0.0.1" + }, + "optional":false + } + } + ] + }, + "taskParameters":{ + "entry":[ + + ] + }, + "contextAlbumReference":[ + { + "name":"PMSubscriptionAlbum", + "version":"0.0.1" + } + ], + "taskLogic":{ + "key":"TaskLogic", + "logicFlavour":"JAVASCRIPT", + "logic":"/*\n * ============LICENSE_START=======================================================\n * Copyright (C) 2020 Nordix. All rights reserved.\n * ================================================================================\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n *\n * SPDX-License-Identifier: Apache-2.0\n * ============LICENSE_END=========================================================\n */\n\nexecutor.logger.info(executor.subject.id);\n\nvar pmSubscriptionInfo = executor.getContextAlbum(\"PMSubscriptionAlbum\").get(executor.inFields.get(\"albumID\").toString())\n\nvar changeType = pmSubscriptionInfo.get(\"changeType\").toLowerCase()\nvar blueprintName = pmSubscriptionInfo.get(\"blueprintName\").toLowerCase()\nvar blueprintVersion = pmSubscriptionInfo.get(\"blueprintVersion\").toLowerCase()\nvar payload = executor.inFields.get(\"payload\")\nvar actionName = changeType + \"-subscription\"\n\nvar commonHeader = executor.subject.getOutFieldSchemaHelper(\"commonHeader\").createNewInstance();\ncommonHeader.put(\"originatorId\", \"sdnc\");\ncommonHeader.put(\"requestId\", executor.inFields.get(\"albumID\").toString());\ncommonHeader.put(\"subRequestId\", \"sub-123456-1000\");\n\nvar actionIdentifiers = executor.subject.getOutFieldSchemaHelper(\"actionIdentifiers\").createNewInstance();\nactionIdentifiers.put(\"actionName\", actionName);\nactionIdentifiers.put(\"blueprintName\", blueprintName);\nactionIdentifiers.put(\"blueprintVersion\", blueprintVersion);\nactionIdentifiers.put(\"mode\", \"sync\");\n\nexecutor.outFields.put(\"commonHeader\", commonHeader);\nexecutor.outFields.put(\"actionIdentifiers\", actionIdentifiers);\nexecutor.outFields.put(\"payload\", payload);\n\n//var returnValue = executor.isTrue;\ntrue;" + } + } + }, + { + "key":{ + "name":"ReceiveSubscriptionTask", + "version":"0.0.1" + }, + "value":{ + "key":{ + "name":"ReceiveSubscriptionTask", + "version":"0.0.1" + }, + "inputFields":{ + "entry":[ + { + "key":"blueprintName", + "value":{ + "key":"blueprintName", + "fieldSchemaKey":{ + "name":"SimpleStringType", + "version":"0.0.1" + }, + "optional":false + } + }, + { + "key":"blueprintVersion", + "value":{ + "key":"blueprintVersion", + "fieldSchemaKey":{ + "name":"SimpleStringType", + "version":"0.0.1" + }, + "optional":false + } + }, + { + "key":"changeType", + "value":{ + "key":"changeType", + "fieldSchemaKey":{ + "name":"SimpleStringType", + "version":"0.0.1" + }, + "optional":false + } + }, + { + "key":"closedLoopControlName", + "value":{ + "key":"closedLoopControlName", + "fieldSchemaKey":{ + "name":"SimpleStringType", + "version":"0.0.1" + }, + "optional":false + } + }, + { + "key":"nfName", + "value":{ + "key":"nfName", + "fieldSchemaKey":{ + "name":"SimpleStringType", + "version":"0.0.1" + }, + "optional":false + } + }, + { + "key":"policyName", + "value":{ + "key":"policyName", + "fieldSchemaKey":{ + "name":"SimpleStringType", + "version":"0.0.1" + }, + "optional":false + } + }, + { + "key":"subscription", + "value":{ + "key":"subscription", + "fieldSchemaKey":{ + "name":"SubscriptionType", + "version":"0.0.1" + }, + "optional":false + } + } + ] + }, + "outputFields":{ + "entry":[ + { + "key":"albumID", + "value":{ + "key":"albumID", + "fieldSchemaKey":{ + "name":"UUIDType", + "version":"0.0.1" + }, + "optional":false + } + } + ] + }, + "taskParameters":{ + "entry":[ + + ] + }, + "contextAlbumReference":[ + { + "name":"PMSubscriptionAlbum", + "version":"0.0.1" + } + ], + "taskLogic":{ + "key":"TaskLogic", + "logicFlavour":"JAVASCRIPT", + "logic":"/*\n * ============LICENSE_START=======================================================\n * Copyright (C) 2020 Nordix. All rights reserved.\n * ================================================================================\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n *\n * SPDX-License-Identifier: Apache-2.0\n * ============LICENSE_END=========================================================\n */\nvar uuidType = java.util.UUID;\n\nexecutor.logger.info(executor.subject.id);\n\n//albumID will be used to fetch info from our album later\nvar albumID = uuidType.randomUUID();\nvar pmSubscriptionInfo = executor.getContextAlbum(\"PMSubscriptionAlbum\").getSchemaHelper().createNewInstance();\nvar returnValue = true;\n\nif(executor.inFields.get(\"policyName\") != null) {\n executor.logger.info(\"nfName in receive sub event \" + executor.inFields.get(\"nfName\"));\n\n var changeType = executor.inFields.get(\"changeType\")\n var nfName = executor.inFields.get(\"nfName\")\n var policyName = executor.inFields.get(\"policyName\")\n var closedLoopControlName = executor.inFields.get(\"closedLoopControlName\")\n var subscription = executor.inFields.get(\"subscription\")\n var blueprintName = executor.inFields.get(\"blueprintName\")\n var blueprintVersion = executor.inFields.get(\"blueprintVersion\")\n\n pmSubscriptionInfo.put(\"nfName\", executor.inFields.get(\"nfName\"));\n pmSubscriptionInfo.put(\"changeType\", executor.inFields.get(\"changeType\"))\n pmSubscriptionInfo.put(\"policyName\", executor.inFields.get(\"policyName\"))\n pmSubscriptionInfo.put(\"closedLoopControlName\", executor.inFields.get(\"closedLoopControlName\"))\n pmSubscriptionInfo.put(\"subscription\", subscription)\n pmSubscriptionInfo.put(\"blueprintName\", blueprintName)\n pmSubscriptionInfo.put(\"blueprintVersion\", blueprintVersion)\n\n\n executor.getContextAlbum(\"PMSubscriptionAlbum\").put(albumID.toString(), pmSubscriptionInfo);\n\n executor.outFields.put(\"albumID\", albumID)\n} else {\n executor.message = \"Received invalid event\"\n returnValue = false;\n}\n\nreturnValue;" + } + } + } + ] + } + }, + "events":{ + "key":{ + "name":"PMControlPolicy_Events", + "version":"0.0.1" + }, + "eventMap":{ + "entry":[ + { + "key":{ + "name":"CDSCreateResponseEvent", + "version":"0.0.1" + }, + "value":{ + "key":{ + "name":"CDSCreateResponseEvent", + "version":"0.0.1" + }, + "nameSpace":"org.onap.policy.apex.onap.pmcontrol", + "source":"CDS", + "target":"APEX", + "parameter":{ + "entry":[ + { + "key":"actionIdentifiers", + "value":{ + "key":"actionIdentifiers", + "fieldSchemaKey":{ + "name":"CDSActionIdentifiersType", + "version":"0.0.1" + }, + "optional":false + } + }, + { + "key":"commonHeader", + "value":{ + "key":"commonHeader", + "fieldSchemaKey":{ + "name":"CDSResponseCommonHeaderType", + "version":"0.0.1" + }, + "optional":false + } + }, + { + "key":"payload", + "value":{ + "key":"payload", + "fieldSchemaKey":{ + "name":"CDSCreateResponsePayloadType", + "version":"0.0.1" + }, + "optional":false + } + }, + { + "key":"status", + "value":{ + "key":"status", + "fieldSchemaKey":{ + "name":"CDSResponseStatusType", + "version":"0.0.1" + }, + "optional":false + } + } + ] + } + } + }, + { + "key":{ + "name":"CDSCreateSubscriptionRequestEvent", + "version":"0.0.1" + }, + "value":{ + "key":{ + "name":"CDSCreateSubscriptionRequestEvent", + "version":"0.0.1" + }, + "nameSpace":"org.onap.policy.apex.onap.pmcontrol", + "source":"APEX", + "target":"APEX", + "parameter":{ + "entry":[ + { + "key":"actionIdentifiers", + "value":{ + "key":"actionIdentifiers", + "fieldSchemaKey":{ + "name":"CDSActionIdentifiersType", + "version":"0.0.1" + }, + "optional":false + } + }, + { + "key":"commonHeader", + "value":{ + "key":"commonHeader", + "fieldSchemaKey":{ + "name":"CDSRequestCommonHeaderType", + "version":"0.0.1" + }, + "optional":false + } + }, + { + "key":"payload", + "value":{ + "key":"payload", + "fieldSchemaKey":{ + "name":"CDSCreateSubscriptionPayloadType", + "version":"0.0.1" + }, + "optional":false + } + } + ] + } + } + }, + { + "key":{ + "name":"CDSDeleteResponseEvent", + "version":"0.0.1" + }, + "value":{ + "key":{ + "name":"CDSDeleteResponseEvent", + "version":"0.0.1" + }, + "nameSpace":"org.onap.policy.apex.onap.pmcontrol", + "source":"CDS", + "target":"APEX", + "parameter":{ + "entry":[ + { + "key":"actionIdentifiers", + "value":{ + "key":"actionIdentifiers", + "fieldSchemaKey":{ + "name":"CDSActionIdentifiersType", + "version":"0.0.1" + }, + "optional":false + } + }, + { + "key":"commonHeader", + "value":{ + "key":"commonHeader", + "fieldSchemaKey":{ + "name":"CDSResponseCommonHeaderType", + "version":"0.0.1" + }, + "optional":false + } + }, + { + "key":"payload", + "value":{ + "key":"payload", + "fieldSchemaKey":{ + "name":"CDSDeleteResponsePayloadType", + "version":"0.0.1" + }, + "optional":false + } + }, + { + "key":"status", + "value":{ + "key":"status", + "fieldSchemaKey":{ + "name":"CDSResponseStatusType", + "version":"0.0.1" + }, + "optional":false + } + } + ] + } + } + }, + { + "key":{ + "name":"CDSDeleteSubscriptionRequestEvent", + "version":"0.0.1" + }, + "value":{ + "key":{ + "name":"CDSDeleteSubscriptionRequestEvent", + "version":"0.0.1" + }, + "nameSpace":"org.onap.policy.apex.onap.pmcontrol", + "source":"APEX", + "target":"APEX", + "parameter":{ + "entry":[ + { + "key":"actionIdentifiers", + "value":{ + "key":"actionIdentifiers", + "fieldSchemaKey":{ + "name":"CDSActionIdentifiersType", + "version":"0.0.1" + }, + "optional":false + } + }, + { + "key":"commonHeader", + "value":{ + "key":"commonHeader", + "fieldSchemaKey":{ + "name":"CDSRequestCommonHeaderType", + "version":"0.0.1" + }, + "optional":false + } + }, + { + "key":"payload", + "value":{ + "key":"payload", + "fieldSchemaKey":{ + "name":"CDSDeleteSubscriptionPayloadType", + "version":"0.0.1" + }, + "optional":false + } + } + ] + } + } + }, + { + "key":{ + "name":"CDSResponseStatusEvent", + "version":"0.0.1" + }, + "value":{ + "key":{ + "name":"CDSResponseStatusEvent", + "version":"0.0.1" + }, + "nameSpace":"org.onap.policy.apex.onap.pmcontrol", + "source":"APEX", + "target":"DCAE", + "parameter":{ + "entry":[ + { + "key":"status", + "value":{ + "key":"status", + "fieldSchemaKey":{ + "name":"SubscriptionStatusType", + "version":"0.0.1" + }, + "optional":false + } + } + ] + } + } + }, + { + "key":{ + "name":"CreateSubscriptionPayloadEvent", + "version":"0.0.1" + }, + "value":{ + "key":{ + "name":"CreateSubscriptionPayloadEvent", + "version":"0.0.1" + }, + "nameSpace":"org.onap.policy.apex.onap.pmcontrol", + "source":"APEX", + "target":"APEX", + "parameter":{ + "entry":[ + { + "key":"albumID", + "value":{ + "key":"albumID", + "fieldSchemaKey":{ + "name":"UUIDType", + "version":"0.0.1" + }, + "optional":false + } + }, + { + "key":"payload", + "value":{ + "key":"payload", + "fieldSchemaKey":{ + "name":"CDSCreateSubscriptionPayloadType", + "version":"0.0.1" + }, + "optional":false + } + } + ] + } + } + }, + { + "key":{ + "name":"DeleteSubscriptionPayloadEvent", + "version":"0.0.1" + }, + "value":{ + "key":{ + "name":"DeleteSubscriptionPayloadEvent", + "version":"0.0.1" + }, + "nameSpace":"org.onap.policy.apex.onap.pmcontrol", + "source":"APEX", + "target":"APEX", + "parameter":{ + "entry":[ + { + "key":"albumID", + "value":{ + "key":"albumID", + "fieldSchemaKey":{ + "name":"UUIDType", + "version":"0.0.1" + }, + "optional":false + } + }, + { + "key":"payload", + "value":{ + "key":"payload", + "fieldSchemaKey":{ + "name":"CDSDeleteSubscriptionPayloadType", + "version":"0.0.1" + }, + "optional":false + } + } + ] + } + } + }, + { + "key":{ + "name":"MRResponseEvent", + "version":"0.0.1" + }, + "value":{ + "key":{ + "name":"MRResponseEvent", + "version":"0.0.1" + }, + "nameSpace":"org.onap.policy.apex.onap.pmcontrol", + "source":"DCAE", + "target":"APEX", + "parameter":{ + "entry":[ + { + "key":"count", + "value":{ + "key":"count", + "fieldSchemaKey":{ + "name":"SimpleIntType", + "version":"0.0.1" + }, + "optional":false + } + }, + { + "key":"serverTimeMs", + "value":{ + "key":"serverTimeMs", + "fieldSchemaKey":{ + "name":"SimpleIntType", + "version":"0.0.1" + }, + "optional":false + } + } + ] + } + } + }, + { + "key":{ + "name":"PMSubscriptionOutputEvent", + "version":"0.0.1" + }, + "value":{ + "key":{ + "name":"PMSubscriptionOutputEvent", + "version":"0.0.1" + }, + "nameSpace":"org.onap.policy.apex.onap.pmcontrol", + "source":"APEX", + "target":"APEX", + "parameter":{ + "entry":[ + { + "key":"albumID", + "value":{ + "key":"albumID", + "fieldSchemaKey":{ + "name":"UUIDType", + "version":"0.0.1" + }, + "optional":false + } + } + ] + } + } + }, + { + "key":{ + "name":"pmsh-operational-policy", + "version":"0.0.1" + }, + "value":{ + "key":{ + "name":"pmsh-operational-policy", + "version":"0.0.1" + }, + "nameSpace":"org.onap.policy.apex.onap.pmcontrol", + "source":"DCAE", + "target":"APEX", + "parameter":{ + "entry":[ + { + "key":"blueprintName", + "value":{ + "key":"blueprintName", + "fieldSchemaKey":{ + "name":"SimpleStringType", + "version":"0.0.1" + }, + "optional":false + } + }, + { + "key":"blueprintVersion", + "value":{ + "key":"blueprintVersion", + "fieldSchemaKey":{ + "name":"SimpleStringType", + "version":"0.0.1" + }, + "optional":false + } + }, + { + "key":"changeType", + "value":{ + "key":"changeType", + "fieldSchemaKey":{ + "name":"SimpleStringType", + "version":"0.0.1" + }, + "optional":false + } + }, + { + "key":"closedLoopControlName", + "value":{ + "key":"closedLoopControlName", + "fieldSchemaKey":{ + "name":"SimpleStringType", + "version":"0.0.1" + }, + "optional":false + } + }, + { + "key":"nfName", + "value":{ + "key":"nfName", + "fieldSchemaKey":{ + "name":"SimpleStringType", + "version":"0.0.1" + }, + "optional":false + } + }, + { + "key":"policyName", + "value":{ + "key":"policyName", + "fieldSchemaKey":{ + "name":"SimpleStringType", + "version":"0.0.1" + }, + "optional":false + } + }, + { + "key":"subscription", + "value":{ + "key":"subscription", + "fieldSchemaKey":{ + "name":"SubscriptionType", + "version":"0.0.1" + }, + "optional":false + } + } + ] + } + } + } + ] + } + }, + "albums":{ + "key":{ + "name":"PMControlPolicy_Albums", + "version":"0.0.1" + }, + "albums":{ + "entry":[ + { + "key":{ + "name":"PMSubscriptionAlbum", + "version":"0.0.1" + }, + "value":{ + "key":{ + "name":"PMSubscriptionAlbum", + "version":"0.0.1" + }, + "scope":"policy", + "isWritable":true, + "itemSchema":{ + "name":"PMSubscriptionType", + "version":"0.0.1" + } + } + } + ] + } + }, + "schemas":{ + "key":{ + "name":"PMControlPolicy_Schemas", + "version":"0.0.1" + }, + "schemas":{ + "entry":[ + { + "key":{ + "name":"CDSActionIdentifiersType", + "version":"0.0.1" + }, + "value":{ + "key":{ + "name":"CDSActionIdentifiersType", + "version":"0.0.1" + }, + "schemaFlavour":"Avro", + "schemaDefinition":"{\n \"type\": \"record\",\n \"name\": \"ActionIdentifiers_Type\",\n \"namespace\": \"org.onap.policy.apex.onap.helloworld\",\n \"fields\": [\n {\n \"name\": \"actionName\",\n \"type\": \"string\"\n },\n {\n \"name\": \"blueprintName\",\n \"type\": \"string\"\n },\n {\n \"name\": \"blueprintVersion\",\n \"type\": \"string\"\n },\n {\n \"name\": \"mode\",\n \"type\": \"string\"\n }\n ]\n}" + } + }, + { + "key":{ + "name":"CDSCreateResponsePayloadType", + "version":"0.0.1" + }, + "value":{ + "key":{ + "name":"CDSCreateResponsePayloadType", + "version":"0.0.1" + }, + "schemaFlavour":"Avro", + "schemaDefinition":"{\n \"name\": \"CreateResponsePayloadEntry\",\n \"type\": \"record\",\n \"namespace\": \"org.onap.policy.apex.onap.helloworld\",\n \"fields\": [\n {\n \"name\": \"create_DasH_subscription_DasH_response\",\n \"type\": {\n \"name\": \"create_DasH_subscription_DasH_response\",\n \"type\": \"record\",\n \"fields\": [\n {\n \"name\": \"odl_DasH_response\",\n \"type\": {\n \"name\": \"odl_DasH_response\",\n \"type\": \"record\",\n \"fields\": [\n {\n \"name\": \"status\",\n \"type\": \"string\"\n }\n ]\n }\n }\n ]\n }\n }\n ]\n}" + } + }, + { + "key":{ + "name":"CDSCreateSubscriptionPayloadType", + "version":"0.0.1" + }, + "value":{ + "key":{ + "name":"CDSCreateSubscriptionPayloadType", + "version":"0.0.1" + }, + "schemaFlavour":"Avro", + "schemaDefinition":"{\n \"type\": \"map\",\n \"values\": {\n \"type\": \"record\",\n \"name\": \"CDSRequestPayloadEntry\",\n \"fields\": [\n {\n \"name\": \"create_DasH_subscription_DasH_properties\",\n \"type\": {\n \"name\": \"create_DasH_subscription_DasH_properties_record\",\n \"type\": \"record\",\n \"fields\": [\n {\n \"name\": \"nfName\",\n \"type\": \"string\"\n },\n {\n \"name\": \"subscriptionName\",\n \"type\": \"string\"\n },\n {\n \"name\": \"administrativeState\",\n \"type\": \"string\"\n },\n {\n \"name\": \"fileBasedGP\",\n \"type\": \"string\"\n },\n {\n \"name\": \"fileLocation\",\n \"type\": \"string\"\n },\n {\n \"name\": \"measurementGroups\",\n \"type\": {\n \"type\": \"array\",\n \"items\": {\n \"name\": \"measurementGroups_record\",\n \"type\": \"record\",\n \"fields\": [\n {\n \"name\": \"measurementGroup\",\n \"type\": {\n \"name\": \"measurementGroup\",\n \"type\": \"record\",\n \"fields\": [\n {\n \"name\": \"measurementTypes\",\n \"type\": {\n \"type\": \"array\",\n \"items\": {\n \"name\": \"measurementTypes_record\",\n \"type\": \"record\",\n \"fields\": [\n {\n \"name\": \"measurementType\",\n \"type\": \"string\"\n }\n ]\n }\n }\n },\n {\n \"name\": \"managedObjectDNsBasic\",\n \"type\": {\n \"type\": \"array\",\n \"items\": {\n \"name\": \"managedObjectDNsBasic_record\",\n \"type\": \"record\",\n \"fields\": [\n {\n \"name\": \"DN\",\n \"type\": \"string\"\n }\n ]\n }\n }\n }\n ]\n }\n }\n ]\n }\n }\n }\n ]\n }\n }\n ]\n }\n}" + } + }, + { + "key":{ + "name":"CDSDeleteResponsePayloadType", + "version":"0.0.1" + }, + "value":{ + "key":{ + "name":"CDSDeleteResponsePayloadType", + "version":"0.0.1" + }, + "schemaFlavour":"Avro", + "schemaDefinition":"{\n \"name\": \"DeleteResponsePayloadEntry\",\n \"type\": \"record\",\n \"namespace\": \"com.acme.avro\",\n \"fields\": [\n {\n \"name\": \"delete_DasH_subscription_DasH_response\",\n \"type\": {\n \"name\": \"delete_DasH_subscription_DasH_response\",\n \"type\": \"record\",\n \"fields\": [\n {\n \"name\": \"odl_DasH_response\",\n \"type\": {\n \"name\": \"odl_DasH_response\",\n \"type\": \"record\",\n \"fields\": [\n {\n \"name\": \"status\",\n \"type\": \"string\"\n }\n ]\n }\n }\n ]\n }\n }\n ]\n}" + } + }, + { + "key":{ + "name":"CDSDeleteSubscriptionPayloadType", + "version":"0.0.1" + }, + "value":{ + "key":{ + "name":"CDSDeleteSubscriptionPayloadType", + "version":"0.0.1" + }, + "schemaFlavour":"Avro", + "schemaDefinition":"{\n \"type\": \"map\",\n \"values\": {\n \"type\": \"record\",\n \"name\": \"CDSRequestPayloadEntry\",\n \"fields\": [\n {\n \"name\": \"delete_DasH_subscription_DasH_properties\",\n \"type\": {\n \"name\": \"delete_DasH_subscription_DasH_properties_record\",\n \"type\": \"record\",\n \"fields\": [\n {\n \"name\": \"nfName\",\n \"type\": \"string\"\n },\n {\n \"name\": \"subscriptionName\",\n \"type\": \"string\"\n },\n {\n \"name\": \"administrativeState\",\n \"type\": \"string\"\n },\n {\n \"name\": \"fileBasedGP\",\n \"type\": \"string\"\n },\n {\n \"name\": \"fileLocation\",\n \"type\": \"string\"\n },\n {\n \"name\": \"measurementGroups\",\n \"type\": {\n \"type\": \"array\",\n \"items\": {\n \"name\": \"measurementGroups_record\",\n \"type\": \"record\",\n \"fields\": [\n {\n \"name\": \"measurementGroup\",\n \"type\": {\n \"name\": \"measurementGroup\",\n \"type\": \"record\",\n \"fields\": [\n {\n \"name\": \"measurementTypes\",\n \"type\": {\n \"type\": \"array\",\n \"items\": {\n \"name\": \"measurementTypes_record\",\n \"type\": \"record\",\n \"fields\": [\n {\n \"name\": \"measurementType\",\n \"type\": \"string\"\n }\n ]\n }\n }\n },\n {\n \"name\": \"managedObjectDNsBasic\",\n \"type\": {\n \"type\": \"array\",\n \"items\": {\n \"name\": \"managedObjectDNsBasic_record\",\n \"type\": \"record\",\n \"fields\": [\n {\n \"name\": \"DN\",\n \"type\": \"string\"\n }\n ]\n }\n }\n }\n ]\n }\n }\n ]\n }\n }\n }\n ]\n }\n }\n ]\n }\n}" + } + }, + { + "key":{ + "name":"CDSRequestCommonHeaderType", + "version":"0.0.1" + }, + "value":{ + "key":{ + "name":"CDSRequestCommonHeaderType", + "version":"0.0.1" + }, + "schemaFlavour":"Avro", + "schemaDefinition":"{\n \"type\": \"record\",\n \"name\": \"RequestCommonHeader_Type\",\n \"namespace\": \"org.onap.policy.apex.onap.helloworld\",\n \"fields\": [\n {\n \"name\": \"originatorId\",\n \"type\": \"string\"\n },\n {\n \"name\": \"requestId\",\n \"type\": \"string\"\n },\n {\n \"name\": \"subRequestId\",\n \"type\": \"string\"\n }\n ]\n}" + } + }, + { + "key":{ + "name":"CDSResponseCommonHeaderType", + "version":"0.0.1" + }, + "value":{ + "key":{ + "name":"CDSResponseCommonHeaderType", + "version":"0.0.1" + }, + "schemaFlavour":"Avro", + "schemaDefinition":"{\n \"type\": \"record\",\n \"name\": \"ResponseCommonHeader_Type\",\n \"namespace\": \"org.onap.policy.apex.onap.helloworld\",\n \"fields\": [\n {\n \"name\": \"originatorId\",\n \"type\": \"string\"\n },\n {\n \"name\": \"requestId\",\n \"type\": \"string\"\n },\n {\n \"name\": \"subRequestId\",\n \"type\": \"string\"\n },\n {\n \"name\": \"timestamp\",\n \"type\": \"string\"\n },\n {\n \"name\": \"flags\",\n \"type\": [\"null\", \"string\"]\n }\n ]\n}" + } + }, + { + "key":{ + "name":"CDSResponseStatusType", + "version":"0.0.1" + }, + "value":{ + "key":{ + "name":"CDSResponseStatusType", + "version":"0.0.1" + }, + "schemaFlavour":"Avro", + "schemaDefinition":"{\n \"type\": \"record\",\n \"name\": \"ResponseStatus_Type\",\n \"namespace\": \"org.onap.policy.apex.onap.helloworld\",\n \"fields\": [\n {\n \"name\": \"code\",\n \"type\": \"int\"\n },\n {\n \"name\": \"eventType\",\n \"type\": \"string\"\n },\n {\n \"name\": \"timestamp\",\n \"type\": \"string\"\n },\n {\n \"name\": \"message\",\n \"type\": \"string\"\n }\n ]\n}" + } + }, + { + "key":{ + "name":"PMSubscriptionType", + "version":"0.0.1" + }, + "value":{ + "key":{ + "name":"PMSubscriptionType", + "version":"0.0.1" + }, + "schemaFlavour":"Avro", + "schemaDefinition":"{\n\t\"name\": \"PMSubscription\",\n\t\"type\": \"record\",\n\t\"namespace\": \"org.onap.policy.apex.onap.pmcontrol\",\n\t\"fields\": [\n {\n \"name\": \"nfName\",\n \"type\": \"string\"\n },\n\t {\n\t\t\t\"name\": \"changeType\",\n\t\t\t\"type\": \"string\"\n\t\t},\n\t\t{\n\t\t\t\"name\": \"closedLoopControlName\",\n\t\t\t\"type\": \"string\"\n\t\t},\n\t\t{\n\t\t\t\"name\": \"policyName\",\n\t\t\t\"type\": \"string\"\n\t\t},\n\t\t{\n\t\t \"name\": \"blueprintName\",\n\t\t \"type\": \"string\"\n\t\t},\n\t\t{\n\t\t \"name\": \"blueprintVersion\",\n\t\t \"type\": \"string\"\n\t\t},\n\t\t{\n\t\t\t\"name\": \"subscription\",\n\t\t\t\"type\": {\n\t\t\t\t\"name\": \"subscription\",\n\t\t\t\t\"type\": \"record\",\n\t\t\t\t\"fields\": [{\n\t\t\t\t\t\t\"name\": \"subscriptionName\",\n\t\t\t\t\t\t\"type\": \"string\"\n\t\t\t\t\t},\n\t\t\t\t\t{\n\t\t\t\t\t\t\"name\": \"administrativeState\",\n\t\t\t\t\t\t\"type\": \"string\"\n\t\t\t\t\t},\n\t\t\t\t\t{\n\t\t\t\t\t\t\"name\": \"fileBasedGP\",\n\t\t\t\t\t\t\"type\": \"int\"\n\t\t\t\t\t},\n\t\t\t\t\t{\n\t\t\t\t\t\t\"name\": \"fileLocation\",\n\t\t\t\t\t\t\"type\": \"string\"\n\t\t\t\t\t},\n\t\t\t\t\t{\n\t\t\t\t\t\t\"name\": \"measurementGroups\",\n\t\t\t\t\t\t\"type\": {\n\t\t\t\t\t\t\t\"type\": \"array\",\n\t\t\t\t\t\t\t\"items\": {\n\t\t\t\t\t\t\t\t\"name\": \"Measurement_Groups_Type\",\n\t\t\t\t\t\t\t\t\"type\": \"record\",\n\t\t\t\t\t\t\t\t\"fields\": [{\n\t\t\t\t\t\t\t\t\t\"name\": \"measurementGroup\",\n\t\t\t\t\t\t\t\t\t\"type\": {\n\t\t\t\t\t\t\t\t\t\t\"name\": \"Measurement_Group_Type\",\n\t\t\t\t\t\t\t\t\t\t\"type\": \"record\",\n\t\t\t\t\t\t\t\t\t\t\"fields\": [{\n\t\t\t\t\t\t\t\t\t\t\t\t\"name\": \"measurementTypes\",\n\t\t\t\t\t\t\t\t\t\t\t\t\"type\": {\n\t\t\t\t\t\t\t\t\t\t\t\t\t\"type\": \"array\",\n\t\t\t\t\t\t\t\t\t\t\t\t\t\"items\": {\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\"name\": \"Measurement_Types_Type\",\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\"type\": \"record\",\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\"fields\": [{\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\"name\": \"measurementType\",\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\"type\": \"string\"\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t}]\n\t\t\t\t\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\t\t\t\t\"name\": \"managedObjectDNsBasic\",\n\t\t\t\t\t\t\t\t\t\t\t\t\"type\": {\n\t\t\t\t\t\t\t\t\t\t\t\t\t\"type\": \"array\",\n\t\t\t\t\t\t\t\t\t\t\t\t\t\"items\": {\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\"name\": \"Managed_Object_Dns_Basic_Type\",\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\"type\": \"record\",\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\"fields\": [{\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\"name\": \"DN\",\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\"type\": \"string\"\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t}]\n\t\t\t\t\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\t\t]\n\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t}]\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t]\n\t\t\t}\n\t\t}\n\t]\n}" + } + }, + { + "key":{ + "name":"SimpleIntType", + "version":"0.0.1" + }, + "value":{ + "key":{ + "name":"SimpleIntType", + "version":"0.0.1" + }, + "schemaFlavour":"Java", + "schemaDefinition":"java.lang.Integer" + } + }, + { + "key":{ + "name":"SimpleStringType", + "version":"0.0.1" + }, + "value":{ + "key":{ + "name":"SimpleStringType", + "version":"0.0.1" + }, + "schemaFlavour":"Java", + "schemaDefinition":"java.lang.String" + } + }, + { + "key":{ + "name":"SubscriptionStatusType", + "version":"0.0.1" + }, + "value":{ + "key":{ + "name":"SubscriptionStatusType", + "version":"0.0.1" + }, + "schemaFlavour":"Avro", + "schemaDefinition":"{\n \"type\": \"record\",\n \"name\": \"ActivateSubscriptionStatus_Type\",\n \"namespace\": \"org.onap.policy.apex.onap.helloworld\",\n \"fields\": [\n {\n \"name\": \"subscriptionName\",\n \"type\": \"string\"\n },\n {\n \"name\": \"nfName\",\n \"type\": \"string\"\n },\n {\n \"name\": \"changeType\",\n \"type\": \"string\"\n },\n {\n \"name\": \"message\",\n \"type\": \"string\"\n }\n ]\n}" + } + }, + { + "key":{ + "name":"SubscriptionType", + "version":"0.0.1" + }, + "value":{ + "key":{ + "name":"SubscriptionType", + "version":"0.0.1" + }, + "schemaFlavour":"Avro", + "schemaDefinition":"{\n\t\"name\": \"subscription\",\n\t\"type\": \"record\",\n\t\"fields\": [{\n\t\t\t\"name\": \"subscriptionName\",\n\t\t\t\"type\": \"string\"\n\t\t},\n\t\t{\n\t\t\t\"name\": \"administrativeState\",\n\t\t\t\"type\": \"string\"\n\t\t},\n\t\t{\n\t\t\t\"name\": \"fileBasedGP\",\n\t\t\t\"type\": \"int\"\n\t\t},\n\t\t{\n\t\t\t\"name\": \"fileLocation\",\n\t\t\t\"type\": \"string\"\n\t\t},\n\t\t{\n\t\t\t\"name\": \"measurementGroups\",\n\t\t\t\"type\": {\n\t\t\t\t\"type\": \"array\",\n\t\t\t\t\"items\": {\n\t\t\t\t\t\"name\": \"Measurement_Groups_Type\",\n\t\t\t\t\t\"type\": \"record\",\n\t\t\t\t\t\"fields\": [{\n\t\t\t\t\t\t\"name\": \"measurementGroup\",\n\t\t\t\t\t\t\"type\": {\n\t\t\t\t\t\t\t\"name\": \"Measurement_Group_Type\",\n\t\t\t\t\t\t\t\"type\": \"record\",\n\t\t\t\t\t\t\t\"fields\": [{\n\t\t\t\t\t\t\t\t\t\"name\": \"measurementTypes\",\n\t\t\t\t\t\t\t\t\t\"type\": {\n\t\t\t\t\t\t\t\t\t\t\"type\": \"array\",\n\t\t\t\t\t\t\t\t\t\t\"items\": {\n\t\t\t\t\t\t\t\t\t\t\t\"name\": \"Measurement_Types_Type\",\n\t\t\t\t\t\t\t\t\t\t\t\"type\": \"record\",\n\t\t\t\t\t\t\t\t\t\t\t\"fields\": [{\n\t\t\t\t\t\t\t\t\t\t\t\t\"name\": \"measurementType\",\n\t\t\t\t\t\t\t\t\t\t\t\t\"type\": \"string\"\n\t\t\t\t\t\t\t\t\t\t\t}]\n\t\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\t\"name\": \"managedObjectDNsBasic\",\n\t\t\t\t\t\t\t\t\t\"type\": {\n\t\t\t\t\t\t\t\t\t\t\"type\": \"array\",\n\t\t\t\t\t\t\t\t\t\t\"items\": {\n\t\t\t\t\t\t\t\t\t\t\t\"name\": \"Managed_Object_Dns_Basic_Type\",\n\t\t\t\t\t\t\t\t\t\t\t\"type\": \"record\",\n\t\t\t\t\t\t\t\t\t\t\t\"fields\": [{\n\t\t\t\t\t\t\t\t\t\t\t\t\"name\": \"DN\",\n\t\t\t\t\t\t\t\t\t\t\t\t\"type\": \"string\"\n\t\t\t\t\t\t\t\t\t\t\t}]\n\t\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t]\n\t\t\t\t\t\t}\n\t\t\t\t\t}]\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t]\n}" + } + }, + { + "key":{ + "name":"UUIDType", + "version":"0.0.1" + }, + "value":{ + "key":{ + "name":"UUIDType", + "version":"0.0.1" + }, + "schemaFlavour":"Java", + "schemaDefinition":"java.util.UUID" + } + } + ] + } + } + } + }, + "engineParameters":{ + "executorParameters":{ + "JAVASCRIPT":{ + "parameterClassName":"org.onap.policy.apex.plugins.executor.javascript.JavascriptExecutorParameters" + } + }, + "contextParameters":{ + "parameterClassName":"org.onap.policy.apex.context.parameters.ContextParameters", + "schemaParameters":{ + "Avro":{ + "parameterClassName":"org.onap.policy.apex.plugins.context.schema.avro.AvroSchemaHelperParameters" + }, + "Java":{ + "parameterClassName":"org.onap.policy.apex.context.impl.schema.java.JavaSchemaHelperParameters", + "jsonAdapters":{ + "Instant":{ + "adaptedClass":"java.time.Instant", + "adaptorClass":"org.onap.policy.controlloop.util.Serialization$GsonInstantAdapter" + } + } + } + } + } + } + }, + "eventInputParameters":{ + "DCAEConsumer":{ + "carrierTechnologyParameters":{ + "carrierTechnology":"RESTCLIENT", + "parameterClassName":"org.onap.policy.apex.plugins.event.carrier.restclient.RestClientCarrierTechnologyParameters", + "parameters":{ + "consumerPollTime":"50", + "url":"https://message-router:3905/events/unauthenticated.DCAE_CL_OUTPUT/cg1/sg1" + } + }, + "eventProtocolParameters":{ + "eventProtocol":"JSON", + "parameters":{ + "nameAlias":"policyName" + } + }, + "eventName":"pmsh-operational-policy", + "eventNameFilter":"pmsh-operational-policy" + }, + "CDSRequestConsumer":{ + "carrierTechnologyParameters":{ + "carrierTechnology":"RESTREQUESTOR", + "parameterClassName":"org.onap.policy.apex.plugins.event.carrier.restrequestor.RestRequestorCarrierTechnologyParameters", + "parameters":{ + "url":"http://10.10.10.184:30254/api/v1/execution-service/process", + "httpMethod":"POST", + "restRequestTimeout":2000, + "httpHeaders":[ + [ + "Authorization", + "Basic Y2NzZGthcHBzOmNjc2RrYXBwcw==" + ] + ] + } + }, + "eventProtocolParameters":{ + "eventProtocol":"JSON" + }, + "eventName":"CDSCreateResponseEvent", + "eventNameFilter":"CDSCreateResponseEvent", + "requestorMode":true, + "requestorPeer":"CDSRequestProducer", + "requestorTimeout":500 + }, + "CDSDeleteRequestConsumer":{ + "carrierTechnologyParameters":{ + "carrierTechnology":"RESTREQUESTOR", + "parameterClassName":"org.onap.policy.apex.plugins.event.carrier.restrequestor.RestRequestorCarrierTechnologyParameters", + "parameters":{ + "url":"http://10.10.10.184:30254/api/v1/execution-service/process", + "httpMethod":"POST", + "restRequestTimeout":2000, + "httpHeaders":[ + [ + "Authorization", + "Basic Y2NzZGthcHBzOmNjc2RrYXBwcw==" + ] + ] + } + }, + "eventProtocolParameters":{ + "eventProtocol":"JSON" + }, + "eventName":"CDSDeleteResponseEvent", + "eventNameFilter":"CDSDeleteResponseEvent", + "requestorMode":true, + "requestorPeer":"CDSDeleteRequestProducer", + "requestorTimeout":500 + }, + "CDSReplyConsumer":{ + "carrierTechnologyParameters":{ + "carrierTechnology":"RESTREQUESTOR", + "parameterClassName":"org.onap.policy.apex.plugins.event.carrier.restrequestor.RestRequestorCarrierTechnologyParameters", + "parameters":{ + "url":"https://message-router:3905/events/unauthenticated.PMSH_CL_INPUT", + "httpMethod":"POST", + "restRequestTimeout":2000 + } + }, + "eventProtocolParameters":{ + "eventProtocol":"JSON" + }, + "eventName":"MRResponseEvent", + "eventNameFilter":"MRResponseEvent", + "requestorMode":true, + "requestorPeer":"CDSReplyProducer", + "requestorTimeout":500 + } + }, + "eventOutputParameters":{ + "logOutputter":{ + "carrierTechnologyParameters":{ + "carrierTechnology":"FILE", + "parameters":{ + "fileName":"/tmp/outputevents.log" + } + }, + "eventProtocolParameters":{ + "eventProtocol":"JSON" + } + }, + "StdOutOutputter":{ + "carrierTechnologyParameters":{ + "carrierTechnology":"FILE", + "parameters":{ + "standardIo":true + } + }, + "eventProtocolParameters":{ + "eventProtocol":"JSON" + } + }, + "CDSRequestProducer":{ + "carrierTechnologyParameters":{ + "carrierTechnology":"RESTREQUESTOR", + "parameterClassName":"org.onap.policy.apex.plugins.event.carrier.restrequestor.RestRequestorCarrierTechnologyParameters" + }, + "eventProtocolParameters":{ + "eventProtocol":"JSON" + }, + "eventNameFilter":"CDSCreateSubscriptionRequestEvent", + "requestorMode":true, + "requestorPeer":"CDSRequestConsumer", + "requestorTimeout":500 + }, + "CDSDeleteRequestProducer":{ + "carrierTechnologyParameters":{ + "carrierTechnology":"RESTREQUESTOR", + "parameterClassName":"org.onap.policy.apex.plugins.event.carrier.restrequestor.RestRequestorCarrierTechnologyParameters" + }, + "eventProtocolParameters":{ + "eventProtocol":"JSON" + }, + "eventNameFilter":"CDSDeleteSubscriptionRequestEvent", + "requestorMode":true, + "requestorPeer":"CDSDeleteRequestConsumer", + "requestorTimeout":500 + }, + "CDSReplyProducer":{ + "carrierTechnologyParameters":{ + "carrierTechnology":"RESTREQUESTOR", + "parameterClassName":"org.onap.policy.apex.plugins.event.carrier.restrequestor.RestRequestorCarrierTechnologyParameters" + }, + "eventProtocolParameters":{ + "eventProtocol":"JSON" + }, + "eventNameFilter":"CDSResponseStatusEvent", + "requestorMode":true, + "requestorPeer":"CDSReplyConsumer", + "requestorTimeout":500 + } + } + } + } + } + ] + } +} \ No newline at end of file diff --git a/common/src/test/resources/examples/acm/PMSH/pmsh_operational_policy.yaml b/common/src/test/resources/examples/acm/PMSH/pmsh_operational_policy.yaml new file mode 100644 index 000000000..faf579012 --- /dev/null +++ b/common/src/test/resources/examples/acm/PMSH/pmsh_operational_policy.yaml @@ -0,0 +1,2619 @@ +--- +tosca_definitions_version: tosca_simple_yaml_1_1_0 +topology_template: + policies: + - operational.apex.pmcontrol: + type: onap.policies.controlloop.operational.Apex + type_version: 1.0.0 + version: 1.0.0 + metadata: + policy-id: operational.apex.pmcontrol + policy-version: 1 + properties: + engineServiceParameters: + name: MyApexEngine + version: 0.0.1 + id: 45 + instanceCount: 2 + deploymentPort: 12561 + policy_type_impl: + apexPolicyModel: + key: + name: PMControlPolicy + version: 0.0.1 + keyInformation: + key: + name: PMControlPolicy_KeyInfo + version: 0.0.1 + keyInfoMap: + entry: + - key: + name: CDSActionIdentifiersType + version: 0.0.1 + value: + key: + name: CDSActionIdentifiersType + version: 0.0.1 + UUID: 6e5fa19b-14df-37e3-a4ae-8c537e861a82 + description: Generated description for concept referred to by + key "CDSActionIdentifiersType:0.0.1" + - key: + name: CDSCreateResponseEvent + version: 0.0.1 + value: + key: + name: CDSCreateResponseEvent + version: 0.0.1 + UUID: 14b29e38-ac75-3273-aa4e-8583c0aa7dad + description: Generated description for concept referred to by + key "CDSCreateResponseEvent:0.0.1" + - key: + name: CDSCreateResponsePayloadType + version: 0.0.1 + value: + key: + name: CDSCreateResponsePayloadType + version: 0.0.1 + UUID: 04573f8f-e772-30a5-b1d9-d7318d4a1e13 + description: Generated description for concept referred to by + key "CDSCreateResponsePayloadType:0.0.1" + - key: + name: CDSCreateResponsePolicy + version: 0.0.1 + value: + key: + name: CDSCreateResponsePolicy + version: 0.0.1 + UUID: e126c965-fc09-3bfe-8f55-70f380a4a49c + description: Generated description for concept referred to by + key "CDSCreateResponsePolicy:0.0.1" + - key: + name: CDSCreateResponseTask + version: 0.0.1 + value: + key: + name: CDSCreateResponseTask + version: 0.0.1 + UUID: 6165ee82-afd2-3aab-a517-f00b3f2461d2 + description: Generated description for concept referred to by + key "CDSCreateResponseTask:0.0.1" + - key: + name: CDSCreateSubscriptionPayloadType + version: 0.0.1 + value: + key: + name: CDSCreateSubscriptionPayloadType + version: 0.0.1 + UUID: 8350ac5e-c157-38b9-9614-a0f93a830e60 + description: Generated description for concept referred to by + key "CDSCreateSubscriptionPayloadType:0.0.1" + - key: + name: CDSCreateSubscriptionRequestEvent + version: 0.0.1 + value: + key: + name: CDSCreateSubscriptionRequestEvent + version: 0.0.1 + UUID: cfa325ba-226b-3a31-9183-ec43e2b6e9a2 + description: Generated description for concept referred to by + key "CDSCreateSubscriptionRequestEvent:0.0.1" + - key: + name: CDSDeleteResponseEvent + version: 0.0.1 + value: + key: + name: CDSDeleteResponseEvent + version: 0.0.1 + UUID: 8be9c0fa-7437-3841-aff2-b3cec6ae3bd8 + description: Generated description for concept referred to by + key "CDSDeleteResponseEvent:0.0.1" + - key: + name: CDSDeleteResponsePayloadType + version: 0.0.1 + value: + key: + name: CDSDeleteResponsePayloadType + version: 0.0.1 + UUID: 3fbfe0c9-152e-34d3-a504-09cd13c058d0 + description: Generated description for concept referred to by + key "CDSDeleteResponsePayloadType:0.0.1" + - key: + name: CDSDeleteResponsePolicy + version: 0.0.1 + value: + key: + name: CDSDeleteResponsePolicy + version: 0.0.1 + UUID: a780251c-edd5-3132-b865-04313246b43c + description: Generated description for concept referred to by + key "CDSDeleteResponsePolicy:0.0.1" + - key: + name: CDSDeleteResponseTask + version: 0.0.1 + value: + key: + name: CDSDeleteResponseTask + version: 0.0.1 + UUID: afce4555-3aa3-3521-a7d8-ee8cdf0d3efc + description: Generated description for concept referred to by + key "CDSDeleteResponseTask:0.0.1" + - key: + name: CDSDeleteSubscriptionPayloadType + version: 0.0.1 + value: + key: + name: CDSDeleteSubscriptionPayloadType + version: 0.0.1 + UUID: 12658406-9147-3c9d-a38c-5ad5e30b092b + description: Generated description for concept referred to by + key "CDSDeleteSubscriptionPayloadType:0.0.1" + - key: + name: CDSDeleteSubscriptionRequestEvent + version: 0.0.1 + value: + key: + name: CDSDeleteSubscriptionRequestEvent + version: 0.0.1 + UUID: 24380c95-9289-36e6-8cbf-0edefa15ccd9 + description: Generated description for concept referred to by + key "CDSDeleteSubscriptionRequestEvent:0.0.1" + - key: + name: CDSRequestCommonHeaderType + version: 0.0.1 + value: + key: + name: CDSRequestCommonHeaderType + version: 0.0.1 + UUID: 35590ac0-062c-39f1-8786-b4ff716e30b1 + description: Generated description for concept referred to by + key "CDSRequestCommonHeaderType:0.0.1" + - key: + name: CDSResponseCommonHeaderType + version: 0.0.1 + value: + key: + name: CDSResponseCommonHeaderType + version: 0.0.1 + UUID: dd7e1805-885a-350b-aaf9-ed541321ae3c + description: Generated description for concept referred to by + key "CDSResponseCommonHeaderType:0.0.1" + - key: + name: CDSResponseStatusEvent + version: 0.0.1 + value: + key: + name: CDSResponseStatusEvent + version: 0.0.1 + UUID: 7986e21b-32f7-302e-9554-31f21b673493 + description: Generated description for concept referred to by + key "CDSResponseStatusEvent:0.0.1" + - key: + name: CDSResponseStatusType + version: 0.0.1 + value: + key: + name: CDSResponseStatusType + version: 0.0.1 + UUID: 92b8a2cf-344e-3ce1-8cc0-2b7d3cb695fa + description: Generated description for concept referred to by + key "CDSResponseStatusType:0.0.1" + - key: + name: CreateSubscriptionPayloadEvent + version: 0.0.1 + value: + key: + name: CreateSubscriptionPayloadEvent + version: 0.0.1 + UUID: 92162397-1a8e-3a3f-a469-d2af7700af4a + description: Generated description for concept referred to by + key "CreateSubscriptionPayloadEvent:0.0.1" + - key: + name: CreateSubscriptionPayloadTask + version: 0.0.1 + value: + key: + name: CreateSubscriptionPayloadTask + version: 0.0.1 + UUID: bc0c69f0-52ed-38ea-b468-ae4a6fd1730d + description: Generated description for concept referred to by + key "CreateSubscriptionPayloadTask:0.0.1" + - key: + name: CreateSubscriptionRequestTask + version: 0.0.1 + value: + key: + name: CreateSubscriptionRequestTask + version: 0.0.1 + UUID: 89cb75e9-f06c-30d3-b4ff-698d45f63869 + description: Generated description for concept referred to by + key "CreateSubscriptionRequestTask:0.0.1" + - key: + name: DeleteSubscriptionPayloadEvent + version: 0.0.1 + value: + key: + name: DeleteSubscriptionPayloadEvent + version: 0.0.1 + UUID: 994fa441-04ab-33bb-832d-1cd12ab5d074 + description: Generated description for concept referred to by + key "DeleteSubscriptionPayloadEvent:0.0.1" + - key: + name: DeleteSubscriptionPayloadTask + version: 0.0.1 + value: + key: + name: DeleteSubscriptionPayloadTask + version: 0.0.1 + UUID: 0f519117-5fea-3e4b-941f-8f778100465f + description: Generated description for concept referred to by + key "DeleteSubscriptionPayloadTask:0.0.1" + - key: + name: DeleteSubscriptionRequestTask + version: 0.0.1 + value: + key: + name: DeleteSubscriptionRequestTask + version: 0.0.1 + UUID: acb772fe-d442-39e3-98f9-b1080caf4150 + description: Generated description for concept referred to by + key "DeleteSubscriptionRequestTask:0.0.1" + - key: + name: MRResponseEvent + version: 0.0.1 + value: + key: + name: MRResponseEvent + version: 0.0.1 + UUID: 13c747a3-6bae-3bcf-9c80-b152e01dc194 + description: Generated description for concept referred to by + key "MRResponseEvent:0.0.1" + - key: + name: PMControlPolicy + version: 0.0.1 + value: + key: + name: PMControlPolicy + version: 0.0.1 + UUID: acf1e55c-7bc5-3bd5-975a-0ca54afcd8a4 + description: Generated description for concept referred to by + key "PMControlPolicy:0.0.1" + - key: + name: PMControlPolicy_Albums + version: 0.0.1 + value: + key: + name: PMControlPolicy_Albums + version: 0.0.1 + UUID: b38ad204-c2c8-32f4-9b5a-dda0aeb0145b + description: Generated description for concept referred to by + key "PMControlPolicy_Albums:0.0.1" + - key: + name: PMControlPolicy_Events + version: 0.0.1 + value: + key: + name: PMControlPolicy_Events + version: 0.0.1 + UUID: be3871a0-c42a-3113-a066-82d192840eca + description: Generated description for concept referred to by + key "PMControlPolicy_Events:0.0.1" + - key: + name: PMControlPolicy_KeyInfo + version: 0.0.1 + value: + key: + name: PMControlPolicy_KeyInfo + version: 0.0.1 + UUID: ced37634-28a4-3178-b7f6-2980794927b0 + description: Generated description for concept referred to by + key "PMControlPolicy_KeyInfo:0.0.1" + - key: + name: PMControlPolicy_Policies + version: 0.0.1 + value: + key: + name: PMControlPolicy_Policies + version: 0.0.1 + UUID: be3d180d-ef9c-3a75-8e9c-84271a038bed + description: Generated description for concept referred to by + key "PMControlPolicy_Policies:0.0.1" + - key: + name: PMControlPolicy_Schemas + version: 0.0.1 + value: + key: + name: PMControlPolicy_Schemas + version: 0.0.1 + UUID: e61973f1-189c-39e5-82f6-0d3afe298a20 + description: Generated description for concept referred to by + key "PMControlPolicy_Schemas:0.0.1" + - key: + name: PMControlPolicy_Tasks + version: 0.0.1 + value: + key: + name: PMControlPolicy_Tasks + version: 0.0.1 + UUID: 5658adb3-2962-30a3-a241-fae75bb8eb4a + description: Generated description for concept referred to by + key "PMControlPolicy_Tasks:0.0.1" + - key: + name: PMSubscriptionAlbum + version: 0.0.1 + value: + key: + name: PMSubscriptionAlbum + version: 0.0.1 + UUID: c2bd6f0d-6854-317a-9be2-97c08338428c + description: Generated description for concept referred to by + key "PMSubscriptionAlbum:0.0.1" + - key: + name: PMSubscriptionOutputEvent + version: 0.0.1 + value: + key: + name: PMSubscriptionOutputEvent + version: 0.0.1 + UUID: 992b7819-9f69-3aa0-bb0f-6e45ea15ce05 + description: Generated description for concept referred to by + key "PMSubscriptionOutputEvent:0.0.1" + - key: + name: PMSubscriptionType + version: 0.0.1 + value: + key: + name: PMSubscriptionType + version: 0.0.1 + UUID: 73c1c397-4fc3-357f-93b6-a8ad707fbaae + description: Generated description for concept referred to by + key "PMSubscriptionType:0.0.1" + - key: + name: ReceiveEventPolicy + version: 0.0.1 + value: + key: + name: ReceiveEventPolicy + version: 0.0.1 + UUID: 568b7345-9de1-36d3-b6a3-9b857e6809a1 + description: Generated description for concept referred to by + key "ReceiveEventPolicy:0.0.1" + - key: + name: ReceiveSubscriptionTask + version: 0.0.1 + value: + key: + name: ReceiveSubscriptionTask + version: 0.0.1 + UUID: f596afc8-100c-35eb-92c8-352355ea457d + description: Generated description for concept referred to by + key "ReceiveSubscriptionTask:0.0.1" + - key: + name: SimpleIntType + version: 0.0.1 + value: + key: + name: SimpleIntType + version: 0.0.1 + UUID: 153791fd-ae0a-36a7-88a5-309a7936415d + description: Generated description for concept referred to by + key "SimpleIntType:0.0.1" + - key: + name: SimpleStringType + version: 0.0.1 + value: + key: + name: SimpleStringType + version: 0.0.1 + UUID: 8a4957cf-9493-3a76-8c22-a208e23259af + description: Generated description for concept referred to by + key "SimpleStringType:0.0.1" + - key: + name: SubscriptionStatusType + version: 0.0.1 + value: + key: + name: SubscriptionStatusType + version: 0.0.1 + UUID: 597643b1-9db1-31ce-85d0-e1c63c43b30b + description: Generated description for concept referred to by + key "SubscriptionStatusType:0.0.1" + - key: + name: SubscriptionType + version: 0.0.1 + value: + key: + name: SubscriptionType + version: 0.0.1 + UUID: 184547bb-7d64-3cb2-a273-d7185102c5ce + description: Generated description for concept referred to by + key "SubscriptionType:0.0.1" + - key: + name: UUIDType + version: 0.0.1 + value: + key: + name: UUIDType + version: 0.0.1 + UUID: 6a8cc68e-dfc8-3403-9c6d-071c886b319c + description: Generated description for concept referred to by + key "UUIDType:0.0.1" + - key: + name: pmsh-operational-policy + version: 0.0.1 + value: + key: + name: pmsh-operational-policy + version: 0.0.1 + UUID: fdf2c9ff-6422-3ea6-b6b6-49b12116265d + description: Generated description for concept referred to by + key "pmsh-operational-policy:0.0.1" + policies: + key: + name: PMControlPolicy_Policies + version: 0.0.1 + policyMap: + entry: + - key: + name: CDSCreateResponsePolicy + version: 0.0.1 + value: + policyKey: + name: CDSCreateResponsePolicy + version: 0.0.1 + template: Freestyle + state: + entry: + - key: CDSCreateResponseState + value: + stateKey: + parentKeyName: CDSCreateResponsePolicy + parentKeyVersion: 0.0.1 + parentLocalName: 'NULL' + localName: CDSCreateResponseState + trigger: + name: CDSCreateResponseEvent + version: 0.0.1 + stateOutputs: + entry: + - key: ResponseOutput + value: + key: + parentKeyName: CDSCreateResponsePolicy + parentKeyVersion: 0.0.1 + parentLocalName: CDSCreateResponseState + localName: ResponseOutput + outgoingEvent: + name: CDSResponseStatusEvent + version: 0.0.1 + nextState: + parentKeyName: 'NULL' + parentKeyVersion: 0.0.0 + parentLocalName: 'NULL' + localName: 'NULL' + contextAlbumReference: [] + taskSelectionLogic: + key: 'NULL' + logicFlavour: UNDEFINED + logic: '' + stateFinalizerLogicMap: + entry: [] + defaultTask: + name: CDSCreateResponseTask + version: 0.0.1 + taskReferences: + entry: + - key: + name: CDSCreateResponseTask + version: 0.0.1 + value: + key: + parentKeyName: CDSCreateResponsePolicy + parentKeyVersion: 0.0.1 + parentLocalName: CDSCreateResponseState + localName: CDSCreateResponsePolicy + outputType: DIRECT + output: + parentKeyName: CDSCreateResponsePolicy + parentKeyVersion: 0.0.1 + parentLocalName: CDSCreateResponseState + localName: ResponseOutput + firstState: CDSCreateResponseState + - key: + name: CDSDeleteResponsePolicy + version: 0.0.1 + value: + policyKey: + name: CDSDeleteResponsePolicy + version: 0.0.1 + template: Freestyle + state: + entry: + - key: CDSDeleteResponseState + value: + stateKey: + parentKeyName: CDSDeleteResponsePolicy + parentKeyVersion: 0.0.1 + parentLocalName: 'NULL' + localName: CDSDeleteResponseState + trigger: + name: CDSDeleteResponseEvent + version: 0.0.1 + stateOutputs: + entry: + - key: ResponseOutput + value: + key: + parentKeyName: CDSDeleteResponsePolicy + parentKeyVersion: 0.0.1 + parentLocalName: CDSDeleteResponseState + localName: ResponseOutput + outgoingEvent: + name: CDSResponseStatusEvent + version: 0.0.1 + nextState: + parentKeyName: 'NULL' + parentKeyVersion: 0.0.0 + parentLocalName: 'NULL' + localName: 'NULL' + contextAlbumReference: [] + taskSelectionLogic: + key: 'NULL' + logicFlavour: UNDEFINED + logic: '' + stateFinalizerLogicMap: + entry: [] + defaultTask: + name: CDSDeleteResponseTask + version: 0.0.1 + taskReferences: + entry: + - key: + name: CDSDeleteResponseTask + version: 0.0.1 + value: + key: + parentKeyName: CDSDeleteResponsePolicy + parentKeyVersion: 0.0.1 + parentLocalName: CDSDeleteResponseState + localName: CDSDeleteResponsePolicy + outputType: DIRECT + output: + parentKeyName: CDSDeleteResponsePolicy + parentKeyVersion: 0.0.1 + parentLocalName: CDSDeleteResponseState + localName: ResponseOutput + firstState: CDSDeleteResponseState + - key: + name: ReceiveEventPolicy + version: 0.0.1 + value: + policyKey: + name: ReceiveEventPolicy + version: 0.0.1 + template: Freestyle + state: + entry: + - key: CreateOrDeleteState + value: + stateKey: + parentKeyName: ReceiveEventPolicy + parentKeyVersion: 0.0.1 + parentLocalName: 'NULL' + localName: CreateOrDeleteState + trigger: + name: PMSubscriptionOutputEvent + version: 0.0.1 + stateOutputs: + entry: + - key: CreateSubscriptionPayload + value: + key: + parentKeyName: ReceiveEventPolicy + parentKeyVersion: 0.0.1 + parentLocalName: CreateOrDeleteState + localName: CreateSubscriptionPayload + outgoingEvent: + name: CreateSubscriptionPayloadEvent + version: 0.0.1 + nextState: + parentKeyName: ReceiveEventPolicy + parentKeyVersion: 0.0.1 + parentLocalName: 'NULL' + localName: CreateSubscription + - key: DeleteSubscriptionPayload + value: + key: + parentKeyName: ReceiveEventPolicy + parentKeyVersion: 0.0.1 + parentLocalName: CreateOrDeleteState + localName: DeleteSubscriptionPayload + outgoingEvent: + name: DeleteSubscriptionPayloadEvent + version: 0.0.1 + nextState: + parentKeyName: ReceiveEventPolicy + parentKeyVersion: 0.0.1 + parentLocalName: 'NULL' + localName: DeleteSubscription + contextAlbumReference: + - name: PMSubscriptionAlbum + version: 0.0.1 + taskSelectionLogic: + key: TaskSelectionLogic + logicFlavour: JAVASCRIPT + logic: |- + /* + * ============LICENSE_START======================================================= + * Copyright (C) 2020 Nordix. 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); + + var pmSubscriptionInfo = executor.getContextAlbum("PMSubscriptionAlbum").get(executor.inFields.get("albumID").toString()) + var changeType = pmSubscriptionInfo.get("changeType").toString() + + executor.logger.info("Change Type is " + changeType) + + if ("CREATE".equals(changeType)) { + executor.logger.info("Choosing to create a subscription") + executor.subject.getTaskKey("CreateSubscriptionPayloadTask").copyTo(executor.selectedTask); + } + else if ("DELETE".equals(changeType)) { + executor.logger.info("Choosing to delete a subscription") + executor.subject.getTaskKey("DeleteSubscriptionPayloadTask").copyTo(executor.selectedTask); + } + + //var returnValue = executor.isTrue; + true; + stateFinalizerLogicMap: + entry: [] + defaultTask: + name: CreateSubscriptionPayloadTask + version: 0.0.1 + taskReferences: + entry: + - key: + name: CreateSubscriptionPayloadTask + version: 0.0.1 + value: + key: + parentKeyName: ReceiveEventPolicy + parentKeyVersion: 0.0.1 + parentLocalName: CreateOrDeleteState + localName: ReceiveEventPolicy + outputType: DIRECT + output: + parentKeyName: ReceiveEventPolicy + parentKeyVersion: 0.0.1 + parentLocalName: CreateOrDeleteState + localName: CreateSubscriptionPayload + - key: + name: DeleteSubscriptionPayloadTask + version: 0.0.1 + value: + key: + parentKeyName: ReceiveEventPolicy + parentKeyVersion: 0.0.1 + parentLocalName: CreateOrDeleteState + localName: ReceiveEventPolicy + outputType: DIRECT + output: + parentKeyName: ReceiveEventPolicy + parentKeyVersion: 0.0.1 + parentLocalName: CreateOrDeleteState + localName: DeleteSubscriptionPayload + - key: CreateSubscription + value: + stateKey: + parentKeyName: ReceiveEventPolicy + parentKeyVersion: 0.0.1 + parentLocalName: 'NULL' + localName: CreateSubscription + trigger: + name: CreateSubscriptionPayloadEvent + version: 0.0.1 + stateOutputs: + entry: + - key: IssueCreateSubscriptionRequestOutput + value: + key: + parentKeyName: ReceiveEventPolicy + parentKeyVersion: 0.0.1 + parentLocalName: CreateSubscription + localName: IssueCreateSubscriptionRequestOutput + outgoingEvent: + name: CDSCreateSubscriptionRequestEvent + version: 0.0.1 + nextState: + parentKeyName: 'NULL' + parentKeyVersion: 0.0.0 + parentLocalName: 'NULL' + localName: 'NULL' + contextAlbumReference: + - name: PMSubscriptionAlbum + version: 0.0.1 + taskSelectionLogic: + key: 'NULL' + logicFlavour: UNDEFINED + logic: '' + stateFinalizerLogicMap: + entry: [] + defaultTask: + name: CreateSubscriptionRequestTask + version: 0.0.1 + taskReferences: + entry: + - key: + name: CreateSubscriptionRequestTask + version: 0.0.1 + value: + key: + parentKeyName: ReceiveEventPolicy + parentKeyVersion: 0.0.1 + parentLocalName: CreateSubscription + localName: ReceiveEventPolicy + outputType: DIRECT + output: + parentKeyName: ReceiveEventPolicy + parentKeyVersion: 0.0.1 + parentLocalName: CreateSubscription + localName: IssueCreateSubscriptionRequestOutput + - key: DeleteSubscription + value: + stateKey: + parentKeyName: ReceiveEventPolicy + parentKeyVersion: 0.0.1 + parentLocalName: 'NULL' + localName: DeleteSubscription + trigger: + name: DeleteSubscriptionPayloadEvent + version: 0.0.1 + stateOutputs: + entry: + - key: IssueDeleteSubscriptionRequestOutput + value: + key: + parentKeyName: ReceiveEventPolicy + parentKeyVersion: 0.0.1 + parentLocalName: DeleteSubscription + localName: IssueDeleteSubscriptionRequestOutput + outgoingEvent: + name: CDSDeleteSubscriptionRequestEvent + version: 0.0.1 + nextState: + parentKeyName: 'NULL' + parentKeyVersion: 0.0.0 + parentLocalName: 'NULL' + localName: 'NULL' + contextAlbumReference: + - name: PMSubscriptionAlbum + version: 0.0.1 + taskSelectionLogic: + key: 'NULL' + logicFlavour: UNDEFINED + logic: '' + stateFinalizerLogicMap: + entry: [] + defaultTask: + name: DeleteSubscriptionRequestTask + version: 0.0.1 + taskReferences: + entry: + - key: + name: DeleteSubscriptionRequestTask + version: 0.0.1 + value: + key: + parentKeyName: ReceiveEventPolicy + parentKeyVersion: 0.0.1 + parentLocalName: DeleteSubscription + localName: ReceiveEventPolicy + outputType: DIRECT + output: + parentKeyName: ReceiveEventPolicy + parentKeyVersion: 0.0.1 + parentLocalName: DeleteSubscription + localName: IssueDeleteSubscriptionRequestOutput + - key: ReceiveSubscriptionState + value: + stateKey: + parentKeyName: ReceiveEventPolicy + parentKeyVersion: 0.0.1 + parentLocalName: 'NULL' + localName: ReceiveSubscriptionState + trigger: + name: pmsh-operational-policy + version: 0.0.1 + stateOutputs: + entry: + - key: ReceivePMSubscriptionOutput + value: + key: + parentKeyName: ReceiveEventPolicy + parentKeyVersion: 0.0.1 + parentLocalName: ReceiveSubscriptionState + localName: ReceivePMSubscriptionOutput + outgoingEvent: + name: PMSubscriptionOutputEvent + version: 0.0.1 + nextState: + parentKeyName: ReceiveEventPolicy + parentKeyVersion: 0.0.1 + parentLocalName: 'NULL' + localName: CreateOrDeleteState + contextAlbumReference: + - name: PMSubscriptionAlbum + version: 0.0.1 + taskSelectionLogic: + key: 'NULL' + logicFlavour: UNDEFINED + logic: '' + stateFinalizerLogicMap: + entry: [] + defaultTask: + name: ReceiveSubscriptionTask + version: 0.0.1 + taskReferences: + entry: + - key: + name: ReceiveSubscriptionTask + version: 0.0.1 + value: + key: + parentKeyName: ReceiveEventPolicy + parentKeyVersion: 0.0.1 + parentLocalName: ReceiveSubscriptionState + localName: ReceiveEventPolicy + outputType: DIRECT + output: + parentKeyName: ReceiveEventPolicy + parentKeyVersion: 0.0.1 + parentLocalName: ReceiveSubscriptionState + localName: ReceivePMSubscriptionOutput + firstState: ReceiveSubscriptionState + tasks: + key: + name: PMControlPolicy_Tasks + version: 0.0.1 + taskMap: + entry: + - key: + name: CDSCreateResponseTask + version: 0.0.1 + value: + key: + name: CDSCreateResponseTask + version: 0.0.1 + inputFields: + entry: + - key: actionIdentifiers + value: + key: actionIdentifiers + fieldSchemaKey: + name: CDSActionIdentifiersType + version: 0.0.1 + optional: false + - key: commonHeader + value: + key: commonHeader + fieldSchemaKey: + name: CDSResponseCommonHeaderType + version: 0.0.1 + optional: false + - key: payload + value: + key: payload + fieldSchemaKey: + name: CDSCreateResponsePayloadType + version: 0.0.1 + optional: false + - key: status + value: + key: status + fieldSchemaKey: + name: CDSResponseStatusType + version: 0.0.1 + optional: false + outputFields: + entry: + - key: status + value: + key: status + fieldSchemaKey: + name: SubscriptionStatusType + version: 0.0.1 + optional: false + taskParameters: + entry: [] + contextAlbumReference: + - name: PMSubscriptionAlbum + version: 0.0.1 + taskLogic: + key: TaskLogic + logicFlavour: JAVASCRIPT + logic: |- + /* + * ============LICENSE_START======================================================= + * Copyright (C) 2020 Nordix. 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); + + var commonHeader = executor.inFields.get("commonHeader") + var response = executor.inFields.get("payload") + var albumID = commonHeader.get("requestId") + + var pmSubscriptionInfo = executor.getContextAlbum("PMSubscriptionAlbum").get(albumID.toString()); + var responseStatus = executor.subject.getOutFieldSchemaHelper("status").createNewInstance(); + + responseStatus.put("subscriptionName", pmSubscriptionInfo.get("subscription").get("subscriptionName")) + responseStatus.put("nfName", pmSubscriptionInfo.get("nfName")) + responseStatus.put("changeType", pmSubscriptionInfo.get("changeType")) + + var status = response.get(pmSubscriptionInfo.get("changeType").toLowerCase() + "_DasH_subscription_DasH_response").get("odl_DasH_response").get("status") + + executor.logger.info("RESPONSE STATUS = " + status) + + if(status == "success") { + responseStatus.put("message", "success") + } else { + responseStatus.put("message", "failed") + } + + executor.outFields.put("status", responseStatus) + + //var returnValue = executor.isTrue; + true; + - key: + name: CDSDeleteResponseTask + version: 0.0.1 + value: + key: + name: CDSDeleteResponseTask + version: 0.0.1 + inputFields: + entry: + - key: actionIdentifiers + value: + key: actionIdentifiers + fieldSchemaKey: + name: CDSActionIdentifiersType + version: 0.0.1 + optional: false + - key: commonHeader + value: + key: commonHeader + fieldSchemaKey: + name: CDSResponseCommonHeaderType + version: 0.0.1 + optional: false + - key: payload + value: + key: payload + fieldSchemaKey: + name: CDSDeleteResponsePayloadType + version: 0.0.1 + optional: false + - key: status + value: + key: status + fieldSchemaKey: + name: CDSResponseStatusType + version: 0.0.1 + optional: false + outputFields: + entry: + - key: status + value: + key: status + fieldSchemaKey: + name: SubscriptionStatusType + version: 0.0.1 + optional: false + taskParameters: + entry: [] + contextAlbumReference: + - name: PMSubscriptionAlbum + version: 0.0.1 + taskLogic: + key: TaskLogic + logicFlavour: JAVASCRIPT + logic: |- + /* + * ============LICENSE_START======================================================= + * Copyright (C) 2020 Nordix. 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); + + var commonHeader = executor.inFields.get("commonHeader") + var response = executor.inFields.get("payload") + var albumID = commonHeader.get("requestId") + + var pmSubscriptionInfo = executor.getContextAlbum("PMSubscriptionAlbum").get(albumID.toString()); + var responseStatus = executor.subject.getOutFieldSchemaHelper("status").createNewInstance(); + + responseStatus.put("subscriptionName", pmSubscriptionInfo.get("subscription").get("subscriptionName")) + responseStatus.put("nfName", pmSubscriptionInfo.get("nfName")) + responseStatus.put("changeType", pmSubscriptionInfo.get("changeType")) + + var status = response.get(pmSubscriptionInfo.get("changeType").toLowerCase() + "_DasH_subscription_DasH_response").get("odl_DasH_response").get("status") + + executor.logger.info("RESPONSE STATUS = " + status) + + if(status == "success") { + responseStatus.put("message", "success") + } else { + responseStatus.put("message", "failed") + } + + executor.outFields.put("status", responseStatus) + + //var returnValue = executor.isTrue; + true; + - key: + name: CreateSubscriptionPayloadTask + version: 0.0.1 + value: + key: + name: CreateSubscriptionPayloadTask + version: 0.0.1 + inputFields: + entry: + - key: albumID + value: + key: albumID + fieldSchemaKey: + name: UUIDType + version: 0.0.1 + optional: false + outputFields: + entry: + - key: albumID + value: + key: albumID + fieldSchemaKey: + name: UUIDType + version: 0.0.1 + optional: false + - key: payload + value: + key: payload + fieldSchemaKey: + name: CDSCreateSubscriptionPayloadType + version: 0.0.1 + optional: false + taskParameters: + entry: [] + contextAlbumReference: + - name: PMSubscriptionAlbum + version: 0.0.1 + taskLogic: + key: TaskLogic + logicFlavour: JAVASCRIPT + logic: |- + /* + * ============LICENSE_START======================================================= + * Copyright (C) 2020 Nordix. 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); + + var pmSubscriptionInfo = executor.getContextAlbum("PMSubscriptionAlbum").get(executor.inFields.get("albumID").toString()) + + var changeType = pmSubscriptionInfo.get("changeType").toLowerCase() + + var payloadProperties = executor.subject.getOutFieldSchemaHelper("payload").createNewSubInstance(changeType + "_DasH_subscription_DasH_properties_record"); + + payloadProperties.put("nfName", pmSubscriptionInfo.get("nfName")) + payloadProperties.put("subscriptionName", pmSubscriptionInfo.get("subscription").get("subscriptionName")) + payloadProperties.put("administrativeState", pmSubscriptionInfo.get("subscription").get("administrativeState")) + payloadProperties.put("fileBasedGP", pmSubscriptionInfo.get("subscription").get("fileBasedGP").toString()) + payloadProperties.put("fileLocation", pmSubscriptionInfo.get("subscription").get("fileLocation")) + payloadProperties.put("measurementGroups", pmSubscriptionInfo.get("subscription").get("measurementGroups")) + + var payloadEntry = executor.subject.getOutFieldSchemaHelper("payload").createNewSubInstance("CDSRequestPayloadEntry"); + payloadEntry.put(changeType + "_DasH_subscription_DasH_properties", payloadProperties) + + var payload = executor.subject.getOutFieldSchemaHelper("payload").createNewInstance(); + payload.put(changeType + "_DasH_subscription_DasH_request", payloadEntry); + + executor.outFields.put("albumID", executor.inFields.get("albumID")) + executor.outFields.put("payload", payload); + + //var returnValue = executor.isTrue; + true; + - key: + name: CreateSubscriptionRequestTask + version: 0.0.1 + value: + key: + name: CreateSubscriptionRequestTask + version: 0.0.1 + inputFields: + entry: + - key: albumID + value: + key: albumID + fieldSchemaKey: + name: UUIDType + version: 0.0.1 + optional: false + - key: payload + value: + key: payload + fieldSchemaKey: + name: CDSCreateSubscriptionPayloadType + version: 0.0.1 + optional: false + outputFields: + entry: + - key: actionIdentifiers + value: + key: actionIdentifiers + fieldSchemaKey: + name: CDSActionIdentifiersType + version: 0.0.1 + optional: false + - key: commonHeader + value: + key: commonHeader + fieldSchemaKey: + name: CDSRequestCommonHeaderType + version: 0.0.1 + optional: false + - key: payload + value: + key: payload + fieldSchemaKey: + name: CDSCreateSubscriptionPayloadType + version: 0.0.1 + optional: false + taskParameters: + entry: [] + contextAlbumReference: + - name: PMSubscriptionAlbum + version: 0.0.1 + taskLogic: + key: TaskLogic + logicFlavour: JAVASCRIPT + logic: |- + /* + * ============LICENSE_START======================================================= + * Copyright (C) 2020 Nordix. 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); + + var pmSubscriptionInfo = executor.getContextAlbum("PMSubscriptionAlbum").get(executor.inFields.get("albumID").toString()) + + var changeType = pmSubscriptionInfo.get("changeType").toLowerCase() + var blueprintName = pmSubscriptionInfo.get("blueprintName").toLowerCase() + var blueprintVersion = pmSubscriptionInfo.get("blueprintVersion").toLowerCase() + var payload = executor.inFields.get("payload") + var actionName = changeType + "-subscription" + + var commonHeader = executor.subject.getOutFieldSchemaHelper("commonHeader").createNewInstance(); + commonHeader.put("originatorId", "sdnc"); + commonHeader.put("requestId", executor.inFields.get("albumID").toString()); + commonHeader.put("subRequestId", "sub-123456-1000"); + + var actionIdentifiers = executor.subject.getOutFieldSchemaHelper("actionIdentifiers").createNewInstance(); + actionIdentifiers.put("actionName", actionName); + actionIdentifiers.put("blueprintName", blueprintName); + actionIdentifiers.put("blueprintVersion", blueprintVersion); + actionIdentifiers.put("mode", "sync"); + + executor.outFields.put("commonHeader", commonHeader); + executor.outFields.put("actionIdentifiers", actionIdentifiers); + executor.outFields.put("payload", payload); + + //var returnValue = executor.isTrue; + true; + - key: + name: DeleteSubscriptionPayloadTask + version: 0.0.1 + value: + key: + name: DeleteSubscriptionPayloadTask + version: 0.0.1 + inputFields: + entry: + - key: albumID + value: + key: albumID + fieldSchemaKey: + name: UUIDType + version: 0.0.1 + optional: false + outputFields: + entry: + - key: albumID + value: + key: albumID + fieldSchemaKey: + name: UUIDType + version: 0.0.1 + optional: false + - key: payload + value: + key: payload + fieldSchemaKey: + name: CDSDeleteSubscriptionPayloadType + version: 0.0.1 + optional: false + taskParameters: + entry: [] + contextAlbumReference: + - name: PMSubscriptionAlbum + version: 0.0.1 + taskLogic: + key: TaskLogic + logicFlavour: JAVASCRIPT + logic: |- + /* + * ============LICENSE_START======================================================= + * Copyright (C) 2020 Nordix. 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); + + var pmSubscriptionInfo = executor.getContextAlbum("PMSubscriptionAlbum").get(executor.inFields.get("albumID").toString()) + + var changeType = pmSubscriptionInfo.get("changeType").toLowerCase() + + var payloadProperties = executor.subject.getOutFieldSchemaHelper("payload").createNewSubInstance(changeType + "_DasH_subscription_DasH_properties_record"); + + payloadProperties.put("nfName", pmSubscriptionInfo.get("nfName")) + payloadProperties.put("subscriptionName", pmSubscriptionInfo.get("subscription").get("subscriptionName")) + payloadProperties.put("administrativeState", pmSubscriptionInfo.get("subscription").get("administrativeState")) + payloadProperties.put("fileBasedGP", pmSubscriptionInfo.get("subscription").get("fileBasedGP").toString()) + payloadProperties.put("fileLocation", pmSubscriptionInfo.get("subscription").get("fileLocation")) + payloadProperties.put("measurementGroups", pmSubscriptionInfo.get("subscription").get("measurementGroups")) + + var payloadEntry = executor.subject.getOutFieldSchemaHelper("payload").createNewSubInstance("CDSRequestPayloadEntry"); + payloadEntry.put(changeType + "_DasH_subscription_DasH_properties", payloadProperties) + + var payload = executor.subject.getOutFieldSchemaHelper("payload").createNewInstance(); + payload.put(changeType + "_DasH_subscription_DasH_request", payloadEntry); + + executor.outFields.put("albumID", executor.inFields.get("albumID")) + executor.outFields.put("payload", payload); + + //var returnValue = executor.isTrue; + true; + - key: + name: DeleteSubscriptionRequestTask + version: 0.0.1 + value: + key: + name: DeleteSubscriptionRequestTask + version: 0.0.1 + inputFields: + entry: + - key: albumID + value: + key: albumID + fieldSchemaKey: + name: UUIDType + version: 0.0.1 + optional: false + - key: payload + value: + key: payload + fieldSchemaKey: + name: CDSDeleteSubscriptionPayloadType + version: 0.0.1 + optional: false + outputFields: + entry: + - key: actionIdentifiers + value: + key: actionIdentifiers + fieldSchemaKey: + name: CDSActionIdentifiersType + version: 0.0.1 + optional: false + - key: commonHeader + value: + key: commonHeader + fieldSchemaKey: + name: CDSRequestCommonHeaderType + version: 0.0.1 + optional: false + - key: payload + value: + key: payload + fieldSchemaKey: + name: CDSDeleteSubscriptionPayloadType + version: 0.0.1 + optional: false + taskParameters: + entry: [] + contextAlbumReference: + - name: PMSubscriptionAlbum + version: 0.0.1 + taskLogic: + key: TaskLogic + logicFlavour: JAVASCRIPT + logic: |- + /* + * ============LICENSE_START======================================================= + * Copyright (C) 2020 Nordix. 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); + + var pmSubscriptionInfo = executor.getContextAlbum("PMSubscriptionAlbum").get(executor.inFields.get("albumID").toString()) + + var changeType = pmSubscriptionInfo.get("changeType").toLowerCase() + var blueprintName = pmSubscriptionInfo.get("blueprintName").toLowerCase() + var blueprintVersion = pmSubscriptionInfo.get("blueprintVersion").toLowerCase() + var payload = executor.inFields.get("payload") + var actionName = changeType + "-subscription" + + var commonHeader = executor.subject.getOutFieldSchemaHelper("commonHeader").createNewInstance(); + commonHeader.put("originatorId", "sdnc"); + commonHeader.put("requestId", executor.inFields.get("albumID").toString()); + commonHeader.put("subRequestId", "sub-123456-1000"); + + var actionIdentifiers = executor.subject.getOutFieldSchemaHelper("actionIdentifiers").createNewInstance(); + actionIdentifiers.put("actionName", actionName); + actionIdentifiers.put("blueprintName", blueprintName); + actionIdentifiers.put("blueprintVersion", blueprintVersion); + actionIdentifiers.put("mode", "sync"); + + executor.outFields.put("commonHeader", commonHeader); + executor.outFields.put("actionIdentifiers", actionIdentifiers); + executor.outFields.put("payload", payload); + + //var returnValue = executor.isTrue; + true; + - key: + name: ReceiveSubscriptionTask + version: 0.0.1 + value: + key: + name: ReceiveSubscriptionTask + version: 0.0.1 + inputFields: + entry: + - key: blueprintName + value: + key: blueprintName + fieldSchemaKey: + name: SimpleStringType + version: 0.0.1 + optional: false + - key: blueprintVersion + value: + key: blueprintVersion + fieldSchemaKey: + name: SimpleStringType + version: 0.0.1 + optional: false + - key: changeType + value: + key: changeType + fieldSchemaKey: + name: SimpleStringType + version: 0.0.1 + optional: false + - key: closedLoopControlName + value: + key: closedLoopControlName + fieldSchemaKey: + name: SimpleStringType + version: 0.0.1 + optional: false + - key: nfName + value: + key: nfName + fieldSchemaKey: + name: SimpleStringType + version: 0.0.1 + optional: false + - key: policyName + value: + key: policyName + fieldSchemaKey: + name: SimpleStringType + version: 0.0.1 + optional: false + - key: subscription + value: + key: subscription + fieldSchemaKey: + name: SubscriptionType + version: 0.0.1 + optional: false + outputFields: + entry: + - key: albumID + value: + key: albumID + fieldSchemaKey: + name: UUIDType + version: 0.0.1 + optional: false + taskParameters: + entry: [] + contextAlbumReference: + - name: PMSubscriptionAlbum + version: 0.0.1 + taskLogic: + key: TaskLogic + logicFlavour: JAVASCRIPT + logic: |- + /* + * ============LICENSE_START======================================================= + * Copyright (C) 2020 Nordix. 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========================================================= + */ + var uuidType = java.util.UUID; + + executor.logger.info(executor.subject.id); + + //albumID will be used to fetch info from our album later + var albumID = uuidType.randomUUID(); + var pmSubscriptionInfo = executor.getContextAlbum("PMSubscriptionAlbum").getSchemaHelper().createNewInstance(); + var returnValue = true; + + if(executor.inFields.get("policyName") != null) { + executor.logger.info("nfName in receive sub event " + executor.inFields.get("nfName")); + + var changeType = executor.inFields.get("changeType") + var nfName = executor.inFields.get("nfName") + var policyName = executor.inFields.get("policyName") + var closedLoopControlName = executor.inFields.get("closedLoopControlName") + var subscription = executor.inFields.get("subscription") + var blueprintName = executor.inFields.get("blueprintName") + var blueprintVersion = executor.inFields.get("blueprintVersion") + + pmSubscriptionInfo.put("nfName", executor.inFields.get("nfName")); + pmSubscriptionInfo.put("changeType", executor.inFields.get("changeType")) + pmSubscriptionInfo.put("policyName", executor.inFields.get("policyName")) + pmSubscriptionInfo.put("closedLoopControlName", executor.inFields.get("closedLoopControlName")) + pmSubscriptionInfo.put("subscription", subscription) + pmSubscriptionInfo.put("blueprintName", blueprintName) + pmSubscriptionInfo.put("blueprintVersion", blueprintVersion) + + + executor.getContextAlbum("PMSubscriptionAlbum").put(albumID.toString(), pmSubscriptionInfo); + + executor.outFields.put("albumID", albumID) + } else { + executor.message = "Received invalid event" + returnValue = false; + } + + returnValue; + events: + key: + name: PMControlPolicy_Events + version: 0.0.1 + eventMap: + entry: + - key: + name: CDSCreateResponseEvent + version: 0.0.1 + value: + key: + name: CDSCreateResponseEvent + version: 0.0.1 + nameSpace: org.onap.policy.apex.onap.pmcontrol + source: CDS + target: APEX + parameter: + entry: + - key: actionIdentifiers + value: + key: actionIdentifiers + fieldSchemaKey: + name: CDSActionIdentifiersType + version: 0.0.1 + optional: false + - key: commonHeader + value: + key: commonHeader + fieldSchemaKey: + name: CDSResponseCommonHeaderType + version: 0.0.1 + optional: false + - key: payload + value: + key: payload + fieldSchemaKey: + name: CDSCreateResponsePayloadType + version: 0.0.1 + optional: false + - key: status + value: + key: status + fieldSchemaKey: + name: CDSResponseStatusType + version: 0.0.1 + optional: false + - key: + name: CDSCreateSubscriptionRequestEvent + version: 0.0.1 + value: + key: + name: CDSCreateSubscriptionRequestEvent + version: 0.0.1 + nameSpace: org.onap.policy.apex.onap.pmcontrol + source: APEX + target: APEX + parameter: + entry: + - key: actionIdentifiers + value: + key: actionIdentifiers + fieldSchemaKey: + name: CDSActionIdentifiersType + version: 0.0.1 + optional: false + - key: commonHeader + value: + key: commonHeader + fieldSchemaKey: + name: CDSRequestCommonHeaderType + version: 0.0.1 + optional: false + - key: payload + value: + key: payload + fieldSchemaKey: + name: CDSCreateSubscriptionPayloadType + version: 0.0.1 + optional: false + - key: + name: CDSDeleteResponseEvent + version: 0.0.1 + value: + key: + name: CDSDeleteResponseEvent + version: 0.0.1 + nameSpace: org.onap.policy.apex.onap.pmcontrol + source: CDS + target: APEX + parameter: + entry: + - key: actionIdentifiers + value: + key: actionIdentifiers + fieldSchemaKey: + name: CDSActionIdentifiersType + version: 0.0.1 + optional: false + - key: commonHeader + value: + key: commonHeader + fieldSchemaKey: + name: CDSResponseCommonHeaderType + version: 0.0.1 + optional: false + - key: payload + value: + key: payload + fieldSchemaKey: + name: CDSDeleteResponsePayloadType + version: 0.0.1 + optional: false + - key: status + value: + key: status + fieldSchemaKey: + name: CDSResponseStatusType + version: 0.0.1 + optional: false + - key: + name: CDSDeleteSubscriptionRequestEvent + version: 0.0.1 + value: + key: + name: CDSDeleteSubscriptionRequestEvent + version: 0.0.1 + nameSpace: org.onap.policy.apex.onap.pmcontrol + source: APEX + target: APEX + parameter: + entry: + - key: actionIdentifiers + value: + key: actionIdentifiers + fieldSchemaKey: + name: CDSActionIdentifiersType + version: 0.0.1 + optional: false + - key: commonHeader + value: + key: commonHeader + fieldSchemaKey: + name: CDSRequestCommonHeaderType + version: 0.0.1 + optional: false + - key: payload + value: + key: payload + fieldSchemaKey: + name: CDSDeleteSubscriptionPayloadType + version: 0.0.1 + optional: false + - key: + name: CDSResponseStatusEvent + version: 0.0.1 + value: + key: + name: CDSResponseStatusEvent + version: 0.0.1 + nameSpace: org.onap.policy.apex.onap.pmcontrol + source: APEX + target: DCAE + parameter: + entry: + - key: status + value: + key: status + fieldSchemaKey: + name: SubscriptionStatusType + version: 0.0.1 + optional: false + - key: + name: CreateSubscriptionPayloadEvent + version: 0.0.1 + value: + key: + name: CreateSubscriptionPayloadEvent + version: 0.0.1 + nameSpace: org.onap.policy.apex.onap.pmcontrol + source: APEX + target: APEX + parameter: + entry: + - key: albumID + value: + key: albumID + fieldSchemaKey: + name: UUIDType + version: 0.0.1 + optional: false + - key: payload + value: + key: payload + fieldSchemaKey: + name: CDSCreateSubscriptionPayloadType + version: 0.0.1 + optional: false + - key: + name: DeleteSubscriptionPayloadEvent + version: 0.0.1 + value: + key: + name: DeleteSubscriptionPayloadEvent + version: 0.0.1 + nameSpace: org.onap.policy.apex.onap.pmcontrol + source: APEX + target: APEX + parameter: + entry: + - key: albumID + value: + key: albumID + fieldSchemaKey: + name: UUIDType + version: 0.0.1 + optional: false + - key: payload + value: + key: payload + fieldSchemaKey: + name: CDSDeleteSubscriptionPayloadType + version: 0.0.1 + optional: false + - key: + name: MRResponseEvent + version: 0.0.1 + value: + key: + name: MRResponseEvent + version: 0.0.1 + nameSpace: org.onap.policy.apex.onap.pmcontrol + source: DCAE + target: APEX + parameter: + entry: + - key: count + value: + key: count + fieldSchemaKey: + name: SimpleIntType + version: 0.0.1 + optional: false + - key: serverTimeMs + value: + key: serverTimeMs + fieldSchemaKey: + name: SimpleIntType + version: 0.0.1 + optional: false + - key: + name: PMSubscriptionOutputEvent + version: 0.0.1 + value: + key: + name: PMSubscriptionOutputEvent + version: 0.0.1 + nameSpace: org.onap.policy.apex.onap.pmcontrol + source: APEX + target: APEX + parameter: + entry: + - key: albumID + value: + key: albumID + fieldSchemaKey: + name: UUIDType + version: 0.0.1 + optional: false + - key: + name: pmsh-operational-policy + version: 0.0.1 + value: + key: + name: pmsh-operational-policy + version: 0.0.1 + nameSpace: org.onap.policy.apex.onap.pmcontrol + source: DCAE + target: APEX + parameter: + entry: + - key: blueprintName + value: + key: blueprintName + fieldSchemaKey: + name: SimpleStringType + version: 0.0.1 + optional: false + - key: blueprintVersion + value: + key: blueprintVersion + fieldSchemaKey: + name: SimpleStringType + version: 0.0.1 + optional: false + - key: changeType + value: + key: changeType + fieldSchemaKey: + name: SimpleStringType + version: 0.0.1 + optional: false + - key: closedLoopControlName + value: + key: closedLoopControlName + fieldSchemaKey: + name: SimpleStringType + version: 0.0.1 + optional: false + - key: nfName + value: + key: nfName + fieldSchemaKey: + name: SimpleStringType + version: 0.0.1 + optional: false + - key: policyName + value: + key: policyName + fieldSchemaKey: + name: SimpleStringType + version: 0.0.1 + optional: false + - key: subscription + value: + key: subscription + fieldSchemaKey: + name: SubscriptionType + version: 0.0.1 + optional: false + albums: + key: + name: PMControlPolicy_Albums + version: 0.0.1 + albums: + entry: + - key: + name: PMSubscriptionAlbum + version: 0.0.1 + value: + key: + name: PMSubscriptionAlbum + version: 0.0.1 + scope: policy + isWritable: true + itemSchema: + name: PMSubscriptionType + version: 0.0.1 + schemas: + key: + name: PMControlPolicy_Schemas + version: 0.0.1 + schemas: + entry: + - key: + name: CDSActionIdentifiersType + version: 0.0.1 + value: + key: + name: CDSActionIdentifiersType + version: 0.0.1 + schemaFlavour: Avro + schemaDefinition: |- + { + "type": "record", + "name": "ActionIdentifiers_Type", + "namespace": "org.onap.policy.apex.onap.helloworld", + "fields": [ + { + "name": "actionName", + "type": "string" + }, + { + "name": "blueprintName", + "type": "string" + }, + { + "name": "blueprintVersion", + "type": "string" + }, + { + "name": "mode", + "type": "string" + } + ] + } + - key: + name: CDSCreateResponsePayloadType + version: 0.0.1 + value: + key: + name: CDSCreateResponsePayloadType + version: 0.0.1 + schemaFlavour: Avro + schemaDefinition: |- + { + "name": "CreateResponsePayloadEntry", + "type": "record", + "namespace": "org.onap.policy.apex.onap.helloworld", + "fields": [ + { + "name": "create_DasH_subscription_DasH_response", + "type": { + "name": "create_DasH_subscription_DasH_response", + "type": "record", + "fields": [ + { + "name": "odl_DasH_response", + "type": { + "name": "odl_DasH_response", + "type": "record", + "fields": [ + { + "name": "status", + "type": "string" + } + ] + } + } + ] + } + } + ] + } + - key: + name: CDSCreateSubscriptionPayloadType + version: 0.0.1 + value: + key: + name: CDSCreateSubscriptionPayloadType + version: 0.0.1 + schemaFlavour: Avro + schemaDefinition: |- + { + "type": "map", + "values": { + "type": "record", + "name": "CDSRequestPayloadEntry", + "fields": [ + { + "name": "create_DasH_subscription_DasH_properties", + "type": { + "name": "create_DasH_subscription_DasH_properties_record", + "type": "record", + "fields": [ + { + "name": "nfName", + "type": "string" + }, + { + "name": "subscriptionName", + "type": "string" + }, + { + "name": "administrativeState", + "type": "string" + }, + { + "name": "fileBasedGP", + "type": "string" + }, + { + "name": "fileLocation", + "type": "string" + }, + { + "name": "measurementGroups", + "type": { + "type": "array", + "items": { + "name": "measurementGroups_record", + "type": "record", + "fields": [ + { + "name": "measurementGroup", + "type": { + "name": "measurementGroup", + "type": "record", + "fields": [ + { + "name": "measurementTypes", + "type": { + "type": "array", + "items": { + "name": "measurementTypes_record", + "type": "record", + "fields": [ + { + "name": "measurementType", + "type": "string" + } + ] + } + } + }, + { + "name": "managedObjectDNsBasic", + "type": { + "type": "array", + "items": { + "name": "managedObjectDNsBasic_record", + "type": "record", + "fields": [ + { + "name": "DN", + "type": "string" + } + ] + } + } + } + ] + } + } + ] + } + } + } + ] + } + } + ] + } + } + - key: + name: CDSDeleteResponsePayloadType + version: 0.0.1 + value: + key: + name: CDSDeleteResponsePayloadType + version: 0.0.1 + schemaFlavour: Avro + schemaDefinition: |- + { + "name": "DeleteResponsePayloadEntry", + "type": "record", + "namespace": "com.acme.avro", + "fields": [ + { + "name": "delete_DasH_subscription_DasH_response", + "type": { + "name": "delete_DasH_subscription_DasH_response", + "type": "record", + "fields": [ + { + "name": "odl_DasH_response", + "type": { + "name": "odl_DasH_response", + "type": "record", + "fields": [ + { + "name": "status", + "type": "string" + } + ] + } + } + ] + } + } + ] + } + - key: + name: CDSDeleteSubscriptionPayloadType + version: 0.0.1 + value: + key: + name: CDSDeleteSubscriptionPayloadType + version: 0.0.1 + schemaFlavour: Avro + schemaDefinition: |- + { + "type": "map", + "values": { + "type": "record", + "name": "CDSRequestPayloadEntry", + "fields": [ + { + "name": "delete_DasH_subscription_DasH_properties", + "type": { + "name": "delete_DasH_subscription_DasH_properties_record", + "type": "record", + "fields": [ + { + "name": "nfName", + "type": "string" + }, + { + "name": "subscriptionName", + "type": "string" + }, + { + "name": "administrativeState", + "type": "string" + }, + { + "name": "fileBasedGP", + "type": "string" + }, + { + "name": "fileLocation", + "type": "string" + }, + { + "name": "measurementGroups", + "type": { + "type": "array", + "items": { + "name": "measurementGroups_record", + "type": "record", + "fields": [ + { + "name": "measurementGroup", + "type": { + "name": "measurementGroup", + "type": "record", + "fields": [ + { + "name": "measurementTypes", + "type": { + "type": "array", + "items": { + "name": "measurementTypes_record", + "type": "record", + "fields": [ + { + "name": "measurementType", + "type": "string" + } + ] + } + } + }, + { + "name": "managedObjectDNsBasic", + "type": { + "type": "array", + "items": { + "name": "managedObjectDNsBasic_record", + "type": "record", + "fields": [ + { + "name": "DN", + "type": "string" + } + ] + } + } + } + ] + } + } + ] + } + } + } + ] + } + } + ] + } + } + - key: + name: CDSRequestCommonHeaderType + version: 0.0.1 + value: + key: + name: CDSRequestCommonHeaderType + version: 0.0.1 + schemaFlavour: Avro + schemaDefinition: |- + { + "type": "record", + "name": "RequestCommonHeader_Type", + "namespace": "org.onap.policy.apex.onap.helloworld", + "fields": [ + { + "name": "originatorId", + "type": "string" + }, + { + "name": "requestId", + "type": "string" + }, + { + "name": "subRequestId", + "type": "string" + } + ] + } + - key: + name: CDSResponseCommonHeaderType + version: 0.0.1 + value: + key: + name: CDSResponseCommonHeaderType + version: 0.0.1 + schemaFlavour: Avro + schemaDefinition: |- + { + "type": "record", + "name": "ResponseCommonHeader_Type", + "namespace": "org.onap.policy.apex.onap.helloworld", + "fields": [ + { + "name": "originatorId", + "type": "string" + }, + { + "name": "requestId", + "type": "string" + }, + { + "name": "subRequestId", + "type": "string" + }, + { + "name": "timestamp", + "type": "string" + }, + { + "name": "flags", + "type": ["null", "string"] + } + ] + } + - key: + name: CDSResponseStatusType + version: 0.0.1 + value: + key: + name: CDSResponseStatusType + version: 0.0.1 + schemaFlavour: Avro + schemaDefinition: |- + { + "type": "record", + "name": "ResponseStatus_Type", + "namespace": "org.onap.policy.apex.onap.helloworld", + "fields": [ + { + "name": "code", + "type": "int" + }, + { + "name": "eventType", + "type": "string" + }, + { + "name": "timestamp", + "type": "string" + }, + { + "name": "message", + "type": "string" + } + ] + } + - key: + name: PMSubscriptionType + version: 0.0.1 + value: + key: + name: PMSubscriptionType + version: 0.0.1 + schemaFlavour: Avro + schemaDefinition: "{\n\t\"name\": \"PMSubscription\",\n\t\"type\": + \"record\",\n\t\"namespace\": \"org.onap.policy.apex.onap.pmcontrol\",\n\t\"fields\": + [\n {\n \"name\": \"nfName\",\n \"type\": + \"string\"\n },\n\t {\n\t\t\t\"name\": \"changeType\",\n\t\t\t\"type\": + \"string\"\n\t\t},\n\t\t{\n\t\t\t\"name\": \"closedLoopControlName\",\n\t\t\t\"type\": + \"string\"\n\t\t},\n\t\t{\n\t\t\t\"name\": \"policyName\",\n\t\t\t\"type\": + \"string\"\n\t\t},\n\t\t{\n\t\t \"name\": \"blueprintName\",\n\t\t + \ \"type\": \"string\"\n\t\t},\n\t\t{\n\t\t \"name\": + \"blueprintVersion\",\n\t\t \"type\": \"string\"\n\t\t},\n\t\t{\n\t\t\t\"name\": + \"subscription\",\n\t\t\t\"type\": {\n\t\t\t\t\"name\": \"subscription\",\n\t\t\t\t\"type\": + \"record\",\n\t\t\t\t\"fields\": [{\n\t\t\t\t\t\t\"name\": + \"subscriptionName\",\n\t\t\t\t\t\t\"type\": \"string\"\n\t\t\t\t\t},\n\t\t\t\t\t{\n\t\t\t\t\t\t\"name\": + \"administrativeState\",\n\t\t\t\t\t\t\"type\": \"string\"\n\t\t\t\t\t},\n\t\t\t\t\t{\n\t\t\t\t\t\t\"name\": + \"fileBasedGP\",\n\t\t\t\t\t\t\"type\": \"int\"\n\t\t\t\t\t},\n\t\t\t\t\t{\n\t\t\t\t\t\t\"name\": + \"fileLocation\",\n\t\t\t\t\t\t\"type\": \"string\"\n\t\t\t\t\t},\n\t\t\t\t\t{\n\t\t\t\t\t\t\"name\": + \"measurementGroups\",\n\t\t\t\t\t\t\"type\": {\n\t\t\t\t\t\t\t\"type\": + \"array\",\n\t\t\t\t\t\t\t\"items\": {\n\t\t\t\t\t\t\t\t\"name\": + \"Measurement_Groups_Type\",\n\t\t\t\t\t\t\t\t\"type\": \"record\",\n\t\t\t\t\t\t\t\t\"fields\": + [{\n\t\t\t\t\t\t\t\t\t\"name\": \"measurementGroup\",\n\t\t\t\t\t\t\t\t\t\"type\": + {\n\t\t\t\t\t\t\t\t\t\t\"name\": \"Measurement_Group_Type\",\n\t\t\t\t\t\t\t\t\t\t\"type\": + \"record\",\n\t\t\t\t\t\t\t\t\t\t\"fields\": [{\n\t\t\t\t\t\t\t\t\t\t\t\t\"name\": + \"measurementTypes\",\n\t\t\t\t\t\t\t\t\t\t\t\t\"type\": {\n\t\t\t\t\t\t\t\t\t\t\t\t\t\"type\": + \"array\",\n\t\t\t\t\t\t\t\t\t\t\t\t\t\"items\": {\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\"name\": + \"Measurement_Types_Type\",\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\"type\": + \"record\",\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\"fields\": [{\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\"name\": + \"measurementType\",\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\"type\": + \"string\"\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t}]\n\t\t\t\t\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\t\t\t\t\"name\": + \"managedObjectDNsBasic\",\n\t\t\t\t\t\t\t\t\t\t\t\t\"type\": + {\n\t\t\t\t\t\t\t\t\t\t\t\t\t\"type\": \"array\",\n\t\t\t\t\t\t\t\t\t\t\t\t\t\"items\": + {\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\"name\": \"Managed_Object_Dns_Basic_Type\",\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\"type\": + \"record\",\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\"fields\": [{\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\"name\": + \"DN\",\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\"type\": \"string\"\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t}]\n\t\t\t\t\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\t\t]\n\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t}]\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t]\n\t\t\t}\n\t\t}\n\t]\n}" + - key: + name: SimpleIntType + version: 0.0.1 + value: + key: + name: SimpleIntType + version: 0.0.1 + schemaFlavour: Java + schemaDefinition: java.lang.Integer + - key: + name: SimpleStringType + version: 0.0.1 + value: + key: + name: SimpleStringType + version: 0.0.1 + schemaFlavour: Java + schemaDefinition: java.lang.String + - key: + name: SubscriptionStatusType + version: 0.0.1 + value: + key: + name: SubscriptionStatusType + version: 0.0.1 + schemaFlavour: Avro + schemaDefinition: |- + { + "type": "record", + "name": "ActivateSubscriptionStatus_Type", + "namespace": "org.onap.policy.apex.onap.helloworld", + "fields": [ + { + "name": "subscriptionName", + "type": "string" + }, + { + "name": "nfName", + "type": "string" + }, + { + "name": "changeType", + "type": "string" + }, + { + "name": "message", + "type": "string" + } + ] + } + - key: + name: SubscriptionType + version: 0.0.1 + value: + key: + name: SubscriptionType + version: 0.0.1 + schemaFlavour: Avro + schemaDefinition: "{\n\t\"name\": \"subscription\",\n\t\"type\": + \"record\",\n\t\"fields\": [{\n\t\t\t\"name\": \"subscriptionName\",\n\t\t\t\"type\": + \"string\"\n\t\t},\n\t\t{\n\t\t\t\"name\": \"administrativeState\",\n\t\t\t\"type\": + \"string\"\n\t\t},\n\t\t{\n\t\t\t\"name\": \"fileBasedGP\",\n\t\t\t\"type\": + \"int\"\n\t\t},\n\t\t{\n\t\t\t\"name\": \"fileLocation\",\n\t\t\t\"type\": + \"string\"\n\t\t},\n\t\t{\n\t\t\t\"name\": \"measurementGroups\",\n\t\t\t\"type\": + {\n\t\t\t\t\"type\": \"array\",\n\t\t\t\t\"items\": {\n\t\t\t\t\t\"name\": + \"Measurement_Groups_Type\",\n\t\t\t\t\t\"type\": \"record\",\n\t\t\t\t\t\"fields\": + [{\n\t\t\t\t\t\t\"name\": \"measurementGroup\",\n\t\t\t\t\t\t\"type\": + {\n\t\t\t\t\t\t\t\"name\": \"Measurement_Group_Type\",\n\t\t\t\t\t\t\t\"type\": + \"record\",\n\t\t\t\t\t\t\t\"fields\": [{\n\t\t\t\t\t\t\t\t\t\"name\": + \"measurementTypes\",\n\t\t\t\t\t\t\t\t\t\"type\": {\n\t\t\t\t\t\t\t\t\t\t\"type\": + \"array\",\n\t\t\t\t\t\t\t\t\t\t\"items\": {\n\t\t\t\t\t\t\t\t\t\t\t\"name\": + \"Measurement_Types_Type\",\n\t\t\t\t\t\t\t\t\t\t\t\"type\": + \"record\",\n\t\t\t\t\t\t\t\t\t\t\t\"fields\": [{\n\t\t\t\t\t\t\t\t\t\t\t\t\"name\": + \"measurementType\",\n\t\t\t\t\t\t\t\t\t\t\t\t\"type\": \"string\"\n\t\t\t\t\t\t\t\t\t\t\t}]\n\t\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\t\"name\": + \"managedObjectDNsBasic\",\n\t\t\t\t\t\t\t\t\t\"type\": {\n\t\t\t\t\t\t\t\t\t\t\"type\": + \"array\",\n\t\t\t\t\t\t\t\t\t\t\"items\": {\n\t\t\t\t\t\t\t\t\t\t\t\"name\": + \"Managed_Object_Dns_Basic_Type\",\n\t\t\t\t\t\t\t\t\t\t\t\"type\": + \"record\",\n\t\t\t\t\t\t\t\t\t\t\t\"fields\": [{\n\t\t\t\t\t\t\t\t\t\t\t\t\"name\": + \"DN\",\n\t\t\t\t\t\t\t\t\t\t\t\t\"type\": \"string\"\n\t\t\t\t\t\t\t\t\t\t\t}]\n\t\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t]\n\t\t\t\t\t\t}\n\t\t\t\t\t}]\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t]\n}" + - key: + name: UUIDType + version: 0.0.1 + value: + key: + name: UUIDType + version: 0.0.1 + schemaFlavour: Java + schemaDefinition: java.util.UUID + engineParameters: + executorParameters: + JAVASCRIPT: + parameterClassName: org.onap.policy.apex.plugins.executor.javascript.JavascriptExecutorParameters + contextParameters: + parameterClassName: org.onap.policy.apex.context.parameters.ContextParameters + schemaParameters: + Avro: + parameterClassName: org.onap.policy.apex.plugins.context.schema.avro.AvroSchemaHelperParameters + Java: + parameterClassName: org.onap.policy.apex.context.impl.schema.java.JavaSchemaHelperParameters + jsonAdapters: + Instant: + adaptedClass: java.time.Instant + adaptorClass: org.onap.policy.controlloop.util.Serialization$GsonInstantAdapter + eventInputParameters: + DCAEConsumer: + carrierTechnologyParameters: + carrierTechnology: RESTCLIENT + parameterClassName: org.onap.policy.apex.plugins.event.carrier.restclient.RestClientCarrierTechnologyParameters + parameters: + consumerPollTime: '50' + url: https://message-router:3905/events/unauthenticated.DCAE_CL_OUTPUT/cg1/sg1 + eventProtocolParameters: + eventProtocol: JSON + parameters: + nameAlias: policyName + eventName: pmsh-operational-policy + eventNameFilter: pmsh-operational-policy + CDSRequestConsumer: + carrierTechnologyParameters: + carrierTechnology: RESTREQUESTOR + parameterClassName: org.onap.policy.apex.plugins.event.carrier.restrequestor.RestRequestorCarrierTechnologyParameters + parameters: + url: http://10.10.10.184:30254/api/v1/execution-service/process + httpMethod: POST + restRequestTimeout: 2000 + httpHeaders: + - - Authorization + - Basic Y2NzZGthcHBzOmNjc2RrYXBwcw== + eventProtocolParameters: + eventProtocol: JSON + eventName: CDSCreateResponseEvent + eventNameFilter: CDSCreateResponseEvent + requestorMode: true + requestorPeer: CDSRequestProducer + requestorTimeout: 500 + CDSDeleteRequestConsumer: + carrierTechnologyParameters: + carrierTechnology: RESTREQUESTOR + parameterClassName: org.onap.policy.apex.plugins.event.carrier.restrequestor.RestRequestorCarrierTechnologyParameters + parameters: + url: http://10.10.10.184:30254/api/v1/execution-service/process + httpMethod: POST + restRequestTimeout: 2000 + httpHeaders: + - - Authorization + - Basic Y2NzZGthcHBzOmNjc2RrYXBwcw== + eventProtocolParameters: + eventProtocol: JSON + eventName: CDSDeleteResponseEvent + eventNameFilter: CDSDeleteResponseEvent + requestorMode: true + requestorPeer: CDSDeleteRequestProducer + requestorTimeout: 500 + CDSReplyConsumer: + carrierTechnologyParameters: + carrierTechnology: RESTREQUESTOR + parameterClassName: org.onap.policy.apex.plugins.event.carrier.restrequestor.RestRequestorCarrierTechnologyParameters + parameters: + url: https://message-router:3905/events/unauthenticated.PMSH_CL_INPUT + httpMethod: POST + restRequestTimeout: 2000 + eventProtocolParameters: + eventProtocol: JSON + eventName: MRResponseEvent + eventNameFilter: MRResponseEvent + requestorMode: true + requestorPeer: CDSReplyProducer + requestorTimeout: 500 + eventOutputParameters: + logOutputter: + carrierTechnologyParameters: + carrierTechnology: FILE + parameters: + fileName: "/tmp/outputevents.log" + eventProtocolParameters: + eventProtocol: JSON + StdOutOutputter: + carrierTechnologyParameters: + carrierTechnology: FILE + parameters: + standardIo: true + eventProtocolParameters: + eventProtocol: JSON + CDSRequestProducer: + carrierTechnologyParameters: + carrierTechnology: RESTREQUESTOR + parameterClassName: org.onap.policy.apex.plugins.event.carrier.restrequestor.RestRequestorCarrierTechnologyParameters + eventProtocolParameters: + eventProtocol: JSON + eventNameFilter: CDSCreateSubscriptionRequestEvent + requestorMode: true + requestorPeer: CDSRequestConsumer + requestorTimeout: 500 + CDSDeleteRequestProducer: + carrierTechnologyParameters: + carrierTechnology: RESTREQUESTOR + parameterClassName: org.onap.policy.apex.plugins.event.carrier.restrequestor.RestRequestorCarrierTechnologyParameters + eventProtocolParameters: + eventProtocol: JSON + eventNameFilter: CDSDeleteSubscriptionRequestEvent + requestorMode: true + requestorPeer: CDSDeleteRequestConsumer + requestorTimeout: 500 + CDSReplyProducer: + carrierTechnologyParameters: + carrierTechnology: RESTREQUESTOR + parameterClassName: org.onap.policy.apex.plugins.event.carrier.restrequestor.RestRequestorCarrierTechnologyParameters + eventProtocolParameters: + eventProtocol: JSON + eventNameFilter: CDSResponseStatusEvent + requestorMode: true + requestorPeer: CDSReplyConsumer + requestorTimeout: 500 diff --git a/common/src/test/resources/examples/acm/PMSubscriptionHandling.yaml b/common/src/test/resources/examples/acm/PMSubscriptionHandling.yaml new file mode 100644 index 000000000..8e8f3cd39 --- /dev/null +++ b/common/src/test/resources/examples/acm/PMSubscriptionHandling.yaml @@ -0,0 +1,3325 @@ +# ============LICENSE_START======================================================= +# Copyright (C) 2021 Nordix Foundation. +# ================================================================================ +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# SPDX-License-Identifier: Apache-2.0 +# ============LICENSE_END========================================================= +tosca_definitions_version: tosca_simple_yaml_1_3 +data_types: + onap.datatypes.ToscaConceptIdentifier: + derived_from: tosca.datatypes.Root + properties: + name: + type: string + required: true + version: + type: string + required: true + org.onap.datatypes.policy.clamp.controlloop.DCAEMicroserviceControlLoopElementConsulInfo: + name: org.onap.datatypes.policy.clamp.controlloop.DCAEMicroserviceControlLoopElementConsulInfo + version: 0.0.0 + derived_from: tosca.datatypes.Root + properties: + consulUrl: + name: consulUrl + type: string + typeVersion: 0.0.0 + description: Consul url for this entry + required: true + consul_body: + name: consulBody + type: string + typeVersion: 0.0.0 + description: Body of Consul entry + required: true + onap.datatypes.monitoring.managedObjectDNsBasic: + constraints: [] + properties: + DN: + name: DN + type: string + typeVersion: 0.0.0 + description: Managed object distinguished name + required: true + constraints: [] + metadata: {} + name: onap.datatypes.monitoring.managedObjectDNsBasic + version: 0.0.0 + derived_from: tosca.datatypes.Root + metadata: {} + onap.datatypes.monitoring.managedObjectDNsBasics: + constraints: [] + properties: + managedObjectDNsBasic: + name: managedObjectDNsBasic + type: map + typeVersion: 0.0.0 + description: Managed object distinguished name object + required: true + constraints: [] + entry_schema: + type: onap.datatypes.monitoring.managedObjectDNsBasic + typeVersion: 0.0.0 + constraints: [] + metadata: {} + name: onap.datatypes.monitoring.managedObjectDNsBasics + version: 0.0.0 + derived_from: tosca.datatypes.Root + metadata: {} + onap.datatypes.monitoring.measurementGroup: + constraints: [] + properties: + measurementTypes: + name: measurementTypes + type: list + typeVersion: 0.0.0 + description: List of measurement types + required: true + constraints: [] + entry_schema: + type: onap.datatypes.monitoring.measurementTypes + typeVersion: 0.0.0 + constraints: [] + metadata: {} + managedObjectDNsBasic: + name: managedObjectDNsBasic + type: list + typeVersion: 0.0.0 + description: List of managed object distinguished names + required: true + constraints: [] + entry_schema: + type: onap.datatypes.monitoring.managedObjectDNsBasics + typeVersion: 0.0.0 + constraints: [] + metadata: {} + name: onap.datatypes.monitoring.measurementGroup + version: 0.0.0 + derived_from: tosca.datatypes.Root + metadata: {} + onap.datatypes.monitoring.measurementGroups: + constraints: [] + properties: + measurementGroup: + name: measurementGroup + type: map + typeVersion: 0.0.0 + description: Measurement Group + required: true + constraints: [] + entry_schema: + type: onap.datatypes.monitoring.measurementGroup + typeVersion: 0.0.0 + constraints: [] + metadata: {} + name: onap.datatypes.monitoring.measurementGroups + version: 0.0.0 + derived_from: tosca.datatypes.Root + metadata: {} + onap.datatypes.monitoring.measurementType: + constraints: [] + properties: + measurementType: + name: measurementType + type: string + typeVersion: 0.0.0 + description: Measurement type + required: true + constraints: [] + metadata: {} + name: onap.datatypes.monitoring.measurementType + version: 0.0.0 + derived_from: tosca.datatypes.Root + metadata: {} + onap.datatypes.monitoring.measurementTypes: + constraints: [] + properties: + measurementType: + name: measurementType + type: map + typeVersion: 0.0.0 + description: Measurement type object + required: true + constraints: [] + entry_schema: + type: onap.datatypes.monitoring.measurementType + typeVersion: 0.0.0 + constraints: [] + metadata: {} + name: onap.datatypes.monitoring.measurementTypes + version: 0.0.0 + derived_from: tosca.datatypes.Root + metadata: {} + onap.datatypes.monitoring.nfFilter: + constraints: [] + properties: + modelNames: + name: modelNames + type: list + typeVersion: 0.0.0 + description: List of model names + required: true + constraints: [] + entry_schema: + type: string + typeVersion: 0.0.0 + constraints: [] + metadata: {} + modelInvariantIDs: + name: modelInvariantIDs + type: list + typeVersion: 0.0.0 + description: List of model invariant IDs + required: true + constraints: [] + entry_schema: + type: string + typeVersion: 0.0.0 + constraints: [] + metadata: {} + modelVersionIDs: + name: modelVersionIDs + type: list + typeVersion: 0.0.0 + description: List of model version IDs + required: true + constraints: [] + entry_schema: + type: string + typeVersion: 0.0.0 + constraints: [] + metadata: {} + nfNames: + name: nfNames + type: list + typeVersion: 0.0.0 + description: List of network functions + required: true + constraints: [] + entry_schema: + type: string + typeVersion: 0.0.0 + constraints: [] + metadata: {} + name: onap.datatypes.monitoring.nfFilter + version: 0.0.0 + derived_from: tosca.datatypes.Root + metadata: {} + onap.datatypes.monitoring.subscription: + constraints: [] + properties: + measurementGroups: + name: measurementGroups + type: list + typeVersion: 0.0.0 + description: Measurement Groups + required: true + constraints: [] + entry_schema: + type: onap.datatypes.monitoring.measurementGroups + typeVersion: 0.0.0 + constraints: [] + metadata: {} + fileBasedGP: + name: fileBasedGP + type: integer + typeVersion: 0.0.0 + description: File based granularity period + required: true + constraints: [] + metadata: {} + fileLocation: + name: fileLocation + type: string + typeVersion: 0.0.0 + description: ROP file location + required: true + constraints: [] + metadata: {} + subscriptionName: + name: subscriptionName + type: string + typeVersion: 0.0.0 + description: Name of the subscription + required: true + constraints: [] + metadata: {} + administrativeState: + name: administrativeState + type: string + typeVersion: 0.0.0 + description: State of the subscription + required: true + constraints: + - valid_values: + - LOCKED + - UNLOCKED + metadata: {} + nfFilter: + name: nfFilter + type: map + typeVersion: 0.0.0 + description: Network function filter + required: true + constraints: [] + entry_schema: + type: onap.datatypes.monitoring.nfFilter + typeVersion: 0.0.0 + constraints: [] + metadata: {} + name: onap.datatypes.monitoring.subscription + version: 0.0.0 + derived_from: tosca.datatypes.Root + metadata: {} +policy_types: + onap.policies.Monitoring: + derived_from: tosca.policies.Root + description: a base policy type for all policies that govern monitoring provisioning + version: 1.0.0 + name: onap.policies.Monitoring + onap.policies.monitoring.dcae-pm-subscription-handler: + properties: + pmsh_policy: + name: pmsh_policy + type: onap.datatypes.monitoring.subscription + typeVersion: 0.0.0 + description: PMSH Policy JSON + required: false + constraints: [] + metadata: {} + name: onap.policies.monitoring.dcae-pm-subscription-handler + version: 1.0.0 + derived_from: onap.policies.Monitoring + metadata: {} +node_types: + org.onap.policy.clamp.controlloop.Participant: + version: 1.0.1 + derived_from: tosca.nodetypes.Root + properties: + provider: + type: string + required: false + org.onap.policy.clamp.controlloop.ControlLoopElement: + version: 1.0.1 + derived_from: tosca.nodetypes.Root + properties: + provider: + type: string + required: false + participantType: + type: onap.datatypes.ToscaConceptIdentifier + required: true + startPhase: + type: integer + required: false + constraints: + - greater-or-equal: 0 + metadata: + common: true + description: A value indicating the start phase in which this control loop element will be started, the + first start phase is zero. Control Loop Elements are started in their start_phase order and stopped + in reverse start phase order. Control Loop Elements with the same start phase are started and + stopped simultaneously + org.onap.policy.clamp.controlloop.ControlLoop: + version: 1.0.1 + derived_from: tosca.nodetypes.Root + properties: + provider: + type: string + required: false + elements: + type: list + required: true + entry_schema: + type: onap.datatypes.ToscaConceptIdentifier + org.onap.policy.clamp.controlloop.DCAEMicroserviceControlLoopElement: + version: 1.0.1 + derived_from: org.onap.policy.clamp.controlloop.ControlLoopElement + properties: + dcae_blueprint_id: + type: onap.datatypes.ToscaConceptIdentifier + required: false + dcae_blueprint: + type: onap.dcae.cloudify_blueprint + required: false + consul_info: + type: list + required: false + entry_schema: + type: org.onap.datatypes.policy.clamp.controlloop.DCAEMicroserviceControlLoopElementConsulInfo + org.onap.policy.clamp.controlloop.PolicyControlLoopElement: + version: 1.0.1 + derived_from: org.onap.policy.clamp.controlloop.ControlLoopElement + properties: + policy_type_id: + type: onap.datatypes.ToscaConceptIdentifier + required: true + policy_id: + type: onap.datatypes.ToscaConceptIdentifier + required: false + org.onap.policy.clamp.controlloop.CDSControlLoopElement: + version: 1.0.1 + derived_from: org.onap.policy.clamp.controlloop.ControlLoopElement + properties: + cds_blueprint_id: + type: onap.datatypes.ToscaConceptIdentifier + required: true +topology_template: + inputs: + pmsh_monitoring_policy: + type: onap.datatypes.ToscaConceptIdentifier + description: The ID of the PMSH monitoring policy to use + default: + name: MICROSERVICE_vLoadBalancerMS_v1_0_dcae-pm-subscription-handler_1_0_0test + version: 1.0.0 + pmsh_operational_policy: + type: onap.datatypes.ToscaConceptIdentifier + description: The ID of the PMSH operational policy to use + default: + name: operational.apex.pmcontrol + version: 1.0.0 + node_templates: + org.onap.dcae.controlloop.DCAEMicroserviceControlLoopParticipant: + version: 2.3.4 + type: org.onap.policy.clamp.controlloop.Participant + type_version: 1.0.1 + description: Participant for DCAE microservices + properties: + provider: ONAP + org.onap.policy.controlloop.PolicyControlLoopParticipant: + version: 2.3.1 + type: org.onap.policy.clamp.controlloop.Participant + type_version: 1.0.1 + description: Participant for DCAE microservices + properties: + provider: ONAP + org.onap.ccsdk.cds.controlloop.CdsControlLoopParticipant: + version: 2.2.1 + type: org.onap.policy.clamp.controlloop.Participant + type_version: 1.0.1 + description: Participant for DCAE microservices + properties: + provider: ONAP + org.onap.domain.pmsh.PMSH_DCAEMicroservice: + version: 1.2.3 + type: org.onap.policy.clamp.controlloop.DCAEMicroserviceControlLoopElement + type_version: 1.0.0 + description: Control loop element for the DCAE microservice for Performance Management Subscription Handling + properties: + provider: Ericsson + participantType: + name: org.onap.dcae.controlloop.DCAEMicroserviceControlLoopParticipant + version: 2.3.4 + dcae_blueprint: + tosca_definitions_version: cloudify_dsl_1_3 + imports: + - https://www.getcloudify.org/spec/cloudify/4.5.5/types.yaml + - plugin:k8splugin?version=3.7.0 + - plugin:pgaas?version=1.3.0 + - plugin:clamppolicyplugin?version=1.1.0 + inputs: + tag_version: + type: string + description: Docker image to be used + default: nexus3.onap.org:10001/onap/org.onap.dcaegen2.services.pmsh:1.1.2 + replicas: + type: integer + description: Number of instances + default: 1 + operational_policy_name: + type: string + default: operational.apex.pmcontrol + control_loop_name: + type: string + default: pmsh-control-loop + pmsh_publish_topic_name: + type: string + default: unauthenticated.DCAE_CL_OUTPUT + policy_feedback_topic_name: + type: string + default: unauthenticated.PMSH_CL_INPUT + aai_notification_topic_name: + type: string + default: AAI-EVENT + publisher_client_role: + type: string + description: Client role to request secure access to topic + default: org.onap.dcae.pmPublisher + subscriber_client_role: + type: string + description: Client role to request secure access to topic + default: org.onap.dcae.pmSubscriber + dcae_location: + type: string + description: DCAE location for the subscriber, used to set up routing + default: san-francisco + cpu_limit: + type: string + default: 1000m + cpu_request: + type: string + default: 1000m + memory_limit: + type: string + default: 1024Mi + memory_request: + type: string + default: 1024Mi + pgaas_cluster_name: + type: string + default: dcae-pg-primary.onap + enable_tls: + type: boolean + default: true + protocol: + type: string + description: PMSH protocol. If enable_tls is false, set to http + default: https + policy_model_id: + type: string + default: onap.policies.monitoring.dcae-pm-subscription-handler + policy_id: + type: string + default: MICROSERVICE_vLoadBalancerMS_v1_0_dcae-pm-subscription-handler_1_0_0test + node_templates: + pgaasvm: + type: dcae.nodes.pgaas.database + properties: + writerfqdn: + get_input: pgaas_cluster_name + name: pmsh + pmsh: + type: dcae.nodes.ContainerizedServiceComponentUsingDmaap + interfaces: + cloudify.interfaces.lifecycle: + create: + inputs: + ports: + - '8443:0' + envs: + PMSH_PG_URL: + get_attribute: + - pgaasvm + - admin + - host + PMSH_PG_PASSWORD: + get_attribute: + - pgaasvm + - admin + - password + PMSH_PG_USERNAME: + get_attribute: + - pgaasvm + - admin + - user + PMSH_DB_NAME: + get_attribute: + - pgaasvm + - admin + - database + relationships: + - target: pmsh-policy + type: cloudify.relationships.depends_on + properties: + service_component_type: dcae-pmsh + service_component_name_override: dcae-pmsh + application_config: + enable_tls: + get_input: enable_tls + aaf_identity: dcae@dcae.onap.org + aaf_password: demo123456! + operational_policy_name: + get_input: operational_policy_name + control_loop_name: + get_input: control_loop_name + cert_path: /opt/app/pmsh/etc/certs/cert.pem + key_path: /opt/app/pmsh/etc/certs/key.pem + ca_cert_path: /opt/app/pmsh/etc/certs/cacert.pem + streams_publishes: + policy_pm_publisher: + type: message_router + dmaap_info: + topic_url: + concat: + - http://message-router:3904/events/ + - get_input: pmsh_publish_topic_name + streams_subscribes: + policy_pm_subscriber: + type: message_router + dmaap_info: + topic_url: + concat: + - http://message-router:3904/events/ + - get_input: policy_feedback_topic_name + aai_subscriber: + type: message_router + dmaap_info: + topic_url: + concat: + - http://message-router:3904/events/ + - get_input: aai_notification_topic_name + resource_config: + limits: + cpu: + get_input: cpu_limit + memory: + get_input: memory_limit + requests: + cpu: + get_input: cpu_request + memory: + get_input: memory_request + docker_config: + healthcheck: + endpoint: /healthcheck + interval: 15s + timeout: 1s + type: + get_input: protocol + image: + get_input: tag_version + replicas: + get_input: replicas + log_info: + log_directory: /var/log/ONAP/dcaegen2/services/pmsh + tls_info: + cert_directory: /opt/app/pmsh/etc/certs + use_tls: + get_input: enable_tls + pmsh-policy: + type: clamp.nodes.policy + properties: + policy_model_id: + get_input: policy_model_id + policy_id: + get_input: policy_id + consul_info: + - consulUrl: http://consul:31321/v1/kv/dcae-pmsh:policy + consulBody: + subscription: + subscriptionName: subscriptiona + administrativeState: UNLOCKED + fileBasedGP: 15 + fileLocation: /pm/pm.xml + nfFilter: + nfNames: + - ^pnf1.* + modelInvariantIDs: + - 5845y423-g654-6fju-po78-8n53154532k6 + - 7129e420-d396-4efb-af02-6b83499b12f8 + modelVersionIDs: + - e80a6ae3-cafd-4d24-850d-e14c084a5ca9 + measurementGroups: + - measurementGroup: + measurementTypes: + - measurementType: countera + - measurementType: counterb + managedObjectDNsBasic: + - DN: dna + - DN: dnb + - measurementGroup: + measurementTypes: + - measurementType: counterc + - measurementType: counterd + managedObjectDNsBasic: + - DN: dnc + - DN: dnd + org.onap.domain.pmsh.PMSH_MonitoringPolicyControlLoopElement: + version: 1.2.3 + type: org.onap.policy.clamp.controlloop.PolicyControlLoopElement + type_version: 1.0.0 + description: Control loop element for the monitoring policy for Performance Management Subscription Handling + properties: + provider: Ericsson + participantType: + name: org.onap.policy.controlloop.PolicyControlLoopParticipant + version: 2.3.1 + policy_type_id: + name: onap.policies.monitoring.pm-subscription-handler + version: 1.0.0 + policy_id: + get_input: pmsh_monitoring_policy + org.onap.domain.pmsh.PMSH_OperationalPolicyControlLoopElement: + version: 1.2.3 + type: org.onap.policy.clamp.controlloop.PolicyControlLoopElement + type_version: 1.0.0 + description: Control loop element for the operational policy for Performance Management Subscription Handling + properties: + provider: Ericsson + participantType: + name: org.onap.policy.controlloop.PolicyControlLoopParticipant + version: 2.2.1 + policy_type_id: + name: onap.policies.operational.pm-subscription-handler + version: 1.0.0 + policy_id: + get_input: pmsh_operational_policy + org.onap.domain.pmsh.PMSH_CDS_ControlLoopElement: + version: 1.2.3 + type: org.onap.policy.clamp.controlloop.CDSControlLoopElement + type_version: 1.0.0 + description: Control loop element for CDS for Performance Management Subscription Handling + properties: + provider: Ericsson + participantType: + name: org.onap.ccsdk.cds.controlloop.CdsControlLoopParticipant + version: 3.2.1 + cds_blueprint_id: + name: org.onap.ccsdk.cds.PMSHCdsBlueprint + version: 1.0.0 + org.onap.domain.pmsh.PMSHControlLoopDefinition: + version: 1.2.3 + type: org.onap.policy.clamp.controlloop.ControlLoop + type_version: 1.0.0 + description: Control loop for Performance Management Subscription Handling + properties: + provider: Ericsson + elements: + - name: org.onap.domain.pmsh.PMSH_DCAEMicroservice + version: 1.2.3 + - name: org.onap.domain.pmsh.PMSH_MonitoringPolicyControlLoopElement + version: 1.2.3 + - name: org.onap.domain.pmsh.PMSH_OperationalPolicyControlLoopElement + version: 1.2.3 + - name: org.onap.domain.pmsh.PMSH_CDS_ControlLoopElement + version: 1.2.3 + policies: + - MICROSERVICE_vLoadBalancerMS_v1_0_dcae-pm-subscription-handler_1_0_0test: + type: onap.policies.monitoring.dcae-pm-subscription-handler + type_version: 1.0.0 + name: MICROSERVICE_vLoadBalancerMS_v1_0_dcae-pm-subscription-handler_1_0_0test + version: 1.0.0 + metadata: + policy-id: MICROSERVICE_vLoadBalancerMS_v1_0_dcae-pm-subscription-handler_1_0_0test + policy-version: 1.0.0 + properties: + pmsh_policy: + fileBasedGP: 15 + fileLocation: /pm/pm.xml + subscriptionName: subscriptiona + administrativeState: UNLOCKED + nfFilter: + onap.datatypes.monitoring.nfFilter: + modelVersionIDs: + - e80a6ae3-cafd-4d24-850d-e14c084a5ca9 + modelInvariantIDs: + - 5845y423-g654-6fju-po78-8n53154532k6 + - 7129e420-d396-4efb-af02-6b83499b12f8 + modelNames: [] + nfNames: + - '"^pnf1.*"' + measurementGroups: + - measurementGroup: + onap.datatypes.monitoring.measurementGroup: + measurementTypes: + - measurementType: + onap.datatypes.monitoring.measurementType: + measurementType: countera + - measurementType: + onap.datatypes.monitoring.measurementType: + measurementType: counterb + managedObjectDNsBasic: + - managedObjectDNsBasic: + onap.datatypes.monitoring.managedObjectDNsBasic: + DN: dna + - managedObjectDNsBasic: + onap.datatypes.monitoring.managedObjectDNsBasic: + DN: dnb + - measurementGroup: + onap.datatypes.monitoring.measurementGroup: + measurementTypes: + - measurementType: + onap.datatypes.monitoring.measurementType: + measurementType: counterc + - measurementType: + onap.datatypes.monitoring.measurementType: + measurementType: counterd + managedObjectDNsBasic: + - managedObjectDNsBasic: + onap.datatypes.monitoring.managedObjectDNsBasic: + DN: dnc + - managedObjectDNsBasic: + onap.datatypes.monitoring.managedObjectDNsBasic: + DN: dnd + - operational.apex.pmcontrol: + type: onap.policies.controlloop.operational.common.Apex + type_version: 1.0.0 + version: 1.0.0 + metadata: + policy-id: operational.apex.pmcontrol + policy-version: 1 + properties: + engineServiceParameters: + name: MyApexEngine + version: 0.0.1 + id: 45 + instanceCount: 2 + deploymentPort: 12561 + policy_type_impl: + apexPolicyModel: + key: + name: PMControlPolicy + version: 0.0.1 + keyInformation: + key: + name: PMControlPolicy_KeyInfo + version: 0.0.1 + keyInfoMap: + entry: + - key: + name: CDSActionIdentifiersType + version: 0.0.1 + value: + key: + name: CDSActionIdentifiersType + version: 0.0.1 + UUID: 6e5fa19b-14df-37e3-a4ae-8c537e861a82 + description: Generated description for concept referred to by key "CDSActionIdentifiersType:0.0.1" + - key: + name: CDSCreateResponseEvent + version: 0.0.1 + value: + key: + name: CDSCreateResponseEvent + version: 0.0.1 + UUID: 14b29e38-ac75-3273-aa4e-8583c0aa7dad + description: Generated description for concept referred to by key "CDSCreateResponseEvent:0.0.1" + - key: + name: CDSCreateResponsePayloadType + version: 0.0.1 + value: + key: + name: CDSCreateResponsePayloadType + version: 0.0.1 + UUID: 04573f8f-e772-30a5-b1d9-d7318d4a1e13 + description: Generated description for concept referred to by key "CDSCreateResponsePayloadType:0.0.1" + - key: + name: CDSCreateResponsePolicy + version: 0.0.1 + value: + key: + name: CDSCreateResponsePolicy + version: 0.0.1 + UUID: e126c965-fc09-3bfe-8f55-70f380a4a49c + description: Generated description for concept referred to by key "CDSCreateResponsePolicy:0.0.1" + - key: + name: CDSCreateResponseTask + version: 0.0.1 + value: + key: + name: CDSCreateResponseTask + version: 0.0.1 + UUID: 6165ee82-afd2-3aab-a517-f00b3f2461d2 + description: Generated description for concept referred to by key "CDSCreateResponseTask:0.0.1" + - key: + name: CDSCreateSubscriptionPayloadType + version: 0.0.1 + value: + key: + name: CDSCreateSubscriptionPayloadType + version: 0.0.1 + UUID: 8350ac5e-c157-38b9-9614-a0f93a830e60 + description: Generated description for concept referred to by key "CDSCreateSubscriptionPayloadType:0.0.1" + - key: + name: CDSCreateSubscriptionRequestEvent + version: 0.0.1 + value: + key: + name: CDSCreateSubscriptionRequestEvent + version: 0.0.1 + UUID: cfa325ba-226b-3a31-9183-ec43e2b6e9a2 + description: Generated description for concept referred to by key "CDSCreateSubscriptionRequestEvent:0.0.1" + - key: + name: CDSDeleteResponseEvent + version: 0.0.1 + value: + key: + name: CDSDeleteResponseEvent + version: 0.0.1 + UUID: 8be9c0fa-7437-3841-aff2-b3cec6ae3bd8 + description: Generated description for concept referred to by key "CDSDeleteResponseEvent:0.0.1" + - key: + name: CDSDeleteResponsePayloadType + version: 0.0.1 + value: + key: + name: CDSDeleteResponsePayloadType + version: 0.0.1 + UUID: 3fbfe0c9-152e-34d3-a504-09cd13c058d0 + description: Generated description for concept referred to by key "CDSDeleteResponsePayloadType:0.0.1" + - key: + name: CDSDeleteResponsePolicy + version: 0.0.1 + value: + key: + name: CDSDeleteResponsePolicy + version: 0.0.1 + UUID: a780251c-edd5-3132-b865-04313246b43c + description: Generated description for concept referred to by key "CDSDeleteResponsePolicy:0.0.1" + - key: + name: CDSDeleteResponseTask + version: 0.0.1 + value: + key: + name: CDSDeleteResponseTask + version: 0.0.1 + UUID: afce4555-3aa3-3521-a7d8-ee8cdf0d3efc + description: Generated description for concept referred to by key "CDSDeleteResponseTask:0.0.1" + - key: + name: CDSDeleteSubscriptionPayloadType + version: 0.0.1 + value: + key: + name: CDSDeleteSubscriptionPayloadType + version: 0.0.1 + UUID: 12658406-9147-3c9d-a38c-5ad5e30b092b + description: Generated description for concept referred to by key "CDSDeleteSubscriptionPayloadType:0.0.1" + - key: + name: CDSDeleteSubscriptionRequestEvent + version: 0.0.1 + value: + key: + name: CDSDeleteSubscriptionRequestEvent + version: 0.0.1 + UUID: 24380c95-9289-36e6-8cbf-0edefa15ccd9 + description: Generated description for concept referred to by key "CDSDeleteSubscriptionRequestEvent:0.0.1" + - key: + name: CDSRequestCommonHeaderType + version: 0.0.1 + value: + key: + name: CDSRequestCommonHeaderType + version: 0.0.1 + UUID: 35590ac0-062c-39f1-8786-b4ff716e30b1 + description: Generated description for concept referred to by key "CDSRequestCommonHeaderType:0.0.1" + - key: + name: CDSResponseCommonHeaderType + version: 0.0.1 + value: + key: + name: CDSResponseCommonHeaderType + version: 0.0.1 + UUID: dd7e1805-885a-350b-aaf9-ed541321ae3c + description: Generated description for concept referred to by key "CDSResponseCommonHeaderType:0.0.1" + - key: + name: CDSResponseStatusEvent + version: 0.0.1 + value: + key: + name: CDSResponseStatusEvent + version: 0.0.1 + UUID: 7986e21b-32f7-302e-9554-31f21b673493 + description: Generated description for concept referred to by key "CDSResponseStatusEvent:0.0.1" + - key: + name: CDSResponseStatusType + version: 0.0.1 + value: + key: + name: CDSResponseStatusType + version: 0.0.1 + UUID: 92b8a2cf-344e-3ce1-8cc0-2b7d3cb695fa + description: Generated description for concept referred to by key "CDSResponseStatusType:0.0.1" + - key: + name: CreateSubscriptionPayloadEvent + version: 0.0.1 + value: + key: + name: CreateSubscriptionPayloadEvent + version: 0.0.1 + UUID: 92162397-1a8e-3a3f-a469-d2af7700af4a + description: Generated description for concept referred to by key "CreateSubscriptionPayloadEvent:0.0.1" + - key: + name: CreateSubscriptionPayloadTask + version: 0.0.1 + value: + key: + name: CreateSubscriptionPayloadTask + version: 0.0.1 + UUID: bc0c69f0-52ed-38ea-b468-ae4a6fd1730d + description: Generated description for concept referred to by key "CreateSubscriptionPayloadTask:0.0.1" + - key: + name: CreateSubscriptionRequestTask + version: 0.0.1 + value: + key: + name: CreateSubscriptionRequestTask + version: 0.0.1 + UUID: 89cb75e9-f06c-30d3-b4ff-698d45f63869 + description: Generated description for concept referred to by key "CreateSubscriptionRequestTask:0.0.1" + - key: + name: DeleteSubscriptionPayloadEvent + version: 0.0.1 + value: + key: + name: DeleteSubscriptionPayloadEvent + version: 0.0.1 + UUID: 994fa441-04ab-33bb-832d-1cd12ab5d074 + description: Generated description for concept referred to by key "DeleteSubscriptionPayloadEvent:0.0.1" + - key: + name: DeleteSubscriptionPayloadTask + version: 0.0.1 + value: + key: + name: DeleteSubscriptionPayloadTask + version: 0.0.1 + UUID: 0f519117-5fea-3e4b-941f-8f778100465f + description: Generated description for concept referred to by key "DeleteSubscriptionPayloadTask:0.0.1" + - key: + name: DeleteSubscriptionRequestTask + version: 0.0.1 + value: + key: + name: DeleteSubscriptionRequestTask + version: 0.0.1 + UUID: acb772fe-d442-39e3-98f9-b1080caf4150 + description: Generated description for concept referred to by key "DeleteSubscriptionRequestTask:0.0.1" + - key: + name: MRResponseEvent + version: 0.0.1 + value: + key: + name: MRResponseEvent + version: 0.0.1 + UUID: 13c747a3-6bae-3bcf-9c80-b152e01dc194 + description: Generated description for concept referred to by key "MRResponseEvent:0.0.1" + - key: + name: PMControlPolicy + version: 0.0.1 + value: + key: + name: PMControlPolicy + version: 0.0.1 + UUID: acf1e55c-7bc5-3bd5-975a-0ca54afcd8a4 + description: Generated description for concept referred to by key "PMControlPolicy:0.0.1" + - key: + name: PMControlPolicy_Albums + version: 0.0.1 + value: + key: + name: PMControlPolicy_Albums + version: 0.0.1 + UUID: b38ad204-c2c8-32f4-9b5a-dda0aeb0145b + description: Generated description for concept referred to by key "PMControlPolicy_Albums:0.0.1" + - key: + name: PMControlPolicy_Events + version: 0.0.1 + value: + key: + name: PMControlPolicy_Events + version: 0.0.1 + UUID: be3871a0-c42a-3113-a066-82d192840eca + description: Generated description for concept referred to by key "PMControlPolicy_Events:0.0.1" + - key: + name: PMControlPolicy_KeyInfo + version: 0.0.1 + value: + key: + name: PMControlPolicy_KeyInfo + version: 0.0.1 + UUID: ced37634-28a4-3178-b7f6-2980794927b0 + description: Generated description for concept referred to by key "PMControlPolicy_KeyInfo:0.0.1" + - key: + name: PMControlPolicy_Policies + version: 0.0.1 + value: + key: + name: PMControlPolicy_Policies + version: 0.0.1 + UUID: be3d180d-ef9c-3a75-8e9c-84271a038bed + description: Generated description for concept referred to by key "PMControlPolicy_Policies:0.0.1" + - key: + name: PMControlPolicy_Schemas + version: 0.0.1 + value: + key: + name: PMControlPolicy_Schemas + version: 0.0.1 + UUID: e61973f1-189c-39e5-82f6-0d3afe298a20 + description: Generated description for concept referred to by key "PMControlPolicy_Schemas:0.0.1" + - key: + name: PMControlPolicy_Tasks + version: 0.0.1 + value: + key: + name: PMControlPolicy_Tasks + version: 0.0.1 + UUID: 5658adb3-2962-30a3-a241-fae75bb8eb4a + description: Generated description for concept referred to by key "PMControlPolicy_Tasks:0.0.1" + - key: + name: PMSubscriptionAlbum + version: 0.0.1 + value: + key: + name: PMSubscriptionAlbum + version: 0.0.1 + UUID: c2bd6f0d-6854-317a-9be2-97c08338428c + description: Generated description for concept referred to by key "PMSubscriptionAlbum:0.0.1" + - key: + name: PMSubscriptionOutputEvent + version: 0.0.1 + value: + key: + name: PMSubscriptionOutputEvent + version: 0.0.1 + UUID: 992b7819-9f69-3aa0-bb0f-6e45ea15ce05 + description: Generated description for concept referred to by key "PMSubscriptionOutputEvent:0.0.1" + - key: + name: PMSubscriptionType + version: 0.0.1 + value: + key: + name: PMSubscriptionType + version: 0.0.1 + UUID: 73c1c397-4fc3-357f-93b6-a8ad707fbaae + description: Generated description for concept referred to by key "PMSubscriptionType:0.0.1" + - key: + name: ReceiveEventPolicy + version: 0.0.1 + value: + key: + name: ReceiveEventPolicy + version: 0.0.1 + UUID: 568b7345-9de1-36d3-b6a3-9b857e6809a1 + description: Generated description for concept referred to by key "ReceiveEventPolicy:0.0.1" + - key: + name: ReceiveSubscriptionTask + version: 0.0.1 + value: + key: + name: ReceiveSubscriptionTask + version: 0.0.1 + UUID: f596afc8-100c-35eb-92c8-352355ea457d + description: Generated description for concept referred to by key "ReceiveSubscriptionTask:0.0.1" + - key: + name: SimpleIntType + version: 0.0.1 + value: + key: + name: SimpleIntType + version: 0.0.1 + UUID: 153791fd-ae0a-36a7-88a5-309a7936415d + description: Generated description for concept referred to by key "SimpleIntType:0.0.1" + - key: + name: SimpleStringType + version: 0.0.1 + value: + key: + name: SimpleStringType + version: 0.0.1 + UUID: 8a4957cf-9493-3a76-8c22-a208e23259af + description: Generated description for concept referred to by key "SimpleStringType:0.0.1" + - key: + name: SubscriptionStatusType + version: 0.0.1 + value: + key: + name: SubscriptionStatusType + version: 0.0.1 + UUID: 597643b1-9db1-31ce-85d0-e1c63c43b30b + description: Generated description for concept referred to by key "SubscriptionStatusType:0.0.1" + - key: + name: SubscriptionType + version: 0.0.1 + value: + key: + name: SubscriptionType + version: 0.0.1 + UUID: 184547bb-7d64-3cb2-a273-d7185102c5ce + description: Generated description for concept referred to by key "SubscriptionType:0.0.1" + - key: + name: UUIDType + version: 0.0.1 + value: + key: + name: UUIDType + version: 0.0.1 + UUID: 6a8cc68e-dfc8-3403-9c6d-071c886b319c + description: Generated description for concept referred to by key "UUIDType:0.0.1" + - key: + name: pmsh-operational-policy + version: 0.0.1 + value: + key: + name: pmsh-operational-policy + version: 0.0.1 + UUID: fdf2c9ff-6422-3ea6-b6b6-49b12116265d + description: Generated description for concept referred to by key "pmsh-operational-policy:0.0.1" + policies: + key: + name: PMControlPolicy_Policies + version: 0.0.1 + policyMap: + entry: + - key: + name: CDSCreateResponsePolicy + version: 0.0.1 + value: + policyKey: + name: CDSCreateResponsePolicy + version: 0.0.1 + template: Freestyle + state: + entry: + - key: CDSCreateResponseState + value: + stateKey: + parentKeyName: CDSCreateResponsePolicy + parentKeyVersion: 0.0.1 + parentLocalName: 'NULL' + localName: CDSCreateResponseState + trigger: + name: CDSCreateResponseEvent + version: 0.0.1 + stateOutputs: + entry: + - key: ResponseOutput + value: + key: + parentKeyName: CDSCreateResponsePolicy + parentKeyVersion: 0.0.1 + parentLocalName: CDSCreateResponseState + localName: ResponseOutput + outgoingEvent: + name: CDSResponseStatusEvent + version: 0.0.1 + nextState: + parentKeyName: 'NULL' + parentKeyVersion: 0.0.0 + parentLocalName: 'NULL' + localName: 'NULL' + contextAlbumReference: [] + taskSelectionLogic: + key: 'NULL' + logicFlavour: UNDEFINED + logic: '' + stateFinalizerLogicMap: + entry: [] + defaultTask: + name: CDSCreateResponseTask + version: 0.0.1 + taskReferences: + entry: + - key: + name: CDSCreateResponseTask + version: 0.0.1 + value: + key: + parentKeyName: CDSCreateResponsePolicy + parentKeyVersion: 0.0.1 + parentLocalName: CDSCreateResponseState + localName: CDSCreateResponsePolicy + outputType: DIRECT + output: + parentKeyName: CDSCreateResponsePolicy + parentKeyVersion: 0.0.1 + parentLocalName: CDSCreateResponseState + localName: ResponseOutput + firstState: CDSCreateResponseState + - key: + name: CDSDeleteResponsePolicy + version: 0.0.1 + value: + policyKey: + name: CDSDeleteResponsePolicy + version: 0.0.1 + template: Freestyle + state: + entry: + - key: CDSDeleteResponseState + value: + stateKey: + parentKeyName: CDSDeleteResponsePolicy + parentKeyVersion: 0.0.1 + parentLocalName: 'NULL' + localName: CDSDeleteResponseState + trigger: + name: CDSDeleteResponseEvent + version: 0.0.1 + stateOutputs: + entry: + - key: ResponseOutput + value: + key: + parentKeyName: CDSDeleteResponsePolicy + parentKeyVersion: 0.0.1 + parentLocalName: CDSDeleteResponseState + localName: ResponseOutput + outgoingEvent: + name: CDSResponseStatusEvent + version: 0.0.1 + nextState: + parentKeyName: 'NULL' + parentKeyVersion: 0.0.0 + parentLocalName: 'NULL' + localName: 'NULL' + contextAlbumReference: [] + taskSelectionLogic: + key: 'NULL' + logicFlavour: UNDEFINED + logic: '' + stateFinalizerLogicMap: + entry: [] + defaultTask: + name: CDSDeleteResponseTask + version: 0.0.1 + taskReferences: + entry: + - key: + name: CDSDeleteResponseTask + version: 0.0.1 + value: + key: + parentKeyName: CDSDeleteResponsePolicy + parentKeyVersion: 0.0.1 + parentLocalName: CDSDeleteResponseState + localName: CDSDeleteResponsePolicy + outputType: DIRECT + output: + parentKeyName: CDSDeleteResponsePolicy + parentKeyVersion: 0.0.1 + parentLocalName: CDSDeleteResponseState + localName: ResponseOutput + firstState: CDSDeleteResponseState + - key: + name: ReceiveEventPolicy + version: 0.0.1 + value: + policyKey: + name: ReceiveEventPolicy + version: 0.0.1 + template: Freestyle + state: + entry: + - key: CreateOrDeleteState + value: + stateKey: + parentKeyName: ReceiveEventPolicy + parentKeyVersion: 0.0.1 + parentLocalName: 'NULL' + localName: CreateOrDeleteState + trigger: + name: PMSubscriptionOutputEvent + version: 0.0.1 + stateOutputs: + entry: + - key: CreateSubscriptionPayload + value: + key: + parentKeyName: ReceiveEventPolicy + parentKeyVersion: 0.0.1 + parentLocalName: CreateOrDeleteState + localName: CreateSubscriptionPayload + outgoingEvent: + name: CreateSubscriptionPayloadEvent + version: 0.0.1 + nextState: + parentKeyName: ReceiveEventPolicy + parentKeyVersion: 0.0.1 + parentLocalName: 'NULL' + localName: CreateSubscription + - key: DeleteSubscriptionPayload + value: + key: + parentKeyName: ReceiveEventPolicy + parentKeyVersion: 0.0.1 + parentLocalName: CreateOrDeleteState + localName: DeleteSubscriptionPayload + outgoingEvent: + name: DeleteSubscriptionPayloadEvent + version: 0.0.1 + nextState: + parentKeyName: ReceiveEventPolicy + parentKeyVersion: 0.0.1 + parentLocalName: 'NULL' + localName: DeleteSubscription + contextAlbumReference: + - name: PMSubscriptionAlbum + version: 0.0.1 + taskSelectionLogic: + key: TaskSelectionLogic + logicFlavour: JAVASCRIPT + logic: |- + /* + * ============LICENSE_START======================================================= + * Copyright (C) 2020 Nordix. 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); + + var pmSubscriptionInfo = executor.getContextAlbum("PMSubscriptionAlbum").get(executor.inFields.get("albumID").toString()) + var changeType = pmSubscriptionInfo.get("changeType").toString() + + executor.logger.info("Change Type is " + changeType) + + if ("CREATE".equals(changeType)) { + executor.logger.info("Choosing to create a subscription") + executor.subject.getTaskKey("CreateSubscriptionPayloadTask").copyTo(executor.selectedTask); + } + else if ("DELETE".equals(changeType)) { + executor.logger.info("Choosing to delete a subscription") + executor.subject.getTaskKey("DeleteSubscriptionPayloadTask").copyTo(executor.selectedTask); + } + + //var returnValue = executor.isTrue; + true; + stateFinalizerLogicMap: + entry: [] + defaultTask: + name: CreateSubscriptionPayloadTask + version: 0.0.1 + taskReferences: + entry: + - key: + name: CreateSubscriptionPayloadTask + version: 0.0.1 + value: + key: + parentKeyName: ReceiveEventPolicy + parentKeyVersion: 0.0.1 + parentLocalName: CreateOrDeleteState + localName: ReceiveEventPolicy + outputType: DIRECT + output: + parentKeyName: ReceiveEventPolicy + parentKeyVersion: 0.0.1 + parentLocalName: CreateOrDeleteState + localName: CreateSubscriptionPayload + - key: + name: DeleteSubscriptionPayloadTask + version: 0.0.1 + value: + key: + parentKeyName: ReceiveEventPolicy + parentKeyVersion: 0.0.1 + parentLocalName: CreateOrDeleteState + localName: ReceiveEventPolicy + outputType: DIRECT + output: + parentKeyName: ReceiveEventPolicy + parentKeyVersion: 0.0.1 + parentLocalName: CreateOrDeleteState + localName: DeleteSubscriptionPayload + - key: CreateSubscription + value: + stateKey: + parentKeyName: ReceiveEventPolicy + parentKeyVersion: 0.0.1 + parentLocalName: 'NULL' + localName: CreateSubscription + trigger: + name: CreateSubscriptionPayloadEvent + version: 0.0.1 + stateOutputs: + entry: + - key: IssueCreateSubscriptionRequestOutput + value: + key: + parentKeyName: ReceiveEventPolicy + parentKeyVersion: 0.0.1 + parentLocalName: CreateSubscription + localName: IssueCreateSubscriptionRequestOutput + outgoingEvent: + name: CDSCreateSubscriptionRequestEvent + version: 0.0.1 + nextState: + parentKeyName: 'NULL' + parentKeyVersion: 0.0.0 + parentLocalName: 'NULL' + localName: 'NULL' + contextAlbumReference: + - name: PMSubscriptionAlbum + version: 0.0.1 + taskSelectionLogic: + key: 'NULL' + logicFlavour: UNDEFINED + logic: '' + stateFinalizerLogicMap: + entry: [] + defaultTask: + name: CreateSubscriptionRequestTask + version: 0.0.1 + taskReferences: + entry: + - key: + name: CreateSubscriptionRequestTask + version: 0.0.1 + value: + key: + parentKeyName: ReceiveEventPolicy + parentKeyVersion: 0.0.1 + parentLocalName: CreateSubscription + localName: ReceiveEventPolicy + outputType: DIRECT + output: + parentKeyName: ReceiveEventPolicy + parentKeyVersion: 0.0.1 + parentLocalName: CreateSubscription + localName: IssueCreateSubscriptionRequestOutput + - key: DeleteSubscription + value: + stateKey: + parentKeyName: ReceiveEventPolicy + parentKeyVersion: 0.0.1 + parentLocalName: 'NULL' + localName: DeleteSubscription + trigger: + name: DeleteSubscriptionPayloadEvent + version: 0.0.1 + stateOutputs: + entry: + - key: IssueDeleteSubscriptionRequestOutput + value: + key: + parentKeyName: ReceiveEventPolicy + parentKeyVersion: 0.0.1 + parentLocalName: DeleteSubscription + localName: IssueDeleteSubscriptionRequestOutput + outgoingEvent: + name: CDSDeleteSubscriptionRequestEvent + version: 0.0.1 + nextState: + parentKeyName: 'NULL' + parentKeyVersion: 0.0.0 + parentLocalName: 'NULL' + localName: 'NULL' + contextAlbumReference: + - name: PMSubscriptionAlbum + version: 0.0.1 + taskSelectionLogic: + key: 'NULL' + logicFlavour: UNDEFINED + logic: '' + stateFinalizerLogicMap: + entry: [] + defaultTask: + name: DeleteSubscriptionRequestTask + version: 0.0.1 + taskReferences: + entry: + - key: + name: DeleteSubscriptionRequestTask + version: 0.0.1 + value: + key: + parentKeyName: ReceiveEventPolicy + parentKeyVersion: 0.0.1 + parentLocalName: DeleteSubscription + localName: ReceiveEventPolicy + outputType: DIRECT + output: + parentKeyName: ReceiveEventPolicy + parentKeyVersion: 0.0.1 + parentLocalName: DeleteSubscription + localName: IssueDeleteSubscriptionRequestOutput + - key: ReceiveSubscriptionState + value: + stateKey: + parentKeyName: ReceiveEventPolicy + parentKeyVersion: 0.0.1 + parentLocalName: 'NULL' + localName: ReceiveSubscriptionState + trigger: + name: pmsh-operational-policy + version: 0.0.1 + stateOutputs: + entry: + - key: ReceivePMSubscriptionOutput + value: + key: + parentKeyName: ReceiveEventPolicy + parentKeyVersion: 0.0.1 + parentLocalName: ReceiveSubscriptionState + localName: ReceivePMSubscriptionOutput + outgoingEvent: + name: PMSubscriptionOutputEvent + version: 0.0.1 + nextState: + parentKeyName: ReceiveEventPolicy + parentKeyVersion: 0.0.1 + parentLocalName: 'NULL' + localName: CreateOrDeleteState + contextAlbumReference: + - name: PMSubscriptionAlbum + version: 0.0.1 + taskSelectionLogic: + key: 'NULL' + logicFlavour: UNDEFINED + logic: '' + stateFinalizerLogicMap: + entry: [] + defaultTask: + name: ReceiveSubscriptionTask + version: 0.0.1 + taskReferences: + entry: + - key: + name: ReceiveSubscriptionTask + version: 0.0.1 + value: + key: + parentKeyName: ReceiveEventPolicy + parentKeyVersion: 0.0.1 + parentLocalName: ReceiveSubscriptionState + localName: ReceiveEventPolicy + outputType: DIRECT + output: + parentKeyName: ReceiveEventPolicy + parentKeyVersion: 0.0.1 + parentLocalName: ReceiveSubscriptionState + localName: ReceivePMSubscriptionOutput + firstState: ReceiveSubscriptionState + tasks: + key: + name: PMControlPolicy_Tasks + version: 0.0.1 + taskMap: + entry: + - key: + name: CDSCreateResponseTask + version: 0.0.1 + value: + key: + name: CDSCreateResponseTask + version: 0.0.1 + inputFields: + entry: + - key: actionIdentifiers + value: + key: actionIdentifiers + fieldSchemaKey: + name: CDSActionIdentifiersType + version: 0.0.1 + optional: false + - key: commonHeader + value: + key: commonHeader + fieldSchemaKey: + name: CDSResponseCommonHeaderType + version: 0.0.1 + optional: false + - key: payload + value: + key: payload + fieldSchemaKey: + name: CDSCreateResponsePayloadType + version: 0.0.1 + optional: false + - key: status + value: + key: status + fieldSchemaKey: + name: CDSResponseStatusType + version: 0.0.1 + optional: false + outputFields: + entry: + - key: status + value: + key: status + fieldSchemaKey: + name: SubscriptionStatusType + version: 0.0.1 + optional: false + taskParameters: + entry: [] + contextAlbumReference: + - name: PMSubscriptionAlbum + version: 0.0.1 + taskLogic: + key: TaskLogic + logicFlavour: JAVASCRIPT + logic: |- + /* + * ============LICENSE_START======================================================= + * Copyright (C) 2020 Nordix. 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); + + var commonHeader = executor.inFields.get("commonHeader") + var response = executor.inFields.get("payload") + var albumID = commonHeader.get("requestId") + + var pmSubscriptionInfo = executor.getContextAlbum("PMSubscriptionAlbum").get(albumID.toString()); + var responseStatus = executor.subject.getOutFieldSchemaHelper("status").createNewInstance(); + + responseStatus.put("subscriptionName", pmSubscriptionInfo.get("subscription").get("subscriptionName")) + responseStatus.put("nfName", pmSubscriptionInfo.get("nfName")) + responseStatus.put("changeType", pmSubscriptionInfo.get("changeType")) + + var status = response.get(pmSubscriptionInfo.get("changeType").toLowerCase() + "_DasH_subscription_DasH_response").get("odl_DasH_response").get("status") + + executor.logger.info("RESPONSE STATUS = " + status) + + if(status == "success") { + responseStatus.put("message", "success") + } else { + responseStatus.put("message", "failed") + } + + executor.outFields.put("status", responseStatus) + + //var returnValue = executor.isTrue; + true; + - key: + name: CDSDeleteResponseTask + version: 0.0.1 + value: + key: + name: CDSDeleteResponseTask + version: 0.0.1 + inputFields: + entry: + - key: actionIdentifiers + value: + key: actionIdentifiers + fieldSchemaKey: + name: CDSActionIdentifiersType + version: 0.0.1 + optional: false + - key: commonHeader + value: + key: commonHeader + fieldSchemaKey: + name: CDSResponseCommonHeaderType + version: 0.0.1 + optional: false + - key: payload + value: + key: payload + fieldSchemaKey: + name: CDSDeleteResponsePayloadType + version: 0.0.1 + optional: false + - key: status + value: + key: status + fieldSchemaKey: + name: CDSResponseStatusType + version: 0.0.1 + optional: false + outputFields: + entry: + - key: status + value: + key: status + fieldSchemaKey: + name: SubscriptionStatusType + version: 0.0.1 + optional: false + taskParameters: + entry: [] + contextAlbumReference: + - name: PMSubscriptionAlbum + version: 0.0.1 + taskLogic: + key: TaskLogic + logicFlavour: JAVASCRIPT + logic: |- + /* + * ============LICENSE_START======================================================= + * Copyright (C) 2020 Nordix. 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); + + var commonHeader = executor.inFields.get("commonHeader") + var response = executor.inFields.get("payload") + var albumID = commonHeader.get("requestId") + + var pmSubscriptionInfo = executor.getContextAlbum("PMSubscriptionAlbum").get(albumID.toString()); + var responseStatus = executor.subject.getOutFieldSchemaHelper("status").createNewInstance(); + + responseStatus.put("subscriptionName", pmSubscriptionInfo.get("subscription").get("subscriptionName")) + responseStatus.put("nfName", pmSubscriptionInfo.get("nfName")) + responseStatus.put("changeType", pmSubscriptionInfo.get("changeType")) + + var status = response.get(pmSubscriptionInfo.get("changeType").toLowerCase() + "_DasH_subscription_DasH_response").get("odl_DasH_response").get("status") + + executor.logger.info("RESPONSE STATUS = " + status) + + if(status == "success") { + responseStatus.put("message", "success") + } else { + responseStatus.put("message", "failed") + } + + executor.outFields.put("status", responseStatus) + + //var returnValue = executor.isTrue; + true; + - key: + name: CreateSubscriptionPayloadTask + version: 0.0.1 + value: + key: + name: CreateSubscriptionPayloadTask + version: 0.0.1 + inputFields: + entry: + - key: albumID + value: + key: albumID + fieldSchemaKey: + name: UUIDType + version: 0.0.1 + optional: false + outputFields: + entry: + - key: albumID + value: + key: albumID + fieldSchemaKey: + name: UUIDType + version: 0.0.1 + optional: false + - key: payload + value: + key: payload + fieldSchemaKey: + name: CDSCreateSubscriptionPayloadType + version: 0.0.1 + optional: false + taskParameters: + entry: [] + contextAlbumReference: + - name: PMSubscriptionAlbum + version: 0.0.1 + taskLogic: + key: TaskLogic + logicFlavour: JAVASCRIPT + logic: |- + /* + * ============LICENSE_START======================================================= + * Copyright (C) 2020 Nordix. 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); + + var pmSubscriptionInfo = executor.getContextAlbum("PMSubscriptionAlbum").get(executor.inFields.get("albumID").toString()) + + var changeType = pmSubscriptionInfo.get("changeType").toLowerCase() + + var payloadProperties = executor.subject.getOutFieldSchemaHelper("payload").createNewSubInstance(changeType + "_DasH_subscription_DasH_properties_record"); + + payloadProperties.put("nfName", pmSubscriptionInfo.get("nfName")) + payloadProperties.put("subscriptionName", pmSubscriptionInfo.get("subscription").get("subscriptionName")) + payloadProperties.put("administrativeState", pmSubscriptionInfo.get("subscription").get("administrativeState")) + payloadProperties.put("fileBasedGP", pmSubscriptionInfo.get("subscription").get("fileBasedGP").toString()) + payloadProperties.put("fileLocation", pmSubscriptionInfo.get("subscription").get("fileLocation")) + payloadProperties.put("measurementGroups", pmSubscriptionInfo.get("subscription").get("measurementGroups")) + + var payloadEntry = executor.subject.getOutFieldSchemaHelper("payload").createNewSubInstance("CDSRequestPayloadEntry"); + payloadEntry.put(changeType + "_DasH_subscription_DasH_properties", payloadProperties) + + var payload = executor.subject.getOutFieldSchemaHelper("payload").createNewInstance(); + payload.put(changeType + "_DasH_subscription_DasH_request", payloadEntry); + + executor.outFields.put("albumID", executor.inFields.get("albumID")) + executor.outFields.put("payload", payload); + + //var returnValue = executor.isTrue; + true; + - key: + name: CreateSubscriptionRequestTask + version: 0.0.1 + value: + key: + name: CreateSubscriptionRequestTask + version: 0.0.1 + inputFields: + entry: + - key: albumID + value: + key: albumID + fieldSchemaKey: + name: UUIDType + version: 0.0.1 + optional: false + - key: payload + value: + key: payload + fieldSchemaKey: + name: CDSCreateSubscriptionPayloadType + version: 0.0.1 + optional: false + outputFields: + entry: + - key: actionIdentifiers + value: + key: actionIdentifiers + fieldSchemaKey: + name: CDSActionIdentifiersType + version: 0.0.1 + optional: false + - key: commonHeader + value: + key: commonHeader + fieldSchemaKey: + name: CDSRequestCommonHeaderType + version: 0.0.1 + optional: false + - key: payload + value: + key: payload + fieldSchemaKey: + name: CDSCreateSubscriptionPayloadType + version: 0.0.1 + optional: false + taskParameters: + entry: [] + contextAlbumReference: + - name: PMSubscriptionAlbum + version: 0.0.1 + taskLogic: + key: TaskLogic + logicFlavour: JAVASCRIPT + logic: |- + /* + * ============LICENSE_START======================================================= + * Copyright (C) 2020 Nordix. 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); + + var pmSubscriptionInfo = executor.getContextAlbum("PMSubscriptionAlbum").get(executor.inFields.get("albumID").toString()) + + var changeType = pmSubscriptionInfo.get("changeType").toLowerCase() + var blueprintName = pmSubscriptionInfo.get("blueprintName").toLowerCase() + var blueprintVersion = pmSubscriptionInfo.get("blueprintVersion").toLowerCase() + var payload = executor.inFields.get("payload") + var actionName = changeType + "-subscription" + + var commonHeader = executor.subject.getOutFieldSchemaHelper("commonHeader").createNewInstance(); + commonHeader.put("originatorId", "sdnc"); + commonHeader.put("requestId", executor.inFields.get("albumID").toString()); + commonHeader.put("subRequestId", "sub-123456-1000"); + + var actionIdentifiers = executor.subject.getOutFieldSchemaHelper("actionIdentifiers").createNewInstance(); + actionIdentifiers.put("actionName", actionName); + actionIdentifiers.put("blueprintName", blueprintName); + actionIdentifiers.put("blueprintVersion", blueprintVersion); + actionIdentifiers.put("mode", "sync"); + + executor.outFields.put("commonHeader", commonHeader); + executor.outFields.put("actionIdentifiers", actionIdentifiers); + executor.outFields.put("payload", payload); + + //var returnValue = executor.isTrue; + true; + - key: + name: DeleteSubscriptionPayloadTask + version: 0.0.1 + value: + key: + name: DeleteSubscriptionPayloadTask + version: 0.0.1 + inputFields: + entry: + - key: albumID + value: + key: albumID + fieldSchemaKey: + name: UUIDType + version: 0.0.1 + optional: false + outputFields: + entry: + - key: albumID + value: + key: albumID + fieldSchemaKey: + name: UUIDType + version: 0.0.1 + optional: false + - key: payload + value: + key: payload + fieldSchemaKey: + name: CDSDeleteSubscriptionPayloadType + version: 0.0.1 + optional: false + taskParameters: + entry: [] + contextAlbumReference: + - name: PMSubscriptionAlbum + version: 0.0.1 + taskLogic: + key: TaskLogic + logicFlavour: JAVASCRIPT + logic: |- + /* + * ============LICENSE_START======================================================= + * Copyright (C) 2020 Nordix. 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); + + var pmSubscriptionInfo = executor.getContextAlbum("PMSubscriptionAlbum").get(executor.inFields.get("albumID").toString()) + + var changeType = pmSubscriptionInfo.get("changeType").toLowerCase() + + var payloadProperties = executor.subject.getOutFieldSchemaHelper("payload").createNewSubInstance(changeType + "_DasH_subscription_DasH_properties_record"); + + payloadProperties.put("nfName", pmSubscriptionInfo.get("nfName")) + payloadProperties.put("subscriptionName", pmSubscriptionInfo.get("subscription").get("subscriptionName")) + payloadProperties.put("administrativeState", pmSubscriptionInfo.get("subscription").get("administrativeState")) + payloadProperties.put("fileBasedGP", pmSubscriptionInfo.get("subscription").get("fileBasedGP").toString()) + payloadProperties.put("fileLocation", pmSubscriptionInfo.get("subscription").get("fileLocation")) + payloadProperties.put("measurementGroups", pmSubscriptionInfo.get("subscription").get("measurementGroups")) + + var payloadEntry = executor.subject.getOutFieldSchemaHelper("payload").createNewSubInstance("CDSRequestPayloadEntry"); + payloadEntry.put(changeType + "_DasH_subscription_DasH_properties", payloadProperties) + + var payload = executor.subject.getOutFieldSchemaHelper("payload").createNewInstance(); + payload.put(changeType + "_DasH_subscription_DasH_request", payloadEntry); + + executor.outFields.put("albumID", executor.inFields.get("albumID")) + executor.outFields.put("payload", payload); + + //var returnValue = executor.isTrue; + true; + - key: + name: DeleteSubscriptionRequestTask + version: 0.0.1 + value: + key: + name: DeleteSubscriptionRequestTask + version: 0.0.1 + inputFields: + entry: + - key: albumID + value: + key: albumID + fieldSchemaKey: + name: UUIDType + version: 0.0.1 + optional: false + - key: payload + value: + key: payload + fieldSchemaKey: + name: CDSDeleteSubscriptionPayloadType + version: 0.0.1 + optional: false + outputFields: + entry: + - key: actionIdentifiers + value: + key: actionIdentifiers + fieldSchemaKey: + name: CDSActionIdentifiersType + version: 0.0.1 + optional: false + - key: commonHeader + value: + key: commonHeader + fieldSchemaKey: + name: CDSRequestCommonHeaderType + version: 0.0.1 + optional: false + - key: payload + value: + key: payload + fieldSchemaKey: + name: CDSDeleteSubscriptionPayloadType + version: 0.0.1 + optional: false + taskParameters: + entry: [] + contextAlbumReference: + - name: PMSubscriptionAlbum + version: 0.0.1 + taskLogic: + key: TaskLogic + logicFlavour: JAVASCRIPT + logic: |- + /* + * ============LICENSE_START======================================================= + * Copyright (C) 2020 Nordix. 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); + + var pmSubscriptionInfo = executor.getContextAlbum("PMSubscriptionAlbum").get(executor.inFields.get("albumID").toString()) + + var changeType = pmSubscriptionInfo.get("changeType").toLowerCase() + var blueprintName = pmSubscriptionInfo.get("blueprintName").toLowerCase() + var blueprintVersion = pmSubscriptionInfo.get("blueprintVersion").toLowerCase() + var payload = executor.inFields.get("payload") + var actionName = changeType + "-subscription" + + var commonHeader = executor.subject.getOutFieldSchemaHelper("commonHeader").createNewInstance(); + commonHeader.put("originatorId", "sdnc"); + commonHeader.put("requestId", executor.inFields.get("albumID").toString()); + commonHeader.put("subRequestId", "sub-123456-1000"); + + var actionIdentifiers = executor.subject.getOutFieldSchemaHelper("actionIdentifiers").createNewInstance(); + actionIdentifiers.put("actionName", actionName); + actionIdentifiers.put("blueprintName", blueprintName); + actionIdentifiers.put("blueprintVersion", blueprintVersion); + actionIdentifiers.put("mode", "sync"); + + executor.outFields.put("commonHeader", commonHeader); + executor.outFields.put("actionIdentifiers", actionIdentifiers); + executor.outFields.put("payload", payload); + + //var returnValue = executor.isTrue; + true; + - key: + name: ReceiveSubscriptionTask + version: 0.0.1 + value: + key: + name: ReceiveSubscriptionTask + version: 0.0.1 + inputFields: + entry: + - key: blueprintName + value: + key: blueprintName + fieldSchemaKey: + name: SimpleStringType + version: 0.0.1 + optional: false + - key: blueprintVersion + value: + key: blueprintVersion + fieldSchemaKey: + name: SimpleStringType + version: 0.0.1 + optional: false + - key: changeType + value: + key: changeType + fieldSchemaKey: + name: SimpleStringType + version: 0.0.1 + optional: false + - key: closedLoopControlName + value: + key: closedLoopControlName + fieldSchemaKey: + name: SimpleStringType + version: 0.0.1 + optional: false + - key: nfName + value: + key: nfName + fieldSchemaKey: + name: SimpleStringType + version: 0.0.1 + optional: false + - key: policyName + value: + key: policyName + fieldSchemaKey: + name: SimpleStringType + version: 0.0.1 + optional: false + - key: subscription + value: + key: subscription + fieldSchemaKey: + name: SubscriptionType + version: 0.0.1 + optional: false + outputFields: + entry: + - key: albumID + value: + key: albumID + fieldSchemaKey: + name: UUIDType + version: 0.0.1 + optional: false + taskParameters: + entry: [] + contextAlbumReference: + - name: PMSubscriptionAlbum + version: 0.0.1 + taskLogic: + key: TaskLogic + logicFlavour: JAVASCRIPT + logic: |- + /* + * ============LICENSE_START======================================================= + * Copyright (C) 2020 Nordix. 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========================================================= + */ + var uuidType = java.util.UUID; + + executor.logger.info(executor.subject.id); + + //albumID will be used to fetch info from our album later + var albumID = uuidType.randomUUID(); + var pmSubscriptionInfo = executor.getContextAlbum("PMSubscriptionAlbum").getSchemaHelper().createNewInstance(); + var returnValue = true; + + if(executor.inFields.get("policyName") != null) { + executor.logger.info("nfName in receive sub event " + executor.inFields.get("nfName")); + + var changeType = executor.inFields.get("changeType") + var nfName = executor.inFields.get("nfName") + var policyName = executor.inFields.get("policyName") + var closedLoopControlName = executor.inFields.get("closedLoopControlName") + var subscription = executor.inFields.get("subscription") + var blueprintName = executor.inFields.get("blueprintName") + var blueprintVersion = executor.inFields.get("blueprintVersion") + + pmSubscriptionInfo.put("nfName", executor.inFields.get("nfName")); + pmSubscriptionInfo.put("changeType", executor.inFields.get("changeType")) + pmSubscriptionInfo.put("policyName", executor.inFields.get("policyName")) + pmSubscriptionInfo.put("closedLoopControlName", executor.inFields.get("closedLoopControlName")) + pmSubscriptionInfo.put("subscription", subscription) + pmSubscriptionInfo.put("blueprintName", blueprintName) + pmSubscriptionInfo.put("blueprintVersion", blueprintVersion) + + + executor.getContextAlbum("PMSubscriptionAlbum").put(albumID.toString(), pmSubscriptionInfo); + + executor.outFields.put("albumID", albumID) + } else { + executor.message = "Received invalid event" + returnValue = false; + } + + returnValue; + events: + key: + name: PMControlPolicy_Events + version: 0.0.1 + eventMap: + entry: + - key: + name: CDSCreateResponseEvent + version: 0.0.1 + value: + key: + name: CDSCreateResponseEvent + version: 0.0.1 + nameSpace: org.onap.policy.apex.onap.pmcontrol + source: CDS + target: APEX + parameter: + entry: + - key: actionIdentifiers + value: + key: actionIdentifiers + fieldSchemaKey: + name: CDSActionIdentifiersType + version: 0.0.1 + optional: false + - key: commonHeader + value: + key: commonHeader + fieldSchemaKey: + name: CDSResponseCommonHeaderType + version: 0.0.1 + optional: false + - key: payload + value: + key: payload + fieldSchemaKey: + name: CDSCreateResponsePayloadType + version: 0.0.1 + optional: false + - key: status + value: + key: status + fieldSchemaKey: + name: CDSResponseStatusType + version: 0.0.1 + optional: false + - key: + name: CDSCreateSubscriptionRequestEvent + version: 0.0.1 + value: + key: + name: CDSCreateSubscriptionRequestEvent + version: 0.0.1 + nameSpace: org.onap.policy.apex.onap.pmcontrol + source: APEX + target: APEX + parameter: + entry: + - key: actionIdentifiers + value: + key: actionIdentifiers + fieldSchemaKey: + name: CDSActionIdentifiersType + version: 0.0.1 + optional: false + - key: commonHeader + value: + key: commonHeader + fieldSchemaKey: + name: CDSRequestCommonHeaderType + version: 0.0.1 + optional: false + - key: payload + value: + key: payload + fieldSchemaKey: + name: CDSCreateSubscriptionPayloadType + version: 0.0.1 + optional: false + - key: + name: CDSDeleteResponseEvent + version: 0.0.1 + value: + key: + name: CDSDeleteResponseEvent + version: 0.0.1 + nameSpace: org.onap.policy.apex.onap.pmcontrol + source: CDS + target: APEX + parameter: + entry: + - key: actionIdentifiers + value: + key: actionIdentifiers + fieldSchemaKey: + name: CDSActionIdentifiersType + version: 0.0.1 + optional: false + - key: commonHeader + value: + key: commonHeader + fieldSchemaKey: + name: CDSResponseCommonHeaderType + version: 0.0.1 + optional: false + - key: payload + value: + key: payload + fieldSchemaKey: + name: CDSDeleteResponsePayloadType + version: 0.0.1 + optional: false + - key: status + value: + key: status + fieldSchemaKey: + name: CDSResponseStatusType + version: 0.0.1 + optional: false + - key: + name: CDSDeleteSubscriptionRequestEvent + version: 0.0.1 + value: + key: + name: CDSDeleteSubscriptionRequestEvent + version: 0.0.1 + nameSpace: org.onap.policy.apex.onap.pmcontrol + source: APEX + target: APEX + parameter: + entry: + - key: actionIdentifiers + value: + key: actionIdentifiers + fieldSchemaKey: + name: CDSActionIdentifiersType + version: 0.0.1 + optional: false + - key: commonHeader + value: + key: commonHeader + fieldSchemaKey: + name: CDSRequestCommonHeaderType + version: 0.0.1 + optional: false + - key: payload + value: + key: payload + fieldSchemaKey: + name: CDSDeleteSubscriptionPayloadType + version: 0.0.1 + optional: false + - key: + name: CDSResponseStatusEvent + version: 0.0.1 + value: + key: + name: CDSResponseStatusEvent + version: 0.0.1 + nameSpace: org.onap.policy.apex.onap.pmcontrol + source: APEX + target: DCAE + parameter: + entry: + - key: status + value: + key: status + fieldSchemaKey: + name: SubscriptionStatusType + version: 0.0.1 + optional: false + - key: + name: CreateSubscriptionPayloadEvent + version: 0.0.1 + value: + key: + name: CreateSubscriptionPayloadEvent + version: 0.0.1 + nameSpace: org.onap.policy.apex.onap.pmcontrol + source: APEX + target: APEX + parameter: + entry: + - key: albumID + value: + key: albumID + fieldSchemaKey: + name: UUIDType + version: 0.0.1 + optional: false + - key: payload + value: + key: payload + fieldSchemaKey: + name: CDSCreateSubscriptionPayloadType + version: 0.0.1 + optional: false + - key: + name: DeleteSubscriptionPayloadEvent + version: 0.0.1 + value: + key: + name: DeleteSubscriptionPayloadEvent + version: 0.0.1 + nameSpace: org.onap.policy.apex.onap.pmcontrol + source: APEX + target: APEX + parameter: + entry: + - key: albumID + value: + key: albumID + fieldSchemaKey: + name: UUIDType + version: 0.0.1 + optional: false + - key: payload + value: + key: payload + fieldSchemaKey: + name: CDSDeleteSubscriptionPayloadType + version: 0.0.1 + optional: false + - key: + name: MRResponseEvent + version: 0.0.1 + value: + key: + name: MRResponseEvent + version: 0.0.1 + nameSpace: org.onap.policy.apex.onap.pmcontrol + source: DCAE + target: APEX + parameter: + entry: + - key: count + value: + key: count + fieldSchemaKey: + name: SimpleIntType + version: 0.0.1 + optional: false + - key: serverTimeMs + value: + key: serverTimeMs + fieldSchemaKey: + name: SimpleIntType + version: 0.0.1 + optional: false + - key: + name: PMSubscriptionOutputEvent + version: 0.0.1 + value: + key: + name: PMSubscriptionOutputEvent + version: 0.0.1 + nameSpace: org.onap.policy.apex.onap.pmcontrol + source: APEX + target: APEX + parameter: + entry: + - key: albumID + value: + key: albumID + fieldSchemaKey: + name: UUIDType + version: 0.0.1 + optional: false + - key: + name: pmsh-operational-policy + version: 0.0.1 + value: + key: + name: pmsh-operational-policy + version: 0.0.1 + nameSpace: org.onap.policy.apex.onap.pmcontrol + source: DCAE + target: APEX + parameter: + entry: + - key: blueprintName + value: + key: blueprintName + fieldSchemaKey: + name: SimpleStringType + version: 0.0.1 + optional: false + - key: blueprintVersion + value: + key: blueprintVersion + fieldSchemaKey: + name: SimpleStringType + version: 0.0.1 + optional: false + - key: changeType + value: + key: changeType + fieldSchemaKey: + name: SimpleStringType + version: 0.0.1 + optional: false + - key: closedLoopControlName + value: + key: closedLoopControlName + fieldSchemaKey: + name: SimpleStringType + version: 0.0.1 + optional: false + - key: nfName + value: + key: nfName + fieldSchemaKey: + name: SimpleStringType + version: 0.0.1 + optional: false + - key: policyName + value: + key: policyName + fieldSchemaKey: + name: SimpleStringType + version: 0.0.1 + optional: false + - key: subscription + value: + key: subscription + fieldSchemaKey: + name: SubscriptionType + version: 0.0.1 + optional: false + albums: + key: + name: PMControlPolicy_Albums + version: 0.0.1 + albums: + entry: + - key: + name: PMSubscriptionAlbum + version: 0.0.1 + value: + key: + name: PMSubscriptionAlbum + version: 0.0.1 + scope: policy + isWritable: true + itemSchema: + name: PMSubscriptionType + version: 0.0.1 + schemas: + key: + name: PMControlPolicy_Schemas + version: 0.0.1 + schemas: + entry: + - key: + name: CDSActionIdentifiersType + version: 0.0.1 + value: + key: + name: CDSActionIdentifiersType + version: 0.0.1 + schemaFlavour: Avro + schemaDefinition: |- + { + "type": "record", + "name": "ActionIdentifiers_Type", + "namespace": "org.onap.policy.apex.onap.helloworld", + "fields": [ + { + "name": "actionName", + "type": "string" + }, + { + "name": "blueprintName", + "type": "string" + }, + { + "name": "blueprintVersion", + "type": "string" + }, + { + "name": "mode", + "type": "string" + } + ] + } + - key: + name: CDSCreateResponsePayloadType + version: 0.0.1 + value: + key: + name: CDSCreateResponsePayloadType + version: 0.0.1 + schemaFlavour: Avro + schemaDefinition: |- + { + "name": "CreateResponsePayloadEntry", + "type": "record", + "namespace": "org.onap.policy.apex.onap.helloworld", + "fields": [ + { + "name": "create_DasH_subscription_DasH_response", + "type": { + "name": "create_DasH_subscription_DasH_response", + "type": "record", + "fields": [ + { + "name": "odl_DasH_response", + "type": { + "name": "odl_DasH_response", + "type": "record", + "fields": [ + { + "name": "status", + "type": "string" + } + ] + } + } + ] + } + } + ] + } + - key: + name: CDSCreateSubscriptionPayloadType + version: 0.0.1 + value: + key: + name: CDSCreateSubscriptionPayloadType + version: 0.0.1 + schemaFlavour: Avro + schemaDefinition: |- + { + "type": "map", + "values": { + "type": "record", + "name": "CDSRequestPayloadEntry", + "fields": [ + { + "name": "create_DasH_subscription_DasH_properties", + "type": { + "name": "create_DasH_subscription_DasH_properties_record", + "type": "record", + "fields": [ + { + "name": "nfName", + "type": "string" + }, + { + "name": "subscriptionName", + "type": "string" + }, + { + "name": "administrativeState", + "type": "string" + }, + { + "name": "fileBasedGP", + "type": "string" + }, + { + "name": "fileLocation", + "type": "string" + }, + { + "name": "measurementGroups", + "type": { + "type": "array", + "items": { + "name": "measurementGroups_record", + "type": "record", + "fields": [ + { + "name": "measurementGroup", + "type": { + "name": "measurementGroup", + "type": "record", + "fields": [ + { + "name": "measurementTypes", + "type": { + "type": "array", + "items": { + "name": "measurementTypes_record", + "type": "record", + "fields": [ + { + "name": "measurementType", + "type": "string" + } + ] + } + } + }, + { + "name": "managedObjectDNsBasic", + "type": { + "type": "array", + "items": { + "name": "managedObjectDNsBasic_record", + "type": "record", + "fields": [ + { + "name": "DN", + "type": "string" + } + ] + } + } + } + ] + } + } + ] + } + } + } + ] + } + } + ] + } + } + - key: + name: CDSDeleteResponsePayloadType + version: 0.0.1 + value: + key: + name: CDSDeleteResponsePayloadType + version: 0.0.1 + schemaFlavour: Avro + schemaDefinition: |- + { + "name": "DeleteResponsePayloadEntry", + "type": "record", + "namespace": "com.acme.avro", + "fields": [ + { + "name": "delete_DasH_subscription_DasH_response", + "type": { + "name": "delete_DasH_subscription_DasH_response", + "type": "record", + "fields": [ + { + "name": "odl_DasH_response", + "type": { + "name": "odl_DasH_response", + "type": "record", + "fields": [ + { + "name": "status", + "type": "string" + } + ] + } + } + ] + } + } + ] + } + - key: + name: CDSDeleteSubscriptionPayloadType + version: 0.0.1 + value: + key: + name: CDSDeleteSubscriptionPayloadType + version: 0.0.1 + schemaFlavour: Avro + schemaDefinition: |- + { + "type": "map", + "values": { + "type": "record", + "name": "CDSRequestPayloadEntry", + "fields": [ + { + "name": "delete_DasH_subscription_DasH_properties", + "type": { + "name": "delete_DasH_subscription_DasH_properties_record", + "type": "record", + "fields": [ + { + "name": "nfName", + "type": "string" + }, + { + "name": "subscriptionName", + "type": "string" + }, + { + "name": "administrativeState", + "type": "string" + }, + { + "name": "fileBasedGP", + "type": "string" + }, + { + "name": "fileLocation", + "type": "string" + }, + { + "name": "measurementGroups", + "type": { + "type": "array", + "items": { + "name": "measurementGroups_record", + "type": "record", + "fields": [ + { + "name": "measurementGroup", + "type": { + "name": "measurementGroup", + "type": "record", + "fields": [ + { + "name": "measurementTypes", + "type": { + "type": "array", + "items": { + "name": "measurementTypes_record", + "type": "record", + "fields": [ + { + "name": "measurementType", + "type": "string" + } + ] + } + } + }, + { + "name": "managedObjectDNsBasic", + "type": { + "type": "array", + "items": { + "name": "managedObjectDNsBasic_record", + "type": "record", + "fields": [ + { + "name": "DN", + "type": "string" + } + ] + } + } + } + ] + } + } + ] + } + } + } + ] + } + } + ] + } + } + - key: + name: CDSRequestCommonHeaderType + version: 0.0.1 + value: + key: + name: CDSRequestCommonHeaderType + version: 0.0.1 + schemaFlavour: Avro + schemaDefinition: |- + { + "type": "record", + "name": "RequestCommonHeader_Type", + "namespace": "org.onap.policy.apex.onap.helloworld", + "fields": [ + { + "name": "originatorId", + "type": "string" + }, + { + "name": "requestId", + "type": "string" + }, + { + "name": "subRequestId", + "type": "string" + } + ] + } + - key: + name: CDSResponseCommonHeaderType + version: 0.0.1 + value: + key: + name: CDSResponseCommonHeaderType + version: 0.0.1 + schemaFlavour: Avro + schemaDefinition: |- + { + "type": "record", + "name": "ResponseCommonHeader_Type", + "namespace": "org.onap.policy.apex.onap.helloworld", + "fields": [ + { + "name": "originatorId", + "type": "string" + }, + { + "name": "requestId", + "type": "string" + }, + { + "name": "subRequestId", + "type": "string" + }, + { + "name": "timestamp", + "type": "string" + }, + { + "name": "flags", + "type": ["null", "string"] + } + ] + } + - key: + name: CDSResponseStatusType + version: 0.0.1 + value: + key: + name: CDSResponseStatusType + version: 0.0.1 + schemaFlavour: Avro + schemaDefinition: |- + { + "type": "record", + "name": "ResponseStatus_Type", + "namespace": "org.onap.policy.apex.onap.helloworld", + "fields": [ + { + "name": "code", + "type": "int" + }, + { + "name": "eventType", + "type": "string" + }, + { + "name": "timestamp", + "type": "string" + }, + { + "name": "message", + "type": "string" + } + ] + } + - key: + name: PMSubscriptionType + version: 0.0.1 + value: + key: + name: PMSubscriptionType + version: 0.0.1 + schemaFlavour: Avro + schemaDefinition: "{\n\t\"name\": \"PMSubscription\",\n\t\"type\": \"record\",\n\t\"namespace\": \"\ + org.onap.policy.apex.onap.pmcontrol\",\n\t\"fields\": [\n {\n \"name\": \"nfName\"\ + ,\n \"type\": \"string\"\n },\n\t {\n\t\t\t\"name\": \"changeType\",\n\t\t\t\"\ + type\": \"string\"\n\t\t},\n\t\t{\n\t\t\t\"name\": \"closedLoopControlName\",\n\t\t\t\"type\": \"\ + string\"\n\t\t},\n\t\t{\n\t\t\t\"name\": \"policyName\",\n\t\t\t\"type\": \"string\"\n\t\t},\n\t\t\ + {\n\t\t \"name\": \"blueprintName\",\n\t\t \"type\": \"string\"\n\t\t},\n\t\t{\n\t\t \"name\"\ + : \"blueprintVersion\",\n\t\t \"type\": \"string\"\n\t\t},\n\t\t{\n\t\t\t\"name\": \"subscription\"\ + ,\n\t\t\t\"type\": {\n\t\t\t\t\"name\": \"subscription\",\n\t\t\t\t\"type\": \"record\",\n\t\t\t\t\ + \"fields\": [{\n\t\t\t\t\t\t\"name\": \"subscriptionName\",\n\t\t\t\t\t\t\"type\": \"string\"\n\t\t\ + \t\t\t},\n\t\t\t\t\t{\n\t\t\t\t\t\t\"name\": \"administrativeState\",\n\t\t\t\t\t\t\"type\": \"string\"\ + \n\t\t\t\t\t},\n\t\t\t\t\t{\n\t\t\t\t\t\t\"name\": \"fileBasedGP\",\n\t\t\t\t\t\t\"type\": \"int\"\ + \n\t\t\t\t\t},\n\t\t\t\t\t{\n\t\t\t\t\t\t\"name\": \"fileLocation\",\n\t\t\t\t\t\t\"type\": \"string\"\ + \n\t\t\t\t\t},\n\t\t\t\t\t{\n\t\t\t\t\t\t\"name\": \"measurementGroups\",\n\t\t\t\t\t\t\"type\": {\n\ + \t\t\t\t\t\t\t\"type\": \"array\",\n\t\t\t\t\t\t\t\"items\": {\n\t\t\t\t\t\t\t\t\"name\": \"Measurement_Groups_Type\"\ + ,\n\t\t\t\t\t\t\t\t\"type\": \"record\",\n\t\t\t\t\t\t\t\t\"fields\": [{\n\t\t\t\t\t\t\t\t\t\"name\"\ + : \"measurementGroup\",\n\t\t\t\t\t\t\t\t\t\"type\": {\n\t\t\t\t\t\t\t\t\t\t\"name\": \"Measurement_Group_Type\"\ + ,\n\t\t\t\t\t\t\t\t\t\t\"type\": \"record\",\n\t\t\t\t\t\t\t\t\t\t\"fields\": [{\n\t\t\t\t\t\t\t\t\ + \t\t\t\t\"name\": \"measurementTypes\",\n\t\t\t\t\t\t\t\t\t\t\t\t\"type\": {\n\t\t\t\t\t\t\t\t\t\t\ + \t\t\t\"type\": \"array\",\n\t\t\t\t\t\t\t\t\t\t\t\t\t\"items\": {\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\"\ + name\": \"Measurement_Types_Type\",\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\"type\": \"record\",\n\t\t\t\t\t\ + \t\t\t\t\t\t\t\t\t\"fields\": [{\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\"name\": \"measurementType\",\n\t\ + \t\t\t\t\t\t\t\t\t\t\t\t\t\t\"type\": \"string\"\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t}]\n\t\t\t\t\t\t\t\t\ + \t\t\t\t\t}\n\t\t\t\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\t\t\t\t{\n\t\t\t\t\ + \t\t\t\t\t\t\t\t\"name\": \"managedObjectDNsBasic\",\n\t\t\t\t\t\t\t\t\t\t\t\t\"type\": {\n\t\t\t\t\ + \t\t\t\t\t\t\t\t\t\"type\": \"array\",\n\t\t\t\t\t\t\t\t\t\t\t\t\t\"items\": {\n\t\t\t\t\t\t\t\t\t\ + \t\t\t\t\t\"name\": \"Managed_Object_Dns_Basic_Type\",\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\"type\": \"record\"\ + ,\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\"fields\": [{\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\"name\": \"DN\",\n\t\ + \t\t\t\t\t\t\t\t\t\t\t\t\t\t\"type\": \"string\"\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t}]\n\t\t\t\t\t\t\t\t\ + \t\t\t\t\t}\n\t\t\t\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\t\t]\n\t\t\t\t\t\ + \t\t\t\t}\n\t\t\t\t\t\t\t\t}]\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t]\n\t\t\t}\n\t\ + \t}\n\t]\n}" + - key: + name: SimpleIntType + version: 0.0.1 + value: + key: + name: SimpleIntType + version: 0.0.1 + schemaFlavour: Java + schemaDefinition: java.lang.Integer + - key: + name: SimpleStringType + version: 0.0.1 + value: + key: + name: SimpleStringType + version: 0.0.1 + schemaFlavour: Java + schemaDefinition: java.lang.String + - key: + name: SubscriptionStatusType + version: 0.0.1 + value: + key: + name: SubscriptionStatusType + version: 0.0.1 + schemaFlavour: Avro + schemaDefinition: |- + { + "type": "record", + "name": "ActivateSubscriptionStatus_Type", + "namespace": "org.onap.policy.apex.onap.helloworld", + "fields": [ + { + "name": "subscriptionName", + "type": "string" + }, + { + "name": "nfName", + "type": "string" + }, + { + "name": "changeType", + "type": "string" + }, + { + "name": "message", + "type": "string" + } + ] + } + - key: + name: SubscriptionType + version: 0.0.1 + value: + key: + name: SubscriptionType + version: 0.0.1 + schemaFlavour: Avro + schemaDefinition: "{\n\t\"name\": \"subscription\",\n\t\"type\": \"record\",\n\t\"fields\": [{\n\t\t\ + \t\"name\": \"subscriptionName\",\n\t\t\t\"type\": \"string\"\n\t\t},\n\t\t{\n\t\t\t\"name\": \"administrativeState\"\ + ,\n\t\t\t\"type\": \"string\"\n\t\t},\n\t\t{\n\t\t\t\"name\": \"fileBasedGP\",\n\t\t\t\"type\": \"\ + int\"\n\t\t},\n\t\t{\n\t\t\t\"name\": \"fileLocation\",\n\t\t\t\"type\": \"string\"\n\t\t},\n\t\t\ + {\n\t\t\t\"name\": \"measurementGroups\",\n\t\t\t\"type\": {\n\t\t\t\t\"type\": \"array\",\n\t\t\t\ + \t\"items\": {\n\t\t\t\t\t\"name\": \"Measurement_Groups_Type\",\n\t\t\t\t\t\"type\": \"record\",\n\ + \t\t\t\t\t\"fields\": [{\n\t\t\t\t\t\t\"name\": \"measurementGroup\",\n\t\t\t\t\t\t\"type\": {\n\t\ + \t\t\t\t\t\t\"name\": \"Measurement_Group_Type\",\n\t\t\t\t\t\t\t\"type\": \"record\",\n\t\t\t\t\t\ + \t\t\"fields\": [{\n\t\t\t\t\t\t\t\t\t\"name\": \"measurementTypes\",\n\t\t\t\t\t\t\t\t\t\"type\"\ + : {\n\t\t\t\t\t\t\t\t\t\t\"type\": \"array\",\n\t\t\t\t\t\t\t\t\t\t\"items\": {\n\t\t\t\t\t\t\t\t\t\ + \t\t\"name\": \"Measurement_Types_Type\",\n\t\t\t\t\t\t\t\t\t\t\t\"type\": \"record\",\n\t\t\t\t\t\ + \t\t\t\t\t\t\"fields\": [{\n\t\t\t\t\t\t\t\t\t\t\t\t\"name\": \"measurementType\",\n\t\t\t\t\t\t\t\ + \t\t\t\t\t\"type\": \"string\"\n\t\t\t\t\t\t\t\t\t\t\t}]\n\t\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\t\ + }\n\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\t\"name\": \"managedObjectDNsBasic\",\n\ + \t\t\t\t\t\t\t\t\t\"type\": {\n\t\t\t\t\t\t\t\t\t\t\"type\": \"array\",\n\t\t\t\t\t\t\t\t\t\t\"items\"\ + : {\n\t\t\t\t\t\t\t\t\t\t\t\"name\": \"Managed_Object_Dns_Basic_Type\",\n\t\t\t\t\t\t\t\t\t\t\t\"\ + type\": \"record\",\n\t\t\t\t\t\t\t\t\t\t\t\"fields\": [{\n\t\t\t\t\t\t\t\t\t\t\t\t\"name\": \"DN\"\ + ,\n\t\t\t\t\t\t\t\t\t\t\t\t\"type\": \"string\"\n\t\t\t\t\t\t\t\t\t\t\t}]\n\t\t\t\t\t\t\t\t\t\t}\n\ + \t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t]\n\t\t\t\t\t\t}\n\t\t\t\t\t}]\n\t\t\t\t}\n\t\ + \t\t}\n\t\t}\n\t]\n}" + - key: + name: UUIDType + version: 0.0.1 + value: + key: + name: UUIDType + version: 0.0.1 + schemaFlavour: Java + schemaDefinition: java.util.UUID + engineParameters: + executorParameters: + JAVASCRIPT: + parameterClassName: org.onap.policy.apex.plugins.executor.javascript.JavascriptExecutorParameters + contextParameters: + parameterClassName: org.onap.policy.apex.context.parameters.ContextParameters + schemaParameters: + Avro: + parameterClassName: org.onap.policy.apex.plugins.context.schema.avro.AvroSchemaHelperParameters + Java: + parameterClassName: org.onap.policy.apex.context.impl.schema.java.JavaSchemaHelperParameters + jsonAdapters: + Instant: + adaptedClass: java.time.Instant + adaptorClass: org.onap.policy.controlloop.util.Serialization$GsonInstantAdapter + eventInputParameters: + DCAEConsumer: + carrierTechnologyParameters: + carrierTechnology: RESTCLIENT + parameterClassName: org.onap.policy.apex.plugins.event.carrier.restclient.RestClientCarrierTechnologyParameters + parameters: + consumerPollTime: '50' + url: https://message-router:3905/events/unauthenticated.DCAE_CL_OUTPUT/cg1/sg1 + eventProtocolParameters: + eventProtocol: JSON + parameters: + nameAlias: policyName + eventName: pmsh-operational-policy + eventNameFilter: pmsh-operational-policy + CDSRequestConsumer: + carrierTechnologyParameters: + carrierTechnology: RESTREQUESTOR + parameterClassName: org.onap.policy.apex.plugins.event.carrier.restrequestor.RestRequestorCarrierTechnologyParameters + parameters: + url: http://10.10.10.184:30254/api/v1/execution-service/process + httpMethod: POST + restRequestTimeout: 2000 + httpHeaders: + - - Authorization + - Basic Y2NzZGthcHBzOmNjc2RrYXBwcw== + eventProtocolParameters: + eventProtocol: JSON + eventName: CDSCreateResponseEvent + eventNameFilter: CDSCreateResponseEvent + requestorMode: true + requestorPeer: CDSRequestProducer + requestorTimeout: 500 + CDSDeleteRequestConsumer: + carrierTechnologyParameters: + carrierTechnology: RESTREQUESTOR + parameterClassName: org.onap.policy.apex.plugins.event.carrier.restrequestor.RestRequestorCarrierTechnologyParameters + parameters: + url: http://10.10.10.184:30254/api/v1/execution-service/process + httpMethod: POST + restRequestTimeout: 2000 + httpHeaders: + - - Authorization + - Basic Y2NzZGthcHBzOmNjc2RrYXBwcw== + eventProtocolParameters: + eventProtocol: JSON + eventName: CDSDeleteResponseEvent + eventNameFilter: CDSDeleteResponseEvent + requestorMode: true + requestorPeer: CDSDeleteRequestProducer + requestorTimeout: 500 + CDSReplyConsumer: + carrierTechnologyParameters: + carrierTechnology: RESTREQUESTOR + parameterClassName: org.onap.policy.apex.plugins.event.carrier.restrequestor.RestRequestorCarrierTechnologyParameters + parameters: + url: https://message-router:3905/events/unauthenticated.PMSH_CL_INPUT + httpMethod: POST + restRequestTimeout: 2000 + eventProtocolParameters: + eventProtocol: JSON + eventName: MRResponseEvent + eventNameFilter: MRResponseEvent + requestorMode: true + requestorPeer: CDSReplyProducer + requestorTimeout: 500 + eventOutputParameters: + logOutputter: + carrierTechnologyParameters: + carrierTechnology: FILE + parameters: + fileName: /tmp/outputevents.log + eventProtocolParameters: + eventProtocol: JSON + StdOutOutputter: + carrierTechnologyParameters: + carrierTechnology: FILE + parameters: + standardIo: true + eventProtocolParameters: + eventProtocol: JSON + CDSRequestProducer: + carrierTechnologyParameters: + carrierTechnology: RESTREQUESTOR + parameterClassName: org.onap.policy.apex.plugins.event.carrier.restrequestor.RestRequestorCarrierTechnologyParameters + eventProtocolParameters: + eventProtocol: JSON + eventNameFilter: CDSCreateSubscriptionRequestEvent + requestorMode: true + requestorPeer: CDSRequestConsumer + requestorTimeout: 500 + CDSDeleteRequestProducer: + carrierTechnologyParameters: + carrierTechnology: RESTREQUESTOR + parameterClassName: org.onap.policy.apex.plugins.event.carrier.restrequestor.RestRequestorCarrierTechnologyParameters + eventProtocolParameters: + eventProtocol: JSON + eventNameFilter: CDSDeleteSubscriptionRequestEvent + requestorMode: true + requestorPeer: CDSDeleteRequestConsumer + requestorTimeout: 500 + CDSReplyProducer: + carrierTechnologyParameters: + carrierTechnology: RESTREQUESTOR + parameterClassName: org.onap.policy.apex.plugins.event.carrier.restrequestor.RestRequestorCarrierTechnologyParameters + eventProtocolParameters: + eventProtocol: JSON + eventNameFilter: CDSResponseStatusEvent + requestorMode: true + requestorPeer: CDSReplyConsumer + requestorTimeout: 500 diff --git a/common/src/test/resources/examples/acm/PMSubscriptionHandling_GuilinFormat.yaml b/common/src/test/resources/examples/acm/PMSubscriptionHandling_GuilinFormat.yaml new file mode 100644 index 000000000..51e369696 --- /dev/null +++ b/common/src/test/resources/examples/acm/PMSubscriptionHandling_GuilinFormat.yaml @@ -0,0 +1,455 @@ +# ============LICENSE_START======================================================= +# Copyright (C) 2021 Nordix Foundation. +# ================================================================================ +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# SPDX-License-Identifier: Apache-2.0 +# ============LICENSE_END========================================================= + +tosca_definitions_version: tosca_simple_yaml_1_3 +capability_types: + org.onap.EventProducer: + properties: + carrier_protocol_type: + type: string + required: true + constraints: + - valid_values: + - DMAAP_message_router + - SOMETHING_ELSE + - REST + data_format: + type: string + required: true + constraints: + - valid_values: + - JSON + - YAML + - JMS + event_format: + type: string + required: true + event_format_version: + type: string + required: false + config_keys: + type: list + required: false + entry_schema: + type: string + constraints: + - valid_values: + - all valid values should be added here + - if not specified, events of any config key may be generated + - 'examples for config_key: ves-measurement, ves-syslog, tca_handle_out, + etc.' + version: 0.0.1 + derived_from: tosca.capabilities.Root + org.onap.EventConsumer: + properties: + responding_capability: + type: string + required: false + carrier_protocol_type: + type: string + required: true + constraints: + - valid_values: + - DMAAP_message_router + - SOMETHING_ELSE + - REST + data_format: + type: string + required: true + constraints: + - valid_values: + - JSON + - YAML + - JMS + - all valid values should be added here + event_format: + type: string + description: 'examples for event_format: Ves_specification, LinkUp, VnfConfigured, + etc.' + required: true + event_format_version: + type: string + description: 'examples for event_format_version: 5.28.4, 7.30.1, etc.' + required: false + config_keys: + type: list + required: false + entry_schema: + type: string + constraints: + - valid_values: + - all valid values should be added here + - if not specified, events of any config key may be generated + - 'examples for config_key: ves-measurement, ves-syslog, tca_handle_out, + etc.' + version: 0.0.1 + derived_from: tosca.capabilities.Root +node_types: + org.onap.DynamicConfig: + properties: + application_name: + type: string + description: Value used to tie the config to an application ? should we be + using a relationship here instead? + required: true + application_version: + type: string + required: true + application_provider: + type: string + required: false + data_types: + type: object + required: false + schema: + type: object + required: false + version: 0.0.1 + derived_from: tosca.nodes.Root + org.onap.APP: + properties: + application_name: + type: string + description: Human readable name for the application Product + required: false + provider: + type: string + description: Provider of the application and of the descriptor + required: true + application_version: + type: string + description: Software version of the application + required: true + blueprint_id: + type: string + description: A reference to the app blueprint + required: false + monitoring_policy: + type: string + description: A reference to the monitoring policy + required: false + requirements: + - receive: + capability: org.onap.EventProducer + relationship: org.onap.PropagateEvent + occurrences: + - 0 + - UNBOUNDED + - send: + capability: org.onap.EventConsumer + relationship: org.onap.PropagateEvent + occurrences: + - 0 + - UNBOUNDED + version: 0.0.1 + derived_from: tosca.nodes.Root + org.onap.EventRelay: + properties: + event_format: + type: string + description: 'examples for event_format: Ves_specification, etc.' + required: true + event_format_version: + type: string + description: 'examples for event_format_version: 5.28.4, 7.30.1, etc.' + required: true + config_keys: + type: list + required: false + entry_schema: + type: string + constraints: + - valid_values: + - all valid values should be added here + - if not specified, events of any config key is relayed + - 'examples for config_key: ves-measurement, ves-syslog, tca_handle_out, + etc.' + supported_carrier_protocols: + type: map + description: 'A map describing supported carrier protocols and translations. + The tuples define what protocol combinations are supported on the producer + and consumer side: e.g. { REST: REST, DMAAP: REST, DMAAP: DMAAP}' + required: true + key_schema: + type: string + constraints: + - valid_values: + - DMAAP_message_router + - SOMETHING_ELSE + - REST + - all valid values should be added here + entry_schema: + type: string + constraints: + - valid_values: + - DMAAP_message_router + - SOMETHING_ELSE + - REST + - all valid values should be added here + supported_data_formats: + type: map + description: 'Is a map describing supported data formats and translation. + The tuples define what protocol combinations are supported on the producer + and consumer side: e.g. { JSON: JSON, JMS: JSON, YAML:YAML }' + required: true + key_schema: + type: string + constraints: + - valid_values: + - JSON + - JMS + - YAML + - etc + - all valid values should be added here + entry_schema: + type: string + constraints: + - valid_values: + - JSON + - JMS + - YAML + - etc + - all valid values should be added here + requirements: + - receive: + capability: org.onap.EventProducer + relationship: org.onap.PropagateEvent + occurrences: + - 0 + - UNBOUNDED + - send: + capability: org.onap.EventConsumer + relationship: org.onap.PropagateEvent + occurrences: + - 0 + - UNBOUNDED + version: 0.0.1 + derived_from: tosca.nodes.Root +relationship_types: + org.onap.PropagateEvent: + properties: + config_keys: + type: list + description: The relationship type used on requirements to org.onap.EventProducer + and org.onap.EventConsumer capabilities. Filters events by specific config_keys + to be transferred by this relationship. That is, any event with a specific + config_key found in the list is transferred. If list is not defined or is + empty, events with all config_keys are transferred. + required: false + entry_schema: + type: string + version: 0.0.1 + derived_from: tosca.relationships.Root +topology_template: + inputs: + pm_subscription_topic: + type: string + pm_subscription_response_topic: + type: string + pm_subscription_handler_blueprint_id: + type: string + pm_subscription_operational_policy_id: + type: string + pm_subscription_cds_blueprint_id: + type: string + enable_tls: + type: string + node_templates: + org.onap.PM_Subscription_Handler: + type: org.onap.polcy.clamp.ControlLoopElement + properties: + application_name: PM Subscription Handler + provider: Ericsson + application_version: 1.0.0 + artifact_id: + get_input: pm_subscription_handler_blueprint_id + description: Is this a reference to the DCAE Cloudify Blueprint that is + already stored(or will be stored before CL configuration & instatiation) + in DCAE Inventory? + artifact_config: + enable_tls: + get_input: enable_tls + pmsh_publish_topic_name: + get_input: pm_subscription_topic + capabilities: + pm-subscription-event-publisher: + properties: + carrier_protocol_type: DMAAP_message_router + data_format: JSON + event_format: pm-subscription-event-format + event_format_version: 1.0.0 + attributes: + type: org.onap.EventProducer + occurrences: + - 0 + - UNBOUNDED + pm-subscription-event-receiver: + properties: + carrier_protocol_type: DMAAP_message_router + data_format: JSON + event_format: pm-subscription-event-response-format + event_format_version: 1.0.0 + relationships: + - type: tosca.relationships.DependsOn + - description: any ideas on a better realtionship ? or is it better to + just use the root realtionship ? + - target: org.onap.PM_Monitoring_Policy + attributes: + type: org.onap.EventConsumer + occurrences: + - 0 + - UNBOUNDED + org.onap.PM_Monitoring_Policy: + type: org.onap.DynamicConfig + properties: + application_name: PM Subscription Handler + application_version: 1.0.0 + provider: Ericsson + data_types: + measurementType: + type: string + DN: + type: string + nfFilter: + properties: + nfNames: + type: list + entry_schema: string + modelInvariantIDs: + type: list + entry_schema: + type: string + modelVersionIDs: + type: list + entry_schema: + type: string + measurementGroup: + properties: + masurementTypes: + type: list + entry_schema: + type: measurementType + managedObjectDNsBasic: + type: list + entry_schema: + type: DN + schema: + subscription: + subscriptionName: + type: string + required: true + administrativeState: + type: string + required: true + filebasedGP: + type: integer + required: true + fileLocation: + type: string + required: true + nfFilter: + type: nfFilter + measurementGroups: + type: list + entry_schema: + type: measurementGroup + description: Should I be showing a dependency between PM Subscription Handler + and the PM Monitoring Policy + org.onap.PM_Policy: + type: org.onap.APP + properties: + application_name: PM Subscription Operational Policy + provider: Ericsson + application_version: 1.0.0 + artifact_id: + get_input: pm_subscription_operational_policy_id + artifact_config: NOT_DEFINED + requirements: + - receive_0: + capability: pm-subscription-event-publisher + node: org.onap.PM_Subscription_Handler + relationship: NOT_DEFINED + properties: + config_keys: + - topic_name: + get_input: pm_subscription_topic + - send_0: + capability: cds-rest-receive + node: org.onap.CDS + - receive_1: + capability: cds-rest-response + node: org.onap.CDS + - send_1: + capability: pm-subscription-event-receiver + node: org.onap.PM_Subscription_Handler + relationship: NOT_DEFINED + properties: + config_keys: + - topic_name: + get_input: pm_subscription_response_topic + capabilities: + pm-subscription-response-event-publisher: + properties: + type: org.onap.EventProducer + carrier_protocol_type: DMAAP_message_router + data_format: JSON + event_format: pm-subscription-event-response-format + event_format_version: 1.0.0 + occurrences: + - 0 + - UNBOUNDED + org.onap.PM_CDS_Blueprint: + type: org.onap.APP + properties: + application_name: PM Subscription CDS Blueprint + provider: Ericsson + application_version: 1.0.0 + artifact_id: + get_input: pm_subscription_cds_blueprint_id + capabilities: + cds-rest-receive: + properties: + type: org.onap.EventConsumer + protocol_type: REST + data_format: JSON + event_format: cds_action_format + event_format_version: 1.0.0 + responding_capability: cds-rest-response + occurrences: + - 0 + - UNBOUNDED + cds-rest-response: + properties: + type: org.onap.EventProducer + protocol_type: REST + data_format: JSON + event_format: cds_action_response_format + event_format_version: 1.0.0 + occurrences: + - 0 + org.onap.controlloop0: + version: 1.2.3 + type: org.onap.policy.clamp.ControlLoop + properties: + application_name: Test Control Loop + provider: Ericsson + application_version: 1.0.0 + status: NOT_DEPLOYED + elements: + element1: org.onap.PM_Monitoring_Policy + diff --git a/common/src/test/resources/examples/acm/http-participant/http.postman2.0_collection.json b/common/src/test/resources/examples/acm/http-participant/http.postman2.0_collection.json new file mode 100644 index 000000000..798b0edd6 --- /dev/null +++ b/common/src/test/resources/examples/acm/http-participant/http.postman2.0_collection.json @@ -0,0 +1,254 @@ +{ + "info": { + "name": "CL-http-participant", + "_postman_id": "cd83c1ac-bc96-41f2-a5a4-f021015461b7", + "description": "", + "schema": "https://schema.getpostman.com/json/collection/v2.0.0/collection.json" + }, + "item": [ + { + "id": "45fed070-6a8f-4e0a-a3cf-904db5596984", + "name": "Get Instantiated Control loops", + "request": { + "url": { + "protocol": "https", + "host": "localhost", + "path": [ + "onap", + "controlloop", + "v2", + "instantiation" + ], + "port": "6969" + }, + "method": "GET", + "header": [ + { + "key": "Accept", + "value": "*/*", + "disabled": false + } + ], + "body": { + "mode": "raw", + "disabled": false + }, + "description": "" + }, + "response": [ + { + "header": [], + "code": 200, + "name": "Response_200", + "id": "5727aa3e-5f62-426b-9a37-ddae2d346165" + } + ] + }, + { + "id": "1bf1a143-38fd-49b8-afab-4c801546ba3b", + "name": "Update a Control loop", + "request": { + "url": { + "protocol": "https", + "host": "localhost", + "path": [ + "onap", + "controlloop", + "v2", + "instantiation/command" + ], + "port": "6969" + }, + "method": "PUT", + "header": [ + { + "key": "Content-Type", + "value": "application/json", + "description": "", + "disabled": false + }, + { + "key": "X-ONAP-RequestID", + "value": "709c62b3-8918-41b9-a747-d21eb79c6c20", + "description": "", + "disabled": false + }, + { + "key": "Accept", + "value": "*/*", + "disabled": false + } + ], + "body": { + "mode": "raw", + "raw": "{\r\n \"orderedState\": \"PASSIVE\",\r\n \"controlLoopIdentifierList\": [\r\n {\r\n \"name\": \"K8SInstance0\",\r\n \"version\": \"1.0.1\"\r\n }\r\n ]\r\n}", + "disabled": false + }, + "description": "" + }, + "response": [ + { + "header": [], + "code": 200, + "name": "Response_200", + "id": "f619f68b-4dbe-4c3d-8236-e90ea85c4094" + } + ] + }, + { + "id": "e5b64f76-c4f5-4c23-b273-e2d6cfb48cd7", + "name": "UnInitialise a Control loop", + "request": { + "url": { + "protocol": "https", + "host": "localhost", + "path": [ + "onap", + "controlloop", + "v2", + "instantiation/command" + ], + "port": "6969" + }, + "method": "PUT", + "header": [ + { + "key": "Content-Type", + "value": "application/json", + "description": "", + "disabled": false + }, + { + "key": "Accept", + "value": "*/*", + "disabled": false + } + ], + "body": { + "mode": "raw", + "raw": "{\r\n \"orderedState\": \"UNINTIALISED\",\r\n \"controlLoopIdentifierList\": [\r\n {\r\n \"name\": \"K8SInstance0\",\r\n \"version\": \"1.0.1\"\r\n }\r\n ]\r\n}", + "disabled": false + }, + "description": "" + }, + "response": [ + { + "header": [], + "code": 200, + "name": "Response_200", + "id": "bc8e0792-85df-4934-9f55-69eaf8535fe3" + } + ] + }, + { + "id": "4f359a02-cd9a-4ffd-b594-3478bf32cc2f", + "name": "Instantiate a Control loop", + "request": { + "url": { + "protocol": "https", + "host": "localhost", + "path": [ + "onap", + "controlloop", + "v2", + "instantiation" + ], + "port": "6969" + }, + "method": "POST", + "header": [ + { + "key": "X-ONAP-RequestID", + "value": "709c62b3-8918-41b9-a747-d21eb79c6c20", + "description": "", + "disabled": false + }, + { + "key": "Content-Type", + "value": "application/json", + "description": "", + "disabled": false + }, + { + "key": "Accept", + "value": "*/*", + "disabled": false + } + ], + "body": { + "mode": "raw", + "raw": "{\r\n \"controlLoopList\": [\r\n {\r\n \"name\": \"ConsulInstance0\",\r\n \"version\": \"1.0.1\",\r\n \"definition\": {\r\n \"name\": \"org.onap.domain.sample.PMSH_Http_ControlLoopDefinition\",\r\n \"version\": \"1.2.3\"\r\n },\r\n \"state\": \"UNINITIALISED\",\r\n \"orderedState\": \"UNINITIALISED\",\r\n \"description\": \"PMSH control loop instance 0\",\r\n \"elements\": {\r\n \"709c62b3-8918-41b9-a747-d21eb79c6c25\": {\r\n \"id\": \"709c62b3-8918-41b9-a747-d21eb79c6c25\",\r\n \"definition\": {\r\n \"name\": \"org.onap.domain.database.Http_PMSHMicroserviceControlLoopElement\",\r\n \"version\": \"1.2.3\"\r\n },\r\n \"participantId\": {\r\n \"name\": \"org.onap.controlloop.HttpControlLoopParticipant\",\r\n \"version\": \"2.3.4\"\r\n },\r\n \"participantType\": {\r\n \"name\": \"org.onap.controlloop.HttpControlLoopParticipant\",\r\n \"version\": \"2.3.4\"\r\n },\r\n \"state\": \"UNINITIALISED\",\r\n \"orderedState\": \"UNINITIALISED\",\r\n \"description\": \"DCAE Control Loop Element for the PMSH instance 0 control loop\"\r\n }\r\n }\r\n }\r\n ]\r\n}", + "disabled": false + }, + "description": "" + }, + "response": [ + { + "header": [], + "code": 200, + "name": "Response_200", + "id": "dbdea1c3-05fe-4757-b9a2-74a16d065a12" + } + ] + }, + { + "id": "ad24b4ac-c6f2-4444-97a7-90b007814ba6", + "name": "Commission a Control loop", + "request": { + "url": { + "protocol": "https", + "host": "localhost", + "path": [ + "onap", + "controlloop", + "v2", + "commission" + ], + "port": "6969" + }, + "method": "POST", + "header": [ + { + "key": "Content-Type", + "value": "application/yaml", + "description": "", + "disabled": false + }, + { + "key": "X-ONAP-RequestID", + "value": "709c62b3-8918-41b9-a747-d21eb79c6c20", + "description": "", + "disabled": false + }, + { + "key": "Accept", + "value": "*/*", + "disabled": false + } + ], + "body": { + "mode": "raw", + "raw": "tosca_definitions_version: tosca_simple_yaml_1_3\ndata_types:\n onap.datatypes.ToscaConceptIdentifier:\n derived_from: tosca.datatypes.Root\n properties:\n name:\n type: string\n required: true\n version:\n type: string\n required: true\n\n org.onap.datatypes.policy.clamp.controlloop.httpControlLoopElement.RestRequest:\n version: 1.0.0\n derived_from: tosca.datatypes.Root\n properties:\n restRequestId:\n type: onap.datatypes.ToscaConceptIdentifier\n typeVersion: 1.0.0\n required: true\n description: The name and version of a REST request to be sent to a REST endpoint\n httpMethod:\n type: string\n required: true\n constraints:\n - valid_values: [POST, PUT, GET, DELETE]\n description: The REST method to use\n path:\n type: string\n required: true\n description: The path of the REST request relative to the base URL\n body:\n type: string\n required: false\n description: The body of the REST request for PUT and POST requests\n expectedResponse:\n type: integer\n required: true\n constraints:\n - in_range: [100, 599]\n description: THe expected HTTP status code for the REST request\n org.onap.datatypes.policy.clamp.controlloop.httpControlLoopElement.ConfigurationEntity:\n version: 1.0.0\n derived_from: tosca.datatypes.Root\n properties:\n configurationEntityId:\n type: onap.datatypes.ToscaConceptIdentifier\n typeVersion: 1.0.0\n required: true\n description: The name and version of a Configuration Entity to be handled by the HTTP Control Loop Element\n restSequence:\n type: list\n entry_schema:\n type: org.onap.datatypes.policy.clamp.controlloop.httpControlLoopElement.RestRequest\n typeVersion: 1.0.0\n description: A sequence of REST commands to send to the REST endpoint\n\n\nnode_types:\n org.onap.policy.clamp.controlloop.Participant:\n version: 1.0.1\n derived_from: tosca.nodetypes.Root\n properties:\n provider:\n type: string\n requred: false\n org.onap.policy.clamp.controlloop.ControlLoopElement:\n version: 1.0.1\n derived_from: tosca.nodetypes.Root\n properties:\n provider:\n type: string\n requred: false\n participant_id:\n type: onap.datatypes.ToscaConceptIdentifier\n requred: true\n org.onap.policy.clamp.controlloop.ControlLoop:\n version: 1.0.1\n derived_from: tosca.nodetypes.Root\n properties:\n provider:\n type: string\n requred: false\n elements:\n type: list\n required: true\n entry_schema:\n type: onap.datatypes.ToscaConceptIdentifier\n org.onap.policy.clamp.controlloop.HttpControlLoopElement:\n version: 1.0.1\n derived_from: org.onap.policy.clamp.controlloop.ControlLoopElement\n properties:\n baseUrl:\n type: string\n required: true\n description: The base URL to be prepended to each path, identifies the host for the REST endpoints.\n httpHeaders:\n type: map\n required: false\n entry_schema:\n type: string\n description: HTTP headers to send on REST requests\n configurationEntities:\n type: map\n required: true\n entry_schema:\n type: org.onap.datatypes.policy.clamp.controlloop.httpControlLoopElement.ConfigurationEntity\n typeVersion: 1.0.0\n description: The connfiguration entities the Control Loop Element is managing and their associated REST requests\ntopology_template:\n node_templates:\n org.onap.controlloop.HttpControlLoopParticipant:\n version: 2.3.4\n type: org.onap.policy.clamp.controlloop.Participant\n type_version: 1.0.1\n description: Participant for Http requests\n properties:\n provider: ONAP\n\n org.onap.domain.database.Http_PMSHMicroserviceControlLoopElement:\n # Http config for PMSH.\n version: 1.2.3\n type: org.onap.policy.clamp.controlloop.HttpControlLoopElement\n type_version: 1.0.1\n description: Control loop element for the http requests of PMSH microservice\n properties:\n provider: ONAP\n participant_id:\n name: org.onap.controlloop.HttpControlLoopParticipant\n version: 2.3.4\n uninitializedToPassiveTimeout: 180\n baseUrl: http://10.152.183.51:8500\n httpHeaders:\n Content-Type: application/json\n configurationEntities:\n - configurationEntityId:\n name: entity1\n version: 1.0.1\n restSequence:\n - restRequestId:\n name: request1\n version: 1.0.1\n httpMethod: PUT\n path: v1/kv/dcae-pmsh\n body: '{\n \"control_loop_name\":\"pmsh-control-loop\",\n \"operational_policy_name\":\"pmsh-operational-policy\",\n \"aaf_password\":\"demo123456!\",\n \"aaf_identity\":\"dcae@dcae.onap.org\",\n \"cert_path\":\"/opt/app/pmsh/etc/certs/cert.pem\",\n \"key_path\":\"/opt/app/pmsh/etc/certs/key.pem\",\n \"ca_cert_path\":\"/opt/app/pmsh/etc/certs/cacert.pem\",\n \"enable_tls\":\"true\",\n \"pmsh_policy\":{\n \"subscription\":{\n \"subscriptionName\":\"ExtraPM-All-gNB-R2B\",\n \"administrativeState\":\"UNLOCKED\",\n \"fileBasedGP\":15,\n \"fileLocation\":\"\\/pm\\/pm.xml\",\n \"nfFilter\":{\n \"nfNames\":[\n \"^pnf.*\",\n \"^vnf.*\"\n ],\n \"modelInvariantIDs\":[\n ],\n \"modelVersionIDs\":[\n ],\n \"modelNames\":[\n ]\n },\n \"measurementGroups\":[\n {\n \"measurementGroup\":{\n \"measurementTypes\":[\n {\n \"measurementType\":\"countera\"\n },\n {\n \"measurementType\":\"counterb\"\n }\n ],\n \"managedObjectDNsBasic\":[\n {\n \"DN\":\"dna\"\n },\n {\n \"DN\":\"dnb\"\n }\n ]\n }\n },\n {\n \"measurementGroup\":{\n \"measurementTypes\":[\n {\n \"measurementType\":\"counterc\"\n },\n {\n \"measurementType\":\"counterd\"\n }\n ],\n \"managedObjectDNsBasic\":[\n {\n \"DN\":\"dnc\"\n },\n {\n \"DN\":\"dnd\"\n }\n ]\n }\n }\n ]\n }\n },\n \"streams_subscribes\":{\n \"aai_subscriber\":{\n \"type\":\"message_router\",\n \"dmaap_info\":{\n \"topic_url\":\"https://10.152.183.151:3905/events/AAI_EVENT\",\n \"client_role\":\"org.onap.dcae.aaiSub\",\n \"location\":\"san-francisco\",\n \"client_id\":\"1575976809466\"\n }\n },\n \"policy_pm_subscriber\":{\n \"type\":\"message_router\",\n \"dmaap_info\":{\n \"topic_url\":\"https://10.152.183.151:3905/events/org.onap.dmaap.mr.PM_SUBSCRIPTIONS\",\n \"client_role\":\"org.onap.dcae.pmSubscriber\",\n \"location\":\"san-francisco\",\n \"client_id\":\"1575876809456\"\n }\n }\n },\n \"streams_publishes\":{\n \"policy_pm_publisher\":{\n \"type\":\"message_router\",\n \"dmaap_info\":{\n \"topic_url\":\"https://10.152.183.151:3905/events/org.onap.dmaap.mr.PM_SUBSCRIPTIONS\",\n \"client_role\":\"org.onap.dcae.pmPublisher\",\n \"location\":\"san-francisco\",\n \"client_id\":\"1475976809466\"\n }\n },\n \"other_publisher\":{\n \"type\":\"message_router\",\n \"dmaap_info\":{\n \"topic_url\":\"https://10.152.183.151:3905/events/org.onap.dmaap.mr.SOME_OTHER_TOPIC\",\n \"client_role\":\"org.onap.dcae.pmControlPub\",\n \"location\":\"san-francisco\",\n \"client_id\":\"1875976809466\"\n }\n }\n }\n }'\n expectedResponse: 200\n\n\n org.onap.domain.sample.PMSH_Http_ControlLoopDefinition:\n version: 1.2.3\n type: org.onap.policy.clamp.controlloop.ControlLoop\n type_version: 1.0.0\n description: Control loop for HTTP request to Consul\n properties:\n provider: ONAP\n elements:\n - name: org.onap.domain.database.Http_PMSHMicroserviceControlLoopElement\n version: 1.2.3", + "disabled": false + }, + "description": "" + }, + "response": [ + { + "header": [], + "code": 200, + "name": "Response_200", + "id": "0e98286f-2143-4af9-a291-4f3719b2cedb" + } + ] + } + ], + "variable": [], + "auth": { + "type": "basic", + "basic": { + "username": "runtimeUser", + "password": "zb!XztG34" + } + } +} \ No newline at end of file diff --git a/common/src/test/resources/examples/acm/k8s-participant/k8s.postman2.0_collection.json b/common/src/test/resources/examples/acm/k8s-participant/k8s.postman2.0_collection.json new file mode 100644 index 000000000..e83bc2594 --- /dev/null +++ b/common/src/test/resources/examples/acm/k8s-participant/k8s.postman2.0_collection.json @@ -0,0 +1,254 @@ +{ + "info": { + "name": "CL-K8s-participant", + "_postman_id": "90ac155d-08ff-4dce-a4f0-24e8d8aefa70", + "description": "", + "schema": "https://schema.getpostman.com/json/collection/v2.0.0/collection.json" + }, + "item": [ + { + "id": "711b8171-7b0f-4461-b5ad-fb00bc03b1a3", + "name": "Get Instantiated Control loops", + "request": { + "url": { + "protocol": "https", + "host": "localhost", + "path": [ + "onap", + "controlloop", + "v2", + "instantiation" + ], + "port": "6969" + }, + "method": "GET", + "header": [ + { + "key": "Accept", + "value": "*/*", + "disabled": false + } + ], + "body": { + "mode": "raw", + "disabled": false + }, + "description": "" + }, + "response": [ + { + "header": [], + "code": 200, + "name": "Response_200", + "id": "d10bdd1f-ff18-49ed-9798-1705bb579668" + } + ] + }, + { + "id": "3b0c5920-42b4-4647-8a15-bfcb02cfbd54", + "name": "Update a Control loop", + "request": { + "url": { + "protocol": "https", + "host": "localhost", + "path": [ + "onap", + "controlloop", + "v2", + "instantiation/command" + ], + "port": "6969" + }, + "method": "PUT", + "header": [ + { + "key": "Content-Type", + "value": "application/json", + "description": "", + "disabled": false + }, + { + "key": "X-ONAP-RequestID", + "value": "709c62b3-8918-41b9-a747-d21eb79c6c20", + "description": "", + "disabled": false + }, + { + "key": "Accept", + "value": "*/*", + "disabled": false + } + ], + "body": { + "mode": "raw", + "raw": "{\r\n \"orderedState\": \"PASSIVE\",\r\n \"controlLoopIdentifierList\": [\r\n {\r\n \"name\": \"K8SInstance0\",\r\n \"version\": \"1.0.1\"\r\n }\r\n ]\r\n}", + "disabled": false + }, + "description": "" + }, + "response": [ + { + "header": [], + "code": 200, + "name": "Response_200", + "id": "9b6719f4-d325-45ee-9951-ac50bc8e4d38" + } + ] + }, + { + "id": "d9c9a188-3fe1-4950-b851-9f76b0c72f63", + "name": "UnInitialise a Control loop", + "request": { + "url": { + "protocol": "https", + "host": "localhost", + "path": [ + "onap", + "controlloop", + "v2", + "instantiation/command" + ], + "port": "6969" + }, + "method": "PUT", + "header": [ + { + "key": "Content-Type", + "value": "application/json", + "description": "", + "disabled": false + }, + { + "key": "Accept", + "value": "*/*", + "disabled": false + } + ], + "body": { + "mode": "raw", + "raw": "{\r\n \"orderedState\": \"UNINTIALISED\",\r\n \"controlLoopIdentifierList\": [\r\n {\r\n \"name\": \"K8SInstance0\",\r\n \"version\": \"1.0.1\"\r\n }\r\n ]\r\n}", + "disabled": false + }, + "description": "" + }, + "response": [ + { + "header": [], + "code": 200, + "name": "Response_200", + "id": "69ae3508-0fef-42c7-b96b-28f3b98f599e" + } + ] + }, + { + "id": "3626da99-5645-4386-85cf-0bbe296adf6d", + "name": "Instantiate a Control loop", + "request": { + "url": { + "protocol": "https", + "host": "localhost", + "path": [ + "onap", + "controlloop", + "v2", + "instantiation" + ], + "port": "6969" + }, + "method": "POST", + "header": [ + { + "key": "X-ONAP-RequestID", + "value": "709c62b3-8918-41b9-a747-d21eb79c6c20", + "description": "", + "disabled": false + }, + { + "key": "Content-Type", + "value": "application/json", + "description": "", + "disabled": false + }, + { + "key": "Accept", + "value": "*/*", + "disabled": false + } + ], + "body": { + "mode": "raw", + "raw": "{\r\n \"controlLoopList\": [\r\n {\r\n \"name\": \"K8SInstance0\",\r\n \"version\": \"1.0.1\",\r\n \"definition\": {\r\n \"name\": \"org.onap.domain.sample.GenericK8s_ControlLoopDefinition\",\r\n \"version\": \"1.2.3\"\r\n },\r\n \"state\": \"UNINITIALISED\",\r\n \"orderedState\": \"UNINITIALISED\",\r\n \"description\": \"K8s control loop instance 0\",\r\n \"elements\": {\r\n \"709c62b3-8918-41b9-a747-d21eb79c6c20\": {\r\n \"id\": \"709c62b3-8918-41b9-a747-d21eb79c6c20\",\r\n \"definition\": {\r\n \"name\": \"org.onap.domain.database.HelloWorld_K8SMicroserviceControlLoopElement\",\r\n \"version\": \"1.2.3\"\r\n },\r\n \"participantId\": {\r\n \"name\": \"org.onap.k8s.controlloop.K8SControlLoopParticipant\",\r\n \"version\": \"2.3.4\"\r\n },\r\n \"participantType\": {\r\n \"name\": \"org.onap.k8s.controlloop.K8SControlLoopParticipant\",\r\n \"version\": \"2.3.4\"\r\n },\r\n \"state\": \"UNINITIALISED\",\r\n \"orderedState\": \"UNINITIALISED\",\r\n \"description\": \"K8s Control Loop Element for the k8s instance 0 control loop\"\r\n },\r\n \"709c62b3-8918-41b9-a747-d21eb79c6c21\": {\r\n \"id\": \"709c62b3-8918-41b9-a747-d21eb79c6c21\",\r\n \"definition\": {\r\n \"name\": \"org.onap.domain.database.PMSH_K8SMicroserviceControlLoopElement\",\r\n \"version\": \"1.2.3\"\r\n },\r\n \"participantId\": {\r\n \"name\": \"org.onap.k8s.controlloop.K8SControlLoopParticipant\",\r\n \"version\": \"2.3.4\"\r\n },\r\n \"participantType\": {\r\n \"name\": \"org.onap.k8s.controlloop.K8SControlLoopParticipant\",\r\n \"version\": \"2.3.4\"\r\n },\r\n \"state\": \"UNINITIALISED\",\r\n \"orderedState\": \"UNINITIALISED\",\r\n \"description\": \"K8s Control Loop Element for the PMSH instance 0 control loop\"\r\n },\r\n \"709c62b3-8918-41b9-a747-d21eb79c6c22\": {\r\n \"id\": \"709c62b3-8918-41b9-a747-d21eb79c6c22\",\r\n \"definition\": {\r\n \"name\": \"org.onap.domain.database.Local_K8SMicroserviceControlLoopElement\",\r\n \"version\": \"1.2.3\"\r\n },\r\n \"participantId\": {\r\n \"name\": \"org.onap.k8s.controlloop.K8SControlLoopParticipant\",\r\n \"version\": \"2.3.4\"\r\n },\r\n \"participantType\": {\r\n \"name\": \"org.onap.k8s.controlloop.K8SControlLoopParticipant\",\r\n \"version\": \"2.3.4\"\r\n },\r\n \"state\": \"UNINITIALISED\",\r\n \"orderedState\": \"UNINITIALISED\",\r\n \"description\": \"K8s Control Loop Element for the local instance 0 control loop\"\r\n }\r\n }\r\n }\r\n ]\r\n}", + "disabled": false + }, + "description": "" + }, + "response": [ + { + "header": [], + "code": 200, + "name": "Response_200", + "id": "76e0d5e8-f5c9-456e-b908-c9f24ebc5613" + } + ] + }, + { + "id": "9e88fc2f-6a65-4693-ab78-d69139d06d02", + "name": "Commission a Control loop", + "request": { + "url": { + "protocol": "https", + "host": "localhost", + "path": [ + "onap", + "controlloop", + "v2", + "commission" + ], + "port": "6969" + }, + "method": "POST", + "header": [ + { + "key": "Content-Type", + "value": "application/yaml", + "description": "", + "disabled": false + }, + { + "key": "X-ONAP-RequestID", + "value": "709c62b3-8918-41b9-a747-d21eb79c6c20", + "description": "", + "disabled": false + }, + { + "key": "Accept", + "value": "*/*", + "disabled": false + } + ], + "body": { + "mode": "raw", + "raw": "tosca_definitions_version: tosca_simple_yaml_1_3\ndata_types:\n onap.datatypes.ToscaConceptIdentifier:\n derived_from: tosca.datatypes.Root\n properties:\n name:\n type: string\n required: true\n version:\n type: string\n required: true\nnode_types:\n org.onap.policy.clamp.controlloop.Participant:\n version: 1.0.1\n derived_from: tosca.nodetypes.Root\n properties:\n provider:\n type: string\n requred: false\n org.onap.policy.clamp.controlloop.ControlLoopElement:\n version: 1.0.1\n derived_from: tosca.nodetypes.Root\n properties:\n provider:\n type: string\n requred: false\n participant_id:\n type: onap.datatypes.ToscaConceptIdentifier\n requred: true\n org.onap.policy.clamp.controlloop.ControlLoop:\n version: 1.0.1\n derived_from: tosca.nodetypes.Root\n properties:\n provider:\n type: string\n requred: false\n elements:\n type: list\n required: true\n entry_schema:\n type: onap.datatypes.ToscaConceptIdentifier\n org.onap.policy.clamp.controlloop.K8SMicroserviceControlLoopElement:\n version: 1.0.1\n derived_from: org.onap.policy.clamp.controlloop.ControlLoopElement\n properties:\n chart:\n type: string\n required: true\n configs:\n type: list\n required: false\n requirements:\n type: string\n requred: false\n templates:\n type: list\n required: false\n entry_schema:\n values:\n type: string\n requred: true\ntopology_template:\n node_templates:\n org.onap.k8s.controlloop.K8SControlLoopParticipant:\n version: 2.3.4\n type: org.onap.policy.clamp.controlloop.Participant\n type_version: 1.0.1\n description: Participant for K8S\n properties:\n provider: ONAP\n \n org.onap.domain.database.HelloWorld_K8SMicroserviceControlLoopElement:\n # Chart from any chart repository configured on helm client.\n version: 1.2.3\n type: org.onap.policy.clamp.controlloop.K8SMicroserviceControlLoopElement\n type_version: 1.0.0\n description: Control loop element for the K8S microservice for Hello World\n properties:\n provider: ONAP\n participant_id:\n name: org.onap.k8s.controlloop.K8SControlLoopParticipant\n version: 2.3.4\n chart: \n chartId: \n name: dummy\n version: 0.1.0 \n releaseName: test \n namespace: test \n\n org.onap.domain.database.PMSH_K8SMicroserviceControlLoopElement: \n # Chart from local file system \n version: 1.2.3\n type: org.onap.policy.clamp.controlloop.K8SMicroserviceControlLoopElement\n type_version: 1.0.0\n description: Control loop element for the K8S microservice for PMSH\n properties:\n provider: ONAP\n participant_id:\n name: org.onap.k8s.controlloop.K8SControlLoopParticipant\n version: 2.3.4\n chart: \n chartId: \n name: dcae-pmsh \n version: 8.0.0\n namespace: onap \n releaseName: pmshms\n repository:\n repoName: chartmuseum\n protocol: http\n address: 10.152.183.120\n port: 80\n userName: onapinitializer\n password: demo123456!\n overrideParams:\n global.masterPassword: test\n \n \n\n org.onap.domain.database.Local_K8SMicroserviceControlLoopElement: \n # Chart installation without passing repository name \n version: 1.2.3\n type: org.onap.policy.clamp.controlloop.K8SMicroserviceControlLoopElement\n type_version: 1.0.0\n description: Control loop element for the K8S microservice for local chart\n properties:\n provider: ONAP\n participant_id:\n name: org.onap.k8s.controlloop.K8SControlLoopParticipant\n version: 2.3.4\n chart:\n chartId: \n name: nginx-ingress\n version: 0.9.1 \n releaseName: nginxms\n namespace: test \n repository:\n repoName: nginx-stable \n\n org.onap.domain.sample.GenericK8s_ControlLoopDefinition:\n version: 1.2.3\n type: org.onap.policy.clamp.controlloop.ControlLoop\n type_version: 1.0.0\n description: Control loop for Hello World\n properties:\n provider: ONAP\n elements: \n - name: org.onap.domain.database.HelloWorld_K8SMicroserviceControlLoopElement\n version: 1.2.3 \n - name: org.onap.domain.database.PMSH_K8SMicroserviceControlLoopElement\n version: 1.2.3 \n - name: org.onap.domain.database.Local_K8SMicroserviceControlLoopElement\n version: 1.2.3 \n ", + "disabled": false + }, + "description": "" + }, + "response": [ + { + "header": [], + "code": 200, + "name": "Response_200", + "id": "ab57b923-a484-486c-a03a-b1ad6bf64d09" + } + ] + } + ], + "variable": [], + "auth": { + "type": "basic", + "basic": { + "username": "runtimeUser", + "password": "zb!XztG34" + } + } +} \ No newline at end of file diff --git a/common/src/test/resources/examples/controlloop/KubernetesHelm.yaml b/common/src/test/resources/examples/controlloop/KubernetesHelm.yaml deleted file mode 100644 index 9b0f449d3..000000000 --- a/common/src/test/resources/examples/controlloop/KubernetesHelm.yaml +++ /dev/null @@ -1,182 +0,0 @@ -# ============LICENSE_START======================================================= -# Copyright (C) 2021 Nordix Foundation. -# ================================================================================ -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# -# SPDX-License-Identifier: Apache-2.0 -# ============LICENSE_END========================================================= - -tosca_definitions_version: tosca_simple_yaml_1_3 -data_types: - onap.datatypes.ToscaConceptIdentifier: - derived_from: tosca.datatypes.Root - properties: - name: - type: string - required: true - version: - type: string - required: true -node_types: - org.onap.policy.clamp.controlloop.Participant: - version: 1.0.1 - derived_from: tosca.nodetypes.Root - properties: - provider: - type: string - requred: false - org.onap.policy.clamp.controlloop.ControlLoopElement: - version: 1.0.1 - derived_from: tosca.nodetypes.Root - properties: - provider: - type: string - requred: false - participantType: - type: onap.datatypes.ToscaConceptIdentifier - requred: true - startPhase: - type: integer - required: false - constraints: - - greater-or-equal: 0 - metadata: - common: true - description: A value indicating the start phase in which this control loop element will be started, the - first start phase is zero. Control Loop Elements are started in their start_phase order and stopped - in reverse start phase order. Control Loop Elements with the same start phase are started and - stopped simultaneously - org.onap.policy.clamp.controlloop.ControlLoop: - version: 1.0.1 - derived_from: tosca.nodetypes.Root - properties: - provider: - type: string - requred: false - elements: - type: list - required: true - entry_schema: - type: onap.datatypes.ToscaConceptIdentifier - org.onap.policy.clamp.controlloop.K8SMicroserviceControlLoopElement: - version: 1.0.1 - derived_from: org.onap.policy.clamp.controlloop.ControlLoopElement - properties: - chart: - type: string - requred: true - configs: - type: list - required: false - requirements: - type: string - requred: false - templates: - type: list - required: false - entry_schema: - values: - type: string - requred: true -topology_template: - node_templates: - org.onap.k8s.controlloop.K8SControlLoopParticipant: - version: 2.3.4 - type: org.onap.policy.clamp.controlloop.Participant - type_version: 1.0.1 - description: Participant for K8S - properties: - provider: ONAP - org.onap.domain.database.Postgres_K8SMicroserviceControlLoopElement: - # See https://github.com/onap/oom/tree/master/kubernetes/common/postgres - version: 1.2.3 - type: org.onap.policy.clamp.controlloop.K8SMicroserviceControlLoopElement - type_version: 1.0.0 - description: Control loop element for the K8S microservice for Postgres - properties: - provider: ONAP - participantType: - name: org.onap.k8s.controlloop.K8SControlLoopParticipant - version: 2.3.4 - startPhase: 2 - chart: - apiVersion: v1 - description: ONAP Postgres Server - name: postgres - version: 7.0.0 - configs: - - name: pg_hba.conf - value: - - name: setup.sql - value: - requirements: - dependencies: - - name: common - version: ~7.x-0 - repository: 'file://../common' - - name: repositoryGenerator - version: ~7.x-0 - repository: 'file://../repositoryGenerator' - templates: - - name: first_template_file - value: - - name: And so on - values: - - org.onap.domain.database.HelloWorld_K8SMicroserviceControlLoopElement: - # See https://github.com/stakater-charts/helloworld/tree/master/helloworld - version: 1.2.3 - type: org.onap.policy.clamp.controlloop.K8SMicroserviceControlLoopElement - type_version: 1.0.0 - description: Control loop element for the K8S microservice for Hello World - properties: - provider: ONAP - participantType: - name: org.onap.k8s.controlloop.K8SControlLoopParticipant - version: 2.3.4 - startPhase: 2 - chart: - apiVersion: v1 - name: helloworld - description: helloworld chart that runs on kubernetes - version: 1.0.0 - keywords: - - helloworld - - kubernetes - home: https://github.com/stakater-charts/helloworld - maintainers: - - name: Stakater - email: stakater@aurorasolutions.io - values: - kubernetes: - host: https://kubernetes.default - helloworld: - namespace: default - image: - name: tutum/hello-world - tag: latest - pullPolicy: IfNotPresent - service: - ingressClass: internal-ingress - org.onap.domain.sample.Postgres_HelloWorld_ControlLoopDefinition: - version: 1.2.3 - type: org.onap.policy.clamp.controlloop.ControlLoop - type_version: 1.0.0 - description: Control loop for Postgres and Hello World - properties: - provider: ONAP - elements: - - name: org.onap.domain.database.Postgres_K8SMicroserviceControlLoopElement - version: 1.2.3 - - name: org.onap.domain.database.HelloWorld_K8SMicroserviceControlLoopElement - version: 1.2.3 diff --git a/common/src/test/resources/examples/controlloop/PMSH/consul_call_body.json b/common/src/test/resources/examples/controlloop/PMSH/consul_call_body.json deleted file mode 100644 index 9118e9a6f..000000000 --- a/common/src/test/resources/examples/controlloop/PMSH/consul_call_body.json +++ /dev/null @@ -1,62 +0,0 @@ -{ - "subscription": { - "subscriptionName": "subscriptiona", - "administrativeState": "UNLOCKED", - "fileBasedGP": 15, - "fileLocation": "/pm/pm.xml", - "nfFilter": { - "nfNames": [ - "^pnf1.*" - ], - "modelInvariantIDs": [ - "5845y423-g654-6fju-po78-8n53154532k6", - "7129e420-d396-4efb-af02-6b83499b12f8" - ], - "modelVersionIDs": [ - "e80a6ae3-cafd-4d24-850d-e14c084a5ca9" - ] - }, - "measurementGroups": [ - { - "measurementGroup": { - "measurementTypes": [ - { - "measurementType": "countera" - }, - { - "measurementType": "counterb" - } - ], - "managedObjectDNsBasic": [ - { - "DN": "dna" - }, - { - "DN": "dnb" - } - ] - } - }, - { - "measurementGroup": { - "measurementTypes": [ - { - "measurementType": "counterc" - }, - { - "measurementType": "counterd" - } - ], - "managedObjectDNsBasic": [ - { - "DN": "dnc" - }, - { - "DN": "dnd" - } - ] - } - } - ] - } -} diff --git a/common/src/test/resources/examples/controlloop/PMSH/consul_url.txt b/common/src/test/resources/examples/controlloop/PMSH/consul_url.txt deleted file mode 100644 index 2a2e77e86..000000000 --- a/common/src/test/resources/examples/controlloop/PMSH/consul_url.txt +++ /dev/null @@ -1 +0,0 @@ -http://consul:31321/v1/kv/dcae-pmsh:policy diff --git a/common/src/test/resources/examples/controlloop/PMSH/pmsh.postman2.0_collection.json b/common/src/test/resources/examples/controlloop/PMSH/pmsh.postman2.0_collection.json deleted file mode 100644 index 6efddc256..000000000 --- a/common/src/test/resources/examples/controlloop/PMSH/pmsh.postman2.0_collection.json +++ /dev/null @@ -1,254 +0,0 @@ -{ - "info": { - "name": "CL-PMSH usecase", - "_postman_id": "5fb85996-3b5b-40fb-9564-bd44eff287d4", - "description": "", - "schema": "https://schema.getpostman.com/json/collection/v2.0.0/collection.json" - }, - "item": [ - { - "id": "b436e642-10a0-40d7-a37f-9979693cdb02", - "name": "Get Instantiated Control loops", - "request": { - "url": { - "protocol": "https", - "host": "localhost", - "path": [ - "onap", - "controlloop", - "v2", - "instantiation" - ], - "port": "6969" - }, - "method": "GET", - "header": [ - { - "key": "Accept", - "value": "*/*", - "disabled": false - } - ], - "body": { - "mode": "raw", - "disabled": false - }, - "description": "" - }, - "response": [ - { - "header": [], - "code": 200, - "name": "Response_200", - "id": "d9328b54-71fa-43aa-96cd-0d002e958da9" - } - ] - }, - { - "id": "021d7ff6-5cad-4967-afe2-f68317cba1f1", - "name": "Update a Control loop", - "request": { - "url": { - "protocol": "https", - "host": "localhost", - "path": [ - "onap", - "controlloop", - "v2", - "instantiation/command" - ], - "port": "6969" - }, - "method": "PUT", - "header": [ - { - "key": "Content-Type", - "value": "application/json", - "description": "", - "disabled": false - }, - { - "key": "X-ONAP-RequestID", - "value": "709c62b3-8918-41b9-a747-d21eb79c6c20", - "description": "", - "disabled": false - }, - { - "key": "Accept", - "value": "*/*", - "disabled": false - } - ], - "body": { - "mode": "raw", - "raw": "{\r\n \"orderedState\": \"PASSIVE\",\r\n \"controlLoopIdentifierList\": [\r\n {\r\n \"name\": \"PmshInstance0\",\r\n \"version\": \"1.0.1\"\r\n }\r\n ]\r\n}", - "disabled": false - }, - "description": "" - }, - "response": [ - { - "header": [], - "code": 200, - "name": "Response_200", - "id": "15718e82-6647-4102-9c1e-7e5c0cc48261" - } - ] - }, - { - "id": "96d15818-1f95-41bd-ac18-37a96f99a0d8", - "name": "UnInitialise a Control loop", - "request": { - "url": { - "protocol": "https", - "host": "localhost", - "path": [ - "onap", - "controlloop", - "v2", - "instantiation/command" - ], - "port": "6969" - }, - "method": "PUT", - "header": [ - { - "key": "Content-Type", - "value": "application/json", - "description": "", - "disabled": false - }, - { - "key": "Accept", - "value": "*/*", - "disabled": false - } - ], - "body": { - "mode": "raw", - "raw": "{\r\n \"orderedState\": \"UNINTIALISED\",\r\n \"controlLoopIdentifierList\": [\r\n {\r\n \"name\": \"PmshInstance0\",\r\n \"version\": \"1.0.1\"\r\n }\r\n ]\r\n}", - "disabled": false - }, - "description": "" - }, - "response": [ - { - "header": [], - "code": 200, - "name": "Response_200", - "id": "a02ccea0-d357-4ced-9f19-82bd5712d318" - } - ] - }, - { - "id": "43776ab0-4851-41bb-8c43-407d0b807696", - "name": "Instantiate a Control loop", - "request": { - "url": { - "protocol": "https", - "host": "localhost", - "path": [ - "onap", - "controlloop", - "v2", - "instantiation" - ], - "port": "6969" - }, - "method": "POST", - "header": [ - { - "key": "X-ONAP-RequestID", - "value": "709c62b3-8918-41b9-a747-d21eb79c6c20", - "description": "", - "disabled": false - }, - { - "key": "Content-Type", - "value": "application/json", - "description": "", - "disabled": false - }, - { - "key": "Accept", - "value": "*/*", - "disabled": false - } - ], - "body": { - "mode": "raw", - "raw": "{\r\n \"controlLoopList\": [\r\n {\r\n \"name\": \"PmshInstance0\",\r\n \"version\": \"1.0.1\",\r\n \"definition\": {\r\n \"name\": \"org.onap.domain.sample.GenericK8s_ControlLoopDefinition\",\r\n \"version\": \"1.2.3\"\r\n },\r\n \"state\": \"UNINITIALISED\",\r\n \"orderedState\": \"UNINITIALISED\",\r\n \"description\": \"K8s control loop instance 0\",\r\n \"elements\": {\r\n \"709c62b3-8918-41b9-a747-d21eb79c6c21\": {\r\n \"id\": \"709c62b3-8918-41b9-a747-d21eb79c6c21\",\r\n \"definition\": {\r\n \"name\": \"org.onap.domain.database.PMSH_K8SMicroserviceControlLoopElement\",\r\n \"version\": \"1.2.3\"\r\n },\r\n \"participantId\": {\r\n \"name\": \"org.onap.k8s.controlloop.K8SControlLoopParticipant\",\r\n \"version\": \"2.3.4\"\r\n },\r\n \"participantType\": {\r\n \"name\": \"org.onap.k8s.controlloop.K8SControlLoopParticipant\",\r\n \"version\": \"2.3.4\"\r\n },\r\n \"state\": \"UNINITIALISED\",\r\n \"orderedState\": \"UNINITIALISED\",\r\n \"description\": \"K8s Control Loop Element for the PMSH instance 0 control loop\"\r\n },\r\n \"709c62b3-8918-41b9-a747-d21eb79c6c22\": {\r\n \"id\": \"709c62b3-8918-41b9-a747-d21eb79c6c22\",\r\n \"definition\": {\r\n \"name\": \"org.onap.domain.database.Local_K8SMicroserviceControlLoopElement\",\r\n \"version\": \"1.2.3\"\r\n },\r\n \"participantId\": {\r\n \"name\": \"org.onap.k8s.controlloop.K8SControlLoopParticipant\",\r\n \"version\": \"2.3.4\"\r\n },\r\n \"participantType\": {\r\n \"name\": \"org.onap.k8s.controlloop.K8SControlLoopParticipant\",\r\n \"version\": \"2.3.4\"\r\n },\r\n \"state\": \"UNINITIALISED\",\r\n \"orderedState\": \"UNINITIALISED\",\r\n \"description\": \"K8s Control Loop Element for the local instance 0 control loop\"\r\n },\r\n \"709c62b3-8918-41b9-a747-d21eb79c6c25\": {\r\n \"id\": \"709c62b3-8918-41b9-a747-d21eb79c6c25\",\r\n \"definition\": {\r\n \"name\": \"org.onap.domain.database.Http_PMSHMicroserviceControlLoopElement\",\r\n \"version\": \"1.2.3\"\r\n },\r\n \"participantId\": {\r\n \"name\": \"org.onap.controlloop.HttpControlLoopParticipant\",\r\n \"version\": \"2.3.4\"\r\n },\r\n \"participantType\": {\r\n \"name\": \"org.onap.controlloop.HttpControlLoopParticipant\",\r\n \"version\": \"2.3.4\"\r\n },\r\n \"state\": \"UNINITIALISED\",\r\n \"orderedState\": \"UNINITIALISED\",\r\n \"description\": \"DCAE Control Loop Element for the PMSH instance 0 control loop\"\r\n }\r\n }\r\n }\r\n ]\r\n}", - "disabled": false - }, - "description": "" - }, - "response": [ - { - "header": [], - "code": 200, - "name": "Response_200", - "id": "855ec245-13ef-48ab-a0e0-3de6e11090a4" - } - ] - }, - { - "id": "3f6d5d18-8a29-46c3-8fec-d6645e7f7c2b", - "name": "Commission a Control loop", - "request": { - "url": { - "protocol": "https", - "host": "localhost", - "path": [ - "onap", - "controlloop", - "v2", - "commission" - ], - "port": "6969" - }, - "method": "POST", - "header": [ - { - "key": "Content-Type", - "value": "application/yaml", - "description": "", - "disabled": false - }, - { - "key": "X-ONAP-RequestID", - "value": "709c62b3-8918-41b9-a747-d21eb79c6c20", - "description": "", - "disabled": false - }, - { - "key": "Accept", - "value": "*/*", - "disabled": false - } - ], - "body": { - "mode": "raw", - "raw": "tosca_definitions_version: tosca_simple_yaml_1_3\ndata_types:\n onap.datatypes.ToscaConceptIdentifier:\n derived_from: tosca.datatypes.Root\n properties:\n name:\n type: string\n required: true\n version:\n type: string\n required: true\n \n org.onap.datatypes.policy.clamp.controlloop.httpControlLoopElement.RestRequest:\n version: 1.0.0\n derived_from: tosca.datatypes.Root\n properties:\n restRequestId:\n type: onap.datatypes.ToscaConceptIdentifier\n typeVersion: 1.0.0\n required: true\n description: The name and version of a REST request to be sent to a REST endpoint\n httpMethod:\n type: string\n required: true\n constraints:\n - valid_values: [POST, PUT, GET, DELETE]\n description: The REST method to use\n path:\n type: string\n required: true\n description: The path of the REST request relative to the base URL\n body:\n type: string\n required: false\n description: The body of the REST request for PUT and POST requests\n expectedResponse:\n type: integer\n required: true\n constraints:\n - in_range: [100, 599]\n description: THe expected HTTP status code for the REST request\n org.onap.datatypes.policy.clamp.controlloop.httpControlLoopElement.ConfigurationEntity:\n version: 1.0.0\n derived_from: tosca.datatypes.Root\n properties:\n configurationEntityId:\n type: onap.datatypes.ToscaConceptIdentifier\n typeVersion: 1.0.0\n required: true\n description: The name and version of a Configuration Entity to be handled by the HTTP Control Loop Element\n restSequence:\n type: list\n entry_schema:\n type: org.onap.datatypes.policy.clamp.controlloop.httpControlLoopElement.RestRequest\n typeVersion: 1.0.0\n description: A sequence of REST commands to send to the REST endpoint \nnode_types:\n org.onap.policy.clamp.controlloop.Participant:\n version: 1.0.1\n derived_from: tosca.nodetypes.Root\n properties:\n provider:\n type: string\n requred: false\n org.onap.policy.clamp.controlloop.ControlLoopElement:\n version: 1.0.1\n derived_from: tosca.nodetypes.Root\n properties:\n provider:\n type: string\n requred: false\n participant_id:\n type: onap.datatypes.ToscaConceptIdentifier\n requred: true\n org.onap.policy.clamp.controlloop.ControlLoop:\n version: 1.0.1\n derived_from: tosca.nodetypes.Root\n properties:\n provider:\n type: string\n requred: false\n elements:\n type: list\n required: true\n entry_schema:\n type: onap.datatypes.ToscaConceptIdentifier\n org.onap.policy.clamp.controlloop.K8SMicroserviceControlLoopElement:\n version: 1.0.1\n derived_from: org.onap.policy.clamp.controlloop.ControlLoopElement\n properties:\n chart:\n type: string\n required: true\n configs:\n type: list\n required: false\n requirements:\n type: string\n requred: false\n templates:\n type: list\n required: false\n entry_schema:\n values:\n type: string\n requred: true\n \n org.onap.policy.clamp.controlloop.HttpControlLoopElement:\n version: 1.0.1\n derived_from: org.onap.policy.clamp.controlloop.ControlLoopElement\n properties:\n baseUrl:\n type: string\n required: true\n description: The base URL to be prepended to each path, identifies the host for the REST endpoints.\n httpHeaders:\n type: map\n required: false\n entry_schema:\n type: string\n description: HTTP headers to send on REST requests\n configurationEntities:\n type: map\n required: true\n entry_schema:\n type: org.onap.datatypes.policy.clamp.controlloop.httpControlLoopElement.ConfigurationEntity\n typeVersion: 1.0.0\n description: The connfiguration entities the Control Loop Element is managing and their associated REST requests \n \n \ntopology_template:\n node_templates:\n org.onap.k8s.controlloop.K8SControlLoopParticipant:\n version: 2.3.4\n type: org.onap.policy.clamp.controlloop.Participant\n type_version: 1.0.1\n description: Participant for K8S\n properties:\n provider: ONAP \n\n org.onap.domain.database.PMSH_K8SMicroserviceControlLoopElement: \n # Chart from new repository \n version: 1.2.3\n type: org.onap.policy.clamp.controlloop.K8SMicroserviceControlLoopElement\n type_version: 1.0.0\n description: Control loop element for the K8S microservice for PMSH\n properties:\n provider: ONAP\n participant_id:\n name: org.onap.k8s.controlloop.K8SControlLoopParticipant\n version: 2.3.4\n chart: \n chartId: \n name: dcae-pmsh \n version: 8.0.0\n namespace: onap \n releaseName: pmshms\n repository:\n repoName: chartmuseum\n protocol: http\n address: 10.152.183.120\n port: 80\n userName: onapinitializer\n password: demo123456!\n overrideParams:\n global.masterPassword: test\n \n \n\n org.onap.domain.database.Local_K8SMicroserviceControlLoopElement: \n # Chart installation without passing repository info \n version: 1.2.3\n type: org.onap.policy.clamp.controlloop.K8SMicroserviceControlLoopElement\n type_version: 1.0.0\n description: Control loop element for the K8S microservice for local chart\n properties:\n provider: ONAP\n participant_id:\n name: org.onap.k8s.controlloop.K8SControlLoopParticipant\n version: 2.3.4\n chart:\n chartId: \n name: nginx-ingress\n version: 0.9.1 \n releaseName: nginxms\n namespace: test \n \n org.onap.controlloop.HttpControlLoopParticipant:\n version: 2.3.4\n type: org.onap.policy.clamp.controlloop.Participant\n type_version: 1.0.1\n description: Participant for Http requests\n properties:\n provider: ONAP\n\n org.onap.domain.database.Http_PMSHMicroserviceControlLoopElement:\n # Consul http config for PMSH.\n version: 1.2.3\n type: org.onap.policy.clamp.controlloop.HttpControlLoopElement\n type_version: 1.0.1\n description: Control loop element for the http requests of PMSH microservice\n properties:\n provider: ONAP\n participant_id:\n name: org.onap.controlloop.HttpControlLoopParticipant\n version: 2.3.4\n uninitializedToPassiveTimeout: 180\n baseUrl: http://10.152.183.51:8500\n httpHeaders:\n Content-Type: application/json\n configurationEntities:\n - configurationEntityId:\n name: entity1\n version: 1.0.1\n restSequence:\n - restRequestId:\n name: request1\n version: 1.0.1\n httpMethod: PUT\n path: v1/kv/dcae-pmsh2\n body: '{\n \"control_loop_name\":\"pmsh-control-loop\",\n \"operational_policy_name\":\"pmsh-operational-policy\",\n \"aaf_password\":\"demo123456!\",\n \"aaf_identity\":\"dcae@dcae.onap.org\",\n \"cert_path\":\"/opt/app/pmsh/etc/certs/cert.pem\",\n \"key_path\":\"/opt/app/pmsh/etc/certs/key.pem\",\n \"ca_cert_path\":\"/opt/app/pmsh/etc/certs/cacert.pem\",\n \"enable_tls\":\"true\",\n \"pmsh_policy\":{\n \"subscription\":{\n \"subscriptionName\":\"ExtraPM-All-gNB-R2B\",\n \"administrativeState\":\"UNLOCKED\",\n \"fileBasedGP\":15,\n \"fileLocation\":\"\\/pm\\/pm.xml\",\n \"nfFilter\":{\n \"nfNames\":[\n \"^pnf.*\",\n \"^vnf.*\"\n ],\n \"modelInvariantIDs\":[\n ],\n \"modelVersionIDs\":[\n ],\n \"modelNames\":[\n ]\n },\n \"measurementGroups\":[\n {\n \"measurementGroup\":{\n \"measurementTypes\":[\n {\n \"measurementType\":\"countera\"\n },\n {\n \"measurementType\":\"counterb\"\n }\n ],\n \"managedObjectDNsBasic\":[\n {\n \"DN\":\"dna\"\n },\n {\n \"DN\":\"dnb\"\n }\n ]\n }\n },\n {\n \"measurementGroup\":{\n \"measurementTypes\":[\n {\n \"measurementType\":\"counterc\"\n },\n {\n \"measurementType\":\"counterd\"\n }\n ],\n \"managedObjectDNsBasic\":[\n {\n \"DN\":\"dnc\"\n },\n {\n \"DN\":\"dnd\"\n }\n ]\n }\n }\n ]\n }\n },\n \"streams_subscribes\":{\n \"aai_subscriber\":{\n \"type\":\"message_router\",\n \"dmaap_info\":{\n \"topic_url\":\"https://10.152.183.151:3905/events/AAI_EVENT\",\n \"client_role\":\"org.onap.dcae.aaiSub\",\n \"location\":\"san-francisco\",\n \"client_id\":\"1575976809466\"\n }\n },\n \"policy_pm_subscriber\":{\n \"type\":\"message_router\",\n \"dmaap_info\":{\n \"topic_url\":\"https://10.152.183.151:3905/events/org.onap.dmaap.mr.PM_SUBSCRIPTIONS\",\n \"client_role\":\"org.onap.dcae.pmSubscriber\",\n \"location\":\"san-francisco\",\n \"client_id\":\"1575876809456\"\n }\n }\n },\n \"streams_publishes\":{\n \"policy_pm_publisher\":{\n \"type\":\"message_router\",\n \"dmaap_info\":{\n \"topic_url\":\"https://10.152.183.151:3905/events/org.onap.dmaap.mr.PM_SUBSCRIPTIONS\",\n \"client_role\":\"org.onap.dcae.pmPublisher\",\n \"location\":\"san-francisco\",\n \"client_id\":\"1475976809466\"\n }\n },\n \"other_publisher\":{\n \"type\":\"message_router\",\n \"dmaap_info\":{\n \"topic_url\":\"https://10.152.183.151:3905/events/org.onap.dmaap.mr.SOME_OTHER_TOPIC\",\n \"client_role\":\"org.onap.dcae.pmControlPub\",\n \"location\":\"san-francisco\",\n \"client_id\":\"1875976809466\"\n }\n }\n }\n }'\n expectedResponse: 200\n \n\n org.onap.domain.sample.GenericK8s_ControlLoopDefinition:\n version: 1.2.3\n type: org.onap.policy.clamp.controlloop.ControlLoop\n type_version: 1.0.0\n description: Control loop for Hello World\n properties:\n provider: ONAP\n elements: \n - name: org.onap.domain.database.PMSH_K8SMicroserviceControlLoopElement\n version: 1.2.3 \n - name: org.onap.domain.database.Local_K8SMicroserviceControlLoopElement\n version: 1.2.3 \n - name: org.onap.domain.database.Http_PMSHMicroserviceControlLoopElement\n version: 1.2.3\n ", - "disabled": false - }, - "description": "" - }, - "response": [ - { - "header": [], - "code": 200, - "name": "Response_200", - "id": "d120b824-7fb5-478b-92a3-4d06b92bd00f" - } - ] - } - ], - "variable": [], - "auth": { - "type": "basic", - "basic": { - "username": "runtimeUser", - "password": "zb!XztG34" - } - } -} \ No newline at end of file diff --git a/common/src/test/resources/examples/controlloop/PMSH/pmsh_cloudify_blueprint.yaml b/common/src/test/resources/examples/controlloop/PMSH/pmsh_cloudify_blueprint.yaml deleted file mode 100644 index 7cdc6d5b9..000000000 --- a/common/src/test/resources/examples/controlloop/PMSH/pmsh_cloudify_blueprint.yaml +++ /dev/null @@ -1,176 +0,0 @@ -# -# ============LICENSE_START======================================================= -# Copyright (C) 2020 Nordix Foundation. -# ================================================================================ -# Licensed under the Apache License, Version 2.0 (the 'License'); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an 'AS IS' BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# -# SPDX-License-Identifier: Apache-2.0 -# ============LICENSE_END========================================================= -# - -tosca_definitions_version: cloudify_dsl_1_3 - -imports: - - https://www.getcloudify.org/spec/cloudify/4.5.5/types.yaml - # - plugin:k8splugin?version=>=3.4.3,<4.0.0 - - plugin:k8splugin?version=3.7.0 - - plugin:pgaas?version=1.3.0 - - plugin:clamppolicyplugin?version=1.1.0 -inputs: - tag_version: - type: string - description: Docker image to be used - default: 'nexus3.onap.org:10001/onap/org.onap.dcaegen2.services.pmsh:1.1.2' - replicas: - type: integer - description: Number of instances - default: 1 - operational_policy_name: - type: string - default: 'pmsh-operational-policy' - control_loop_name: - type: string - default: 'pmsh-control-loop' - pmsh_publish_topic_name: - type: string - default: 'unauthenticated.DCAE_CL_OUTPUT' - policy_feedback_topic_name: - type: string - default: 'unauthenticated.PMSH_CL_INPUT' - aai_notification_topic_name: - type: string - default: 'AAI-EVENT' - publisher_client_role: - type: string - description: Client role to request secure access to topic - default: 'org.onap.dcae.pmPublisher' - subscriber_client_role: - type: string - description: Client role to request secure access to topic - default: 'org.onap.dcae.pmSubscriber' - dcae_location: - type: string - description: DCAE location for the subscriber, used to set up routing - default: 'san-francisco' - cpu_limit: - type: string - default: '1000m' - cpu_request: - type: string - default: '1000m' - memory_limit: - type: string - default: '1024Mi' - memory_request: - type: string - default: '1024Mi' - pgaas_cluster_name: - type: string - default: 'dcae-pg-primary.onap' - enable_tls: - type: boolean - default: true - protocol: - type: string - description: PMSH protocol. If enable_tls is false, set to http - default: 'https' - policy_model_id: - type: 'string' - default: 'onap.policies.monitoring.dcae-pm-subscription-handler' - policy_id: - type: 'string' - default: 'onap.policies.monitoring.dcae-pm-subscription-handler' -node_templates: - pgaasvm: - type: dcae.nodes.pgaas.database - properties: - writerfqdn: { get_input: pgaas_cluster_name } - name: 'pmsh' - pmsh: - type: dcae.nodes.ContainerizedServiceComponentUsingDmaap - interfaces: - cloudify.interfaces.lifecycle: - create: - inputs: - ports: - - '8443:0' - envs: - PMSH_PG_URL: - { get_attribute: [ pgaasvm, admin, host ] } - PMSH_PG_PASSWORD: - { get_attribute: [ pgaasvm, admin, password ] } - PMSH_PG_USERNAME: - { get_attribute: [ pgaasvm, admin, user ] } - PMSH_DB_NAME: - { get_attribute: [ pgaasvm, admin, database ] } - - relationships: - - target: pmsh-policy - type: cloudify.relationships.depends_on - - properties: - service_component_type: 'dcae-pmsh' - service_component_name_override: 'dcae-pmsh' - application_config: - enable_tls: { get_input: enable_tls } - aaf_identity: 'dcae@dcae.onap.org' - aaf_password: 'demo123456!' - operational_policy_name: { get_input: operational_policy_name } - control_loop_name: { get_input: control_loop_name } - cert_path: '/opt/app/pmsh/etc/certs/cert.pem' - key_path: '/opt/app/pmsh/etc/certs/key.pem' - ca_cert_path: '/opt/app/pmsh/etc/certs/cacert.pem' - streams_publishes: - policy_pm_publisher: - type: message_router - dmaap_info: - #topic_url: {concat: ["https://message-router:3905/events/", { get_input: pmsh_publish_topic_name }]} - topic_url: { concat: [ "http://message-router:3904/events/", { get_input: pmsh_publish_topic_name } ] } - streams_subscribes: - policy_pm_subscriber: - type: message_router - dmaap_info: - #topic_url: {concat: ["https://message-router:3905/events/", { get_input: policy_feedback_topic_name }]} - topic_url: {concat: ["http://message-router:3904/events/", { get_input: policy_feedback_topic_name }]} - aai_subscriber: - type: message_router - dmaap_info: - #topic_url: {concat: ["https://message-router:3905/events/", { get_input: aai_notification_topic_name }]} - topic_url: {concat: ["http://message-router:3904/events/", { get_input: aai_notification_topic_name }]} - resource_config: - limits: - cpu: { get_input: cpu_limit } - memory: { get_input: memory_limit } - requests: - cpu: { get_input: cpu_request } - memory: { get_input: memory_request } - docker_config: - healthcheck: - endpoint: /healthcheck - interval: 15s - timeout: 1s - type: { get_input: protocol } - image: { get_input: tag_version } - replicas: { get_input: replicas } - log_info: - log_directory: '/var/log/ONAP/dcaegen2/services/pmsh' - tls_info: - cert_directory: '/opt/app/pmsh/etc/certs' - use_tls: { get_input: enable_tls } - pmsh-policy: - type: clamp.nodes.policy - properties: - policy_model_id: - get_input: policy_model_id - policy_id: - get_input: policy_id diff --git a/common/src/test/resources/examples/controlloop/PMSH/pmsh_monitoring_policy.json b/common/src/test/resources/examples/controlloop/PMSH/pmsh_monitoring_policy.json deleted file mode 100644 index 5b64b5b6f..000000000 --- a/common/src/test/resources/examples/controlloop/PMSH/pmsh_monitoring_policy.json +++ /dev/null @@ -1,123 +0,0 @@ -{ - "tosca_definitions_version": "tosca_simple_yaml_1_1_0", - "topology_template": { - "policies": [ - { - "MICROSERVICE_vLoadBalancerMS_v1_0_dcae-pm-subscription-handler_1_0_0test": { - "type": "onap.policies.monitoring.dcae-pm-subscription-handler", - "type_version": "1.0.0", - "properties": { - "pmsh_policy": { - "measurementGroups": [ - { - "measurementGroup": { - "onap.datatypes.monitoring.measurementGroup": { - "measurementTypes": [ - { - "measurementType": { - "onap.datatypes.monitoring.measurementType": { - "measurementType": "countera" - } - } - }, - { - "measurementType": { - "onap.datatypes.monitoring.measurementType": { - "measurementType": "counterb" - } - } - } - ], - "managedObjectDNsBasic": [ - { - "managedObjectDNsBasic": { - "onap.datatypes.monitoring.managedObjectDNsBasic": { - "DN": "dna" - } - } - }, - { - "managedObjectDNsBasic": { - "onap.datatypes.monitoring.managedObjectDNsBasic": { - "DN": "dnb" - } - } - } - ] - } - } - }, - { - "measurementGroup": { - "onap.datatypes.monitoring.measurementGroup": { - "measurementTypes": [ - { - "measurementType": { - "onap.datatypes.monitoring.measurementType": { - "measurementType": "counterc" - } - } - }, - { - "measurementType": { - "onap.datatypes.monitoring.measurementType": { - "measurementType": "counterd" - } - } - } - ], - "managedObjectDNsBasic": [ - { - "managedObjectDNsBasic": { - "onap.datatypes.monitoring.managedObjectDNsBasic": { - "DN": "dnc" - } - } - }, - { - "managedObjectDNsBasic": { - "onap.datatypes.monitoring.managedObjectDNsBasic": { - "DN": "dnd" - } - } - } - ] - } - } - } - ], - "fileBasedGP": 15, - "fileLocation": "/pm/pm.xml", - "subscriptionName": "subscriptiona", - "administrativeState": "UNLOCKED", - "nfFilter": { - "onap.datatypes.monitoring.nfFilter": { - "modelVersionIDs": [ - "e80a6ae3-cafd-4d24-850d-e14c084a5ca9" - ], - "modelInvariantIDs": [ - "5845y423-g654-6fju-po78-8n53154532k6", - "7129e420-d396-4efb-af02-6b83499b12f8" - ], - "modelNames": [], - "nfNames": [ - "\"^pnf1.*\"" - ] - } - } - } - }, - "name": "MICROSERVICE_vLoadBalancerMS_v1_0_dcae-pm-subscription-handler_1_0_0test", - "version": "1.0.0", - "metadata": { - "policy-id": "MICROSERVICE_vLoadBalancerMS_v1_0_dcae-pm-subscription-handler_1_0_0test", - "policy-version": "1.0.0" - } - } - } - ] - }, - "name": "ToscaServiceTemplateSimple", - "version": "1.0.0", - "metadata": {} -} diff --git a/common/src/test/resources/examples/controlloop/PMSH/pmsh_monitoring_policy.yaml b/common/src/test/resources/examples/controlloop/PMSH/pmsh_monitoring_policy.yaml deleted file mode 100644 index 6021f36bc..000000000 --- a/common/src/test/resources/examples/controlloop/PMSH/pmsh_monitoring_policy.yaml +++ /dev/null @@ -1,64 +0,0 @@ ---- -tosca_definitions_version: tosca_simple_yaml_1_1_0 -name: ToscaServiceTemplateSimple -version: 1.0.0 -metadata: {} -topology_template: - policies: - - MICROSERVICE_vLoadBalancerMS_v1_0_dcae-pm-subscription-handler_1_0_0test: - type: onap.policies.monitoring.dcae-pm-subscription-handler - type_version: 1.0.0 - name: MICROSERVICE_vLoadBalancerMS_v1_0_dcae-pm-subscription-handler_1_0_0test - version: 1.0.0 - metadata: - policy-id: MICROSERVICE_vLoadBalancerMS_v1_0_dcae-pm-subscription-handler_1_0_0test - policy-version: 1.0.0 - properties: - pmsh_policy: - fileBasedGP: 15 - fileLocation: "/pm/pm.xml" - subscriptionName: subscriptiona - administrativeState: UNLOCKED - nfFilter: - onap.datatypes.monitoring.nfFilter: - modelVersionIDs: - - e80a6ae3-cafd-4d24-850d-e14c084a5ca9 - modelInvariantIDs: - - 5845y423-g654-6fju-po78-8n53154532k6 - - 7129e420-d396-4efb-af02-6b83499b12f8 - modelNames: [] - nfNames: - - '"^pnf1.*"' - measurementGroups: - - measurementGroup: - onap.datatypes.monitoring.measurementGroup: - measurementTypes: - - measurementType: - onap.datatypes.monitoring.measurementType: - measurementType: countera - - measurementType: - onap.datatypes.monitoring.measurementType: - measurementType: counterb - managedObjectDNsBasic: - - managedObjectDNsBasic: - onap.datatypes.monitoring.managedObjectDNsBasic: - DN: dna - - managedObjectDNsBasic: - onap.datatypes.monitoring.managedObjectDNsBasic: - DN: dnb - - measurementGroup: - onap.datatypes.monitoring.measurementGroup: - measurementTypes: - - measurementType: - onap.datatypes.monitoring.measurementType: - measurementType: counterc - - measurementType: - onap.datatypes.monitoring.measurementType: - measurementType: counterd - managedObjectDNsBasic: - - managedObjectDNsBasic: - onap.datatypes.monitoring.managedObjectDNsBasic: - DN: dnc - - managedObjectDNsBasic: - onap.datatypes.monitoring.managedObjectDNsBasic: - DN: dnd diff --git a/common/src/test/resources/examples/controlloop/PMSH/pmsh_monitoring_policy_type.yaml b/common/src/test/resources/examples/controlloop/PMSH/pmsh_monitoring_policy_type.yaml deleted file mode 100644 index e282bf5ba..000000000 --- a/common/src/test/resources/examples/controlloop/PMSH/pmsh_monitoring_policy_type.yaml +++ /dev/null @@ -1,264 +0,0 @@ -tosca_definitions_version: tosca_simple_yaml_1_1_0 -name: ToscaServiceTemplateSimple -version: 1.0.0 -metadata: {} -policy_types: - onap.policies.Monitoring: - derived_from: tosca.policies.Root - description: a base policy type for all policies that govern monitoring provisioning - version: 1.0.0 - name: onap.policies.Monitoring - onap.policies.monitoring.dcae-pm-subscription-handler: - name: onap.policies.monitoring.dcae-pm-subscription-handler - version: 1.0.0 - derived_from: onap.policies.Monitoring - metadata: {} - properties: - pmsh_policy: - name: pmsh_policy - type: onap.datatypes.monitoring.subscription - typeVersion: 0.0.0 - description: PMSH Policy JSON - required: false - constraints: [] - metadata: {} -data_types: - onap.datatypes.monitoring.managedObjectDNsBasic: - name: onap.datatypes.monitoring.managedObjectDNsBasic - version: 0.0.0 - derived_from: tosca.datatypes.Root - metadata: {} - constraints: [] - properties: - DN: - name: DN - type: string - typeVersion: 0.0.0 - description: Managed object distinguished name - required: true - constraints: [] - metadata: {} - onap.datatypes.monitoring.managedObjectDNsBasics: - name: onap.datatypes.monitoring.managedObjectDNsBasics - version: 0.0.0 - derived_from: tosca.datatypes.Root - metadata: {} - constraints: [] - properties: - managedObjectDNsBasic: - name: managedObjectDNsBasic - type: map - typeVersion: 0.0.0 - description: Managed object distinguished name object - required: true - constraints: [] - entry_schema: - type: onap.datatypes.monitoring.managedObjectDNsBasic - typeVersion: 0.0.0 - constraints: [] - metadata: {} - onap.datatypes.monitoring.measurementGroup: - name: onap.datatypes.monitoring.measurementGroup - version: 0.0.0 - derived_from: tosca.datatypes.Root - metadata: {} - constraints: [] - properties: - measurementTypes: - name: measurementTypes - type: list - typeVersion: 0.0.0 - description: List of measurement types - required: true - constraints: [] - entry_schema: - type: onap.datatypes.monitoring.measurementTypes - typeVersion: 0.0.0 - constraints: [] - metadata: {} - managedObjectDNsBasic: - name: managedObjectDNsBasic - type: list - typeVersion: 0.0.0 - description: List of managed object distinguished names - required: true - constraints: [] - entry_schema: - type: onap.datatypes.monitoring.managedObjectDNsBasics - typeVersion: 0.0.0 - constraints: [] - metadata: {} - onap.datatypes.monitoring.measurementGroups: - name: onap.datatypes.monitoring.measurementGroups - version: 0.0.0 - derived_from: tosca.datatypes.Root - metadata: {} - constraints: [] - properties: - measurementGroup: - name: measurementGroup - type: map - typeVersion: 0.0.0 - description: Measurement Group - required: true - constraints: [] - entry_schema: - type: onap.datatypes.monitoring.measurementGroup - typeVersion: 0.0.0 - constraints: [] - metadata: {} - onap.datatypes.monitoring.measurementType: - name: onap.datatypes.monitoring.measurementType - version: 0.0.0 - derived_from: tosca.datatypes.Root - metadata: {} - constraints: [] - properties: - measurementType: - name: measurementType - type: string - typeVersion: 0.0.0 - description: Measurement type - required: true - constraints: [] - metadata: {} - onap.datatypes.monitoring.measurementTypes: - name: onap.datatypes.monitoring.measurementTypes - version: 0.0.0 - derived_from: tosca.datatypes.Root - metadata: {} - constraints: [] - properties: - measurementType: - name: measurementType - type: map - typeVersion: 0.0.0 - description: Measurement type object - required: true - constraints: [] - entry_schema: - type: onap.datatypes.monitoring.measurementType - typeVersion: 0.0.0 - constraints: [] - metadata: {} - onap.datatypes.monitoring.nfFilter: - name: onap.datatypes.monitoring.nfFilter - version: 0.0.0 - derived_from: tosca.datatypes.Root - metadata: {} - constraints: [] - properties: - modelNames: - name: modelNames - type: list - typeVersion: 0.0.0 - description: List of model names - required: true - constraints: [] - entry_schema: - type: string - typeVersion: 0.0.0 - constraints: [] - metadata: {} - modelInvariantIDs: - name: modelInvariantIDs - type: list - typeVersion: 0.0.0 - description: List of model invariant IDs - required: true - constraints: [] - entry_schema: - type: string - typeVersion: 0.0.0 - constraints: [] - metadata: {} - modelVersionIDs: - name: modelVersionIDs - type: list - typeVersion: 0.0.0 - description: List of model version IDs - required: true - constraints: [] - entry_schema: - type: string - typeVersion: 0.0.0 - constraints: [] - metadata: {} - nfNames: - name: nfNames - type: list - typeVersion: 0.0.0 - description: List of network functions - required: true - constraints: [] - entry_schema: - type: string - typeVersion: 0.0.0 - constraints: [] - metadata: {} - onap.datatypes.monitoring.subscription: - name: onap.datatypes.monitoring.subscription - version: 0.0.0 - derived_from: tosca.datatypes.Root - metadata: {} - constraints: [] - properties: - measurementGroups: - name: measurementGroups - type: list - typeVersion: 0.0.0 - description: Measurement Groups - required: true - constraints: [] - entry_schema: - type: onap.datatypes.monitoring.measurementGroups - typeVersion: 0.0.0 - constraints: [] - metadata: {} - fileBasedGP: - name: fileBasedGP - type: integer - typeVersion: 0.0.0 - description: File based granularity period - required: true - constraints: [] - metadata: {} - fileLocation: - name: fileLocation - type: string - typeVersion: 0.0.0 - description: ROP file location - required: true - constraints: [] - metadata: {} - subscriptionName: - name: subscriptionName - type: string - typeVersion: 0.0.0 - description: Name of the subscription - required: true - constraints: [] - metadata: {} - administrativeState: - name: administrativeState - type: string - typeVersion: 0.0.0 - description: State of the subscription - required: true - constraints: - - valid_values: - - LOCKED - - UNLOCKED - metadata: {} - nfFilter: - name: nfFilter - type: map - typeVersion: 0.0.0 - description: Network function filter - required: true - constraints: [] - entry_schema: - type: onap.datatypes.monitoring.nfFilter - typeVersion: 0.0.0 - constraints: [] - metadata: {} diff --git a/common/src/test/resources/examples/controlloop/PMSH/pmsh_operational_policy.json b/common/src/test/resources/examples/controlloop/PMSH/pmsh_operational_policy.json deleted file mode 100644 index 6bd681d71..000000000 --- a/common/src/test/resources/examples/controlloop/PMSH/pmsh_operational_policy.json +++ /dev/null @@ -1,2808 +0,0 @@ -{ - "tosca_definitions_version":"tosca_simple_yaml_1_1_0", - "topology_template":{ - "policies":[ - { - "operational.apex.pmcontrol":{ - "type":"onap.policies.controlloop.operational.Apex", - "type_version":"1.0.0", - "version":"1.0.0", - "metadata":{ - "policy-id":"operational.apex.pmcontrol", - "policy-version":1 - }, - "properties":{ - "engineServiceParameters":{ - "name":"MyApexEngine", - "version":"0.0.1", - "id":45, - "instanceCount":2, - "deploymentPort":12561, - "policy_type_impl":{ - "apexPolicyModel":{ - "key":{ - "name":"PMControlPolicy", - "version":"0.0.1" - }, - "keyInformation":{ - "key":{ - "name":"PMControlPolicy_KeyInfo", - "version":"0.0.1" - }, - "keyInfoMap":{ - "entry":[ - { - "key":{ - "name":"CDSActionIdentifiersType", - "version":"0.0.1" - }, - "value":{ - "key":{ - "name":"CDSActionIdentifiersType", - "version":"0.0.1" - }, - "UUID":"6e5fa19b-14df-37e3-a4ae-8c537e861a82", - "description":"Generated description for concept referred to by key \"CDSActionIdentifiersType:0.0.1\"" - } - }, - { - "key":{ - "name":"CDSCreateResponseEvent", - "version":"0.0.1" - }, - "value":{ - "key":{ - "name":"CDSCreateResponseEvent", - "version":"0.0.1" - }, - "UUID":"14b29e38-ac75-3273-aa4e-8583c0aa7dad", - "description":"Generated description for concept referred to by key \"CDSCreateResponseEvent:0.0.1\"" - } - }, - { - "key":{ - "name":"CDSCreateResponsePayloadType", - "version":"0.0.1" - }, - "value":{ - "key":{ - "name":"CDSCreateResponsePayloadType", - "version":"0.0.1" - }, - "UUID":"04573f8f-e772-30a5-b1d9-d7318d4a1e13", - "description":"Generated description for concept referred to by key \"CDSCreateResponsePayloadType:0.0.1\"" - } - }, - { - "key":{ - "name":"CDSCreateResponsePolicy", - "version":"0.0.1" - }, - "value":{ - "key":{ - "name":"CDSCreateResponsePolicy", - "version":"0.0.1" - }, - "UUID":"e126c965-fc09-3bfe-8f55-70f380a4a49c", - "description":"Generated description for concept referred to by key \"CDSCreateResponsePolicy:0.0.1\"" - } - }, - { - "key":{ - "name":"CDSCreateResponseTask", - "version":"0.0.1" - }, - "value":{ - "key":{ - "name":"CDSCreateResponseTask", - "version":"0.0.1" - }, - "UUID":"6165ee82-afd2-3aab-a517-f00b3f2461d2", - "description":"Generated description for concept referred to by key \"CDSCreateResponseTask:0.0.1\"" - } - }, - { - "key":{ - "name":"CDSCreateSubscriptionPayloadType", - "version":"0.0.1" - }, - "value":{ - "key":{ - "name":"CDSCreateSubscriptionPayloadType", - "version":"0.0.1" - }, - "UUID":"8350ac5e-c157-38b9-9614-a0f93a830e60", - "description":"Generated description for concept referred to by key \"CDSCreateSubscriptionPayloadType:0.0.1\"" - } - }, - { - "key":{ - "name":"CDSCreateSubscriptionRequestEvent", - "version":"0.0.1" - }, - "value":{ - "key":{ - "name":"CDSCreateSubscriptionRequestEvent", - "version":"0.0.1" - }, - "UUID":"cfa325ba-226b-3a31-9183-ec43e2b6e9a2", - "description":"Generated description for concept referred to by key \"CDSCreateSubscriptionRequestEvent:0.0.1\"" - } - }, - { - "key":{ - "name":"CDSDeleteResponseEvent", - "version":"0.0.1" - }, - "value":{ - "key":{ - "name":"CDSDeleteResponseEvent", - "version":"0.0.1" - }, - "UUID":"8be9c0fa-7437-3841-aff2-b3cec6ae3bd8", - "description":"Generated description for concept referred to by key \"CDSDeleteResponseEvent:0.0.1\"" - } - }, - { - "key":{ - "name":"CDSDeleteResponsePayloadType", - "version":"0.0.1" - }, - "value":{ - "key":{ - "name":"CDSDeleteResponsePayloadType", - "version":"0.0.1" - }, - "UUID":"3fbfe0c9-152e-34d3-a504-09cd13c058d0", - "description":"Generated description for concept referred to by key \"CDSDeleteResponsePayloadType:0.0.1\"" - } - }, - { - "key":{ - "name":"CDSDeleteResponsePolicy", - "version":"0.0.1" - }, - "value":{ - "key":{ - "name":"CDSDeleteResponsePolicy", - "version":"0.0.1" - }, - "UUID":"a780251c-edd5-3132-b865-04313246b43c", - "description":"Generated description for concept referred to by key \"CDSDeleteResponsePolicy:0.0.1\"" - } - }, - { - "key":{ - "name":"CDSDeleteResponseTask", - "version":"0.0.1" - }, - "value":{ - "key":{ - "name":"CDSDeleteResponseTask", - "version":"0.0.1" - }, - "UUID":"afce4555-3aa3-3521-a7d8-ee8cdf0d3efc", - "description":"Generated description for concept referred to by key \"CDSDeleteResponseTask:0.0.1\"" - } - }, - { - "key":{ - "name":"CDSDeleteSubscriptionPayloadType", - "version":"0.0.1" - }, - "value":{ - "key":{ - "name":"CDSDeleteSubscriptionPayloadType", - "version":"0.0.1" - }, - "UUID":"12658406-9147-3c9d-a38c-5ad5e30b092b", - "description":"Generated description for concept referred to by key \"CDSDeleteSubscriptionPayloadType:0.0.1\"" - } - }, - { - "key":{ - "name":"CDSDeleteSubscriptionRequestEvent", - "version":"0.0.1" - }, - "value":{ - "key":{ - "name":"CDSDeleteSubscriptionRequestEvent", - "version":"0.0.1" - }, - "UUID":"24380c95-9289-36e6-8cbf-0edefa15ccd9", - "description":"Generated description for concept referred to by key \"CDSDeleteSubscriptionRequestEvent:0.0.1\"" - } - }, - { - "key":{ - "name":"CDSRequestCommonHeaderType", - "version":"0.0.1" - }, - "value":{ - "key":{ - "name":"CDSRequestCommonHeaderType", - "version":"0.0.1" - }, - "UUID":"35590ac0-062c-39f1-8786-b4ff716e30b1", - "description":"Generated description for concept referred to by key \"CDSRequestCommonHeaderType:0.0.1\"" - } - }, - { - "key":{ - "name":"CDSResponseCommonHeaderType", - "version":"0.0.1" - }, - "value":{ - "key":{ - "name":"CDSResponseCommonHeaderType", - "version":"0.0.1" - }, - "UUID":"dd7e1805-885a-350b-aaf9-ed541321ae3c", - "description":"Generated description for concept referred to by key \"CDSResponseCommonHeaderType:0.0.1\"" - } - }, - { - "key":{ - "name":"CDSResponseStatusEvent", - "version":"0.0.1" - }, - "value":{ - "key":{ - "name":"CDSResponseStatusEvent", - "version":"0.0.1" - }, - "UUID":"7986e21b-32f7-302e-9554-31f21b673493", - "description":"Generated description for concept referred to by key \"CDSResponseStatusEvent:0.0.1\"" - } - }, - { - "key":{ - "name":"CDSResponseStatusType", - "version":"0.0.1" - }, - "value":{ - "key":{ - "name":"CDSResponseStatusType", - "version":"0.0.1" - }, - "UUID":"92b8a2cf-344e-3ce1-8cc0-2b7d3cb695fa", - "description":"Generated description for concept referred to by key \"CDSResponseStatusType:0.0.1\"" - } - }, - { - "key":{ - "name":"CreateSubscriptionPayloadEvent", - "version":"0.0.1" - }, - "value":{ - "key":{ - "name":"CreateSubscriptionPayloadEvent", - "version":"0.0.1" - }, - "UUID":"92162397-1a8e-3a3f-a469-d2af7700af4a", - "description":"Generated description for concept referred to by key \"CreateSubscriptionPayloadEvent:0.0.1\"" - } - }, - { - "key":{ - "name":"CreateSubscriptionPayloadTask", - "version":"0.0.1" - }, - "value":{ - "key":{ - "name":"CreateSubscriptionPayloadTask", - "version":"0.0.1" - }, - "UUID":"bc0c69f0-52ed-38ea-b468-ae4a6fd1730d", - "description":"Generated description for concept referred to by key \"CreateSubscriptionPayloadTask:0.0.1\"" - } - }, - { - "key":{ - "name":"CreateSubscriptionRequestTask", - "version":"0.0.1" - }, - "value":{ - "key":{ - "name":"CreateSubscriptionRequestTask", - "version":"0.0.1" - }, - "UUID":"89cb75e9-f06c-30d3-b4ff-698d45f63869", - "description":"Generated description for concept referred to by key \"CreateSubscriptionRequestTask:0.0.1\"" - } - }, - { - "key":{ - "name":"DeleteSubscriptionPayloadEvent", - "version":"0.0.1" - }, - "value":{ - "key":{ - "name":"DeleteSubscriptionPayloadEvent", - "version":"0.0.1" - }, - "UUID":"994fa441-04ab-33bb-832d-1cd12ab5d074", - "description":"Generated description for concept referred to by key \"DeleteSubscriptionPayloadEvent:0.0.1\"" - } - }, - { - "key":{ - "name":"DeleteSubscriptionPayloadTask", - "version":"0.0.1" - }, - "value":{ - "key":{ - "name":"DeleteSubscriptionPayloadTask", - "version":"0.0.1" - }, - "UUID":"0f519117-5fea-3e4b-941f-8f778100465f", - "description":"Generated description for concept referred to by key \"DeleteSubscriptionPayloadTask:0.0.1\"" - } - }, - { - "key":{ - "name":"DeleteSubscriptionRequestTask", - "version":"0.0.1" - }, - "value":{ - "key":{ - "name":"DeleteSubscriptionRequestTask", - "version":"0.0.1" - }, - "UUID":"acb772fe-d442-39e3-98f9-b1080caf4150", - "description":"Generated description for concept referred to by key \"DeleteSubscriptionRequestTask:0.0.1\"" - } - }, - { - "key":{ - "name":"MRResponseEvent", - "version":"0.0.1" - }, - "value":{ - "key":{ - "name":"MRResponseEvent", - "version":"0.0.1" - }, - "UUID":"13c747a3-6bae-3bcf-9c80-b152e01dc194", - "description":"Generated description for concept referred to by key \"MRResponseEvent:0.0.1\"" - } - }, - { - "key":{ - "name":"PMControlPolicy", - "version":"0.0.1" - }, - "value":{ - "key":{ - "name":"PMControlPolicy", - "version":"0.0.1" - }, - "UUID":"acf1e55c-7bc5-3bd5-975a-0ca54afcd8a4", - "description":"Generated description for concept referred to by key \"PMControlPolicy:0.0.1\"" - } - }, - { - "key":{ - "name":"PMControlPolicy_Albums", - "version":"0.0.1" - }, - "value":{ - "key":{ - "name":"PMControlPolicy_Albums", - "version":"0.0.1" - }, - "UUID":"b38ad204-c2c8-32f4-9b5a-dda0aeb0145b", - "description":"Generated description for concept referred to by key \"PMControlPolicy_Albums:0.0.1\"" - } - }, - { - "key":{ - "name":"PMControlPolicy_Events", - "version":"0.0.1" - }, - "value":{ - "key":{ - "name":"PMControlPolicy_Events", - "version":"0.0.1" - }, - "UUID":"be3871a0-c42a-3113-a066-82d192840eca", - "description":"Generated description for concept referred to by key \"PMControlPolicy_Events:0.0.1\"" - } - }, - { - "key":{ - "name":"PMControlPolicy_KeyInfo", - "version":"0.0.1" - }, - "value":{ - "key":{ - "name":"PMControlPolicy_KeyInfo", - "version":"0.0.1" - }, - "UUID":"ced37634-28a4-3178-b7f6-2980794927b0", - "description":"Generated description for concept referred to by key \"PMControlPolicy_KeyInfo:0.0.1\"" - } - }, - { - "key":{ - "name":"PMControlPolicy_Policies", - "version":"0.0.1" - }, - "value":{ - "key":{ - "name":"PMControlPolicy_Policies", - "version":"0.0.1" - }, - "UUID":"be3d180d-ef9c-3a75-8e9c-84271a038bed", - "description":"Generated description for concept referred to by key \"PMControlPolicy_Policies:0.0.1\"" - } - }, - { - "key":{ - "name":"PMControlPolicy_Schemas", - "version":"0.0.1" - }, - "value":{ - "key":{ - "name":"PMControlPolicy_Schemas", - "version":"0.0.1" - }, - "UUID":"e61973f1-189c-39e5-82f6-0d3afe298a20", - "description":"Generated description for concept referred to by key \"PMControlPolicy_Schemas:0.0.1\"" - } - }, - { - "key":{ - "name":"PMControlPolicy_Tasks", - "version":"0.0.1" - }, - "value":{ - "key":{ - "name":"PMControlPolicy_Tasks", - "version":"0.0.1" - }, - "UUID":"5658adb3-2962-30a3-a241-fae75bb8eb4a", - "description":"Generated description for concept referred to by key \"PMControlPolicy_Tasks:0.0.1\"" - } - }, - { - "key":{ - "name":"PMSubscriptionAlbum", - "version":"0.0.1" - }, - "value":{ - "key":{ - "name":"PMSubscriptionAlbum", - "version":"0.0.1" - }, - "UUID":"c2bd6f0d-6854-317a-9be2-97c08338428c", - "description":"Generated description for concept referred to by key \"PMSubscriptionAlbum:0.0.1\"" - } - }, - { - "key":{ - "name":"PMSubscriptionOutputEvent", - "version":"0.0.1" - }, - "value":{ - "key":{ - "name":"PMSubscriptionOutputEvent", - "version":"0.0.1" - }, - "UUID":"992b7819-9f69-3aa0-bb0f-6e45ea15ce05", - "description":"Generated description for concept referred to by key \"PMSubscriptionOutputEvent:0.0.1\"" - } - }, - { - "key":{ - "name":"PMSubscriptionType", - "version":"0.0.1" - }, - "value":{ - "key":{ - "name":"PMSubscriptionType", - "version":"0.0.1" - }, - "UUID":"73c1c397-4fc3-357f-93b6-a8ad707fbaae", - "description":"Generated description for concept referred to by key \"PMSubscriptionType:0.0.1\"" - } - }, - { - "key":{ - "name":"ReceiveEventPolicy", - "version":"0.0.1" - }, - "value":{ - "key":{ - "name":"ReceiveEventPolicy", - "version":"0.0.1" - }, - "UUID":"568b7345-9de1-36d3-b6a3-9b857e6809a1", - "description":"Generated description for concept referred to by key \"ReceiveEventPolicy:0.0.1\"" - } - }, - { - "key":{ - "name":"ReceiveSubscriptionTask", - "version":"0.0.1" - }, - "value":{ - "key":{ - "name":"ReceiveSubscriptionTask", - "version":"0.0.1" - }, - "UUID":"f596afc8-100c-35eb-92c8-352355ea457d", - "description":"Generated description for concept referred to by key \"ReceiveSubscriptionTask:0.0.1\"" - } - }, - { - "key":{ - "name":"SimpleIntType", - "version":"0.0.1" - }, - "value":{ - "key":{ - "name":"SimpleIntType", - "version":"0.0.1" - }, - "UUID":"153791fd-ae0a-36a7-88a5-309a7936415d", - "description":"Generated description for concept referred to by key \"SimpleIntType:0.0.1\"" - } - }, - { - "key":{ - "name":"SimpleStringType", - "version":"0.0.1" - }, - "value":{ - "key":{ - "name":"SimpleStringType", - "version":"0.0.1" - }, - "UUID":"8a4957cf-9493-3a76-8c22-a208e23259af", - "description":"Generated description for concept referred to by key \"SimpleStringType:0.0.1\"" - } - }, - { - "key":{ - "name":"SubscriptionStatusType", - "version":"0.0.1" - }, - "value":{ - "key":{ - "name":"SubscriptionStatusType", - "version":"0.0.1" - }, - "UUID":"597643b1-9db1-31ce-85d0-e1c63c43b30b", - "description":"Generated description for concept referred to by key \"SubscriptionStatusType:0.0.1\"" - } - }, - { - "key":{ - "name":"SubscriptionType", - "version":"0.0.1" - }, - "value":{ - "key":{ - "name":"SubscriptionType", - "version":"0.0.1" - }, - "UUID":"184547bb-7d64-3cb2-a273-d7185102c5ce", - "description":"Generated description for concept referred to by key \"SubscriptionType:0.0.1\"" - } - }, - { - "key":{ - "name":"UUIDType", - "version":"0.0.1" - }, - "value":{ - "key":{ - "name":"UUIDType", - "version":"0.0.1" - }, - "UUID":"6a8cc68e-dfc8-3403-9c6d-071c886b319c", - "description":"Generated description for concept referred to by key \"UUIDType:0.0.1\"" - } - }, - { - "key":{ - "name":"pmsh-operational-policy", - "version":"0.0.1" - }, - "value":{ - "key":{ - "name":"pmsh-operational-policy", - "version":"0.0.1" - }, - "UUID":"fdf2c9ff-6422-3ea6-b6b6-49b12116265d", - "description":"Generated description for concept referred to by key \"pmsh-operational-policy:0.0.1\"" - } - } - ] - } - }, - "policies":{ - "key":{ - "name":"PMControlPolicy_Policies", - "version":"0.0.1" - }, - "policyMap":{ - "entry":[ - { - "key":{ - "name":"CDSCreateResponsePolicy", - "version":"0.0.1" - }, - "value":{ - "policyKey":{ - "name":"CDSCreateResponsePolicy", - "version":"0.0.1" - }, - "template":"Freestyle", - "state":{ - "entry":[ - { - "key":"CDSCreateResponseState", - "value":{ - "stateKey":{ - "parentKeyName":"CDSCreateResponsePolicy", - "parentKeyVersion":"0.0.1", - "parentLocalName":"NULL", - "localName":"CDSCreateResponseState" - }, - "trigger":{ - "name":"CDSCreateResponseEvent", - "version":"0.0.1" - }, - "stateOutputs":{ - "entry":[ - { - "key":"ResponseOutput", - "value":{ - "key":{ - "parentKeyName":"CDSCreateResponsePolicy", - "parentKeyVersion":"0.0.1", - "parentLocalName":"CDSCreateResponseState", - "localName":"ResponseOutput" - }, - "outgoingEvent":{ - "name":"CDSResponseStatusEvent", - "version":"0.0.1" - }, - "nextState":{ - "parentKeyName":"NULL", - "parentKeyVersion":"0.0.0", - "parentLocalName":"NULL", - "localName":"NULL" - } - } - } - ] - }, - "contextAlbumReference":[ - - ], - "taskSelectionLogic":{ - "key":"NULL", - "logicFlavour":"UNDEFINED", - "logic":"" - }, - "stateFinalizerLogicMap":{ - "entry":[ - - ] - }, - "defaultTask":{ - "name":"CDSCreateResponseTask", - "version":"0.0.1" - }, - "taskReferences":{ - "entry":[ - { - "key":{ - "name":"CDSCreateResponseTask", - "version":"0.0.1" - }, - "value":{ - "key":{ - "parentKeyName":"CDSCreateResponsePolicy", - "parentKeyVersion":"0.0.1", - "parentLocalName":"CDSCreateResponseState", - "localName":"CDSCreateResponsePolicy" - }, - "outputType":"DIRECT", - "output":{ - "parentKeyName":"CDSCreateResponsePolicy", - "parentKeyVersion":"0.0.1", - "parentLocalName":"CDSCreateResponseState", - "localName":"ResponseOutput" - } - } - } - ] - } - } - } - ] - }, - "firstState":"CDSCreateResponseState" - } - }, - { - "key":{ - "name":"CDSDeleteResponsePolicy", - "version":"0.0.1" - }, - "value":{ - "policyKey":{ - "name":"CDSDeleteResponsePolicy", - "version":"0.0.1" - }, - "template":"Freestyle", - "state":{ - "entry":[ - { - "key":"CDSDeleteResponseState", - "value":{ - "stateKey":{ - "parentKeyName":"CDSDeleteResponsePolicy", - "parentKeyVersion":"0.0.1", - "parentLocalName":"NULL", - "localName":"CDSDeleteResponseState" - }, - "trigger":{ - "name":"CDSDeleteResponseEvent", - "version":"0.0.1" - }, - "stateOutputs":{ - "entry":[ - { - "key":"ResponseOutput", - "value":{ - "key":{ - "parentKeyName":"CDSDeleteResponsePolicy", - "parentKeyVersion":"0.0.1", - "parentLocalName":"CDSDeleteResponseState", - "localName":"ResponseOutput" - }, - "outgoingEvent":{ - "name":"CDSResponseStatusEvent", - "version":"0.0.1" - }, - "nextState":{ - "parentKeyName":"NULL", - "parentKeyVersion":"0.0.0", - "parentLocalName":"NULL", - "localName":"NULL" - } - } - } - ] - }, - "contextAlbumReference":[ - - ], - "taskSelectionLogic":{ - "key":"NULL", - "logicFlavour":"UNDEFINED", - "logic":"" - }, - "stateFinalizerLogicMap":{ - "entry":[ - - ] - }, - "defaultTask":{ - "name":"CDSDeleteResponseTask", - "version":"0.0.1" - }, - "taskReferences":{ - "entry":[ - { - "key":{ - "name":"CDSDeleteResponseTask", - "version":"0.0.1" - }, - "value":{ - "key":{ - "parentKeyName":"CDSDeleteResponsePolicy", - "parentKeyVersion":"0.0.1", - "parentLocalName":"CDSDeleteResponseState", - "localName":"CDSDeleteResponsePolicy" - }, - "outputType":"DIRECT", - "output":{ - "parentKeyName":"CDSDeleteResponsePolicy", - "parentKeyVersion":"0.0.1", - "parentLocalName":"CDSDeleteResponseState", - "localName":"ResponseOutput" - } - } - } - ] - } - } - } - ] - }, - "firstState":"CDSDeleteResponseState" - } - }, - { - "key":{ - "name":"ReceiveEventPolicy", - "version":"0.0.1" - }, - "value":{ - "policyKey":{ - "name":"ReceiveEventPolicy", - "version":"0.0.1" - }, - "template":"Freestyle", - "state":{ - "entry":[ - { - "key":"CreateOrDeleteState", - "value":{ - "stateKey":{ - "parentKeyName":"ReceiveEventPolicy", - "parentKeyVersion":"0.0.1", - "parentLocalName":"NULL", - "localName":"CreateOrDeleteState" - }, - "trigger":{ - "name":"PMSubscriptionOutputEvent", - "version":"0.0.1" - }, - "stateOutputs":{ - "entry":[ - { - "key":"CreateSubscriptionPayload", - "value":{ - "key":{ - "parentKeyName":"ReceiveEventPolicy", - "parentKeyVersion":"0.0.1", - "parentLocalName":"CreateOrDeleteState", - "localName":"CreateSubscriptionPayload" - }, - "outgoingEvent":{ - "name":"CreateSubscriptionPayloadEvent", - "version":"0.0.1" - }, - "nextState":{ - "parentKeyName":"ReceiveEventPolicy", - "parentKeyVersion":"0.0.1", - "parentLocalName":"NULL", - "localName":"CreateSubscription" - } - } - }, - { - "key":"DeleteSubscriptionPayload", - "value":{ - "key":{ - "parentKeyName":"ReceiveEventPolicy", - "parentKeyVersion":"0.0.1", - "parentLocalName":"CreateOrDeleteState", - "localName":"DeleteSubscriptionPayload" - }, - "outgoingEvent":{ - "name":"DeleteSubscriptionPayloadEvent", - "version":"0.0.1" - }, - "nextState":{ - "parentKeyName":"ReceiveEventPolicy", - "parentKeyVersion":"0.0.1", - "parentLocalName":"NULL", - "localName":"DeleteSubscription" - } - } - } - ] - }, - "contextAlbumReference":[ - { - "name":"PMSubscriptionAlbum", - "version":"0.0.1" - } - ], - "taskSelectionLogic":{ - "key":"TaskSelectionLogic", - "logicFlavour":"JAVASCRIPT", - "logic":"/*\n * ============LICENSE_START=======================================================\n * Copyright (C) 2020 Nordix. All rights reserved.\n * ================================================================================\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n *\n * SPDX-License-Identifier: Apache-2.0\n * ============LICENSE_END=========================================================\n */\n\nexecutor.logger.info(executor.subject.id);\n\nvar pmSubscriptionInfo = executor.getContextAlbum(\"PMSubscriptionAlbum\").get(executor.inFields.get(\"albumID\").toString())\nvar changeType = pmSubscriptionInfo.get(\"changeType\").toString()\n\nexecutor.logger.info(\"Change Type is \" + changeType)\n\nif (\"CREATE\".equals(changeType)) {\n executor.logger.info(\"Choosing to create a subscription\")\n executor.subject.getTaskKey(\"CreateSubscriptionPayloadTask\").copyTo(executor.selectedTask);\n}\nelse if (\"DELETE\".equals(changeType)) {\n executor.logger.info(\"Choosing to delete a subscription\")\n executor.subject.getTaskKey(\"DeleteSubscriptionPayloadTask\").copyTo(executor.selectedTask);\n}\n\n//var returnValue = executor.isTrue;\ntrue;" - }, - "stateFinalizerLogicMap":{ - "entry":[ - - ] - }, - "defaultTask":{ - "name":"CreateSubscriptionPayloadTask", - "version":"0.0.1" - }, - "taskReferences":{ - "entry":[ - { - "key":{ - "name":"CreateSubscriptionPayloadTask", - "version":"0.0.1" - }, - "value":{ - "key":{ - "parentKeyName":"ReceiveEventPolicy", - "parentKeyVersion":"0.0.1", - "parentLocalName":"CreateOrDeleteState", - "localName":"ReceiveEventPolicy" - }, - "outputType":"DIRECT", - "output":{ - "parentKeyName":"ReceiveEventPolicy", - "parentKeyVersion":"0.0.1", - "parentLocalName":"CreateOrDeleteState", - "localName":"CreateSubscriptionPayload" - } - } - }, - { - "key":{ - "name":"DeleteSubscriptionPayloadTask", - "version":"0.0.1" - }, - "value":{ - "key":{ - "parentKeyName":"ReceiveEventPolicy", - "parentKeyVersion":"0.0.1", - "parentLocalName":"CreateOrDeleteState", - "localName":"ReceiveEventPolicy" - }, - "outputType":"DIRECT", - "output":{ - "parentKeyName":"ReceiveEventPolicy", - "parentKeyVersion":"0.0.1", - "parentLocalName":"CreateOrDeleteState", - "localName":"DeleteSubscriptionPayload" - } - } - } - ] - } - } - }, - { - "key":"CreateSubscription", - "value":{ - "stateKey":{ - "parentKeyName":"ReceiveEventPolicy", - "parentKeyVersion":"0.0.1", - "parentLocalName":"NULL", - "localName":"CreateSubscription" - }, - "trigger":{ - "name":"CreateSubscriptionPayloadEvent", - "version":"0.0.1" - }, - "stateOutputs":{ - "entry":[ - { - "key":"IssueCreateSubscriptionRequestOutput", - "value":{ - "key":{ - "parentKeyName":"ReceiveEventPolicy", - "parentKeyVersion":"0.0.1", - "parentLocalName":"CreateSubscription", - "localName":"IssueCreateSubscriptionRequestOutput" - }, - "outgoingEvent":{ - "name":"CDSCreateSubscriptionRequestEvent", - "version":"0.0.1" - }, - "nextState":{ - "parentKeyName":"NULL", - "parentKeyVersion":"0.0.0", - "parentLocalName":"NULL", - "localName":"NULL" - } - } - } - ] - }, - "contextAlbumReference":[ - { - "name":"PMSubscriptionAlbum", - "version":"0.0.1" - } - ], - "taskSelectionLogic":{ - "key":"NULL", - "logicFlavour":"UNDEFINED", - "logic":"" - }, - "stateFinalizerLogicMap":{ - "entry":[ - - ] - }, - "defaultTask":{ - "name":"CreateSubscriptionRequestTask", - "version":"0.0.1" - }, - "taskReferences":{ - "entry":[ - { - "key":{ - "name":"CreateSubscriptionRequestTask", - "version":"0.0.1" - }, - "value":{ - "key":{ - "parentKeyName":"ReceiveEventPolicy", - "parentKeyVersion":"0.0.1", - "parentLocalName":"CreateSubscription", - "localName":"ReceiveEventPolicy" - }, - "outputType":"DIRECT", - "output":{ - "parentKeyName":"ReceiveEventPolicy", - "parentKeyVersion":"0.0.1", - "parentLocalName":"CreateSubscription", - "localName":"IssueCreateSubscriptionRequestOutput" - } - } - } - ] - } - } - }, - { - "key":"DeleteSubscription", - "value":{ - "stateKey":{ - "parentKeyName":"ReceiveEventPolicy", - "parentKeyVersion":"0.0.1", - "parentLocalName":"NULL", - "localName":"DeleteSubscription" - }, - "trigger":{ - "name":"DeleteSubscriptionPayloadEvent", - "version":"0.0.1" - }, - "stateOutputs":{ - "entry":[ - { - "key":"IssueDeleteSubscriptionRequestOutput", - "value":{ - "key":{ - "parentKeyName":"ReceiveEventPolicy", - "parentKeyVersion":"0.0.1", - "parentLocalName":"DeleteSubscription", - "localName":"IssueDeleteSubscriptionRequestOutput" - }, - "outgoingEvent":{ - "name":"CDSDeleteSubscriptionRequestEvent", - "version":"0.0.1" - }, - "nextState":{ - "parentKeyName":"NULL", - "parentKeyVersion":"0.0.0", - "parentLocalName":"NULL", - "localName":"NULL" - } - } - } - ] - }, - "contextAlbumReference":[ - { - "name":"PMSubscriptionAlbum", - "version":"0.0.1" - } - ], - "taskSelectionLogic":{ - "key":"NULL", - "logicFlavour":"UNDEFINED", - "logic":"" - }, - "stateFinalizerLogicMap":{ - "entry":[ - - ] - }, - "defaultTask":{ - "name":"DeleteSubscriptionRequestTask", - "version":"0.0.1" - }, - "taskReferences":{ - "entry":[ - { - "key":{ - "name":"DeleteSubscriptionRequestTask", - "version":"0.0.1" - }, - "value":{ - "key":{ - "parentKeyName":"ReceiveEventPolicy", - "parentKeyVersion":"0.0.1", - "parentLocalName":"DeleteSubscription", - "localName":"ReceiveEventPolicy" - }, - "outputType":"DIRECT", - "output":{ - "parentKeyName":"ReceiveEventPolicy", - "parentKeyVersion":"0.0.1", - "parentLocalName":"DeleteSubscription", - "localName":"IssueDeleteSubscriptionRequestOutput" - } - } - } - ] - } - } - }, - { - "key":"ReceiveSubscriptionState", - "value":{ - "stateKey":{ - "parentKeyName":"ReceiveEventPolicy", - "parentKeyVersion":"0.0.1", - "parentLocalName":"NULL", - "localName":"ReceiveSubscriptionState" - }, - "trigger":{ - "name":"pmsh-operational-policy", - "version":"0.0.1" - }, - "stateOutputs":{ - "entry":[ - { - "key":"ReceivePMSubscriptionOutput", - "value":{ - "key":{ - "parentKeyName":"ReceiveEventPolicy", - "parentKeyVersion":"0.0.1", - "parentLocalName":"ReceiveSubscriptionState", - "localName":"ReceivePMSubscriptionOutput" - }, - "outgoingEvent":{ - "name":"PMSubscriptionOutputEvent", - "version":"0.0.1" - }, - "nextState":{ - "parentKeyName":"ReceiveEventPolicy", - "parentKeyVersion":"0.0.1", - "parentLocalName":"NULL", - "localName":"CreateOrDeleteState" - } - } - } - ] - }, - "contextAlbumReference":[ - { - "name":"PMSubscriptionAlbum", - "version":"0.0.1" - } - ], - "taskSelectionLogic":{ - "key":"NULL", - "logicFlavour":"UNDEFINED", - "logic":"" - }, - "stateFinalizerLogicMap":{ - "entry":[ - - ] - }, - "defaultTask":{ - "name":"ReceiveSubscriptionTask", - "version":"0.0.1" - }, - "taskReferences":{ - "entry":[ - { - "key":{ - "name":"ReceiveSubscriptionTask", - "version":"0.0.1" - }, - "value":{ - "key":{ - "parentKeyName":"ReceiveEventPolicy", - "parentKeyVersion":"0.0.1", - "parentLocalName":"ReceiveSubscriptionState", - "localName":"ReceiveEventPolicy" - }, - "outputType":"DIRECT", - "output":{ - "parentKeyName":"ReceiveEventPolicy", - "parentKeyVersion":"0.0.1", - "parentLocalName":"ReceiveSubscriptionState", - "localName":"ReceivePMSubscriptionOutput" - } - } - } - ] - } - } - } - ] - }, - "firstState":"ReceiveSubscriptionState" - } - } - ] - } - }, - "tasks":{ - "key":{ - "name":"PMControlPolicy_Tasks", - "version":"0.0.1" - }, - "taskMap":{ - "entry":[ - { - "key":{ - "name":"CDSCreateResponseTask", - "version":"0.0.1" - }, - "value":{ - "key":{ - "name":"CDSCreateResponseTask", - "version":"0.0.1" - }, - "inputFields":{ - "entry":[ - { - "key":"actionIdentifiers", - "value":{ - "key":"actionIdentifiers", - "fieldSchemaKey":{ - "name":"CDSActionIdentifiersType", - "version":"0.0.1" - }, - "optional":false - } - }, - { - "key":"commonHeader", - "value":{ - "key":"commonHeader", - "fieldSchemaKey":{ - "name":"CDSResponseCommonHeaderType", - "version":"0.0.1" - }, - "optional":false - } - }, - { - "key":"payload", - "value":{ - "key":"payload", - "fieldSchemaKey":{ - "name":"CDSCreateResponsePayloadType", - "version":"0.0.1" - }, - "optional":false - } - }, - { - "key":"status", - "value":{ - "key":"status", - "fieldSchemaKey":{ - "name":"CDSResponseStatusType", - "version":"0.0.1" - }, - "optional":false - } - } - ] - }, - "outputFields":{ - "entry":[ - { - "key":"status", - "value":{ - "key":"status", - "fieldSchemaKey":{ - "name":"SubscriptionStatusType", - "version":"0.0.1" - }, - "optional":false - } - } - ] - }, - "taskParameters":{ - "entry":[ - - ] - }, - "contextAlbumReference":[ - { - "name":"PMSubscriptionAlbum", - "version":"0.0.1" - } - ], - "taskLogic":{ - "key":"TaskLogic", - "logicFlavour":"JAVASCRIPT", - "logic":"/*\n * ============LICENSE_START=======================================================\n * Copyright (C) 2020 Nordix. All rights reserved.\n * ================================================================================\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n *\n * SPDX-License-Identifier: Apache-2.0\n * ============LICENSE_END=========================================================\n */\n\nexecutor.logger.info(executor.subject.id);\n\nvar commonHeader = executor.inFields.get(\"commonHeader\")\nvar response = executor.inFields.get(\"payload\")\nvar albumID = commonHeader.get(\"requestId\")\n\nvar pmSubscriptionInfo = executor.getContextAlbum(\"PMSubscriptionAlbum\").get(albumID.toString());\nvar responseStatus = executor.subject.getOutFieldSchemaHelper(\"status\").createNewInstance();\n\nresponseStatus.put(\"subscriptionName\", pmSubscriptionInfo.get(\"subscription\").get(\"subscriptionName\"))\nresponseStatus.put(\"nfName\", pmSubscriptionInfo.get(\"nfName\"))\nresponseStatus.put(\"changeType\", pmSubscriptionInfo.get(\"changeType\"))\n\nvar status = response.get(pmSubscriptionInfo.get(\"changeType\").toLowerCase() + \"_DasH_subscription_DasH_response\").get(\"odl_DasH_response\").get(\"status\")\n\nexecutor.logger.info(\"RESPONSE STATUS = \" + status)\n\nif(status == \"success\") {\n responseStatus.put(\"message\", \"success\")\n} else {\n responseStatus.put(\"message\", \"failed\")\n}\n\nexecutor.outFields.put(\"status\", responseStatus)\n\n//var returnValue = executor.isTrue;\ntrue;" - } - } - }, - { - "key":{ - "name":"CDSDeleteResponseTask", - "version":"0.0.1" - }, - "value":{ - "key":{ - "name":"CDSDeleteResponseTask", - "version":"0.0.1" - }, - "inputFields":{ - "entry":[ - { - "key":"actionIdentifiers", - "value":{ - "key":"actionIdentifiers", - "fieldSchemaKey":{ - "name":"CDSActionIdentifiersType", - "version":"0.0.1" - }, - "optional":false - } - }, - { - "key":"commonHeader", - "value":{ - "key":"commonHeader", - "fieldSchemaKey":{ - "name":"CDSResponseCommonHeaderType", - "version":"0.0.1" - }, - "optional":false - } - }, - { - "key":"payload", - "value":{ - "key":"payload", - "fieldSchemaKey":{ - "name":"CDSDeleteResponsePayloadType", - "version":"0.0.1" - }, - "optional":false - } - }, - { - "key":"status", - "value":{ - "key":"status", - "fieldSchemaKey":{ - "name":"CDSResponseStatusType", - "version":"0.0.1" - }, - "optional":false - } - } - ] - }, - "outputFields":{ - "entry":[ - { - "key":"status", - "value":{ - "key":"status", - "fieldSchemaKey":{ - "name":"SubscriptionStatusType", - "version":"0.0.1" - }, - "optional":false - } - } - ] - }, - "taskParameters":{ - "entry":[ - - ] - }, - "contextAlbumReference":[ - { - "name":"PMSubscriptionAlbum", - "version":"0.0.1" - } - ], - "taskLogic":{ - "key":"TaskLogic", - "logicFlavour":"JAVASCRIPT", - "logic":"/*\n * ============LICENSE_START=======================================================\n * Copyright (C) 2020 Nordix. All rights reserved.\n * ================================================================================\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n *\n * SPDX-License-Identifier: Apache-2.0\n * ============LICENSE_END=========================================================\n */\n\nexecutor.logger.info(executor.subject.id);\n\nvar commonHeader = executor.inFields.get(\"commonHeader\")\nvar response = executor.inFields.get(\"payload\")\nvar albumID = commonHeader.get(\"requestId\")\n\nvar pmSubscriptionInfo = executor.getContextAlbum(\"PMSubscriptionAlbum\").get(albumID.toString());\nvar responseStatus = executor.subject.getOutFieldSchemaHelper(\"status\").createNewInstance();\n\nresponseStatus.put(\"subscriptionName\", pmSubscriptionInfo.get(\"subscription\").get(\"subscriptionName\"))\nresponseStatus.put(\"nfName\", pmSubscriptionInfo.get(\"nfName\"))\nresponseStatus.put(\"changeType\", pmSubscriptionInfo.get(\"changeType\"))\n\nvar status = response.get(pmSubscriptionInfo.get(\"changeType\").toLowerCase() + \"_DasH_subscription_DasH_response\").get(\"odl_DasH_response\").get(\"status\")\n\nexecutor.logger.info(\"RESPONSE STATUS = \" + status)\n\nif(status == \"success\") {\n responseStatus.put(\"message\", \"success\")\n} else {\n responseStatus.put(\"message\", \"failed\")\n}\n\nexecutor.outFields.put(\"status\", responseStatus)\n\n//var returnValue = executor.isTrue;\ntrue;" - } - } - }, - { - "key":{ - "name":"CreateSubscriptionPayloadTask", - "version":"0.0.1" - }, - "value":{ - "key":{ - "name":"CreateSubscriptionPayloadTask", - "version":"0.0.1" - }, - "inputFields":{ - "entry":[ - { - "key":"albumID", - "value":{ - "key":"albumID", - "fieldSchemaKey":{ - "name":"UUIDType", - "version":"0.0.1" - }, - "optional":false - } - } - ] - }, - "outputFields":{ - "entry":[ - { - "key":"albumID", - "value":{ - "key":"albumID", - "fieldSchemaKey":{ - "name":"UUIDType", - "version":"0.0.1" - }, - "optional":false - } - }, - { - "key":"payload", - "value":{ - "key":"payload", - "fieldSchemaKey":{ - "name":"CDSCreateSubscriptionPayloadType", - "version":"0.0.1" - }, - "optional":false - } - } - ] - }, - "taskParameters":{ - "entry":[ - - ] - }, - "contextAlbumReference":[ - { - "name":"PMSubscriptionAlbum", - "version":"0.0.1" - } - ], - "taskLogic":{ - "key":"TaskLogic", - "logicFlavour":"JAVASCRIPT", - "logic":"/*\n * ============LICENSE_START=======================================================\n * Copyright (C) 2020 Nordix. All rights reserved.\n * ================================================================================\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n *\n * SPDX-License-Identifier: Apache-2.0\n * ============LICENSE_END=========================================================\n */\n\nexecutor.logger.info(executor.subject.id);\n\nvar pmSubscriptionInfo = executor.getContextAlbum(\"PMSubscriptionAlbum\").get(executor.inFields.get(\"albumID\").toString())\n\nvar changeType = pmSubscriptionInfo.get(\"changeType\").toLowerCase()\n\nvar payloadProperties = executor.subject.getOutFieldSchemaHelper(\"payload\").createNewSubInstance(changeType + \"_DasH_subscription_DasH_properties_record\");\n\npayloadProperties.put(\"nfName\", pmSubscriptionInfo.get(\"nfName\"))\npayloadProperties.put(\"subscriptionName\", pmSubscriptionInfo.get(\"subscription\").get(\"subscriptionName\"))\npayloadProperties.put(\"administrativeState\", pmSubscriptionInfo.get(\"subscription\").get(\"administrativeState\"))\npayloadProperties.put(\"fileBasedGP\", pmSubscriptionInfo.get(\"subscription\").get(\"fileBasedGP\").toString())\npayloadProperties.put(\"fileLocation\", pmSubscriptionInfo.get(\"subscription\").get(\"fileLocation\"))\npayloadProperties.put(\"measurementGroups\", pmSubscriptionInfo.get(\"subscription\").get(\"measurementGroups\"))\n\nvar payloadEntry = executor.subject.getOutFieldSchemaHelper(\"payload\").createNewSubInstance(\"CDSRequestPayloadEntry\");\npayloadEntry.put(changeType + \"_DasH_subscription_DasH_properties\", payloadProperties)\n\nvar payload = executor.subject.getOutFieldSchemaHelper(\"payload\").createNewInstance();\npayload.put(changeType + \"_DasH_subscription_DasH_request\", payloadEntry);\n\nexecutor.outFields.put(\"albumID\", executor.inFields.get(\"albumID\"))\nexecutor.outFields.put(\"payload\", payload);\n\n//var returnValue = executor.isTrue;\ntrue;" - } - } - }, - { - "key":{ - "name":"CreateSubscriptionRequestTask", - "version":"0.0.1" - }, - "value":{ - "key":{ - "name":"CreateSubscriptionRequestTask", - "version":"0.0.1" - }, - "inputFields":{ - "entry":[ - { - "key":"albumID", - "value":{ - "key":"albumID", - "fieldSchemaKey":{ - "name":"UUIDType", - "version":"0.0.1" - }, - "optional":false - } - }, - { - "key":"payload", - "value":{ - "key":"payload", - "fieldSchemaKey":{ - "name":"CDSCreateSubscriptionPayloadType", - "version":"0.0.1" - }, - "optional":false - } - } - ] - }, - "outputFields":{ - "entry":[ - { - "key":"actionIdentifiers", - "value":{ - "key":"actionIdentifiers", - "fieldSchemaKey":{ - "name":"CDSActionIdentifiersType", - "version":"0.0.1" - }, - "optional":false - } - }, - { - "key":"commonHeader", - "value":{ - "key":"commonHeader", - "fieldSchemaKey":{ - "name":"CDSRequestCommonHeaderType", - "version":"0.0.1" - }, - "optional":false - } - }, - { - "key":"payload", - "value":{ - "key":"payload", - "fieldSchemaKey":{ - "name":"CDSCreateSubscriptionPayloadType", - "version":"0.0.1" - }, - "optional":false - } - } - ] - }, - "taskParameters":{ - "entry":[ - - ] - }, - "contextAlbumReference":[ - { - "name":"PMSubscriptionAlbum", - "version":"0.0.1" - } - ], - "taskLogic":{ - "key":"TaskLogic", - "logicFlavour":"JAVASCRIPT", - "logic":"/*\n * ============LICENSE_START=======================================================\n * Copyright (C) 2020 Nordix. All rights reserved.\n * ================================================================================\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n *\n * SPDX-License-Identifier: Apache-2.0\n * ============LICENSE_END=========================================================\n */\n\nexecutor.logger.info(executor.subject.id);\n\nvar pmSubscriptionInfo = executor.getContextAlbum(\"PMSubscriptionAlbum\").get(executor.inFields.get(\"albumID\").toString())\n\nvar changeType = pmSubscriptionInfo.get(\"changeType\").toLowerCase()\nvar blueprintName = pmSubscriptionInfo.get(\"blueprintName\").toLowerCase()\nvar blueprintVersion = pmSubscriptionInfo.get(\"blueprintVersion\").toLowerCase()\nvar payload = executor.inFields.get(\"payload\")\nvar actionName = changeType + \"-subscription\"\n\nvar commonHeader = executor.subject.getOutFieldSchemaHelper(\"commonHeader\").createNewInstance();\ncommonHeader.put(\"originatorId\", \"sdnc\");\ncommonHeader.put(\"requestId\", executor.inFields.get(\"albumID\").toString());\ncommonHeader.put(\"subRequestId\", \"sub-123456-1000\");\n\nvar actionIdentifiers = executor.subject.getOutFieldSchemaHelper(\"actionIdentifiers\").createNewInstance();\nactionIdentifiers.put(\"actionName\", actionName);\nactionIdentifiers.put(\"blueprintName\", blueprintName);\nactionIdentifiers.put(\"blueprintVersion\", blueprintVersion);\nactionIdentifiers.put(\"mode\", \"sync\");\n\nexecutor.outFields.put(\"commonHeader\", commonHeader);\nexecutor.outFields.put(\"actionIdentifiers\", actionIdentifiers);\nexecutor.outFields.put(\"payload\", payload);\n\n//var returnValue = executor.isTrue;\ntrue;" - } - } - }, - { - "key":{ - "name":"DeleteSubscriptionPayloadTask", - "version":"0.0.1" - }, - "value":{ - "key":{ - "name":"DeleteSubscriptionPayloadTask", - "version":"0.0.1" - }, - "inputFields":{ - "entry":[ - { - "key":"albumID", - "value":{ - "key":"albumID", - "fieldSchemaKey":{ - "name":"UUIDType", - "version":"0.0.1" - }, - "optional":false - } - } - ] - }, - "outputFields":{ - "entry":[ - { - "key":"albumID", - "value":{ - "key":"albumID", - "fieldSchemaKey":{ - "name":"UUIDType", - "version":"0.0.1" - }, - "optional":false - } - }, - { - "key":"payload", - "value":{ - "key":"payload", - "fieldSchemaKey":{ - "name":"CDSDeleteSubscriptionPayloadType", - "version":"0.0.1" - }, - "optional":false - } - } - ] - }, - "taskParameters":{ - "entry":[ - - ] - }, - "contextAlbumReference":[ - { - "name":"PMSubscriptionAlbum", - "version":"0.0.1" - } - ], - "taskLogic":{ - "key":"TaskLogic", - "logicFlavour":"JAVASCRIPT", - "logic":"/*\n * ============LICENSE_START=======================================================\n * Copyright (C) 2020 Nordix. All rights reserved.\n * ================================================================================\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n *\n * SPDX-License-Identifier: Apache-2.0\n * ============LICENSE_END=========================================================\n */\n\nexecutor.logger.info(executor.subject.id);\n\nvar pmSubscriptionInfo = executor.getContextAlbum(\"PMSubscriptionAlbum\").get(executor.inFields.get(\"albumID\").toString())\n\nvar changeType = pmSubscriptionInfo.get(\"changeType\").toLowerCase()\n\nvar payloadProperties = executor.subject.getOutFieldSchemaHelper(\"payload\").createNewSubInstance(changeType + \"_DasH_subscription_DasH_properties_record\");\n\npayloadProperties.put(\"nfName\", pmSubscriptionInfo.get(\"nfName\"))\npayloadProperties.put(\"subscriptionName\", pmSubscriptionInfo.get(\"subscription\").get(\"subscriptionName\"))\npayloadProperties.put(\"administrativeState\", pmSubscriptionInfo.get(\"subscription\").get(\"administrativeState\"))\npayloadProperties.put(\"fileBasedGP\", pmSubscriptionInfo.get(\"subscription\").get(\"fileBasedGP\").toString())\npayloadProperties.put(\"fileLocation\", pmSubscriptionInfo.get(\"subscription\").get(\"fileLocation\"))\npayloadProperties.put(\"measurementGroups\", pmSubscriptionInfo.get(\"subscription\").get(\"measurementGroups\"))\n\nvar payloadEntry = executor.subject.getOutFieldSchemaHelper(\"payload\").createNewSubInstance(\"CDSRequestPayloadEntry\");\npayloadEntry.put(changeType + \"_DasH_subscription_DasH_properties\", payloadProperties)\n\nvar payload = executor.subject.getOutFieldSchemaHelper(\"payload\").createNewInstance();\npayload.put(changeType + \"_DasH_subscription_DasH_request\", payloadEntry);\n\nexecutor.outFields.put(\"albumID\", executor.inFields.get(\"albumID\"))\nexecutor.outFields.put(\"payload\", payload);\n\n//var returnValue = executor.isTrue;\ntrue;" - } - } - }, - { - "key":{ - "name":"DeleteSubscriptionRequestTask", - "version":"0.0.1" - }, - "value":{ - "key":{ - "name":"DeleteSubscriptionRequestTask", - "version":"0.0.1" - }, - "inputFields":{ - "entry":[ - { - "key":"albumID", - "value":{ - "key":"albumID", - "fieldSchemaKey":{ - "name":"UUIDType", - "version":"0.0.1" - }, - "optional":false - } - }, - { - "key":"payload", - "value":{ - "key":"payload", - "fieldSchemaKey":{ - "name":"CDSDeleteSubscriptionPayloadType", - "version":"0.0.1" - }, - "optional":false - } - } - ] - }, - "outputFields":{ - "entry":[ - { - "key":"actionIdentifiers", - "value":{ - "key":"actionIdentifiers", - "fieldSchemaKey":{ - "name":"CDSActionIdentifiersType", - "version":"0.0.1" - }, - "optional":false - } - }, - { - "key":"commonHeader", - "value":{ - "key":"commonHeader", - "fieldSchemaKey":{ - "name":"CDSRequestCommonHeaderType", - "version":"0.0.1" - }, - "optional":false - } - }, - { - "key":"payload", - "value":{ - "key":"payload", - "fieldSchemaKey":{ - "name":"CDSDeleteSubscriptionPayloadType", - "version":"0.0.1" - }, - "optional":false - } - } - ] - }, - "taskParameters":{ - "entry":[ - - ] - }, - "contextAlbumReference":[ - { - "name":"PMSubscriptionAlbum", - "version":"0.0.1" - } - ], - "taskLogic":{ - "key":"TaskLogic", - "logicFlavour":"JAVASCRIPT", - "logic":"/*\n * ============LICENSE_START=======================================================\n * Copyright (C) 2020 Nordix. All rights reserved.\n * ================================================================================\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n *\n * SPDX-License-Identifier: Apache-2.0\n * ============LICENSE_END=========================================================\n */\n\nexecutor.logger.info(executor.subject.id);\n\nvar pmSubscriptionInfo = executor.getContextAlbum(\"PMSubscriptionAlbum\").get(executor.inFields.get(\"albumID\").toString())\n\nvar changeType = pmSubscriptionInfo.get(\"changeType\").toLowerCase()\nvar blueprintName = pmSubscriptionInfo.get(\"blueprintName\").toLowerCase()\nvar blueprintVersion = pmSubscriptionInfo.get(\"blueprintVersion\").toLowerCase()\nvar payload = executor.inFields.get(\"payload\")\nvar actionName = changeType + \"-subscription\"\n\nvar commonHeader = executor.subject.getOutFieldSchemaHelper(\"commonHeader\").createNewInstance();\ncommonHeader.put(\"originatorId\", \"sdnc\");\ncommonHeader.put(\"requestId\", executor.inFields.get(\"albumID\").toString());\ncommonHeader.put(\"subRequestId\", \"sub-123456-1000\");\n\nvar actionIdentifiers = executor.subject.getOutFieldSchemaHelper(\"actionIdentifiers\").createNewInstance();\nactionIdentifiers.put(\"actionName\", actionName);\nactionIdentifiers.put(\"blueprintName\", blueprintName);\nactionIdentifiers.put(\"blueprintVersion\", blueprintVersion);\nactionIdentifiers.put(\"mode\", \"sync\");\n\nexecutor.outFields.put(\"commonHeader\", commonHeader);\nexecutor.outFields.put(\"actionIdentifiers\", actionIdentifiers);\nexecutor.outFields.put(\"payload\", payload);\n\n//var returnValue = executor.isTrue;\ntrue;" - } - } - }, - { - "key":{ - "name":"ReceiveSubscriptionTask", - "version":"0.0.1" - }, - "value":{ - "key":{ - "name":"ReceiveSubscriptionTask", - "version":"0.0.1" - }, - "inputFields":{ - "entry":[ - { - "key":"blueprintName", - "value":{ - "key":"blueprintName", - "fieldSchemaKey":{ - "name":"SimpleStringType", - "version":"0.0.1" - }, - "optional":false - } - }, - { - "key":"blueprintVersion", - "value":{ - "key":"blueprintVersion", - "fieldSchemaKey":{ - "name":"SimpleStringType", - "version":"0.0.1" - }, - "optional":false - } - }, - { - "key":"changeType", - "value":{ - "key":"changeType", - "fieldSchemaKey":{ - "name":"SimpleStringType", - "version":"0.0.1" - }, - "optional":false - } - }, - { - "key":"closedLoopControlName", - "value":{ - "key":"closedLoopControlName", - "fieldSchemaKey":{ - "name":"SimpleStringType", - "version":"0.0.1" - }, - "optional":false - } - }, - { - "key":"nfName", - "value":{ - "key":"nfName", - "fieldSchemaKey":{ - "name":"SimpleStringType", - "version":"0.0.1" - }, - "optional":false - } - }, - { - "key":"policyName", - "value":{ - "key":"policyName", - "fieldSchemaKey":{ - "name":"SimpleStringType", - "version":"0.0.1" - }, - "optional":false - } - }, - { - "key":"subscription", - "value":{ - "key":"subscription", - "fieldSchemaKey":{ - "name":"SubscriptionType", - "version":"0.0.1" - }, - "optional":false - } - } - ] - }, - "outputFields":{ - "entry":[ - { - "key":"albumID", - "value":{ - "key":"albumID", - "fieldSchemaKey":{ - "name":"UUIDType", - "version":"0.0.1" - }, - "optional":false - } - } - ] - }, - "taskParameters":{ - "entry":[ - - ] - }, - "contextAlbumReference":[ - { - "name":"PMSubscriptionAlbum", - "version":"0.0.1" - } - ], - "taskLogic":{ - "key":"TaskLogic", - "logicFlavour":"JAVASCRIPT", - "logic":"/*\n * ============LICENSE_START=======================================================\n * Copyright (C) 2020 Nordix. All rights reserved.\n * ================================================================================\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n *\n * SPDX-License-Identifier: Apache-2.0\n * ============LICENSE_END=========================================================\n */\nvar uuidType = java.util.UUID;\n\nexecutor.logger.info(executor.subject.id);\n\n//albumID will be used to fetch info from our album later\nvar albumID = uuidType.randomUUID();\nvar pmSubscriptionInfo = executor.getContextAlbum(\"PMSubscriptionAlbum\").getSchemaHelper().createNewInstance();\nvar returnValue = true;\n\nif(executor.inFields.get(\"policyName\") != null) {\n executor.logger.info(\"nfName in receive sub event \" + executor.inFields.get(\"nfName\"));\n\n var changeType = executor.inFields.get(\"changeType\")\n var nfName = executor.inFields.get(\"nfName\")\n var policyName = executor.inFields.get(\"policyName\")\n var closedLoopControlName = executor.inFields.get(\"closedLoopControlName\")\n var subscription = executor.inFields.get(\"subscription\")\n var blueprintName = executor.inFields.get(\"blueprintName\")\n var blueprintVersion = executor.inFields.get(\"blueprintVersion\")\n\n pmSubscriptionInfo.put(\"nfName\", executor.inFields.get(\"nfName\"));\n pmSubscriptionInfo.put(\"changeType\", executor.inFields.get(\"changeType\"))\n pmSubscriptionInfo.put(\"policyName\", executor.inFields.get(\"policyName\"))\n pmSubscriptionInfo.put(\"closedLoopControlName\", executor.inFields.get(\"closedLoopControlName\"))\n pmSubscriptionInfo.put(\"subscription\", subscription)\n pmSubscriptionInfo.put(\"blueprintName\", blueprintName)\n pmSubscriptionInfo.put(\"blueprintVersion\", blueprintVersion)\n\n\n executor.getContextAlbum(\"PMSubscriptionAlbum\").put(albumID.toString(), pmSubscriptionInfo);\n\n executor.outFields.put(\"albumID\", albumID)\n} else {\n executor.message = \"Received invalid event\"\n returnValue = false;\n}\n\nreturnValue;" - } - } - } - ] - } - }, - "events":{ - "key":{ - "name":"PMControlPolicy_Events", - "version":"0.0.1" - }, - "eventMap":{ - "entry":[ - { - "key":{ - "name":"CDSCreateResponseEvent", - "version":"0.0.1" - }, - "value":{ - "key":{ - "name":"CDSCreateResponseEvent", - "version":"0.0.1" - }, - "nameSpace":"org.onap.policy.apex.onap.pmcontrol", - "source":"CDS", - "target":"APEX", - "parameter":{ - "entry":[ - { - "key":"actionIdentifiers", - "value":{ - "key":"actionIdentifiers", - "fieldSchemaKey":{ - "name":"CDSActionIdentifiersType", - "version":"0.0.1" - }, - "optional":false - } - }, - { - "key":"commonHeader", - "value":{ - "key":"commonHeader", - "fieldSchemaKey":{ - "name":"CDSResponseCommonHeaderType", - "version":"0.0.1" - }, - "optional":false - } - }, - { - "key":"payload", - "value":{ - "key":"payload", - "fieldSchemaKey":{ - "name":"CDSCreateResponsePayloadType", - "version":"0.0.1" - }, - "optional":false - } - }, - { - "key":"status", - "value":{ - "key":"status", - "fieldSchemaKey":{ - "name":"CDSResponseStatusType", - "version":"0.0.1" - }, - "optional":false - } - } - ] - } - } - }, - { - "key":{ - "name":"CDSCreateSubscriptionRequestEvent", - "version":"0.0.1" - }, - "value":{ - "key":{ - "name":"CDSCreateSubscriptionRequestEvent", - "version":"0.0.1" - }, - "nameSpace":"org.onap.policy.apex.onap.pmcontrol", - "source":"APEX", - "target":"APEX", - "parameter":{ - "entry":[ - { - "key":"actionIdentifiers", - "value":{ - "key":"actionIdentifiers", - "fieldSchemaKey":{ - "name":"CDSActionIdentifiersType", - "version":"0.0.1" - }, - "optional":false - } - }, - { - "key":"commonHeader", - "value":{ - "key":"commonHeader", - "fieldSchemaKey":{ - "name":"CDSRequestCommonHeaderType", - "version":"0.0.1" - }, - "optional":false - } - }, - { - "key":"payload", - "value":{ - "key":"payload", - "fieldSchemaKey":{ - "name":"CDSCreateSubscriptionPayloadType", - "version":"0.0.1" - }, - "optional":false - } - } - ] - } - } - }, - { - "key":{ - "name":"CDSDeleteResponseEvent", - "version":"0.0.1" - }, - "value":{ - "key":{ - "name":"CDSDeleteResponseEvent", - "version":"0.0.1" - }, - "nameSpace":"org.onap.policy.apex.onap.pmcontrol", - "source":"CDS", - "target":"APEX", - "parameter":{ - "entry":[ - { - "key":"actionIdentifiers", - "value":{ - "key":"actionIdentifiers", - "fieldSchemaKey":{ - "name":"CDSActionIdentifiersType", - "version":"0.0.1" - }, - "optional":false - } - }, - { - "key":"commonHeader", - "value":{ - "key":"commonHeader", - "fieldSchemaKey":{ - "name":"CDSResponseCommonHeaderType", - "version":"0.0.1" - }, - "optional":false - } - }, - { - "key":"payload", - "value":{ - "key":"payload", - "fieldSchemaKey":{ - "name":"CDSDeleteResponsePayloadType", - "version":"0.0.1" - }, - "optional":false - } - }, - { - "key":"status", - "value":{ - "key":"status", - "fieldSchemaKey":{ - "name":"CDSResponseStatusType", - "version":"0.0.1" - }, - "optional":false - } - } - ] - } - } - }, - { - "key":{ - "name":"CDSDeleteSubscriptionRequestEvent", - "version":"0.0.1" - }, - "value":{ - "key":{ - "name":"CDSDeleteSubscriptionRequestEvent", - "version":"0.0.1" - }, - "nameSpace":"org.onap.policy.apex.onap.pmcontrol", - "source":"APEX", - "target":"APEX", - "parameter":{ - "entry":[ - { - "key":"actionIdentifiers", - "value":{ - "key":"actionIdentifiers", - "fieldSchemaKey":{ - "name":"CDSActionIdentifiersType", - "version":"0.0.1" - }, - "optional":false - } - }, - { - "key":"commonHeader", - "value":{ - "key":"commonHeader", - "fieldSchemaKey":{ - "name":"CDSRequestCommonHeaderType", - "version":"0.0.1" - }, - "optional":false - } - }, - { - "key":"payload", - "value":{ - "key":"payload", - "fieldSchemaKey":{ - "name":"CDSDeleteSubscriptionPayloadType", - "version":"0.0.1" - }, - "optional":false - } - } - ] - } - } - }, - { - "key":{ - "name":"CDSResponseStatusEvent", - "version":"0.0.1" - }, - "value":{ - "key":{ - "name":"CDSResponseStatusEvent", - "version":"0.0.1" - }, - "nameSpace":"org.onap.policy.apex.onap.pmcontrol", - "source":"APEX", - "target":"DCAE", - "parameter":{ - "entry":[ - { - "key":"status", - "value":{ - "key":"status", - "fieldSchemaKey":{ - "name":"SubscriptionStatusType", - "version":"0.0.1" - }, - "optional":false - } - } - ] - } - } - }, - { - "key":{ - "name":"CreateSubscriptionPayloadEvent", - "version":"0.0.1" - }, - "value":{ - "key":{ - "name":"CreateSubscriptionPayloadEvent", - "version":"0.0.1" - }, - "nameSpace":"org.onap.policy.apex.onap.pmcontrol", - "source":"APEX", - "target":"APEX", - "parameter":{ - "entry":[ - { - "key":"albumID", - "value":{ - "key":"albumID", - "fieldSchemaKey":{ - "name":"UUIDType", - "version":"0.0.1" - }, - "optional":false - } - }, - { - "key":"payload", - "value":{ - "key":"payload", - "fieldSchemaKey":{ - "name":"CDSCreateSubscriptionPayloadType", - "version":"0.0.1" - }, - "optional":false - } - } - ] - } - } - }, - { - "key":{ - "name":"DeleteSubscriptionPayloadEvent", - "version":"0.0.1" - }, - "value":{ - "key":{ - "name":"DeleteSubscriptionPayloadEvent", - "version":"0.0.1" - }, - "nameSpace":"org.onap.policy.apex.onap.pmcontrol", - "source":"APEX", - "target":"APEX", - "parameter":{ - "entry":[ - { - "key":"albumID", - "value":{ - "key":"albumID", - "fieldSchemaKey":{ - "name":"UUIDType", - "version":"0.0.1" - }, - "optional":false - } - }, - { - "key":"payload", - "value":{ - "key":"payload", - "fieldSchemaKey":{ - "name":"CDSDeleteSubscriptionPayloadType", - "version":"0.0.1" - }, - "optional":false - } - } - ] - } - } - }, - { - "key":{ - "name":"MRResponseEvent", - "version":"0.0.1" - }, - "value":{ - "key":{ - "name":"MRResponseEvent", - "version":"0.0.1" - }, - "nameSpace":"org.onap.policy.apex.onap.pmcontrol", - "source":"DCAE", - "target":"APEX", - "parameter":{ - "entry":[ - { - "key":"count", - "value":{ - "key":"count", - "fieldSchemaKey":{ - "name":"SimpleIntType", - "version":"0.0.1" - }, - "optional":false - } - }, - { - "key":"serverTimeMs", - "value":{ - "key":"serverTimeMs", - "fieldSchemaKey":{ - "name":"SimpleIntType", - "version":"0.0.1" - }, - "optional":false - } - } - ] - } - } - }, - { - "key":{ - "name":"PMSubscriptionOutputEvent", - "version":"0.0.1" - }, - "value":{ - "key":{ - "name":"PMSubscriptionOutputEvent", - "version":"0.0.1" - }, - "nameSpace":"org.onap.policy.apex.onap.pmcontrol", - "source":"APEX", - "target":"APEX", - "parameter":{ - "entry":[ - { - "key":"albumID", - "value":{ - "key":"albumID", - "fieldSchemaKey":{ - "name":"UUIDType", - "version":"0.0.1" - }, - "optional":false - } - } - ] - } - } - }, - { - "key":{ - "name":"pmsh-operational-policy", - "version":"0.0.1" - }, - "value":{ - "key":{ - "name":"pmsh-operational-policy", - "version":"0.0.1" - }, - "nameSpace":"org.onap.policy.apex.onap.pmcontrol", - "source":"DCAE", - "target":"APEX", - "parameter":{ - "entry":[ - { - "key":"blueprintName", - "value":{ - "key":"blueprintName", - "fieldSchemaKey":{ - "name":"SimpleStringType", - "version":"0.0.1" - }, - "optional":false - } - }, - { - "key":"blueprintVersion", - "value":{ - "key":"blueprintVersion", - "fieldSchemaKey":{ - "name":"SimpleStringType", - "version":"0.0.1" - }, - "optional":false - } - }, - { - "key":"changeType", - "value":{ - "key":"changeType", - "fieldSchemaKey":{ - "name":"SimpleStringType", - "version":"0.0.1" - }, - "optional":false - } - }, - { - "key":"closedLoopControlName", - "value":{ - "key":"closedLoopControlName", - "fieldSchemaKey":{ - "name":"SimpleStringType", - "version":"0.0.1" - }, - "optional":false - } - }, - { - "key":"nfName", - "value":{ - "key":"nfName", - "fieldSchemaKey":{ - "name":"SimpleStringType", - "version":"0.0.1" - }, - "optional":false - } - }, - { - "key":"policyName", - "value":{ - "key":"policyName", - "fieldSchemaKey":{ - "name":"SimpleStringType", - "version":"0.0.1" - }, - "optional":false - } - }, - { - "key":"subscription", - "value":{ - "key":"subscription", - "fieldSchemaKey":{ - "name":"SubscriptionType", - "version":"0.0.1" - }, - "optional":false - } - } - ] - } - } - } - ] - } - }, - "albums":{ - "key":{ - "name":"PMControlPolicy_Albums", - "version":"0.0.1" - }, - "albums":{ - "entry":[ - { - "key":{ - "name":"PMSubscriptionAlbum", - "version":"0.0.1" - }, - "value":{ - "key":{ - "name":"PMSubscriptionAlbum", - "version":"0.0.1" - }, - "scope":"policy", - "isWritable":true, - "itemSchema":{ - "name":"PMSubscriptionType", - "version":"0.0.1" - } - } - } - ] - } - }, - "schemas":{ - "key":{ - "name":"PMControlPolicy_Schemas", - "version":"0.0.1" - }, - "schemas":{ - "entry":[ - { - "key":{ - "name":"CDSActionIdentifiersType", - "version":"0.0.1" - }, - "value":{ - "key":{ - "name":"CDSActionIdentifiersType", - "version":"0.0.1" - }, - "schemaFlavour":"Avro", - "schemaDefinition":"{\n \"type\": \"record\",\n \"name\": \"ActionIdentifiers_Type\",\n \"namespace\": \"org.onap.policy.apex.onap.helloworld\",\n \"fields\": [\n {\n \"name\": \"actionName\",\n \"type\": \"string\"\n },\n {\n \"name\": \"blueprintName\",\n \"type\": \"string\"\n },\n {\n \"name\": \"blueprintVersion\",\n \"type\": \"string\"\n },\n {\n \"name\": \"mode\",\n \"type\": \"string\"\n }\n ]\n}" - } - }, - { - "key":{ - "name":"CDSCreateResponsePayloadType", - "version":"0.0.1" - }, - "value":{ - "key":{ - "name":"CDSCreateResponsePayloadType", - "version":"0.0.1" - }, - "schemaFlavour":"Avro", - "schemaDefinition":"{\n \"name\": \"CreateResponsePayloadEntry\",\n \"type\": \"record\",\n \"namespace\": \"org.onap.policy.apex.onap.helloworld\",\n \"fields\": [\n {\n \"name\": \"create_DasH_subscription_DasH_response\",\n \"type\": {\n \"name\": \"create_DasH_subscription_DasH_response\",\n \"type\": \"record\",\n \"fields\": [\n {\n \"name\": \"odl_DasH_response\",\n \"type\": {\n \"name\": \"odl_DasH_response\",\n \"type\": \"record\",\n \"fields\": [\n {\n \"name\": \"status\",\n \"type\": \"string\"\n }\n ]\n }\n }\n ]\n }\n }\n ]\n}" - } - }, - { - "key":{ - "name":"CDSCreateSubscriptionPayloadType", - "version":"0.0.1" - }, - "value":{ - "key":{ - "name":"CDSCreateSubscriptionPayloadType", - "version":"0.0.1" - }, - "schemaFlavour":"Avro", - "schemaDefinition":"{\n \"type\": \"map\",\n \"values\": {\n \"type\": \"record\",\n \"name\": \"CDSRequestPayloadEntry\",\n \"fields\": [\n {\n \"name\": \"create_DasH_subscription_DasH_properties\",\n \"type\": {\n \"name\": \"create_DasH_subscription_DasH_properties_record\",\n \"type\": \"record\",\n \"fields\": [\n {\n \"name\": \"nfName\",\n \"type\": \"string\"\n },\n {\n \"name\": \"subscriptionName\",\n \"type\": \"string\"\n },\n {\n \"name\": \"administrativeState\",\n \"type\": \"string\"\n },\n {\n \"name\": \"fileBasedGP\",\n \"type\": \"string\"\n },\n {\n \"name\": \"fileLocation\",\n \"type\": \"string\"\n },\n {\n \"name\": \"measurementGroups\",\n \"type\": {\n \"type\": \"array\",\n \"items\": {\n \"name\": \"measurementGroups_record\",\n \"type\": \"record\",\n \"fields\": [\n {\n \"name\": \"measurementGroup\",\n \"type\": {\n \"name\": \"measurementGroup\",\n \"type\": \"record\",\n \"fields\": [\n {\n \"name\": \"measurementTypes\",\n \"type\": {\n \"type\": \"array\",\n \"items\": {\n \"name\": \"measurementTypes_record\",\n \"type\": \"record\",\n \"fields\": [\n {\n \"name\": \"measurementType\",\n \"type\": \"string\"\n }\n ]\n }\n }\n },\n {\n \"name\": \"managedObjectDNsBasic\",\n \"type\": {\n \"type\": \"array\",\n \"items\": {\n \"name\": \"managedObjectDNsBasic_record\",\n \"type\": \"record\",\n \"fields\": [\n {\n \"name\": \"DN\",\n \"type\": \"string\"\n }\n ]\n }\n }\n }\n ]\n }\n }\n ]\n }\n }\n }\n ]\n }\n }\n ]\n }\n}" - } - }, - { - "key":{ - "name":"CDSDeleteResponsePayloadType", - "version":"0.0.1" - }, - "value":{ - "key":{ - "name":"CDSDeleteResponsePayloadType", - "version":"0.0.1" - }, - "schemaFlavour":"Avro", - "schemaDefinition":"{\n \"name\": \"DeleteResponsePayloadEntry\",\n \"type\": \"record\",\n \"namespace\": \"com.acme.avro\",\n \"fields\": [\n {\n \"name\": \"delete_DasH_subscription_DasH_response\",\n \"type\": {\n \"name\": \"delete_DasH_subscription_DasH_response\",\n \"type\": \"record\",\n \"fields\": [\n {\n \"name\": \"odl_DasH_response\",\n \"type\": {\n \"name\": \"odl_DasH_response\",\n \"type\": \"record\",\n \"fields\": [\n {\n \"name\": \"status\",\n \"type\": \"string\"\n }\n ]\n }\n }\n ]\n }\n }\n ]\n}" - } - }, - { - "key":{ - "name":"CDSDeleteSubscriptionPayloadType", - "version":"0.0.1" - }, - "value":{ - "key":{ - "name":"CDSDeleteSubscriptionPayloadType", - "version":"0.0.1" - }, - "schemaFlavour":"Avro", - "schemaDefinition":"{\n \"type\": \"map\",\n \"values\": {\n \"type\": \"record\",\n \"name\": \"CDSRequestPayloadEntry\",\n \"fields\": [\n {\n \"name\": \"delete_DasH_subscription_DasH_properties\",\n \"type\": {\n \"name\": \"delete_DasH_subscription_DasH_properties_record\",\n \"type\": \"record\",\n \"fields\": [\n {\n \"name\": \"nfName\",\n \"type\": \"string\"\n },\n {\n \"name\": \"subscriptionName\",\n \"type\": \"string\"\n },\n {\n \"name\": \"administrativeState\",\n \"type\": \"string\"\n },\n {\n \"name\": \"fileBasedGP\",\n \"type\": \"string\"\n },\n {\n \"name\": \"fileLocation\",\n \"type\": \"string\"\n },\n {\n \"name\": \"measurementGroups\",\n \"type\": {\n \"type\": \"array\",\n \"items\": {\n \"name\": \"measurementGroups_record\",\n \"type\": \"record\",\n \"fields\": [\n {\n \"name\": \"measurementGroup\",\n \"type\": {\n \"name\": \"measurementGroup\",\n \"type\": \"record\",\n \"fields\": [\n {\n \"name\": \"measurementTypes\",\n \"type\": {\n \"type\": \"array\",\n \"items\": {\n \"name\": \"measurementTypes_record\",\n \"type\": \"record\",\n \"fields\": [\n {\n \"name\": \"measurementType\",\n \"type\": \"string\"\n }\n ]\n }\n }\n },\n {\n \"name\": \"managedObjectDNsBasic\",\n \"type\": {\n \"type\": \"array\",\n \"items\": {\n \"name\": \"managedObjectDNsBasic_record\",\n \"type\": \"record\",\n \"fields\": [\n {\n \"name\": \"DN\",\n \"type\": \"string\"\n }\n ]\n }\n }\n }\n ]\n }\n }\n ]\n }\n }\n }\n ]\n }\n }\n ]\n }\n}" - } - }, - { - "key":{ - "name":"CDSRequestCommonHeaderType", - "version":"0.0.1" - }, - "value":{ - "key":{ - "name":"CDSRequestCommonHeaderType", - "version":"0.0.1" - }, - "schemaFlavour":"Avro", - "schemaDefinition":"{\n \"type\": \"record\",\n \"name\": \"RequestCommonHeader_Type\",\n \"namespace\": \"org.onap.policy.apex.onap.helloworld\",\n \"fields\": [\n {\n \"name\": \"originatorId\",\n \"type\": \"string\"\n },\n {\n \"name\": \"requestId\",\n \"type\": \"string\"\n },\n {\n \"name\": \"subRequestId\",\n \"type\": \"string\"\n }\n ]\n}" - } - }, - { - "key":{ - "name":"CDSResponseCommonHeaderType", - "version":"0.0.1" - }, - "value":{ - "key":{ - "name":"CDSResponseCommonHeaderType", - "version":"0.0.1" - }, - "schemaFlavour":"Avro", - "schemaDefinition":"{\n \"type\": \"record\",\n \"name\": \"ResponseCommonHeader_Type\",\n \"namespace\": \"org.onap.policy.apex.onap.helloworld\",\n \"fields\": [\n {\n \"name\": \"originatorId\",\n \"type\": \"string\"\n },\n {\n \"name\": \"requestId\",\n \"type\": \"string\"\n },\n {\n \"name\": \"subRequestId\",\n \"type\": \"string\"\n },\n {\n \"name\": \"timestamp\",\n \"type\": \"string\"\n },\n {\n \"name\": \"flags\",\n \"type\": [\"null\", \"string\"]\n }\n ]\n}" - } - }, - { - "key":{ - "name":"CDSResponseStatusType", - "version":"0.0.1" - }, - "value":{ - "key":{ - "name":"CDSResponseStatusType", - "version":"0.0.1" - }, - "schemaFlavour":"Avro", - "schemaDefinition":"{\n \"type\": \"record\",\n \"name\": \"ResponseStatus_Type\",\n \"namespace\": \"org.onap.policy.apex.onap.helloworld\",\n \"fields\": [\n {\n \"name\": \"code\",\n \"type\": \"int\"\n },\n {\n \"name\": \"eventType\",\n \"type\": \"string\"\n },\n {\n \"name\": \"timestamp\",\n \"type\": \"string\"\n },\n {\n \"name\": \"message\",\n \"type\": \"string\"\n }\n ]\n}" - } - }, - { - "key":{ - "name":"PMSubscriptionType", - "version":"0.0.1" - }, - "value":{ - "key":{ - "name":"PMSubscriptionType", - "version":"0.0.1" - }, - "schemaFlavour":"Avro", - "schemaDefinition":"{\n\t\"name\": \"PMSubscription\",\n\t\"type\": \"record\",\n\t\"namespace\": \"org.onap.policy.apex.onap.pmcontrol\",\n\t\"fields\": [\n {\n \"name\": \"nfName\",\n \"type\": \"string\"\n },\n\t {\n\t\t\t\"name\": \"changeType\",\n\t\t\t\"type\": \"string\"\n\t\t},\n\t\t{\n\t\t\t\"name\": \"closedLoopControlName\",\n\t\t\t\"type\": \"string\"\n\t\t},\n\t\t{\n\t\t\t\"name\": \"policyName\",\n\t\t\t\"type\": \"string\"\n\t\t},\n\t\t{\n\t\t \"name\": \"blueprintName\",\n\t\t \"type\": \"string\"\n\t\t},\n\t\t{\n\t\t \"name\": \"blueprintVersion\",\n\t\t \"type\": \"string\"\n\t\t},\n\t\t{\n\t\t\t\"name\": \"subscription\",\n\t\t\t\"type\": {\n\t\t\t\t\"name\": \"subscription\",\n\t\t\t\t\"type\": \"record\",\n\t\t\t\t\"fields\": [{\n\t\t\t\t\t\t\"name\": \"subscriptionName\",\n\t\t\t\t\t\t\"type\": \"string\"\n\t\t\t\t\t},\n\t\t\t\t\t{\n\t\t\t\t\t\t\"name\": \"administrativeState\",\n\t\t\t\t\t\t\"type\": \"string\"\n\t\t\t\t\t},\n\t\t\t\t\t{\n\t\t\t\t\t\t\"name\": \"fileBasedGP\",\n\t\t\t\t\t\t\"type\": \"int\"\n\t\t\t\t\t},\n\t\t\t\t\t{\n\t\t\t\t\t\t\"name\": \"fileLocation\",\n\t\t\t\t\t\t\"type\": \"string\"\n\t\t\t\t\t},\n\t\t\t\t\t{\n\t\t\t\t\t\t\"name\": \"measurementGroups\",\n\t\t\t\t\t\t\"type\": {\n\t\t\t\t\t\t\t\"type\": \"array\",\n\t\t\t\t\t\t\t\"items\": {\n\t\t\t\t\t\t\t\t\"name\": \"Measurement_Groups_Type\",\n\t\t\t\t\t\t\t\t\"type\": \"record\",\n\t\t\t\t\t\t\t\t\"fields\": [{\n\t\t\t\t\t\t\t\t\t\"name\": \"measurementGroup\",\n\t\t\t\t\t\t\t\t\t\"type\": {\n\t\t\t\t\t\t\t\t\t\t\"name\": \"Measurement_Group_Type\",\n\t\t\t\t\t\t\t\t\t\t\"type\": \"record\",\n\t\t\t\t\t\t\t\t\t\t\"fields\": [{\n\t\t\t\t\t\t\t\t\t\t\t\t\"name\": \"measurementTypes\",\n\t\t\t\t\t\t\t\t\t\t\t\t\"type\": {\n\t\t\t\t\t\t\t\t\t\t\t\t\t\"type\": \"array\",\n\t\t\t\t\t\t\t\t\t\t\t\t\t\"items\": {\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\"name\": \"Measurement_Types_Type\",\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\"type\": \"record\",\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\"fields\": [{\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\"name\": \"measurementType\",\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\"type\": \"string\"\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t}]\n\t\t\t\t\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\t\t\t\t\"name\": \"managedObjectDNsBasic\",\n\t\t\t\t\t\t\t\t\t\t\t\t\"type\": {\n\t\t\t\t\t\t\t\t\t\t\t\t\t\"type\": \"array\",\n\t\t\t\t\t\t\t\t\t\t\t\t\t\"items\": {\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\"name\": \"Managed_Object_Dns_Basic_Type\",\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\"type\": \"record\",\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\"fields\": [{\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\"name\": \"DN\",\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\"type\": \"string\"\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t}]\n\t\t\t\t\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\t\t]\n\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t}]\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t]\n\t\t\t}\n\t\t}\n\t]\n}" - } - }, - { - "key":{ - "name":"SimpleIntType", - "version":"0.0.1" - }, - "value":{ - "key":{ - "name":"SimpleIntType", - "version":"0.0.1" - }, - "schemaFlavour":"Java", - "schemaDefinition":"java.lang.Integer" - } - }, - { - "key":{ - "name":"SimpleStringType", - "version":"0.0.1" - }, - "value":{ - "key":{ - "name":"SimpleStringType", - "version":"0.0.1" - }, - "schemaFlavour":"Java", - "schemaDefinition":"java.lang.String" - } - }, - { - "key":{ - "name":"SubscriptionStatusType", - "version":"0.0.1" - }, - "value":{ - "key":{ - "name":"SubscriptionStatusType", - "version":"0.0.1" - }, - "schemaFlavour":"Avro", - "schemaDefinition":"{\n \"type\": \"record\",\n \"name\": \"ActivateSubscriptionStatus_Type\",\n \"namespace\": \"org.onap.policy.apex.onap.helloworld\",\n \"fields\": [\n {\n \"name\": \"subscriptionName\",\n \"type\": \"string\"\n },\n {\n \"name\": \"nfName\",\n \"type\": \"string\"\n },\n {\n \"name\": \"changeType\",\n \"type\": \"string\"\n },\n {\n \"name\": \"message\",\n \"type\": \"string\"\n }\n ]\n}" - } - }, - { - "key":{ - "name":"SubscriptionType", - "version":"0.0.1" - }, - "value":{ - "key":{ - "name":"SubscriptionType", - "version":"0.0.1" - }, - "schemaFlavour":"Avro", - "schemaDefinition":"{\n\t\"name\": \"subscription\",\n\t\"type\": \"record\",\n\t\"fields\": [{\n\t\t\t\"name\": \"subscriptionName\",\n\t\t\t\"type\": \"string\"\n\t\t},\n\t\t{\n\t\t\t\"name\": \"administrativeState\",\n\t\t\t\"type\": \"string\"\n\t\t},\n\t\t{\n\t\t\t\"name\": \"fileBasedGP\",\n\t\t\t\"type\": \"int\"\n\t\t},\n\t\t{\n\t\t\t\"name\": \"fileLocation\",\n\t\t\t\"type\": \"string\"\n\t\t},\n\t\t{\n\t\t\t\"name\": \"measurementGroups\",\n\t\t\t\"type\": {\n\t\t\t\t\"type\": \"array\",\n\t\t\t\t\"items\": {\n\t\t\t\t\t\"name\": \"Measurement_Groups_Type\",\n\t\t\t\t\t\"type\": \"record\",\n\t\t\t\t\t\"fields\": [{\n\t\t\t\t\t\t\"name\": \"measurementGroup\",\n\t\t\t\t\t\t\"type\": {\n\t\t\t\t\t\t\t\"name\": \"Measurement_Group_Type\",\n\t\t\t\t\t\t\t\"type\": \"record\",\n\t\t\t\t\t\t\t\"fields\": [{\n\t\t\t\t\t\t\t\t\t\"name\": \"measurementTypes\",\n\t\t\t\t\t\t\t\t\t\"type\": {\n\t\t\t\t\t\t\t\t\t\t\"type\": \"array\",\n\t\t\t\t\t\t\t\t\t\t\"items\": {\n\t\t\t\t\t\t\t\t\t\t\t\"name\": \"Measurement_Types_Type\",\n\t\t\t\t\t\t\t\t\t\t\t\"type\": \"record\",\n\t\t\t\t\t\t\t\t\t\t\t\"fields\": [{\n\t\t\t\t\t\t\t\t\t\t\t\t\"name\": \"measurementType\",\n\t\t\t\t\t\t\t\t\t\t\t\t\"type\": \"string\"\n\t\t\t\t\t\t\t\t\t\t\t}]\n\t\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\t\"name\": \"managedObjectDNsBasic\",\n\t\t\t\t\t\t\t\t\t\"type\": {\n\t\t\t\t\t\t\t\t\t\t\"type\": \"array\",\n\t\t\t\t\t\t\t\t\t\t\"items\": {\n\t\t\t\t\t\t\t\t\t\t\t\"name\": \"Managed_Object_Dns_Basic_Type\",\n\t\t\t\t\t\t\t\t\t\t\t\"type\": \"record\",\n\t\t\t\t\t\t\t\t\t\t\t\"fields\": [{\n\t\t\t\t\t\t\t\t\t\t\t\t\"name\": \"DN\",\n\t\t\t\t\t\t\t\t\t\t\t\t\"type\": \"string\"\n\t\t\t\t\t\t\t\t\t\t\t}]\n\t\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t]\n\t\t\t\t\t\t}\n\t\t\t\t\t}]\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t]\n}" - } - }, - { - "key":{ - "name":"UUIDType", - "version":"0.0.1" - }, - "value":{ - "key":{ - "name":"UUIDType", - "version":"0.0.1" - }, - "schemaFlavour":"Java", - "schemaDefinition":"java.util.UUID" - } - } - ] - } - } - } - }, - "engineParameters":{ - "executorParameters":{ - "JAVASCRIPT":{ - "parameterClassName":"org.onap.policy.apex.plugins.executor.javascript.JavascriptExecutorParameters" - } - }, - "contextParameters":{ - "parameterClassName":"org.onap.policy.apex.context.parameters.ContextParameters", - "schemaParameters":{ - "Avro":{ - "parameterClassName":"org.onap.policy.apex.plugins.context.schema.avro.AvroSchemaHelperParameters" - }, - "Java":{ - "parameterClassName":"org.onap.policy.apex.context.impl.schema.java.JavaSchemaHelperParameters", - "jsonAdapters":{ - "Instant":{ - "adaptedClass":"java.time.Instant", - "adaptorClass":"org.onap.policy.controlloop.util.Serialization$GsonInstantAdapter" - } - } - } - } - } - } - }, - "eventInputParameters":{ - "DCAEConsumer":{ - "carrierTechnologyParameters":{ - "carrierTechnology":"RESTCLIENT", - "parameterClassName":"org.onap.policy.apex.plugins.event.carrier.restclient.RestClientCarrierTechnologyParameters", - "parameters":{ - "consumerPollTime":"50", - "url":"https://message-router:3905/events/unauthenticated.DCAE_CL_OUTPUT/cg1/sg1" - } - }, - "eventProtocolParameters":{ - "eventProtocol":"JSON", - "parameters":{ - "nameAlias":"policyName" - } - }, - "eventName":"pmsh-operational-policy", - "eventNameFilter":"pmsh-operational-policy" - }, - "CDSRequestConsumer":{ - "carrierTechnologyParameters":{ - "carrierTechnology":"RESTREQUESTOR", - "parameterClassName":"org.onap.policy.apex.plugins.event.carrier.restrequestor.RestRequestorCarrierTechnologyParameters", - "parameters":{ - "url":"http://10.10.10.184:30254/api/v1/execution-service/process", - "httpMethod":"POST", - "restRequestTimeout":2000, - "httpHeaders":[ - [ - "Authorization", - "Basic Y2NzZGthcHBzOmNjc2RrYXBwcw==" - ] - ] - } - }, - "eventProtocolParameters":{ - "eventProtocol":"JSON" - }, - "eventName":"CDSCreateResponseEvent", - "eventNameFilter":"CDSCreateResponseEvent", - "requestorMode":true, - "requestorPeer":"CDSRequestProducer", - "requestorTimeout":500 - }, - "CDSDeleteRequestConsumer":{ - "carrierTechnologyParameters":{ - "carrierTechnology":"RESTREQUESTOR", - "parameterClassName":"org.onap.policy.apex.plugins.event.carrier.restrequestor.RestRequestorCarrierTechnologyParameters", - "parameters":{ - "url":"http://10.10.10.184:30254/api/v1/execution-service/process", - "httpMethod":"POST", - "restRequestTimeout":2000, - "httpHeaders":[ - [ - "Authorization", - "Basic Y2NzZGthcHBzOmNjc2RrYXBwcw==" - ] - ] - } - }, - "eventProtocolParameters":{ - "eventProtocol":"JSON" - }, - "eventName":"CDSDeleteResponseEvent", - "eventNameFilter":"CDSDeleteResponseEvent", - "requestorMode":true, - "requestorPeer":"CDSDeleteRequestProducer", - "requestorTimeout":500 - }, - "CDSReplyConsumer":{ - "carrierTechnologyParameters":{ - "carrierTechnology":"RESTREQUESTOR", - "parameterClassName":"org.onap.policy.apex.plugins.event.carrier.restrequestor.RestRequestorCarrierTechnologyParameters", - "parameters":{ - "url":"https://message-router:3905/events/unauthenticated.PMSH_CL_INPUT", - "httpMethod":"POST", - "restRequestTimeout":2000 - } - }, - "eventProtocolParameters":{ - "eventProtocol":"JSON" - }, - "eventName":"MRResponseEvent", - "eventNameFilter":"MRResponseEvent", - "requestorMode":true, - "requestorPeer":"CDSReplyProducer", - "requestorTimeout":500 - } - }, - "eventOutputParameters":{ - "logOutputter":{ - "carrierTechnologyParameters":{ - "carrierTechnology":"FILE", - "parameters":{ - "fileName":"/tmp/outputevents.log" - } - }, - "eventProtocolParameters":{ - "eventProtocol":"JSON" - } - }, - "StdOutOutputter":{ - "carrierTechnologyParameters":{ - "carrierTechnology":"FILE", - "parameters":{ - "standardIo":true - } - }, - "eventProtocolParameters":{ - "eventProtocol":"JSON" - } - }, - "CDSRequestProducer":{ - "carrierTechnologyParameters":{ - "carrierTechnology":"RESTREQUESTOR", - "parameterClassName":"org.onap.policy.apex.plugins.event.carrier.restrequestor.RestRequestorCarrierTechnologyParameters" - }, - "eventProtocolParameters":{ - "eventProtocol":"JSON" - }, - "eventNameFilter":"CDSCreateSubscriptionRequestEvent", - "requestorMode":true, - "requestorPeer":"CDSRequestConsumer", - "requestorTimeout":500 - }, - "CDSDeleteRequestProducer":{ - "carrierTechnologyParameters":{ - "carrierTechnology":"RESTREQUESTOR", - "parameterClassName":"org.onap.policy.apex.plugins.event.carrier.restrequestor.RestRequestorCarrierTechnologyParameters" - }, - "eventProtocolParameters":{ - "eventProtocol":"JSON" - }, - "eventNameFilter":"CDSDeleteSubscriptionRequestEvent", - "requestorMode":true, - "requestorPeer":"CDSDeleteRequestConsumer", - "requestorTimeout":500 - }, - "CDSReplyProducer":{ - "carrierTechnologyParameters":{ - "carrierTechnology":"RESTREQUESTOR", - "parameterClassName":"org.onap.policy.apex.plugins.event.carrier.restrequestor.RestRequestorCarrierTechnologyParameters" - }, - "eventProtocolParameters":{ - "eventProtocol":"JSON" - }, - "eventNameFilter":"CDSResponseStatusEvent", - "requestorMode":true, - "requestorPeer":"CDSReplyConsumer", - "requestorTimeout":500 - } - } - } - } - } - ] - } -} \ No newline at end of file diff --git a/common/src/test/resources/examples/controlloop/PMSH/pmsh_operational_policy.yaml b/common/src/test/resources/examples/controlloop/PMSH/pmsh_operational_policy.yaml deleted file mode 100644 index faf579012..000000000 --- a/common/src/test/resources/examples/controlloop/PMSH/pmsh_operational_policy.yaml +++ /dev/null @@ -1,2619 +0,0 @@ ---- -tosca_definitions_version: tosca_simple_yaml_1_1_0 -topology_template: - policies: - - operational.apex.pmcontrol: - type: onap.policies.controlloop.operational.Apex - type_version: 1.0.0 - version: 1.0.0 - metadata: - policy-id: operational.apex.pmcontrol - policy-version: 1 - properties: - engineServiceParameters: - name: MyApexEngine - version: 0.0.1 - id: 45 - instanceCount: 2 - deploymentPort: 12561 - policy_type_impl: - apexPolicyModel: - key: - name: PMControlPolicy - version: 0.0.1 - keyInformation: - key: - name: PMControlPolicy_KeyInfo - version: 0.0.1 - keyInfoMap: - entry: - - key: - name: CDSActionIdentifiersType - version: 0.0.1 - value: - key: - name: CDSActionIdentifiersType - version: 0.0.1 - UUID: 6e5fa19b-14df-37e3-a4ae-8c537e861a82 - description: Generated description for concept referred to by - key "CDSActionIdentifiersType:0.0.1" - - key: - name: CDSCreateResponseEvent - version: 0.0.1 - value: - key: - name: CDSCreateResponseEvent - version: 0.0.1 - UUID: 14b29e38-ac75-3273-aa4e-8583c0aa7dad - description: Generated description for concept referred to by - key "CDSCreateResponseEvent:0.0.1" - - key: - name: CDSCreateResponsePayloadType - version: 0.0.1 - value: - key: - name: CDSCreateResponsePayloadType - version: 0.0.1 - UUID: 04573f8f-e772-30a5-b1d9-d7318d4a1e13 - description: Generated description for concept referred to by - key "CDSCreateResponsePayloadType:0.0.1" - - key: - name: CDSCreateResponsePolicy - version: 0.0.1 - value: - key: - name: CDSCreateResponsePolicy - version: 0.0.1 - UUID: e126c965-fc09-3bfe-8f55-70f380a4a49c - description: Generated description for concept referred to by - key "CDSCreateResponsePolicy:0.0.1" - - key: - name: CDSCreateResponseTask - version: 0.0.1 - value: - key: - name: CDSCreateResponseTask - version: 0.0.1 - UUID: 6165ee82-afd2-3aab-a517-f00b3f2461d2 - description: Generated description for concept referred to by - key "CDSCreateResponseTask:0.0.1" - - key: - name: CDSCreateSubscriptionPayloadType - version: 0.0.1 - value: - key: - name: CDSCreateSubscriptionPayloadType - version: 0.0.1 - UUID: 8350ac5e-c157-38b9-9614-a0f93a830e60 - description: Generated description for concept referred to by - key "CDSCreateSubscriptionPayloadType:0.0.1" - - key: - name: CDSCreateSubscriptionRequestEvent - version: 0.0.1 - value: - key: - name: CDSCreateSubscriptionRequestEvent - version: 0.0.1 - UUID: cfa325ba-226b-3a31-9183-ec43e2b6e9a2 - description: Generated description for concept referred to by - key "CDSCreateSubscriptionRequestEvent:0.0.1" - - key: - name: CDSDeleteResponseEvent - version: 0.0.1 - value: - key: - name: CDSDeleteResponseEvent - version: 0.0.1 - UUID: 8be9c0fa-7437-3841-aff2-b3cec6ae3bd8 - description: Generated description for concept referred to by - key "CDSDeleteResponseEvent:0.0.1" - - key: - name: CDSDeleteResponsePayloadType - version: 0.0.1 - value: - key: - name: CDSDeleteResponsePayloadType - version: 0.0.1 - UUID: 3fbfe0c9-152e-34d3-a504-09cd13c058d0 - description: Generated description for concept referred to by - key "CDSDeleteResponsePayloadType:0.0.1" - - key: - name: CDSDeleteResponsePolicy - version: 0.0.1 - value: - key: - name: CDSDeleteResponsePolicy - version: 0.0.1 - UUID: a780251c-edd5-3132-b865-04313246b43c - description: Generated description for concept referred to by - key "CDSDeleteResponsePolicy:0.0.1" - - key: - name: CDSDeleteResponseTask - version: 0.0.1 - value: - key: - name: CDSDeleteResponseTask - version: 0.0.1 - UUID: afce4555-3aa3-3521-a7d8-ee8cdf0d3efc - description: Generated description for concept referred to by - key "CDSDeleteResponseTask:0.0.1" - - key: - name: CDSDeleteSubscriptionPayloadType - version: 0.0.1 - value: - key: - name: CDSDeleteSubscriptionPayloadType - version: 0.0.1 - UUID: 12658406-9147-3c9d-a38c-5ad5e30b092b - description: Generated description for concept referred to by - key "CDSDeleteSubscriptionPayloadType:0.0.1" - - key: - name: CDSDeleteSubscriptionRequestEvent - version: 0.0.1 - value: - key: - name: CDSDeleteSubscriptionRequestEvent - version: 0.0.1 - UUID: 24380c95-9289-36e6-8cbf-0edefa15ccd9 - description: Generated description for concept referred to by - key "CDSDeleteSubscriptionRequestEvent:0.0.1" - - key: - name: CDSRequestCommonHeaderType - version: 0.0.1 - value: - key: - name: CDSRequestCommonHeaderType - version: 0.0.1 - UUID: 35590ac0-062c-39f1-8786-b4ff716e30b1 - description: Generated description for concept referred to by - key "CDSRequestCommonHeaderType:0.0.1" - - key: - name: CDSResponseCommonHeaderType - version: 0.0.1 - value: - key: - name: CDSResponseCommonHeaderType - version: 0.0.1 - UUID: dd7e1805-885a-350b-aaf9-ed541321ae3c - description: Generated description for concept referred to by - key "CDSResponseCommonHeaderType:0.0.1" - - key: - name: CDSResponseStatusEvent - version: 0.0.1 - value: - key: - name: CDSResponseStatusEvent - version: 0.0.1 - UUID: 7986e21b-32f7-302e-9554-31f21b673493 - description: Generated description for concept referred to by - key "CDSResponseStatusEvent:0.0.1" - - key: - name: CDSResponseStatusType - version: 0.0.1 - value: - key: - name: CDSResponseStatusType - version: 0.0.1 - UUID: 92b8a2cf-344e-3ce1-8cc0-2b7d3cb695fa - description: Generated description for concept referred to by - key "CDSResponseStatusType:0.0.1" - - key: - name: CreateSubscriptionPayloadEvent - version: 0.0.1 - value: - key: - name: CreateSubscriptionPayloadEvent - version: 0.0.1 - UUID: 92162397-1a8e-3a3f-a469-d2af7700af4a - description: Generated description for concept referred to by - key "CreateSubscriptionPayloadEvent:0.0.1" - - key: - name: CreateSubscriptionPayloadTask - version: 0.0.1 - value: - key: - name: CreateSubscriptionPayloadTask - version: 0.0.1 - UUID: bc0c69f0-52ed-38ea-b468-ae4a6fd1730d - description: Generated description for concept referred to by - key "CreateSubscriptionPayloadTask:0.0.1" - - key: - name: CreateSubscriptionRequestTask - version: 0.0.1 - value: - key: - name: CreateSubscriptionRequestTask - version: 0.0.1 - UUID: 89cb75e9-f06c-30d3-b4ff-698d45f63869 - description: Generated description for concept referred to by - key "CreateSubscriptionRequestTask:0.0.1" - - key: - name: DeleteSubscriptionPayloadEvent - version: 0.0.1 - value: - key: - name: DeleteSubscriptionPayloadEvent - version: 0.0.1 - UUID: 994fa441-04ab-33bb-832d-1cd12ab5d074 - description: Generated description for concept referred to by - key "DeleteSubscriptionPayloadEvent:0.0.1" - - key: - name: DeleteSubscriptionPayloadTask - version: 0.0.1 - value: - key: - name: DeleteSubscriptionPayloadTask - version: 0.0.1 - UUID: 0f519117-5fea-3e4b-941f-8f778100465f - description: Generated description for concept referred to by - key "DeleteSubscriptionPayloadTask:0.0.1" - - key: - name: DeleteSubscriptionRequestTask - version: 0.0.1 - value: - key: - name: DeleteSubscriptionRequestTask - version: 0.0.1 - UUID: acb772fe-d442-39e3-98f9-b1080caf4150 - description: Generated description for concept referred to by - key "DeleteSubscriptionRequestTask:0.0.1" - - key: - name: MRResponseEvent - version: 0.0.1 - value: - key: - name: MRResponseEvent - version: 0.0.1 - UUID: 13c747a3-6bae-3bcf-9c80-b152e01dc194 - description: Generated description for concept referred to by - key "MRResponseEvent:0.0.1" - - key: - name: PMControlPolicy - version: 0.0.1 - value: - key: - name: PMControlPolicy - version: 0.0.1 - UUID: acf1e55c-7bc5-3bd5-975a-0ca54afcd8a4 - description: Generated description for concept referred to by - key "PMControlPolicy:0.0.1" - - key: - name: PMControlPolicy_Albums - version: 0.0.1 - value: - key: - name: PMControlPolicy_Albums - version: 0.0.1 - UUID: b38ad204-c2c8-32f4-9b5a-dda0aeb0145b - description: Generated description for concept referred to by - key "PMControlPolicy_Albums:0.0.1" - - key: - name: PMControlPolicy_Events - version: 0.0.1 - value: - key: - name: PMControlPolicy_Events - version: 0.0.1 - UUID: be3871a0-c42a-3113-a066-82d192840eca - description: Generated description for concept referred to by - key "PMControlPolicy_Events:0.0.1" - - key: - name: PMControlPolicy_KeyInfo - version: 0.0.1 - value: - key: - name: PMControlPolicy_KeyInfo - version: 0.0.1 - UUID: ced37634-28a4-3178-b7f6-2980794927b0 - description: Generated description for concept referred to by - key "PMControlPolicy_KeyInfo:0.0.1" - - key: - name: PMControlPolicy_Policies - version: 0.0.1 - value: - key: - name: PMControlPolicy_Policies - version: 0.0.1 - UUID: be3d180d-ef9c-3a75-8e9c-84271a038bed - description: Generated description for concept referred to by - key "PMControlPolicy_Policies:0.0.1" - - key: - name: PMControlPolicy_Schemas - version: 0.0.1 - value: - key: - name: PMControlPolicy_Schemas - version: 0.0.1 - UUID: e61973f1-189c-39e5-82f6-0d3afe298a20 - description: Generated description for concept referred to by - key "PMControlPolicy_Schemas:0.0.1" - - key: - name: PMControlPolicy_Tasks - version: 0.0.1 - value: - key: - name: PMControlPolicy_Tasks - version: 0.0.1 - UUID: 5658adb3-2962-30a3-a241-fae75bb8eb4a - description: Generated description for concept referred to by - key "PMControlPolicy_Tasks:0.0.1" - - key: - name: PMSubscriptionAlbum - version: 0.0.1 - value: - key: - name: PMSubscriptionAlbum - version: 0.0.1 - UUID: c2bd6f0d-6854-317a-9be2-97c08338428c - description: Generated description for concept referred to by - key "PMSubscriptionAlbum:0.0.1" - - key: - name: PMSubscriptionOutputEvent - version: 0.0.1 - value: - key: - name: PMSubscriptionOutputEvent - version: 0.0.1 - UUID: 992b7819-9f69-3aa0-bb0f-6e45ea15ce05 - description: Generated description for concept referred to by - key "PMSubscriptionOutputEvent:0.0.1" - - key: - name: PMSubscriptionType - version: 0.0.1 - value: - key: - name: PMSubscriptionType - version: 0.0.1 - UUID: 73c1c397-4fc3-357f-93b6-a8ad707fbaae - description: Generated description for concept referred to by - key "PMSubscriptionType:0.0.1" - - key: - name: ReceiveEventPolicy - version: 0.0.1 - value: - key: - name: ReceiveEventPolicy - version: 0.0.1 - UUID: 568b7345-9de1-36d3-b6a3-9b857e6809a1 - description: Generated description for concept referred to by - key "ReceiveEventPolicy:0.0.1" - - key: - name: ReceiveSubscriptionTask - version: 0.0.1 - value: - key: - name: ReceiveSubscriptionTask - version: 0.0.1 - UUID: f596afc8-100c-35eb-92c8-352355ea457d - description: Generated description for concept referred to by - key "ReceiveSubscriptionTask:0.0.1" - - key: - name: SimpleIntType - version: 0.0.1 - value: - key: - name: SimpleIntType - version: 0.0.1 - UUID: 153791fd-ae0a-36a7-88a5-309a7936415d - description: Generated description for concept referred to by - key "SimpleIntType:0.0.1" - - key: - name: SimpleStringType - version: 0.0.1 - value: - key: - name: SimpleStringType - version: 0.0.1 - UUID: 8a4957cf-9493-3a76-8c22-a208e23259af - description: Generated description for concept referred to by - key "SimpleStringType:0.0.1" - - key: - name: SubscriptionStatusType - version: 0.0.1 - value: - key: - name: SubscriptionStatusType - version: 0.0.1 - UUID: 597643b1-9db1-31ce-85d0-e1c63c43b30b - description: Generated description for concept referred to by - key "SubscriptionStatusType:0.0.1" - - key: - name: SubscriptionType - version: 0.0.1 - value: - key: - name: SubscriptionType - version: 0.0.1 - UUID: 184547bb-7d64-3cb2-a273-d7185102c5ce - description: Generated description for concept referred to by - key "SubscriptionType:0.0.1" - - key: - name: UUIDType - version: 0.0.1 - value: - key: - name: UUIDType - version: 0.0.1 - UUID: 6a8cc68e-dfc8-3403-9c6d-071c886b319c - description: Generated description for concept referred to by - key "UUIDType:0.0.1" - - key: - name: pmsh-operational-policy - version: 0.0.1 - value: - key: - name: pmsh-operational-policy - version: 0.0.1 - UUID: fdf2c9ff-6422-3ea6-b6b6-49b12116265d - description: Generated description for concept referred to by - key "pmsh-operational-policy:0.0.1" - policies: - key: - name: PMControlPolicy_Policies - version: 0.0.1 - policyMap: - entry: - - key: - name: CDSCreateResponsePolicy - version: 0.0.1 - value: - policyKey: - name: CDSCreateResponsePolicy - version: 0.0.1 - template: Freestyle - state: - entry: - - key: CDSCreateResponseState - value: - stateKey: - parentKeyName: CDSCreateResponsePolicy - parentKeyVersion: 0.0.1 - parentLocalName: 'NULL' - localName: CDSCreateResponseState - trigger: - name: CDSCreateResponseEvent - version: 0.0.1 - stateOutputs: - entry: - - key: ResponseOutput - value: - key: - parentKeyName: CDSCreateResponsePolicy - parentKeyVersion: 0.0.1 - parentLocalName: CDSCreateResponseState - localName: ResponseOutput - outgoingEvent: - name: CDSResponseStatusEvent - version: 0.0.1 - nextState: - parentKeyName: 'NULL' - parentKeyVersion: 0.0.0 - parentLocalName: 'NULL' - localName: 'NULL' - contextAlbumReference: [] - taskSelectionLogic: - key: 'NULL' - logicFlavour: UNDEFINED - logic: '' - stateFinalizerLogicMap: - entry: [] - defaultTask: - name: CDSCreateResponseTask - version: 0.0.1 - taskReferences: - entry: - - key: - name: CDSCreateResponseTask - version: 0.0.1 - value: - key: - parentKeyName: CDSCreateResponsePolicy - parentKeyVersion: 0.0.1 - parentLocalName: CDSCreateResponseState - localName: CDSCreateResponsePolicy - outputType: DIRECT - output: - parentKeyName: CDSCreateResponsePolicy - parentKeyVersion: 0.0.1 - parentLocalName: CDSCreateResponseState - localName: ResponseOutput - firstState: CDSCreateResponseState - - key: - name: CDSDeleteResponsePolicy - version: 0.0.1 - value: - policyKey: - name: CDSDeleteResponsePolicy - version: 0.0.1 - template: Freestyle - state: - entry: - - key: CDSDeleteResponseState - value: - stateKey: - parentKeyName: CDSDeleteResponsePolicy - parentKeyVersion: 0.0.1 - parentLocalName: 'NULL' - localName: CDSDeleteResponseState - trigger: - name: CDSDeleteResponseEvent - version: 0.0.1 - stateOutputs: - entry: - - key: ResponseOutput - value: - key: - parentKeyName: CDSDeleteResponsePolicy - parentKeyVersion: 0.0.1 - parentLocalName: CDSDeleteResponseState - localName: ResponseOutput - outgoingEvent: - name: CDSResponseStatusEvent - version: 0.0.1 - nextState: - parentKeyName: 'NULL' - parentKeyVersion: 0.0.0 - parentLocalName: 'NULL' - localName: 'NULL' - contextAlbumReference: [] - taskSelectionLogic: - key: 'NULL' - logicFlavour: UNDEFINED - logic: '' - stateFinalizerLogicMap: - entry: [] - defaultTask: - name: CDSDeleteResponseTask - version: 0.0.1 - taskReferences: - entry: - - key: - name: CDSDeleteResponseTask - version: 0.0.1 - value: - key: - parentKeyName: CDSDeleteResponsePolicy - parentKeyVersion: 0.0.1 - parentLocalName: CDSDeleteResponseState - localName: CDSDeleteResponsePolicy - outputType: DIRECT - output: - parentKeyName: CDSDeleteResponsePolicy - parentKeyVersion: 0.0.1 - parentLocalName: CDSDeleteResponseState - localName: ResponseOutput - firstState: CDSDeleteResponseState - - key: - name: ReceiveEventPolicy - version: 0.0.1 - value: - policyKey: - name: ReceiveEventPolicy - version: 0.0.1 - template: Freestyle - state: - entry: - - key: CreateOrDeleteState - value: - stateKey: - parentKeyName: ReceiveEventPolicy - parentKeyVersion: 0.0.1 - parentLocalName: 'NULL' - localName: CreateOrDeleteState - trigger: - name: PMSubscriptionOutputEvent - version: 0.0.1 - stateOutputs: - entry: - - key: CreateSubscriptionPayload - value: - key: - parentKeyName: ReceiveEventPolicy - parentKeyVersion: 0.0.1 - parentLocalName: CreateOrDeleteState - localName: CreateSubscriptionPayload - outgoingEvent: - name: CreateSubscriptionPayloadEvent - version: 0.0.1 - nextState: - parentKeyName: ReceiveEventPolicy - parentKeyVersion: 0.0.1 - parentLocalName: 'NULL' - localName: CreateSubscription - - key: DeleteSubscriptionPayload - value: - key: - parentKeyName: ReceiveEventPolicy - parentKeyVersion: 0.0.1 - parentLocalName: CreateOrDeleteState - localName: DeleteSubscriptionPayload - outgoingEvent: - name: DeleteSubscriptionPayloadEvent - version: 0.0.1 - nextState: - parentKeyName: ReceiveEventPolicy - parentKeyVersion: 0.0.1 - parentLocalName: 'NULL' - localName: DeleteSubscription - contextAlbumReference: - - name: PMSubscriptionAlbum - version: 0.0.1 - taskSelectionLogic: - key: TaskSelectionLogic - logicFlavour: JAVASCRIPT - logic: |- - /* - * ============LICENSE_START======================================================= - * Copyright (C) 2020 Nordix. 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); - - var pmSubscriptionInfo = executor.getContextAlbum("PMSubscriptionAlbum").get(executor.inFields.get("albumID").toString()) - var changeType = pmSubscriptionInfo.get("changeType").toString() - - executor.logger.info("Change Type is " + changeType) - - if ("CREATE".equals(changeType)) { - executor.logger.info("Choosing to create a subscription") - executor.subject.getTaskKey("CreateSubscriptionPayloadTask").copyTo(executor.selectedTask); - } - else if ("DELETE".equals(changeType)) { - executor.logger.info("Choosing to delete a subscription") - executor.subject.getTaskKey("DeleteSubscriptionPayloadTask").copyTo(executor.selectedTask); - } - - //var returnValue = executor.isTrue; - true; - stateFinalizerLogicMap: - entry: [] - defaultTask: - name: CreateSubscriptionPayloadTask - version: 0.0.1 - taskReferences: - entry: - - key: - name: CreateSubscriptionPayloadTask - version: 0.0.1 - value: - key: - parentKeyName: ReceiveEventPolicy - parentKeyVersion: 0.0.1 - parentLocalName: CreateOrDeleteState - localName: ReceiveEventPolicy - outputType: DIRECT - output: - parentKeyName: ReceiveEventPolicy - parentKeyVersion: 0.0.1 - parentLocalName: CreateOrDeleteState - localName: CreateSubscriptionPayload - - key: - name: DeleteSubscriptionPayloadTask - version: 0.0.1 - value: - key: - parentKeyName: ReceiveEventPolicy - parentKeyVersion: 0.0.1 - parentLocalName: CreateOrDeleteState - localName: ReceiveEventPolicy - outputType: DIRECT - output: - parentKeyName: ReceiveEventPolicy - parentKeyVersion: 0.0.1 - parentLocalName: CreateOrDeleteState - localName: DeleteSubscriptionPayload - - key: CreateSubscription - value: - stateKey: - parentKeyName: ReceiveEventPolicy - parentKeyVersion: 0.0.1 - parentLocalName: 'NULL' - localName: CreateSubscription - trigger: - name: CreateSubscriptionPayloadEvent - version: 0.0.1 - stateOutputs: - entry: - - key: IssueCreateSubscriptionRequestOutput - value: - key: - parentKeyName: ReceiveEventPolicy - parentKeyVersion: 0.0.1 - parentLocalName: CreateSubscription - localName: IssueCreateSubscriptionRequestOutput - outgoingEvent: - name: CDSCreateSubscriptionRequestEvent - version: 0.0.1 - nextState: - parentKeyName: 'NULL' - parentKeyVersion: 0.0.0 - parentLocalName: 'NULL' - localName: 'NULL' - contextAlbumReference: - - name: PMSubscriptionAlbum - version: 0.0.1 - taskSelectionLogic: - key: 'NULL' - logicFlavour: UNDEFINED - logic: '' - stateFinalizerLogicMap: - entry: [] - defaultTask: - name: CreateSubscriptionRequestTask - version: 0.0.1 - taskReferences: - entry: - - key: - name: CreateSubscriptionRequestTask - version: 0.0.1 - value: - key: - parentKeyName: ReceiveEventPolicy - parentKeyVersion: 0.0.1 - parentLocalName: CreateSubscription - localName: ReceiveEventPolicy - outputType: DIRECT - output: - parentKeyName: ReceiveEventPolicy - parentKeyVersion: 0.0.1 - parentLocalName: CreateSubscription - localName: IssueCreateSubscriptionRequestOutput - - key: DeleteSubscription - value: - stateKey: - parentKeyName: ReceiveEventPolicy - parentKeyVersion: 0.0.1 - parentLocalName: 'NULL' - localName: DeleteSubscription - trigger: - name: DeleteSubscriptionPayloadEvent - version: 0.0.1 - stateOutputs: - entry: - - key: IssueDeleteSubscriptionRequestOutput - value: - key: - parentKeyName: ReceiveEventPolicy - parentKeyVersion: 0.0.1 - parentLocalName: DeleteSubscription - localName: IssueDeleteSubscriptionRequestOutput - outgoingEvent: - name: CDSDeleteSubscriptionRequestEvent - version: 0.0.1 - nextState: - parentKeyName: 'NULL' - parentKeyVersion: 0.0.0 - parentLocalName: 'NULL' - localName: 'NULL' - contextAlbumReference: - - name: PMSubscriptionAlbum - version: 0.0.1 - taskSelectionLogic: - key: 'NULL' - logicFlavour: UNDEFINED - logic: '' - stateFinalizerLogicMap: - entry: [] - defaultTask: - name: DeleteSubscriptionRequestTask - version: 0.0.1 - taskReferences: - entry: - - key: - name: DeleteSubscriptionRequestTask - version: 0.0.1 - value: - key: - parentKeyName: ReceiveEventPolicy - parentKeyVersion: 0.0.1 - parentLocalName: DeleteSubscription - localName: ReceiveEventPolicy - outputType: DIRECT - output: - parentKeyName: ReceiveEventPolicy - parentKeyVersion: 0.0.1 - parentLocalName: DeleteSubscription - localName: IssueDeleteSubscriptionRequestOutput - - key: ReceiveSubscriptionState - value: - stateKey: - parentKeyName: ReceiveEventPolicy - parentKeyVersion: 0.0.1 - parentLocalName: 'NULL' - localName: ReceiveSubscriptionState - trigger: - name: pmsh-operational-policy - version: 0.0.1 - stateOutputs: - entry: - - key: ReceivePMSubscriptionOutput - value: - key: - parentKeyName: ReceiveEventPolicy - parentKeyVersion: 0.0.1 - parentLocalName: ReceiveSubscriptionState - localName: ReceivePMSubscriptionOutput - outgoingEvent: - name: PMSubscriptionOutputEvent - version: 0.0.1 - nextState: - parentKeyName: ReceiveEventPolicy - parentKeyVersion: 0.0.1 - parentLocalName: 'NULL' - localName: CreateOrDeleteState - contextAlbumReference: - - name: PMSubscriptionAlbum - version: 0.0.1 - taskSelectionLogic: - key: 'NULL' - logicFlavour: UNDEFINED - logic: '' - stateFinalizerLogicMap: - entry: [] - defaultTask: - name: ReceiveSubscriptionTask - version: 0.0.1 - taskReferences: - entry: - - key: - name: ReceiveSubscriptionTask - version: 0.0.1 - value: - key: - parentKeyName: ReceiveEventPolicy - parentKeyVersion: 0.0.1 - parentLocalName: ReceiveSubscriptionState - localName: ReceiveEventPolicy - outputType: DIRECT - output: - parentKeyName: ReceiveEventPolicy - parentKeyVersion: 0.0.1 - parentLocalName: ReceiveSubscriptionState - localName: ReceivePMSubscriptionOutput - firstState: ReceiveSubscriptionState - tasks: - key: - name: PMControlPolicy_Tasks - version: 0.0.1 - taskMap: - entry: - - key: - name: CDSCreateResponseTask - version: 0.0.1 - value: - key: - name: CDSCreateResponseTask - version: 0.0.1 - inputFields: - entry: - - key: actionIdentifiers - value: - key: actionIdentifiers - fieldSchemaKey: - name: CDSActionIdentifiersType - version: 0.0.1 - optional: false - - key: commonHeader - value: - key: commonHeader - fieldSchemaKey: - name: CDSResponseCommonHeaderType - version: 0.0.1 - optional: false - - key: payload - value: - key: payload - fieldSchemaKey: - name: CDSCreateResponsePayloadType - version: 0.0.1 - optional: false - - key: status - value: - key: status - fieldSchemaKey: - name: CDSResponseStatusType - version: 0.0.1 - optional: false - outputFields: - entry: - - key: status - value: - key: status - fieldSchemaKey: - name: SubscriptionStatusType - version: 0.0.1 - optional: false - taskParameters: - entry: [] - contextAlbumReference: - - name: PMSubscriptionAlbum - version: 0.0.1 - taskLogic: - key: TaskLogic - logicFlavour: JAVASCRIPT - logic: |- - /* - * ============LICENSE_START======================================================= - * Copyright (C) 2020 Nordix. 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); - - var commonHeader = executor.inFields.get("commonHeader") - var response = executor.inFields.get("payload") - var albumID = commonHeader.get("requestId") - - var pmSubscriptionInfo = executor.getContextAlbum("PMSubscriptionAlbum").get(albumID.toString()); - var responseStatus = executor.subject.getOutFieldSchemaHelper("status").createNewInstance(); - - responseStatus.put("subscriptionName", pmSubscriptionInfo.get("subscription").get("subscriptionName")) - responseStatus.put("nfName", pmSubscriptionInfo.get("nfName")) - responseStatus.put("changeType", pmSubscriptionInfo.get("changeType")) - - var status = response.get(pmSubscriptionInfo.get("changeType").toLowerCase() + "_DasH_subscription_DasH_response").get("odl_DasH_response").get("status") - - executor.logger.info("RESPONSE STATUS = " + status) - - if(status == "success") { - responseStatus.put("message", "success") - } else { - responseStatus.put("message", "failed") - } - - executor.outFields.put("status", responseStatus) - - //var returnValue = executor.isTrue; - true; - - key: - name: CDSDeleteResponseTask - version: 0.0.1 - value: - key: - name: CDSDeleteResponseTask - version: 0.0.1 - inputFields: - entry: - - key: actionIdentifiers - value: - key: actionIdentifiers - fieldSchemaKey: - name: CDSActionIdentifiersType - version: 0.0.1 - optional: false - - key: commonHeader - value: - key: commonHeader - fieldSchemaKey: - name: CDSResponseCommonHeaderType - version: 0.0.1 - optional: false - - key: payload - value: - key: payload - fieldSchemaKey: - name: CDSDeleteResponsePayloadType - version: 0.0.1 - optional: false - - key: status - value: - key: status - fieldSchemaKey: - name: CDSResponseStatusType - version: 0.0.1 - optional: false - outputFields: - entry: - - key: status - value: - key: status - fieldSchemaKey: - name: SubscriptionStatusType - version: 0.0.1 - optional: false - taskParameters: - entry: [] - contextAlbumReference: - - name: PMSubscriptionAlbum - version: 0.0.1 - taskLogic: - key: TaskLogic - logicFlavour: JAVASCRIPT - logic: |- - /* - * ============LICENSE_START======================================================= - * Copyright (C) 2020 Nordix. 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); - - var commonHeader = executor.inFields.get("commonHeader") - var response = executor.inFields.get("payload") - var albumID = commonHeader.get("requestId") - - var pmSubscriptionInfo = executor.getContextAlbum("PMSubscriptionAlbum").get(albumID.toString()); - var responseStatus = executor.subject.getOutFieldSchemaHelper("status").createNewInstance(); - - responseStatus.put("subscriptionName", pmSubscriptionInfo.get("subscription").get("subscriptionName")) - responseStatus.put("nfName", pmSubscriptionInfo.get("nfName")) - responseStatus.put("changeType", pmSubscriptionInfo.get("changeType")) - - var status = response.get(pmSubscriptionInfo.get("changeType").toLowerCase() + "_DasH_subscription_DasH_response").get("odl_DasH_response").get("status") - - executor.logger.info("RESPONSE STATUS = " + status) - - if(status == "success") { - responseStatus.put("message", "success") - } else { - responseStatus.put("message", "failed") - } - - executor.outFields.put("status", responseStatus) - - //var returnValue = executor.isTrue; - true; - - key: - name: CreateSubscriptionPayloadTask - version: 0.0.1 - value: - key: - name: CreateSubscriptionPayloadTask - version: 0.0.1 - inputFields: - entry: - - key: albumID - value: - key: albumID - fieldSchemaKey: - name: UUIDType - version: 0.0.1 - optional: false - outputFields: - entry: - - key: albumID - value: - key: albumID - fieldSchemaKey: - name: UUIDType - version: 0.0.1 - optional: false - - key: payload - value: - key: payload - fieldSchemaKey: - name: CDSCreateSubscriptionPayloadType - version: 0.0.1 - optional: false - taskParameters: - entry: [] - contextAlbumReference: - - name: PMSubscriptionAlbum - version: 0.0.1 - taskLogic: - key: TaskLogic - logicFlavour: JAVASCRIPT - logic: |- - /* - * ============LICENSE_START======================================================= - * Copyright (C) 2020 Nordix. 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); - - var pmSubscriptionInfo = executor.getContextAlbum("PMSubscriptionAlbum").get(executor.inFields.get("albumID").toString()) - - var changeType = pmSubscriptionInfo.get("changeType").toLowerCase() - - var payloadProperties = executor.subject.getOutFieldSchemaHelper("payload").createNewSubInstance(changeType + "_DasH_subscription_DasH_properties_record"); - - payloadProperties.put("nfName", pmSubscriptionInfo.get("nfName")) - payloadProperties.put("subscriptionName", pmSubscriptionInfo.get("subscription").get("subscriptionName")) - payloadProperties.put("administrativeState", pmSubscriptionInfo.get("subscription").get("administrativeState")) - payloadProperties.put("fileBasedGP", pmSubscriptionInfo.get("subscription").get("fileBasedGP").toString()) - payloadProperties.put("fileLocation", pmSubscriptionInfo.get("subscription").get("fileLocation")) - payloadProperties.put("measurementGroups", pmSubscriptionInfo.get("subscription").get("measurementGroups")) - - var payloadEntry = executor.subject.getOutFieldSchemaHelper("payload").createNewSubInstance("CDSRequestPayloadEntry"); - payloadEntry.put(changeType + "_DasH_subscription_DasH_properties", payloadProperties) - - var payload = executor.subject.getOutFieldSchemaHelper("payload").createNewInstance(); - payload.put(changeType + "_DasH_subscription_DasH_request", payloadEntry); - - executor.outFields.put("albumID", executor.inFields.get("albumID")) - executor.outFields.put("payload", payload); - - //var returnValue = executor.isTrue; - true; - - key: - name: CreateSubscriptionRequestTask - version: 0.0.1 - value: - key: - name: CreateSubscriptionRequestTask - version: 0.0.1 - inputFields: - entry: - - key: albumID - value: - key: albumID - fieldSchemaKey: - name: UUIDType - version: 0.0.1 - optional: false - - key: payload - value: - key: payload - fieldSchemaKey: - name: CDSCreateSubscriptionPayloadType - version: 0.0.1 - optional: false - outputFields: - entry: - - key: actionIdentifiers - value: - key: actionIdentifiers - fieldSchemaKey: - name: CDSActionIdentifiersType - version: 0.0.1 - optional: false - - key: commonHeader - value: - key: commonHeader - fieldSchemaKey: - name: CDSRequestCommonHeaderType - version: 0.0.1 - optional: false - - key: payload - value: - key: payload - fieldSchemaKey: - name: CDSCreateSubscriptionPayloadType - version: 0.0.1 - optional: false - taskParameters: - entry: [] - contextAlbumReference: - - name: PMSubscriptionAlbum - version: 0.0.1 - taskLogic: - key: TaskLogic - logicFlavour: JAVASCRIPT - logic: |- - /* - * ============LICENSE_START======================================================= - * Copyright (C) 2020 Nordix. 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); - - var pmSubscriptionInfo = executor.getContextAlbum("PMSubscriptionAlbum").get(executor.inFields.get("albumID").toString()) - - var changeType = pmSubscriptionInfo.get("changeType").toLowerCase() - var blueprintName = pmSubscriptionInfo.get("blueprintName").toLowerCase() - var blueprintVersion = pmSubscriptionInfo.get("blueprintVersion").toLowerCase() - var payload = executor.inFields.get("payload") - var actionName = changeType + "-subscription" - - var commonHeader = executor.subject.getOutFieldSchemaHelper("commonHeader").createNewInstance(); - commonHeader.put("originatorId", "sdnc"); - commonHeader.put("requestId", executor.inFields.get("albumID").toString()); - commonHeader.put("subRequestId", "sub-123456-1000"); - - var actionIdentifiers = executor.subject.getOutFieldSchemaHelper("actionIdentifiers").createNewInstance(); - actionIdentifiers.put("actionName", actionName); - actionIdentifiers.put("blueprintName", blueprintName); - actionIdentifiers.put("blueprintVersion", blueprintVersion); - actionIdentifiers.put("mode", "sync"); - - executor.outFields.put("commonHeader", commonHeader); - executor.outFields.put("actionIdentifiers", actionIdentifiers); - executor.outFields.put("payload", payload); - - //var returnValue = executor.isTrue; - true; - - key: - name: DeleteSubscriptionPayloadTask - version: 0.0.1 - value: - key: - name: DeleteSubscriptionPayloadTask - version: 0.0.1 - inputFields: - entry: - - key: albumID - value: - key: albumID - fieldSchemaKey: - name: UUIDType - version: 0.0.1 - optional: false - outputFields: - entry: - - key: albumID - value: - key: albumID - fieldSchemaKey: - name: UUIDType - version: 0.0.1 - optional: false - - key: payload - value: - key: payload - fieldSchemaKey: - name: CDSDeleteSubscriptionPayloadType - version: 0.0.1 - optional: false - taskParameters: - entry: [] - contextAlbumReference: - - name: PMSubscriptionAlbum - version: 0.0.1 - taskLogic: - key: TaskLogic - logicFlavour: JAVASCRIPT - logic: |- - /* - * ============LICENSE_START======================================================= - * Copyright (C) 2020 Nordix. 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); - - var pmSubscriptionInfo = executor.getContextAlbum("PMSubscriptionAlbum").get(executor.inFields.get("albumID").toString()) - - var changeType = pmSubscriptionInfo.get("changeType").toLowerCase() - - var payloadProperties = executor.subject.getOutFieldSchemaHelper("payload").createNewSubInstance(changeType + "_DasH_subscription_DasH_properties_record"); - - payloadProperties.put("nfName", pmSubscriptionInfo.get("nfName")) - payloadProperties.put("subscriptionName", pmSubscriptionInfo.get("subscription").get("subscriptionName")) - payloadProperties.put("administrativeState", pmSubscriptionInfo.get("subscription").get("administrativeState")) - payloadProperties.put("fileBasedGP", pmSubscriptionInfo.get("subscription").get("fileBasedGP").toString()) - payloadProperties.put("fileLocation", pmSubscriptionInfo.get("subscription").get("fileLocation")) - payloadProperties.put("measurementGroups", pmSubscriptionInfo.get("subscription").get("measurementGroups")) - - var payloadEntry = executor.subject.getOutFieldSchemaHelper("payload").createNewSubInstance("CDSRequestPayloadEntry"); - payloadEntry.put(changeType + "_DasH_subscription_DasH_properties", payloadProperties) - - var payload = executor.subject.getOutFieldSchemaHelper("payload").createNewInstance(); - payload.put(changeType + "_DasH_subscription_DasH_request", payloadEntry); - - executor.outFields.put("albumID", executor.inFields.get("albumID")) - executor.outFields.put("payload", payload); - - //var returnValue = executor.isTrue; - true; - - key: - name: DeleteSubscriptionRequestTask - version: 0.0.1 - value: - key: - name: DeleteSubscriptionRequestTask - version: 0.0.1 - inputFields: - entry: - - key: albumID - value: - key: albumID - fieldSchemaKey: - name: UUIDType - version: 0.0.1 - optional: false - - key: payload - value: - key: payload - fieldSchemaKey: - name: CDSDeleteSubscriptionPayloadType - version: 0.0.1 - optional: false - outputFields: - entry: - - key: actionIdentifiers - value: - key: actionIdentifiers - fieldSchemaKey: - name: CDSActionIdentifiersType - version: 0.0.1 - optional: false - - key: commonHeader - value: - key: commonHeader - fieldSchemaKey: - name: CDSRequestCommonHeaderType - version: 0.0.1 - optional: false - - key: payload - value: - key: payload - fieldSchemaKey: - name: CDSDeleteSubscriptionPayloadType - version: 0.0.1 - optional: false - taskParameters: - entry: [] - contextAlbumReference: - - name: PMSubscriptionAlbum - version: 0.0.1 - taskLogic: - key: TaskLogic - logicFlavour: JAVASCRIPT - logic: |- - /* - * ============LICENSE_START======================================================= - * Copyright (C) 2020 Nordix. 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); - - var pmSubscriptionInfo = executor.getContextAlbum("PMSubscriptionAlbum").get(executor.inFields.get("albumID").toString()) - - var changeType = pmSubscriptionInfo.get("changeType").toLowerCase() - var blueprintName = pmSubscriptionInfo.get("blueprintName").toLowerCase() - var blueprintVersion = pmSubscriptionInfo.get("blueprintVersion").toLowerCase() - var payload = executor.inFields.get("payload") - var actionName = changeType + "-subscription" - - var commonHeader = executor.subject.getOutFieldSchemaHelper("commonHeader").createNewInstance(); - commonHeader.put("originatorId", "sdnc"); - commonHeader.put("requestId", executor.inFields.get("albumID").toString()); - commonHeader.put("subRequestId", "sub-123456-1000"); - - var actionIdentifiers = executor.subject.getOutFieldSchemaHelper("actionIdentifiers").createNewInstance(); - actionIdentifiers.put("actionName", actionName); - actionIdentifiers.put("blueprintName", blueprintName); - actionIdentifiers.put("blueprintVersion", blueprintVersion); - actionIdentifiers.put("mode", "sync"); - - executor.outFields.put("commonHeader", commonHeader); - executor.outFields.put("actionIdentifiers", actionIdentifiers); - executor.outFields.put("payload", payload); - - //var returnValue = executor.isTrue; - true; - - key: - name: ReceiveSubscriptionTask - version: 0.0.1 - value: - key: - name: ReceiveSubscriptionTask - version: 0.0.1 - inputFields: - entry: - - key: blueprintName - value: - key: blueprintName - fieldSchemaKey: - name: SimpleStringType - version: 0.0.1 - optional: false - - key: blueprintVersion - value: - key: blueprintVersion - fieldSchemaKey: - name: SimpleStringType - version: 0.0.1 - optional: false - - key: changeType - value: - key: changeType - fieldSchemaKey: - name: SimpleStringType - version: 0.0.1 - optional: false - - key: closedLoopControlName - value: - key: closedLoopControlName - fieldSchemaKey: - name: SimpleStringType - version: 0.0.1 - optional: false - - key: nfName - value: - key: nfName - fieldSchemaKey: - name: SimpleStringType - version: 0.0.1 - optional: false - - key: policyName - value: - key: policyName - fieldSchemaKey: - name: SimpleStringType - version: 0.0.1 - optional: false - - key: subscription - value: - key: subscription - fieldSchemaKey: - name: SubscriptionType - version: 0.0.1 - optional: false - outputFields: - entry: - - key: albumID - value: - key: albumID - fieldSchemaKey: - name: UUIDType - version: 0.0.1 - optional: false - taskParameters: - entry: [] - contextAlbumReference: - - name: PMSubscriptionAlbum - version: 0.0.1 - taskLogic: - key: TaskLogic - logicFlavour: JAVASCRIPT - logic: |- - /* - * ============LICENSE_START======================================================= - * Copyright (C) 2020 Nordix. 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========================================================= - */ - var uuidType = java.util.UUID; - - executor.logger.info(executor.subject.id); - - //albumID will be used to fetch info from our album later - var albumID = uuidType.randomUUID(); - var pmSubscriptionInfo = executor.getContextAlbum("PMSubscriptionAlbum").getSchemaHelper().createNewInstance(); - var returnValue = true; - - if(executor.inFields.get("policyName") != null) { - executor.logger.info("nfName in receive sub event " + executor.inFields.get("nfName")); - - var changeType = executor.inFields.get("changeType") - var nfName = executor.inFields.get("nfName") - var policyName = executor.inFields.get("policyName") - var closedLoopControlName = executor.inFields.get("closedLoopControlName") - var subscription = executor.inFields.get("subscription") - var blueprintName = executor.inFields.get("blueprintName") - var blueprintVersion = executor.inFields.get("blueprintVersion") - - pmSubscriptionInfo.put("nfName", executor.inFields.get("nfName")); - pmSubscriptionInfo.put("changeType", executor.inFields.get("changeType")) - pmSubscriptionInfo.put("policyName", executor.inFields.get("policyName")) - pmSubscriptionInfo.put("closedLoopControlName", executor.inFields.get("closedLoopControlName")) - pmSubscriptionInfo.put("subscription", subscription) - pmSubscriptionInfo.put("blueprintName", blueprintName) - pmSubscriptionInfo.put("blueprintVersion", blueprintVersion) - - - executor.getContextAlbum("PMSubscriptionAlbum").put(albumID.toString(), pmSubscriptionInfo); - - executor.outFields.put("albumID", albumID) - } else { - executor.message = "Received invalid event" - returnValue = false; - } - - returnValue; - events: - key: - name: PMControlPolicy_Events - version: 0.0.1 - eventMap: - entry: - - key: - name: CDSCreateResponseEvent - version: 0.0.1 - value: - key: - name: CDSCreateResponseEvent - version: 0.0.1 - nameSpace: org.onap.policy.apex.onap.pmcontrol - source: CDS - target: APEX - parameter: - entry: - - key: actionIdentifiers - value: - key: actionIdentifiers - fieldSchemaKey: - name: CDSActionIdentifiersType - version: 0.0.1 - optional: false - - key: commonHeader - value: - key: commonHeader - fieldSchemaKey: - name: CDSResponseCommonHeaderType - version: 0.0.1 - optional: false - - key: payload - value: - key: payload - fieldSchemaKey: - name: CDSCreateResponsePayloadType - version: 0.0.1 - optional: false - - key: status - value: - key: status - fieldSchemaKey: - name: CDSResponseStatusType - version: 0.0.1 - optional: false - - key: - name: CDSCreateSubscriptionRequestEvent - version: 0.0.1 - value: - key: - name: CDSCreateSubscriptionRequestEvent - version: 0.0.1 - nameSpace: org.onap.policy.apex.onap.pmcontrol - source: APEX - target: APEX - parameter: - entry: - - key: actionIdentifiers - value: - key: actionIdentifiers - fieldSchemaKey: - name: CDSActionIdentifiersType - version: 0.0.1 - optional: false - - key: commonHeader - value: - key: commonHeader - fieldSchemaKey: - name: CDSRequestCommonHeaderType - version: 0.0.1 - optional: false - - key: payload - value: - key: payload - fieldSchemaKey: - name: CDSCreateSubscriptionPayloadType - version: 0.0.1 - optional: false - - key: - name: CDSDeleteResponseEvent - version: 0.0.1 - value: - key: - name: CDSDeleteResponseEvent - version: 0.0.1 - nameSpace: org.onap.policy.apex.onap.pmcontrol - source: CDS - target: APEX - parameter: - entry: - - key: actionIdentifiers - value: - key: actionIdentifiers - fieldSchemaKey: - name: CDSActionIdentifiersType - version: 0.0.1 - optional: false - - key: commonHeader - value: - key: commonHeader - fieldSchemaKey: - name: CDSResponseCommonHeaderType - version: 0.0.1 - optional: false - - key: payload - value: - key: payload - fieldSchemaKey: - name: CDSDeleteResponsePayloadType - version: 0.0.1 - optional: false - - key: status - value: - key: status - fieldSchemaKey: - name: CDSResponseStatusType - version: 0.0.1 - optional: false - - key: - name: CDSDeleteSubscriptionRequestEvent - version: 0.0.1 - value: - key: - name: CDSDeleteSubscriptionRequestEvent - version: 0.0.1 - nameSpace: org.onap.policy.apex.onap.pmcontrol - source: APEX - target: APEX - parameter: - entry: - - key: actionIdentifiers - value: - key: actionIdentifiers - fieldSchemaKey: - name: CDSActionIdentifiersType - version: 0.0.1 - optional: false - - key: commonHeader - value: - key: commonHeader - fieldSchemaKey: - name: CDSRequestCommonHeaderType - version: 0.0.1 - optional: false - - key: payload - value: - key: payload - fieldSchemaKey: - name: CDSDeleteSubscriptionPayloadType - version: 0.0.1 - optional: false - - key: - name: CDSResponseStatusEvent - version: 0.0.1 - value: - key: - name: CDSResponseStatusEvent - version: 0.0.1 - nameSpace: org.onap.policy.apex.onap.pmcontrol - source: APEX - target: DCAE - parameter: - entry: - - key: status - value: - key: status - fieldSchemaKey: - name: SubscriptionStatusType - version: 0.0.1 - optional: false - - key: - name: CreateSubscriptionPayloadEvent - version: 0.0.1 - value: - key: - name: CreateSubscriptionPayloadEvent - version: 0.0.1 - nameSpace: org.onap.policy.apex.onap.pmcontrol - source: APEX - target: APEX - parameter: - entry: - - key: albumID - value: - key: albumID - fieldSchemaKey: - name: UUIDType - version: 0.0.1 - optional: false - - key: payload - value: - key: payload - fieldSchemaKey: - name: CDSCreateSubscriptionPayloadType - version: 0.0.1 - optional: false - - key: - name: DeleteSubscriptionPayloadEvent - version: 0.0.1 - value: - key: - name: DeleteSubscriptionPayloadEvent - version: 0.0.1 - nameSpace: org.onap.policy.apex.onap.pmcontrol - source: APEX - target: APEX - parameter: - entry: - - key: albumID - value: - key: albumID - fieldSchemaKey: - name: UUIDType - version: 0.0.1 - optional: false - - key: payload - value: - key: payload - fieldSchemaKey: - name: CDSDeleteSubscriptionPayloadType - version: 0.0.1 - optional: false - - key: - name: MRResponseEvent - version: 0.0.1 - value: - key: - name: MRResponseEvent - version: 0.0.1 - nameSpace: org.onap.policy.apex.onap.pmcontrol - source: DCAE - target: APEX - parameter: - entry: - - key: count - value: - key: count - fieldSchemaKey: - name: SimpleIntType - version: 0.0.1 - optional: false - - key: serverTimeMs - value: - key: serverTimeMs - fieldSchemaKey: - name: SimpleIntType - version: 0.0.1 - optional: false - - key: - name: PMSubscriptionOutputEvent - version: 0.0.1 - value: - key: - name: PMSubscriptionOutputEvent - version: 0.0.1 - nameSpace: org.onap.policy.apex.onap.pmcontrol - source: APEX - target: APEX - parameter: - entry: - - key: albumID - value: - key: albumID - fieldSchemaKey: - name: UUIDType - version: 0.0.1 - optional: false - - key: - name: pmsh-operational-policy - version: 0.0.1 - value: - key: - name: pmsh-operational-policy - version: 0.0.1 - nameSpace: org.onap.policy.apex.onap.pmcontrol - source: DCAE - target: APEX - parameter: - entry: - - key: blueprintName - value: - key: blueprintName - fieldSchemaKey: - name: SimpleStringType - version: 0.0.1 - optional: false - - key: blueprintVersion - value: - key: blueprintVersion - fieldSchemaKey: - name: SimpleStringType - version: 0.0.1 - optional: false - - key: changeType - value: - key: changeType - fieldSchemaKey: - name: SimpleStringType - version: 0.0.1 - optional: false - - key: closedLoopControlName - value: - key: closedLoopControlName - fieldSchemaKey: - name: SimpleStringType - version: 0.0.1 - optional: false - - key: nfName - value: - key: nfName - fieldSchemaKey: - name: SimpleStringType - version: 0.0.1 - optional: false - - key: policyName - value: - key: policyName - fieldSchemaKey: - name: SimpleStringType - version: 0.0.1 - optional: false - - key: subscription - value: - key: subscription - fieldSchemaKey: - name: SubscriptionType - version: 0.0.1 - optional: false - albums: - key: - name: PMControlPolicy_Albums - version: 0.0.1 - albums: - entry: - - key: - name: PMSubscriptionAlbum - version: 0.0.1 - value: - key: - name: PMSubscriptionAlbum - version: 0.0.1 - scope: policy - isWritable: true - itemSchema: - name: PMSubscriptionType - version: 0.0.1 - schemas: - key: - name: PMControlPolicy_Schemas - version: 0.0.1 - schemas: - entry: - - key: - name: CDSActionIdentifiersType - version: 0.0.1 - value: - key: - name: CDSActionIdentifiersType - version: 0.0.1 - schemaFlavour: Avro - schemaDefinition: |- - { - "type": "record", - "name": "ActionIdentifiers_Type", - "namespace": "org.onap.policy.apex.onap.helloworld", - "fields": [ - { - "name": "actionName", - "type": "string" - }, - { - "name": "blueprintName", - "type": "string" - }, - { - "name": "blueprintVersion", - "type": "string" - }, - { - "name": "mode", - "type": "string" - } - ] - } - - key: - name: CDSCreateResponsePayloadType - version: 0.0.1 - value: - key: - name: CDSCreateResponsePayloadType - version: 0.0.1 - schemaFlavour: Avro - schemaDefinition: |- - { - "name": "CreateResponsePayloadEntry", - "type": "record", - "namespace": "org.onap.policy.apex.onap.helloworld", - "fields": [ - { - "name": "create_DasH_subscription_DasH_response", - "type": { - "name": "create_DasH_subscription_DasH_response", - "type": "record", - "fields": [ - { - "name": "odl_DasH_response", - "type": { - "name": "odl_DasH_response", - "type": "record", - "fields": [ - { - "name": "status", - "type": "string" - } - ] - } - } - ] - } - } - ] - } - - key: - name: CDSCreateSubscriptionPayloadType - version: 0.0.1 - value: - key: - name: CDSCreateSubscriptionPayloadType - version: 0.0.1 - schemaFlavour: Avro - schemaDefinition: |- - { - "type": "map", - "values": { - "type": "record", - "name": "CDSRequestPayloadEntry", - "fields": [ - { - "name": "create_DasH_subscription_DasH_properties", - "type": { - "name": "create_DasH_subscription_DasH_properties_record", - "type": "record", - "fields": [ - { - "name": "nfName", - "type": "string" - }, - { - "name": "subscriptionName", - "type": "string" - }, - { - "name": "administrativeState", - "type": "string" - }, - { - "name": "fileBasedGP", - "type": "string" - }, - { - "name": "fileLocation", - "type": "string" - }, - { - "name": "measurementGroups", - "type": { - "type": "array", - "items": { - "name": "measurementGroups_record", - "type": "record", - "fields": [ - { - "name": "measurementGroup", - "type": { - "name": "measurementGroup", - "type": "record", - "fields": [ - { - "name": "measurementTypes", - "type": { - "type": "array", - "items": { - "name": "measurementTypes_record", - "type": "record", - "fields": [ - { - "name": "measurementType", - "type": "string" - } - ] - } - } - }, - { - "name": "managedObjectDNsBasic", - "type": { - "type": "array", - "items": { - "name": "managedObjectDNsBasic_record", - "type": "record", - "fields": [ - { - "name": "DN", - "type": "string" - } - ] - } - } - } - ] - } - } - ] - } - } - } - ] - } - } - ] - } - } - - key: - name: CDSDeleteResponsePayloadType - version: 0.0.1 - value: - key: - name: CDSDeleteResponsePayloadType - version: 0.0.1 - schemaFlavour: Avro - schemaDefinition: |- - { - "name": "DeleteResponsePayloadEntry", - "type": "record", - "namespace": "com.acme.avro", - "fields": [ - { - "name": "delete_DasH_subscription_DasH_response", - "type": { - "name": "delete_DasH_subscription_DasH_response", - "type": "record", - "fields": [ - { - "name": "odl_DasH_response", - "type": { - "name": "odl_DasH_response", - "type": "record", - "fields": [ - { - "name": "status", - "type": "string" - } - ] - } - } - ] - } - } - ] - } - - key: - name: CDSDeleteSubscriptionPayloadType - version: 0.0.1 - value: - key: - name: CDSDeleteSubscriptionPayloadType - version: 0.0.1 - schemaFlavour: Avro - schemaDefinition: |- - { - "type": "map", - "values": { - "type": "record", - "name": "CDSRequestPayloadEntry", - "fields": [ - { - "name": "delete_DasH_subscription_DasH_properties", - "type": { - "name": "delete_DasH_subscription_DasH_properties_record", - "type": "record", - "fields": [ - { - "name": "nfName", - "type": "string" - }, - { - "name": "subscriptionName", - "type": "string" - }, - { - "name": "administrativeState", - "type": "string" - }, - { - "name": "fileBasedGP", - "type": "string" - }, - { - "name": "fileLocation", - "type": "string" - }, - { - "name": "measurementGroups", - "type": { - "type": "array", - "items": { - "name": "measurementGroups_record", - "type": "record", - "fields": [ - { - "name": "measurementGroup", - "type": { - "name": "measurementGroup", - "type": "record", - "fields": [ - { - "name": "measurementTypes", - "type": { - "type": "array", - "items": { - "name": "measurementTypes_record", - "type": "record", - "fields": [ - { - "name": "measurementType", - "type": "string" - } - ] - } - } - }, - { - "name": "managedObjectDNsBasic", - "type": { - "type": "array", - "items": { - "name": "managedObjectDNsBasic_record", - "type": "record", - "fields": [ - { - "name": "DN", - "type": "string" - } - ] - } - } - } - ] - } - } - ] - } - } - } - ] - } - } - ] - } - } - - key: - name: CDSRequestCommonHeaderType - version: 0.0.1 - value: - key: - name: CDSRequestCommonHeaderType - version: 0.0.1 - schemaFlavour: Avro - schemaDefinition: |- - { - "type": "record", - "name": "RequestCommonHeader_Type", - "namespace": "org.onap.policy.apex.onap.helloworld", - "fields": [ - { - "name": "originatorId", - "type": "string" - }, - { - "name": "requestId", - "type": "string" - }, - { - "name": "subRequestId", - "type": "string" - } - ] - } - - key: - name: CDSResponseCommonHeaderType - version: 0.0.1 - value: - key: - name: CDSResponseCommonHeaderType - version: 0.0.1 - schemaFlavour: Avro - schemaDefinition: |- - { - "type": "record", - "name": "ResponseCommonHeader_Type", - "namespace": "org.onap.policy.apex.onap.helloworld", - "fields": [ - { - "name": "originatorId", - "type": "string" - }, - { - "name": "requestId", - "type": "string" - }, - { - "name": "subRequestId", - "type": "string" - }, - { - "name": "timestamp", - "type": "string" - }, - { - "name": "flags", - "type": ["null", "string"] - } - ] - } - - key: - name: CDSResponseStatusType - version: 0.0.1 - value: - key: - name: CDSResponseStatusType - version: 0.0.1 - schemaFlavour: Avro - schemaDefinition: |- - { - "type": "record", - "name": "ResponseStatus_Type", - "namespace": "org.onap.policy.apex.onap.helloworld", - "fields": [ - { - "name": "code", - "type": "int" - }, - { - "name": "eventType", - "type": "string" - }, - { - "name": "timestamp", - "type": "string" - }, - { - "name": "message", - "type": "string" - } - ] - } - - key: - name: PMSubscriptionType - version: 0.0.1 - value: - key: - name: PMSubscriptionType - version: 0.0.1 - schemaFlavour: Avro - schemaDefinition: "{\n\t\"name\": \"PMSubscription\",\n\t\"type\": - \"record\",\n\t\"namespace\": \"org.onap.policy.apex.onap.pmcontrol\",\n\t\"fields\": - [\n {\n \"name\": \"nfName\",\n \"type\": - \"string\"\n },\n\t {\n\t\t\t\"name\": \"changeType\",\n\t\t\t\"type\": - \"string\"\n\t\t},\n\t\t{\n\t\t\t\"name\": \"closedLoopControlName\",\n\t\t\t\"type\": - \"string\"\n\t\t},\n\t\t{\n\t\t\t\"name\": \"policyName\",\n\t\t\t\"type\": - \"string\"\n\t\t},\n\t\t{\n\t\t \"name\": \"blueprintName\",\n\t\t - \ \"type\": \"string\"\n\t\t},\n\t\t{\n\t\t \"name\": - \"blueprintVersion\",\n\t\t \"type\": \"string\"\n\t\t},\n\t\t{\n\t\t\t\"name\": - \"subscription\",\n\t\t\t\"type\": {\n\t\t\t\t\"name\": \"subscription\",\n\t\t\t\t\"type\": - \"record\",\n\t\t\t\t\"fields\": [{\n\t\t\t\t\t\t\"name\": - \"subscriptionName\",\n\t\t\t\t\t\t\"type\": \"string\"\n\t\t\t\t\t},\n\t\t\t\t\t{\n\t\t\t\t\t\t\"name\": - \"administrativeState\",\n\t\t\t\t\t\t\"type\": \"string\"\n\t\t\t\t\t},\n\t\t\t\t\t{\n\t\t\t\t\t\t\"name\": - \"fileBasedGP\",\n\t\t\t\t\t\t\"type\": \"int\"\n\t\t\t\t\t},\n\t\t\t\t\t{\n\t\t\t\t\t\t\"name\": - \"fileLocation\",\n\t\t\t\t\t\t\"type\": \"string\"\n\t\t\t\t\t},\n\t\t\t\t\t{\n\t\t\t\t\t\t\"name\": - \"measurementGroups\",\n\t\t\t\t\t\t\"type\": {\n\t\t\t\t\t\t\t\"type\": - \"array\",\n\t\t\t\t\t\t\t\"items\": {\n\t\t\t\t\t\t\t\t\"name\": - \"Measurement_Groups_Type\",\n\t\t\t\t\t\t\t\t\"type\": \"record\",\n\t\t\t\t\t\t\t\t\"fields\": - [{\n\t\t\t\t\t\t\t\t\t\"name\": \"measurementGroup\",\n\t\t\t\t\t\t\t\t\t\"type\": - {\n\t\t\t\t\t\t\t\t\t\t\"name\": \"Measurement_Group_Type\",\n\t\t\t\t\t\t\t\t\t\t\"type\": - \"record\",\n\t\t\t\t\t\t\t\t\t\t\"fields\": [{\n\t\t\t\t\t\t\t\t\t\t\t\t\"name\": - \"measurementTypes\",\n\t\t\t\t\t\t\t\t\t\t\t\t\"type\": {\n\t\t\t\t\t\t\t\t\t\t\t\t\t\"type\": - \"array\",\n\t\t\t\t\t\t\t\t\t\t\t\t\t\"items\": {\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\"name\": - \"Measurement_Types_Type\",\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\"type\": - \"record\",\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\"fields\": [{\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\"name\": - \"measurementType\",\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\"type\": - \"string\"\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t}]\n\t\t\t\t\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\t\t\t\t\"name\": - \"managedObjectDNsBasic\",\n\t\t\t\t\t\t\t\t\t\t\t\t\"type\": - {\n\t\t\t\t\t\t\t\t\t\t\t\t\t\"type\": \"array\",\n\t\t\t\t\t\t\t\t\t\t\t\t\t\"items\": - {\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\"name\": \"Managed_Object_Dns_Basic_Type\",\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\"type\": - \"record\",\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\"fields\": [{\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\"name\": - \"DN\",\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\"type\": \"string\"\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t}]\n\t\t\t\t\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\t\t]\n\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t}]\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t]\n\t\t\t}\n\t\t}\n\t]\n}" - - key: - name: SimpleIntType - version: 0.0.1 - value: - key: - name: SimpleIntType - version: 0.0.1 - schemaFlavour: Java - schemaDefinition: java.lang.Integer - - key: - name: SimpleStringType - version: 0.0.1 - value: - key: - name: SimpleStringType - version: 0.0.1 - schemaFlavour: Java - schemaDefinition: java.lang.String - - key: - name: SubscriptionStatusType - version: 0.0.1 - value: - key: - name: SubscriptionStatusType - version: 0.0.1 - schemaFlavour: Avro - schemaDefinition: |- - { - "type": "record", - "name": "ActivateSubscriptionStatus_Type", - "namespace": "org.onap.policy.apex.onap.helloworld", - "fields": [ - { - "name": "subscriptionName", - "type": "string" - }, - { - "name": "nfName", - "type": "string" - }, - { - "name": "changeType", - "type": "string" - }, - { - "name": "message", - "type": "string" - } - ] - } - - key: - name: SubscriptionType - version: 0.0.1 - value: - key: - name: SubscriptionType - version: 0.0.1 - schemaFlavour: Avro - schemaDefinition: "{\n\t\"name\": \"subscription\",\n\t\"type\": - \"record\",\n\t\"fields\": [{\n\t\t\t\"name\": \"subscriptionName\",\n\t\t\t\"type\": - \"string\"\n\t\t},\n\t\t{\n\t\t\t\"name\": \"administrativeState\",\n\t\t\t\"type\": - \"string\"\n\t\t},\n\t\t{\n\t\t\t\"name\": \"fileBasedGP\",\n\t\t\t\"type\": - \"int\"\n\t\t},\n\t\t{\n\t\t\t\"name\": \"fileLocation\",\n\t\t\t\"type\": - \"string\"\n\t\t},\n\t\t{\n\t\t\t\"name\": \"measurementGroups\",\n\t\t\t\"type\": - {\n\t\t\t\t\"type\": \"array\",\n\t\t\t\t\"items\": {\n\t\t\t\t\t\"name\": - \"Measurement_Groups_Type\",\n\t\t\t\t\t\"type\": \"record\",\n\t\t\t\t\t\"fields\": - [{\n\t\t\t\t\t\t\"name\": \"measurementGroup\",\n\t\t\t\t\t\t\"type\": - {\n\t\t\t\t\t\t\t\"name\": \"Measurement_Group_Type\",\n\t\t\t\t\t\t\t\"type\": - \"record\",\n\t\t\t\t\t\t\t\"fields\": [{\n\t\t\t\t\t\t\t\t\t\"name\": - \"measurementTypes\",\n\t\t\t\t\t\t\t\t\t\"type\": {\n\t\t\t\t\t\t\t\t\t\t\"type\": - \"array\",\n\t\t\t\t\t\t\t\t\t\t\"items\": {\n\t\t\t\t\t\t\t\t\t\t\t\"name\": - \"Measurement_Types_Type\",\n\t\t\t\t\t\t\t\t\t\t\t\"type\": - \"record\",\n\t\t\t\t\t\t\t\t\t\t\t\"fields\": [{\n\t\t\t\t\t\t\t\t\t\t\t\t\"name\": - \"measurementType\",\n\t\t\t\t\t\t\t\t\t\t\t\t\"type\": \"string\"\n\t\t\t\t\t\t\t\t\t\t\t}]\n\t\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\t\"name\": - \"managedObjectDNsBasic\",\n\t\t\t\t\t\t\t\t\t\"type\": {\n\t\t\t\t\t\t\t\t\t\t\"type\": - \"array\",\n\t\t\t\t\t\t\t\t\t\t\"items\": {\n\t\t\t\t\t\t\t\t\t\t\t\"name\": - \"Managed_Object_Dns_Basic_Type\",\n\t\t\t\t\t\t\t\t\t\t\t\"type\": - \"record\",\n\t\t\t\t\t\t\t\t\t\t\t\"fields\": [{\n\t\t\t\t\t\t\t\t\t\t\t\t\"name\": - \"DN\",\n\t\t\t\t\t\t\t\t\t\t\t\t\"type\": \"string\"\n\t\t\t\t\t\t\t\t\t\t\t}]\n\t\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t]\n\t\t\t\t\t\t}\n\t\t\t\t\t}]\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t]\n}" - - key: - name: UUIDType - version: 0.0.1 - value: - key: - name: UUIDType - version: 0.0.1 - schemaFlavour: Java - schemaDefinition: java.util.UUID - engineParameters: - executorParameters: - JAVASCRIPT: - parameterClassName: org.onap.policy.apex.plugins.executor.javascript.JavascriptExecutorParameters - contextParameters: - parameterClassName: org.onap.policy.apex.context.parameters.ContextParameters - schemaParameters: - Avro: - parameterClassName: org.onap.policy.apex.plugins.context.schema.avro.AvroSchemaHelperParameters - Java: - parameterClassName: org.onap.policy.apex.context.impl.schema.java.JavaSchemaHelperParameters - jsonAdapters: - Instant: - adaptedClass: java.time.Instant - adaptorClass: org.onap.policy.controlloop.util.Serialization$GsonInstantAdapter - eventInputParameters: - DCAEConsumer: - carrierTechnologyParameters: - carrierTechnology: RESTCLIENT - parameterClassName: org.onap.policy.apex.plugins.event.carrier.restclient.RestClientCarrierTechnologyParameters - parameters: - consumerPollTime: '50' - url: https://message-router:3905/events/unauthenticated.DCAE_CL_OUTPUT/cg1/sg1 - eventProtocolParameters: - eventProtocol: JSON - parameters: - nameAlias: policyName - eventName: pmsh-operational-policy - eventNameFilter: pmsh-operational-policy - CDSRequestConsumer: - carrierTechnologyParameters: - carrierTechnology: RESTREQUESTOR - parameterClassName: org.onap.policy.apex.plugins.event.carrier.restrequestor.RestRequestorCarrierTechnologyParameters - parameters: - url: http://10.10.10.184:30254/api/v1/execution-service/process - httpMethod: POST - restRequestTimeout: 2000 - httpHeaders: - - - Authorization - - Basic Y2NzZGthcHBzOmNjc2RrYXBwcw== - eventProtocolParameters: - eventProtocol: JSON - eventName: CDSCreateResponseEvent - eventNameFilter: CDSCreateResponseEvent - requestorMode: true - requestorPeer: CDSRequestProducer - requestorTimeout: 500 - CDSDeleteRequestConsumer: - carrierTechnologyParameters: - carrierTechnology: RESTREQUESTOR - parameterClassName: org.onap.policy.apex.plugins.event.carrier.restrequestor.RestRequestorCarrierTechnologyParameters - parameters: - url: http://10.10.10.184:30254/api/v1/execution-service/process - httpMethod: POST - restRequestTimeout: 2000 - httpHeaders: - - - Authorization - - Basic Y2NzZGthcHBzOmNjc2RrYXBwcw== - eventProtocolParameters: - eventProtocol: JSON - eventName: CDSDeleteResponseEvent - eventNameFilter: CDSDeleteResponseEvent - requestorMode: true - requestorPeer: CDSDeleteRequestProducer - requestorTimeout: 500 - CDSReplyConsumer: - carrierTechnologyParameters: - carrierTechnology: RESTREQUESTOR - parameterClassName: org.onap.policy.apex.plugins.event.carrier.restrequestor.RestRequestorCarrierTechnologyParameters - parameters: - url: https://message-router:3905/events/unauthenticated.PMSH_CL_INPUT - httpMethod: POST - restRequestTimeout: 2000 - eventProtocolParameters: - eventProtocol: JSON - eventName: MRResponseEvent - eventNameFilter: MRResponseEvent - requestorMode: true - requestorPeer: CDSReplyProducer - requestorTimeout: 500 - eventOutputParameters: - logOutputter: - carrierTechnologyParameters: - carrierTechnology: FILE - parameters: - fileName: "/tmp/outputevents.log" - eventProtocolParameters: - eventProtocol: JSON - StdOutOutputter: - carrierTechnologyParameters: - carrierTechnology: FILE - parameters: - standardIo: true - eventProtocolParameters: - eventProtocol: JSON - CDSRequestProducer: - carrierTechnologyParameters: - carrierTechnology: RESTREQUESTOR - parameterClassName: org.onap.policy.apex.plugins.event.carrier.restrequestor.RestRequestorCarrierTechnologyParameters - eventProtocolParameters: - eventProtocol: JSON - eventNameFilter: CDSCreateSubscriptionRequestEvent - requestorMode: true - requestorPeer: CDSRequestConsumer - requestorTimeout: 500 - CDSDeleteRequestProducer: - carrierTechnologyParameters: - carrierTechnology: RESTREQUESTOR - parameterClassName: org.onap.policy.apex.plugins.event.carrier.restrequestor.RestRequestorCarrierTechnologyParameters - eventProtocolParameters: - eventProtocol: JSON - eventNameFilter: CDSDeleteSubscriptionRequestEvent - requestorMode: true - requestorPeer: CDSDeleteRequestConsumer - requestorTimeout: 500 - CDSReplyProducer: - carrierTechnologyParameters: - carrierTechnology: RESTREQUESTOR - parameterClassName: org.onap.policy.apex.plugins.event.carrier.restrequestor.RestRequestorCarrierTechnologyParameters - eventProtocolParameters: - eventProtocol: JSON - eventNameFilter: CDSResponseStatusEvent - requestorMode: true - requestorPeer: CDSReplyConsumer - requestorTimeout: 500 diff --git a/common/src/test/resources/examples/controlloop/PMSubscriptionHandling.yaml b/common/src/test/resources/examples/controlloop/PMSubscriptionHandling.yaml deleted file mode 100644 index 8e8f3cd39..000000000 --- a/common/src/test/resources/examples/controlloop/PMSubscriptionHandling.yaml +++ /dev/null @@ -1,3325 +0,0 @@ -# ============LICENSE_START======================================================= -# Copyright (C) 2021 Nordix Foundation. -# ================================================================================ -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# -# SPDX-License-Identifier: Apache-2.0 -# ============LICENSE_END========================================================= -tosca_definitions_version: tosca_simple_yaml_1_3 -data_types: - onap.datatypes.ToscaConceptIdentifier: - derived_from: tosca.datatypes.Root - properties: - name: - type: string - required: true - version: - type: string - required: true - org.onap.datatypes.policy.clamp.controlloop.DCAEMicroserviceControlLoopElementConsulInfo: - name: org.onap.datatypes.policy.clamp.controlloop.DCAEMicroserviceControlLoopElementConsulInfo - version: 0.0.0 - derived_from: tosca.datatypes.Root - properties: - consulUrl: - name: consulUrl - type: string - typeVersion: 0.0.0 - description: Consul url for this entry - required: true - consul_body: - name: consulBody - type: string - typeVersion: 0.0.0 - description: Body of Consul entry - required: true - onap.datatypes.monitoring.managedObjectDNsBasic: - constraints: [] - properties: - DN: - name: DN - type: string - typeVersion: 0.0.0 - description: Managed object distinguished name - required: true - constraints: [] - metadata: {} - name: onap.datatypes.monitoring.managedObjectDNsBasic - version: 0.0.0 - derived_from: tosca.datatypes.Root - metadata: {} - onap.datatypes.monitoring.managedObjectDNsBasics: - constraints: [] - properties: - managedObjectDNsBasic: - name: managedObjectDNsBasic - type: map - typeVersion: 0.0.0 - description: Managed object distinguished name object - required: true - constraints: [] - entry_schema: - type: onap.datatypes.monitoring.managedObjectDNsBasic - typeVersion: 0.0.0 - constraints: [] - metadata: {} - name: onap.datatypes.monitoring.managedObjectDNsBasics - version: 0.0.0 - derived_from: tosca.datatypes.Root - metadata: {} - onap.datatypes.monitoring.measurementGroup: - constraints: [] - properties: - measurementTypes: - name: measurementTypes - type: list - typeVersion: 0.0.0 - description: List of measurement types - required: true - constraints: [] - entry_schema: - type: onap.datatypes.monitoring.measurementTypes - typeVersion: 0.0.0 - constraints: [] - metadata: {} - managedObjectDNsBasic: - name: managedObjectDNsBasic - type: list - typeVersion: 0.0.0 - description: List of managed object distinguished names - required: true - constraints: [] - entry_schema: - type: onap.datatypes.monitoring.managedObjectDNsBasics - typeVersion: 0.0.0 - constraints: [] - metadata: {} - name: onap.datatypes.monitoring.measurementGroup - version: 0.0.0 - derived_from: tosca.datatypes.Root - metadata: {} - onap.datatypes.monitoring.measurementGroups: - constraints: [] - properties: - measurementGroup: - name: measurementGroup - type: map - typeVersion: 0.0.0 - description: Measurement Group - required: true - constraints: [] - entry_schema: - type: onap.datatypes.monitoring.measurementGroup - typeVersion: 0.0.0 - constraints: [] - metadata: {} - name: onap.datatypes.monitoring.measurementGroups - version: 0.0.0 - derived_from: tosca.datatypes.Root - metadata: {} - onap.datatypes.monitoring.measurementType: - constraints: [] - properties: - measurementType: - name: measurementType - type: string - typeVersion: 0.0.0 - description: Measurement type - required: true - constraints: [] - metadata: {} - name: onap.datatypes.monitoring.measurementType - version: 0.0.0 - derived_from: tosca.datatypes.Root - metadata: {} - onap.datatypes.monitoring.measurementTypes: - constraints: [] - properties: - measurementType: - name: measurementType - type: map - typeVersion: 0.0.0 - description: Measurement type object - required: true - constraints: [] - entry_schema: - type: onap.datatypes.monitoring.measurementType - typeVersion: 0.0.0 - constraints: [] - metadata: {} - name: onap.datatypes.monitoring.measurementTypes - version: 0.0.0 - derived_from: tosca.datatypes.Root - metadata: {} - onap.datatypes.monitoring.nfFilter: - constraints: [] - properties: - modelNames: - name: modelNames - type: list - typeVersion: 0.0.0 - description: List of model names - required: true - constraints: [] - entry_schema: - type: string - typeVersion: 0.0.0 - constraints: [] - metadata: {} - modelInvariantIDs: - name: modelInvariantIDs - type: list - typeVersion: 0.0.0 - description: List of model invariant IDs - required: true - constraints: [] - entry_schema: - type: string - typeVersion: 0.0.0 - constraints: [] - metadata: {} - modelVersionIDs: - name: modelVersionIDs - type: list - typeVersion: 0.0.0 - description: List of model version IDs - required: true - constraints: [] - entry_schema: - type: string - typeVersion: 0.0.0 - constraints: [] - metadata: {} - nfNames: - name: nfNames - type: list - typeVersion: 0.0.0 - description: List of network functions - required: true - constraints: [] - entry_schema: - type: string - typeVersion: 0.0.0 - constraints: [] - metadata: {} - name: onap.datatypes.monitoring.nfFilter - version: 0.0.0 - derived_from: tosca.datatypes.Root - metadata: {} - onap.datatypes.monitoring.subscription: - constraints: [] - properties: - measurementGroups: - name: measurementGroups - type: list - typeVersion: 0.0.0 - description: Measurement Groups - required: true - constraints: [] - entry_schema: - type: onap.datatypes.monitoring.measurementGroups - typeVersion: 0.0.0 - constraints: [] - metadata: {} - fileBasedGP: - name: fileBasedGP - type: integer - typeVersion: 0.0.0 - description: File based granularity period - required: true - constraints: [] - metadata: {} - fileLocation: - name: fileLocation - type: string - typeVersion: 0.0.0 - description: ROP file location - required: true - constraints: [] - metadata: {} - subscriptionName: - name: subscriptionName - type: string - typeVersion: 0.0.0 - description: Name of the subscription - required: true - constraints: [] - metadata: {} - administrativeState: - name: administrativeState - type: string - typeVersion: 0.0.0 - description: State of the subscription - required: true - constraints: - - valid_values: - - LOCKED - - UNLOCKED - metadata: {} - nfFilter: - name: nfFilter - type: map - typeVersion: 0.0.0 - description: Network function filter - required: true - constraints: [] - entry_schema: - type: onap.datatypes.monitoring.nfFilter - typeVersion: 0.0.0 - constraints: [] - metadata: {} - name: onap.datatypes.monitoring.subscription - version: 0.0.0 - derived_from: tosca.datatypes.Root - metadata: {} -policy_types: - onap.policies.Monitoring: - derived_from: tosca.policies.Root - description: a base policy type for all policies that govern monitoring provisioning - version: 1.0.0 - name: onap.policies.Monitoring - onap.policies.monitoring.dcae-pm-subscription-handler: - properties: - pmsh_policy: - name: pmsh_policy - type: onap.datatypes.monitoring.subscription - typeVersion: 0.0.0 - description: PMSH Policy JSON - required: false - constraints: [] - metadata: {} - name: onap.policies.monitoring.dcae-pm-subscription-handler - version: 1.0.0 - derived_from: onap.policies.Monitoring - metadata: {} -node_types: - org.onap.policy.clamp.controlloop.Participant: - version: 1.0.1 - derived_from: tosca.nodetypes.Root - properties: - provider: - type: string - required: false - org.onap.policy.clamp.controlloop.ControlLoopElement: - version: 1.0.1 - derived_from: tosca.nodetypes.Root - properties: - provider: - type: string - required: false - participantType: - type: onap.datatypes.ToscaConceptIdentifier - required: true - startPhase: - type: integer - required: false - constraints: - - greater-or-equal: 0 - metadata: - common: true - description: A value indicating the start phase in which this control loop element will be started, the - first start phase is zero. Control Loop Elements are started in their start_phase order and stopped - in reverse start phase order. Control Loop Elements with the same start phase are started and - stopped simultaneously - org.onap.policy.clamp.controlloop.ControlLoop: - version: 1.0.1 - derived_from: tosca.nodetypes.Root - properties: - provider: - type: string - required: false - elements: - type: list - required: true - entry_schema: - type: onap.datatypes.ToscaConceptIdentifier - org.onap.policy.clamp.controlloop.DCAEMicroserviceControlLoopElement: - version: 1.0.1 - derived_from: org.onap.policy.clamp.controlloop.ControlLoopElement - properties: - dcae_blueprint_id: - type: onap.datatypes.ToscaConceptIdentifier - required: false - dcae_blueprint: - type: onap.dcae.cloudify_blueprint - required: false - consul_info: - type: list - required: false - entry_schema: - type: org.onap.datatypes.policy.clamp.controlloop.DCAEMicroserviceControlLoopElementConsulInfo - org.onap.policy.clamp.controlloop.PolicyControlLoopElement: - version: 1.0.1 - derived_from: org.onap.policy.clamp.controlloop.ControlLoopElement - properties: - policy_type_id: - type: onap.datatypes.ToscaConceptIdentifier - required: true - policy_id: - type: onap.datatypes.ToscaConceptIdentifier - required: false - org.onap.policy.clamp.controlloop.CDSControlLoopElement: - version: 1.0.1 - derived_from: org.onap.policy.clamp.controlloop.ControlLoopElement - properties: - cds_blueprint_id: - type: onap.datatypes.ToscaConceptIdentifier - required: true -topology_template: - inputs: - pmsh_monitoring_policy: - type: onap.datatypes.ToscaConceptIdentifier - description: The ID of the PMSH monitoring policy to use - default: - name: MICROSERVICE_vLoadBalancerMS_v1_0_dcae-pm-subscription-handler_1_0_0test - version: 1.0.0 - pmsh_operational_policy: - type: onap.datatypes.ToscaConceptIdentifier - description: The ID of the PMSH operational policy to use - default: - name: operational.apex.pmcontrol - version: 1.0.0 - node_templates: - org.onap.dcae.controlloop.DCAEMicroserviceControlLoopParticipant: - version: 2.3.4 - type: org.onap.policy.clamp.controlloop.Participant - type_version: 1.0.1 - description: Participant for DCAE microservices - properties: - provider: ONAP - org.onap.policy.controlloop.PolicyControlLoopParticipant: - version: 2.3.1 - type: org.onap.policy.clamp.controlloop.Participant - type_version: 1.0.1 - description: Participant for DCAE microservices - properties: - provider: ONAP - org.onap.ccsdk.cds.controlloop.CdsControlLoopParticipant: - version: 2.2.1 - type: org.onap.policy.clamp.controlloop.Participant - type_version: 1.0.1 - description: Participant for DCAE microservices - properties: - provider: ONAP - org.onap.domain.pmsh.PMSH_DCAEMicroservice: - version: 1.2.3 - type: org.onap.policy.clamp.controlloop.DCAEMicroserviceControlLoopElement - type_version: 1.0.0 - description: Control loop element for the DCAE microservice for Performance Management Subscription Handling - properties: - provider: Ericsson - participantType: - name: org.onap.dcae.controlloop.DCAEMicroserviceControlLoopParticipant - version: 2.3.4 - dcae_blueprint: - tosca_definitions_version: cloudify_dsl_1_3 - imports: - - https://www.getcloudify.org/spec/cloudify/4.5.5/types.yaml - - plugin:k8splugin?version=3.7.0 - - plugin:pgaas?version=1.3.0 - - plugin:clamppolicyplugin?version=1.1.0 - inputs: - tag_version: - type: string - description: Docker image to be used - default: nexus3.onap.org:10001/onap/org.onap.dcaegen2.services.pmsh:1.1.2 - replicas: - type: integer - description: Number of instances - default: 1 - operational_policy_name: - type: string - default: operational.apex.pmcontrol - control_loop_name: - type: string - default: pmsh-control-loop - pmsh_publish_topic_name: - type: string - default: unauthenticated.DCAE_CL_OUTPUT - policy_feedback_topic_name: - type: string - default: unauthenticated.PMSH_CL_INPUT - aai_notification_topic_name: - type: string - default: AAI-EVENT - publisher_client_role: - type: string - description: Client role to request secure access to topic - default: org.onap.dcae.pmPublisher - subscriber_client_role: - type: string - description: Client role to request secure access to topic - default: org.onap.dcae.pmSubscriber - dcae_location: - type: string - description: DCAE location for the subscriber, used to set up routing - default: san-francisco - cpu_limit: - type: string - default: 1000m - cpu_request: - type: string - default: 1000m - memory_limit: - type: string - default: 1024Mi - memory_request: - type: string - default: 1024Mi - pgaas_cluster_name: - type: string - default: dcae-pg-primary.onap - enable_tls: - type: boolean - default: true - protocol: - type: string - description: PMSH protocol. If enable_tls is false, set to http - default: https - policy_model_id: - type: string - default: onap.policies.monitoring.dcae-pm-subscription-handler - policy_id: - type: string - default: MICROSERVICE_vLoadBalancerMS_v1_0_dcae-pm-subscription-handler_1_0_0test - node_templates: - pgaasvm: - type: dcae.nodes.pgaas.database - properties: - writerfqdn: - get_input: pgaas_cluster_name - name: pmsh - pmsh: - type: dcae.nodes.ContainerizedServiceComponentUsingDmaap - interfaces: - cloudify.interfaces.lifecycle: - create: - inputs: - ports: - - '8443:0' - envs: - PMSH_PG_URL: - get_attribute: - - pgaasvm - - admin - - host - PMSH_PG_PASSWORD: - get_attribute: - - pgaasvm - - admin - - password - PMSH_PG_USERNAME: - get_attribute: - - pgaasvm - - admin - - user - PMSH_DB_NAME: - get_attribute: - - pgaasvm - - admin - - database - relationships: - - target: pmsh-policy - type: cloudify.relationships.depends_on - properties: - service_component_type: dcae-pmsh - service_component_name_override: dcae-pmsh - application_config: - enable_tls: - get_input: enable_tls - aaf_identity: dcae@dcae.onap.org - aaf_password: demo123456! - operational_policy_name: - get_input: operational_policy_name - control_loop_name: - get_input: control_loop_name - cert_path: /opt/app/pmsh/etc/certs/cert.pem - key_path: /opt/app/pmsh/etc/certs/key.pem - ca_cert_path: /opt/app/pmsh/etc/certs/cacert.pem - streams_publishes: - policy_pm_publisher: - type: message_router - dmaap_info: - topic_url: - concat: - - http://message-router:3904/events/ - - get_input: pmsh_publish_topic_name - streams_subscribes: - policy_pm_subscriber: - type: message_router - dmaap_info: - topic_url: - concat: - - http://message-router:3904/events/ - - get_input: policy_feedback_topic_name - aai_subscriber: - type: message_router - dmaap_info: - topic_url: - concat: - - http://message-router:3904/events/ - - get_input: aai_notification_topic_name - resource_config: - limits: - cpu: - get_input: cpu_limit - memory: - get_input: memory_limit - requests: - cpu: - get_input: cpu_request - memory: - get_input: memory_request - docker_config: - healthcheck: - endpoint: /healthcheck - interval: 15s - timeout: 1s - type: - get_input: protocol - image: - get_input: tag_version - replicas: - get_input: replicas - log_info: - log_directory: /var/log/ONAP/dcaegen2/services/pmsh - tls_info: - cert_directory: /opt/app/pmsh/etc/certs - use_tls: - get_input: enable_tls - pmsh-policy: - type: clamp.nodes.policy - properties: - policy_model_id: - get_input: policy_model_id - policy_id: - get_input: policy_id - consul_info: - - consulUrl: http://consul:31321/v1/kv/dcae-pmsh:policy - consulBody: - subscription: - subscriptionName: subscriptiona - administrativeState: UNLOCKED - fileBasedGP: 15 - fileLocation: /pm/pm.xml - nfFilter: - nfNames: - - ^pnf1.* - modelInvariantIDs: - - 5845y423-g654-6fju-po78-8n53154532k6 - - 7129e420-d396-4efb-af02-6b83499b12f8 - modelVersionIDs: - - e80a6ae3-cafd-4d24-850d-e14c084a5ca9 - measurementGroups: - - measurementGroup: - measurementTypes: - - measurementType: countera - - measurementType: counterb - managedObjectDNsBasic: - - DN: dna - - DN: dnb - - measurementGroup: - measurementTypes: - - measurementType: counterc - - measurementType: counterd - managedObjectDNsBasic: - - DN: dnc - - DN: dnd - org.onap.domain.pmsh.PMSH_MonitoringPolicyControlLoopElement: - version: 1.2.3 - type: org.onap.policy.clamp.controlloop.PolicyControlLoopElement - type_version: 1.0.0 - description: Control loop element for the monitoring policy for Performance Management Subscription Handling - properties: - provider: Ericsson - participantType: - name: org.onap.policy.controlloop.PolicyControlLoopParticipant - version: 2.3.1 - policy_type_id: - name: onap.policies.monitoring.pm-subscription-handler - version: 1.0.0 - policy_id: - get_input: pmsh_monitoring_policy - org.onap.domain.pmsh.PMSH_OperationalPolicyControlLoopElement: - version: 1.2.3 - type: org.onap.policy.clamp.controlloop.PolicyControlLoopElement - type_version: 1.0.0 - description: Control loop element for the operational policy for Performance Management Subscription Handling - properties: - provider: Ericsson - participantType: - name: org.onap.policy.controlloop.PolicyControlLoopParticipant - version: 2.2.1 - policy_type_id: - name: onap.policies.operational.pm-subscription-handler - version: 1.0.0 - policy_id: - get_input: pmsh_operational_policy - org.onap.domain.pmsh.PMSH_CDS_ControlLoopElement: - version: 1.2.3 - type: org.onap.policy.clamp.controlloop.CDSControlLoopElement - type_version: 1.0.0 - description: Control loop element for CDS for Performance Management Subscription Handling - properties: - provider: Ericsson - participantType: - name: org.onap.ccsdk.cds.controlloop.CdsControlLoopParticipant - version: 3.2.1 - cds_blueprint_id: - name: org.onap.ccsdk.cds.PMSHCdsBlueprint - version: 1.0.0 - org.onap.domain.pmsh.PMSHControlLoopDefinition: - version: 1.2.3 - type: org.onap.policy.clamp.controlloop.ControlLoop - type_version: 1.0.0 - description: Control loop for Performance Management Subscription Handling - properties: - provider: Ericsson - elements: - - name: org.onap.domain.pmsh.PMSH_DCAEMicroservice - version: 1.2.3 - - name: org.onap.domain.pmsh.PMSH_MonitoringPolicyControlLoopElement - version: 1.2.3 - - name: org.onap.domain.pmsh.PMSH_OperationalPolicyControlLoopElement - version: 1.2.3 - - name: org.onap.domain.pmsh.PMSH_CDS_ControlLoopElement - version: 1.2.3 - policies: - - MICROSERVICE_vLoadBalancerMS_v1_0_dcae-pm-subscription-handler_1_0_0test: - type: onap.policies.monitoring.dcae-pm-subscription-handler - type_version: 1.0.0 - name: MICROSERVICE_vLoadBalancerMS_v1_0_dcae-pm-subscription-handler_1_0_0test - version: 1.0.0 - metadata: - policy-id: MICROSERVICE_vLoadBalancerMS_v1_0_dcae-pm-subscription-handler_1_0_0test - policy-version: 1.0.0 - properties: - pmsh_policy: - fileBasedGP: 15 - fileLocation: /pm/pm.xml - subscriptionName: subscriptiona - administrativeState: UNLOCKED - nfFilter: - onap.datatypes.monitoring.nfFilter: - modelVersionIDs: - - e80a6ae3-cafd-4d24-850d-e14c084a5ca9 - modelInvariantIDs: - - 5845y423-g654-6fju-po78-8n53154532k6 - - 7129e420-d396-4efb-af02-6b83499b12f8 - modelNames: [] - nfNames: - - '"^pnf1.*"' - measurementGroups: - - measurementGroup: - onap.datatypes.monitoring.measurementGroup: - measurementTypes: - - measurementType: - onap.datatypes.monitoring.measurementType: - measurementType: countera - - measurementType: - onap.datatypes.monitoring.measurementType: - measurementType: counterb - managedObjectDNsBasic: - - managedObjectDNsBasic: - onap.datatypes.monitoring.managedObjectDNsBasic: - DN: dna - - managedObjectDNsBasic: - onap.datatypes.monitoring.managedObjectDNsBasic: - DN: dnb - - measurementGroup: - onap.datatypes.monitoring.measurementGroup: - measurementTypes: - - measurementType: - onap.datatypes.monitoring.measurementType: - measurementType: counterc - - measurementType: - onap.datatypes.monitoring.measurementType: - measurementType: counterd - managedObjectDNsBasic: - - managedObjectDNsBasic: - onap.datatypes.monitoring.managedObjectDNsBasic: - DN: dnc - - managedObjectDNsBasic: - onap.datatypes.monitoring.managedObjectDNsBasic: - DN: dnd - - operational.apex.pmcontrol: - type: onap.policies.controlloop.operational.common.Apex - type_version: 1.0.0 - version: 1.0.0 - metadata: - policy-id: operational.apex.pmcontrol - policy-version: 1 - properties: - engineServiceParameters: - name: MyApexEngine - version: 0.0.1 - id: 45 - instanceCount: 2 - deploymentPort: 12561 - policy_type_impl: - apexPolicyModel: - key: - name: PMControlPolicy - version: 0.0.1 - keyInformation: - key: - name: PMControlPolicy_KeyInfo - version: 0.0.1 - keyInfoMap: - entry: - - key: - name: CDSActionIdentifiersType - version: 0.0.1 - value: - key: - name: CDSActionIdentifiersType - version: 0.0.1 - UUID: 6e5fa19b-14df-37e3-a4ae-8c537e861a82 - description: Generated description for concept referred to by key "CDSActionIdentifiersType:0.0.1" - - key: - name: CDSCreateResponseEvent - version: 0.0.1 - value: - key: - name: CDSCreateResponseEvent - version: 0.0.1 - UUID: 14b29e38-ac75-3273-aa4e-8583c0aa7dad - description: Generated description for concept referred to by key "CDSCreateResponseEvent:0.0.1" - - key: - name: CDSCreateResponsePayloadType - version: 0.0.1 - value: - key: - name: CDSCreateResponsePayloadType - version: 0.0.1 - UUID: 04573f8f-e772-30a5-b1d9-d7318d4a1e13 - description: Generated description for concept referred to by key "CDSCreateResponsePayloadType:0.0.1" - - key: - name: CDSCreateResponsePolicy - version: 0.0.1 - value: - key: - name: CDSCreateResponsePolicy - version: 0.0.1 - UUID: e126c965-fc09-3bfe-8f55-70f380a4a49c - description: Generated description for concept referred to by key "CDSCreateResponsePolicy:0.0.1" - - key: - name: CDSCreateResponseTask - version: 0.0.1 - value: - key: - name: CDSCreateResponseTask - version: 0.0.1 - UUID: 6165ee82-afd2-3aab-a517-f00b3f2461d2 - description: Generated description for concept referred to by key "CDSCreateResponseTask:0.0.1" - - key: - name: CDSCreateSubscriptionPayloadType - version: 0.0.1 - value: - key: - name: CDSCreateSubscriptionPayloadType - version: 0.0.1 - UUID: 8350ac5e-c157-38b9-9614-a0f93a830e60 - description: Generated description for concept referred to by key "CDSCreateSubscriptionPayloadType:0.0.1" - - key: - name: CDSCreateSubscriptionRequestEvent - version: 0.0.1 - value: - key: - name: CDSCreateSubscriptionRequestEvent - version: 0.0.1 - UUID: cfa325ba-226b-3a31-9183-ec43e2b6e9a2 - description: Generated description for concept referred to by key "CDSCreateSubscriptionRequestEvent:0.0.1" - - key: - name: CDSDeleteResponseEvent - version: 0.0.1 - value: - key: - name: CDSDeleteResponseEvent - version: 0.0.1 - UUID: 8be9c0fa-7437-3841-aff2-b3cec6ae3bd8 - description: Generated description for concept referred to by key "CDSDeleteResponseEvent:0.0.1" - - key: - name: CDSDeleteResponsePayloadType - version: 0.0.1 - value: - key: - name: CDSDeleteResponsePayloadType - version: 0.0.1 - UUID: 3fbfe0c9-152e-34d3-a504-09cd13c058d0 - description: Generated description for concept referred to by key "CDSDeleteResponsePayloadType:0.0.1" - - key: - name: CDSDeleteResponsePolicy - version: 0.0.1 - value: - key: - name: CDSDeleteResponsePolicy - version: 0.0.1 - UUID: a780251c-edd5-3132-b865-04313246b43c - description: Generated description for concept referred to by key "CDSDeleteResponsePolicy:0.0.1" - - key: - name: CDSDeleteResponseTask - version: 0.0.1 - value: - key: - name: CDSDeleteResponseTask - version: 0.0.1 - UUID: afce4555-3aa3-3521-a7d8-ee8cdf0d3efc - description: Generated description for concept referred to by key "CDSDeleteResponseTask:0.0.1" - - key: - name: CDSDeleteSubscriptionPayloadType - version: 0.0.1 - value: - key: - name: CDSDeleteSubscriptionPayloadType - version: 0.0.1 - UUID: 12658406-9147-3c9d-a38c-5ad5e30b092b - description: Generated description for concept referred to by key "CDSDeleteSubscriptionPayloadType:0.0.1" - - key: - name: CDSDeleteSubscriptionRequestEvent - version: 0.0.1 - value: - key: - name: CDSDeleteSubscriptionRequestEvent - version: 0.0.1 - UUID: 24380c95-9289-36e6-8cbf-0edefa15ccd9 - description: Generated description for concept referred to by key "CDSDeleteSubscriptionRequestEvent:0.0.1" - - key: - name: CDSRequestCommonHeaderType - version: 0.0.1 - value: - key: - name: CDSRequestCommonHeaderType - version: 0.0.1 - UUID: 35590ac0-062c-39f1-8786-b4ff716e30b1 - description: Generated description for concept referred to by key "CDSRequestCommonHeaderType:0.0.1" - - key: - name: CDSResponseCommonHeaderType - version: 0.0.1 - value: - key: - name: CDSResponseCommonHeaderType - version: 0.0.1 - UUID: dd7e1805-885a-350b-aaf9-ed541321ae3c - description: Generated description for concept referred to by key "CDSResponseCommonHeaderType:0.0.1" - - key: - name: CDSResponseStatusEvent - version: 0.0.1 - value: - key: - name: CDSResponseStatusEvent - version: 0.0.1 - UUID: 7986e21b-32f7-302e-9554-31f21b673493 - description: Generated description for concept referred to by key "CDSResponseStatusEvent:0.0.1" - - key: - name: CDSResponseStatusType - version: 0.0.1 - value: - key: - name: CDSResponseStatusType - version: 0.0.1 - UUID: 92b8a2cf-344e-3ce1-8cc0-2b7d3cb695fa - description: Generated description for concept referred to by key "CDSResponseStatusType:0.0.1" - - key: - name: CreateSubscriptionPayloadEvent - version: 0.0.1 - value: - key: - name: CreateSubscriptionPayloadEvent - version: 0.0.1 - UUID: 92162397-1a8e-3a3f-a469-d2af7700af4a - description: Generated description for concept referred to by key "CreateSubscriptionPayloadEvent:0.0.1" - - key: - name: CreateSubscriptionPayloadTask - version: 0.0.1 - value: - key: - name: CreateSubscriptionPayloadTask - version: 0.0.1 - UUID: bc0c69f0-52ed-38ea-b468-ae4a6fd1730d - description: Generated description for concept referred to by key "CreateSubscriptionPayloadTask:0.0.1" - - key: - name: CreateSubscriptionRequestTask - version: 0.0.1 - value: - key: - name: CreateSubscriptionRequestTask - version: 0.0.1 - UUID: 89cb75e9-f06c-30d3-b4ff-698d45f63869 - description: Generated description for concept referred to by key "CreateSubscriptionRequestTask:0.0.1" - - key: - name: DeleteSubscriptionPayloadEvent - version: 0.0.1 - value: - key: - name: DeleteSubscriptionPayloadEvent - version: 0.0.1 - UUID: 994fa441-04ab-33bb-832d-1cd12ab5d074 - description: Generated description for concept referred to by key "DeleteSubscriptionPayloadEvent:0.0.1" - - key: - name: DeleteSubscriptionPayloadTask - version: 0.0.1 - value: - key: - name: DeleteSubscriptionPayloadTask - version: 0.0.1 - UUID: 0f519117-5fea-3e4b-941f-8f778100465f - description: Generated description for concept referred to by key "DeleteSubscriptionPayloadTask:0.0.1" - - key: - name: DeleteSubscriptionRequestTask - version: 0.0.1 - value: - key: - name: DeleteSubscriptionRequestTask - version: 0.0.1 - UUID: acb772fe-d442-39e3-98f9-b1080caf4150 - description: Generated description for concept referred to by key "DeleteSubscriptionRequestTask:0.0.1" - - key: - name: MRResponseEvent - version: 0.0.1 - value: - key: - name: MRResponseEvent - version: 0.0.1 - UUID: 13c747a3-6bae-3bcf-9c80-b152e01dc194 - description: Generated description for concept referred to by key "MRResponseEvent:0.0.1" - - key: - name: PMControlPolicy - version: 0.0.1 - value: - key: - name: PMControlPolicy - version: 0.0.1 - UUID: acf1e55c-7bc5-3bd5-975a-0ca54afcd8a4 - description: Generated description for concept referred to by key "PMControlPolicy:0.0.1" - - key: - name: PMControlPolicy_Albums - version: 0.0.1 - value: - key: - name: PMControlPolicy_Albums - version: 0.0.1 - UUID: b38ad204-c2c8-32f4-9b5a-dda0aeb0145b - description: Generated description for concept referred to by key "PMControlPolicy_Albums:0.0.1" - - key: - name: PMControlPolicy_Events - version: 0.0.1 - value: - key: - name: PMControlPolicy_Events - version: 0.0.1 - UUID: be3871a0-c42a-3113-a066-82d192840eca - description: Generated description for concept referred to by key "PMControlPolicy_Events:0.0.1" - - key: - name: PMControlPolicy_KeyInfo - version: 0.0.1 - value: - key: - name: PMControlPolicy_KeyInfo - version: 0.0.1 - UUID: ced37634-28a4-3178-b7f6-2980794927b0 - description: Generated description for concept referred to by key "PMControlPolicy_KeyInfo:0.0.1" - - key: - name: PMControlPolicy_Policies - version: 0.0.1 - value: - key: - name: PMControlPolicy_Policies - version: 0.0.1 - UUID: be3d180d-ef9c-3a75-8e9c-84271a038bed - description: Generated description for concept referred to by key "PMControlPolicy_Policies:0.0.1" - - key: - name: PMControlPolicy_Schemas - version: 0.0.1 - value: - key: - name: PMControlPolicy_Schemas - version: 0.0.1 - UUID: e61973f1-189c-39e5-82f6-0d3afe298a20 - description: Generated description for concept referred to by key "PMControlPolicy_Schemas:0.0.1" - - key: - name: PMControlPolicy_Tasks - version: 0.0.1 - value: - key: - name: PMControlPolicy_Tasks - version: 0.0.1 - UUID: 5658adb3-2962-30a3-a241-fae75bb8eb4a - description: Generated description for concept referred to by key "PMControlPolicy_Tasks:0.0.1" - - key: - name: PMSubscriptionAlbum - version: 0.0.1 - value: - key: - name: PMSubscriptionAlbum - version: 0.0.1 - UUID: c2bd6f0d-6854-317a-9be2-97c08338428c - description: Generated description for concept referred to by key "PMSubscriptionAlbum:0.0.1" - - key: - name: PMSubscriptionOutputEvent - version: 0.0.1 - value: - key: - name: PMSubscriptionOutputEvent - version: 0.0.1 - UUID: 992b7819-9f69-3aa0-bb0f-6e45ea15ce05 - description: Generated description for concept referred to by key "PMSubscriptionOutputEvent:0.0.1" - - key: - name: PMSubscriptionType - version: 0.0.1 - value: - key: - name: PMSubscriptionType - version: 0.0.1 - UUID: 73c1c397-4fc3-357f-93b6-a8ad707fbaae - description: Generated description for concept referred to by key "PMSubscriptionType:0.0.1" - - key: - name: ReceiveEventPolicy - version: 0.0.1 - value: - key: - name: ReceiveEventPolicy - version: 0.0.1 - UUID: 568b7345-9de1-36d3-b6a3-9b857e6809a1 - description: Generated description for concept referred to by key "ReceiveEventPolicy:0.0.1" - - key: - name: ReceiveSubscriptionTask - version: 0.0.1 - value: - key: - name: ReceiveSubscriptionTask - version: 0.0.1 - UUID: f596afc8-100c-35eb-92c8-352355ea457d - description: Generated description for concept referred to by key "ReceiveSubscriptionTask:0.0.1" - - key: - name: SimpleIntType - version: 0.0.1 - value: - key: - name: SimpleIntType - version: 0.0.1 - UUID: 153791fd-ae0a-36a7-88a5-309a7936415d - description: Generated description for concept referred to by key "SimpleIntType:0.0.1" - - key: - name: SimpleStringType - version: 0.0.1 - value: - key: - name: SimpleStringType - version: 0.0.1 - UUID: 8a4957cf-9493-3a76-8c22-a208e23259af - description: Generated description for concept referred to by key "SimpleStringType:0.0.1" - - key: - name: SubscriptionStatusType - version: 0.0.1 - value: - key: - name: SubscriptionStatusType - version: 0.0.1 - UUID: 597643b1-9db1-31ce-85d0-e1c63c43b30b - description: Generated description for concept referred to by key "SubscriptionStatusType:0.0.1" - - key: - name: SubscriptionType - version: 0.0.1 - value: - key: - name: SubscriptionType - version: 0.0.1 - UUID: 184547bb-7d64-3cb2-a273-d7185102c5ce - description: Generated description for concept referred to by key "SubscriptionType:0.0.1" - - key: - name: UUIDType - version: 0.0.1 - value: - key: - name: UUIDType - version: 0.0.1 - UUID: 6a8cc68e-dfc8-3403-9c6d-071c886b319c - description: Generated description for concept referred to by key "UUIDType:0.0.1" - - key: - name: pmsh-operational-policy - version: 0.0.1 - value: - key: - name: pmsh-operational-policy - version: 0.0.1 - UUID: fdf2c9ff-6422-3ea6-b6b6-49b12116265d - description: Generated description for concept referred to by key "pmsh-operational-policy:0.0.1" - policies: - key: - name: PMControlPolicy_Policies - version: 0.0.1 - policyMap: - entry: - - key: - name: CDSCreateResponsePolicy - version: 0.0.1 - value: - policyKey: - name: CDSCreateResponsePolicy - version: 0.0.1 - template: Freestyle - state: - entry: - - key: CDSCreateResponseState - value: - stateKey: - parentKeyName: CDSCreateResponsePolicy - parentKeyVersion: 0.0.1 - parentLocalName: 'NULL' - localName: CDSCreateResponseState - trigger: - name: CDSCreateResponseEvent - version: 0.0.1 - stateOutputs: - entry: - - key: ResponseOutput - value: - key: - parentKeyName: CDSCreateResponsePolicy - parentKeyVersion: 0.0.1 - parentLocalName: CDSCreateResponseState - localName: ResponseOutput - outgoingEvent: - name: CDSResponseStatusEvent - version: 0.0.1 - nextState: - parentKeyName: 'NULL' - parentKeyVersion: 0.0.0 - parentLocalName: 'NULL' - localName: 'NULL' - contextAlbumReference: [] - taskSelectionLogic: - key: 'NULL' - logicFlavour: UNDEFINED - logic: '' - stateFinalizerLogicMap: - entry: [] - defaultTask: - name: CDSCreateResponseTask - version: 0.0.1 - taskReferences: - entry: - - key: - name: CDSCreateResponseTask - version: 0.0.1 - value: - key: - parentKeyName: CDSCreateResponsePolicy - parentKeyVersion: 0.0.1 - parentLocalName: CDSCreateResponseState - localName: CDSCreateResponsePolicy - outputType: DIRECT - output: - parentKeyName: CDSCreateResponsePolicy - parentKeyVersion: 0.0.1 - parentLocalName: CDSCreateResponseState - localName: ResponseOutput - firstState: CDSCreateResponseState - - key: - name: CDSDeleteResponsePolicy - version: 0.0.1 - value: - policyKey: - name: CDSDeleteResponsePolicy - version: 0.0.1 - template: Freestyle - state: - entry: - - key: CDSDeleteResponseState - value: - stateKey: - parentKeyName: CDSDeleteResponsePolicy - parentKeyVersion: 0.0.1 - parentLocalName: 'NULL' - localName: CDSDeleteResponseState - trigger: - name: CDSDeleteResponseEvent - version: 0.0.1 - stateOutputs: - entry: - - key: ResponseOutput - value: - key: - parentKeyName: CDSDeleteResponsePolicy - parentKeyVersion: 0.0.1 - parentLocalName: CDSDeleteResponseState - localName: ResponseOutput - outgoingEvent: - name: CDSResponseStatusEvent - version: 0.0.1 - nextState: - parentKeyName: 'NULL' - parentKeyVersion: 0.0.0 - parentLocalName: 'NULL' - localName: 'NULL' - contextAlbumReference: [] - taskSelectionLogic: - key: 'NULL' - logicFlavour: UNDEFINED - logic: '' - stateFinalizerLogicMap: - entry: [] - defaultTask: - name: CDSDeleteResponseTask - version: 0.0.1 - taskReferences: - entry: - - key: - name: CDSDeleteResponseTask - version: 0.0.1 - value: - key: - parentKeyName: CDSDeleteResponsePolicy - parentKeyVersion: 0.0.1 - parentLocalName: CDSDeleteResponseState - localName: CDSDeleteResponsePolicy - outputType: DIRECT - output: - parentKeyName: CDSDeleteResponsePolicy - parentKeyVersion: 0.0.1 - parentLocalName: CDSDeleteResponseState - localName: ResponseOutput - firstState: CDSDeleteResponseState - - key: - name: ReceiveEventPolicy - version: 0.0.1 - value: - policyKey: - name: ReceiveEventPolicy - version: 0.0.1 - template: Freestyle - state: - entry: - - key: CreateOrDeleteState - value: - stateKey: - parentKeyName: ReceiveEventPolicy - parentKeyVersion: 0.0.1 - parentLocalName: 'NULL' - localName: CreateOrDeleteState - trigger: - name: PMSubscriptionOutputEvent - version: 0.0.1 - stateOutputs: - entry: - - key: CreateSubscriptionPayload - value: - key: - parentKeyName: ReceiveEventPolicy - parentKeyVersion: 0.0.1 - parentLocalName: CreateOrDeleteState - localName: CreateSubscriptionPayload - outgoingEvent: - name: CreateSubscriptionPayloadEvent - version: 0.0.1 - nextState: - parentKeyName: ReceiveEventPolicy - parentKeyVersion: 0.0.1 - parentLocalName: 'NULL' - localName: CreateSubscription - - key: DeleteSubscriptionPayload - value: - key: - parentKeyName: ReceiveEventPolicy - parentKeyVersion: 0.0.1 - parentLocalName: CreateOrDeleteState - localName: DeleteSubscriptionPayload - outgoingEvent: - name: DeleteSubscriptionPayloadEvent - version: 0.0.1 - nextState: - parentKeyName: ReceiveEventPolicy - parentKeyVersion: 0.0.1 - parentLocalName: 'NULL' - localName: DeleteSubscription - contextAlbumReference: - - name: PMSubscriptionAlbum - version: 0.0.1 - taskSelectionLogic: - key: TaskSelectionLogic - logicFlavour: JAVASCRIPT - logic: |- - /* - * ============LICENSE_START======================================================= - * Copyright (C) 2020 Nordix. 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); - - var pmSubscriptionInfo = executor.getContextAlbum("PMSubscriptionAlbum").get(executor.inFields.get("albumID").toString()) - var changeType = pmSubscriptionInfo.get("changeType").toString() - - executor.logger.info("Change Type is " + changeType) - - if ("CREATE".equals(changeType)) { - executor.logger.info("Choosing to create a subscription") - executor.subject.getTaskKey("CreateSubscriptionPayloadTask").copyTo(executor.selectedTask); - } - else if ("DELETE".equals(changeType)) { - executor.logger.info("Choosing to delete a subscription") - executor.subject.getTaskKey("DeleteSubscriptionPayloadTask").copyTo(executor.selectedTask); - } - - //var returnValue = executor.isTrue; - true; - stateFinalizerLogicMap: - entry: [] - defaultTask: - name: CreateSubscriptionPayloadTask - version: 0.0.1 - taskReferences: - entry: - - key: - name: CreateSubscriptionPayloadTask - version: 0.0.1 - value: - key: - parentKeyName: ReceiveEventPolicy - parentKeyVersion: 0.0.1 - parentLocalName: CreateOrDeleteState - localName: ReceiveEventPolicy - outputType: DIRECT - output: - parentKeyName: ReceiveEventPolicy - parentKeyVersion: 0.0.1 - parentLocalName: CreateOrDeleteState - localName: CreateSubscriptionPayload - - key: - name: DeleteSubscriptionPayloadTask - version: 0.0.1 - value: - key: - parentKeyName: ReceiveEventPolicy - parentKeyVersion: 0.0.1 - parentLocalName: CreateOrDeleteState - localName: ReceiveEventPolicy - outputType: DIRECT - output: - parentKeyName: ReceiveEventPolicy - parentKeyVersion: 0.0.1 - parentLocalName: CreateOrDeleteState - localName: DeleteSubscriptionPayload - - key: CreateSubscription - value: - stateKey: - parentKeyName: ReceiveEventPolicy - parentKeyVersion: 0.0.1 - parentLocalName: 'NULL' - localName: CreateSubscription - trigger: - name: CreateSubscriptionPayloadEvent - version: 0.0.1 - stateOutputs: - entry: - - key: IssueCreateSubscriptionRequestOutput - value: - key: - parentKeyName: ReceiveEventPolicy - parentKeyVersion: 0.0.1 - parentLocalName: CreateSubscription - localName: IssueCreateSubscriptionRequestOutput - outgoingEvent: - name: CDSCreateSubscriptionRequestEvent - version: 0.0.1 - nextState: - parentKeyName: 'NULL' - parentKeyVersion: 0.0.0 - parentLocalName: 'NULL' - localName: 'NULL' - contextAlbumReference: - - name: PMSubscriptionAlbum - version: 0.0.1 - taskSelectionLogic: - key: 'NULL' - logicFlavour: UNDEFINED - logic: '' - stateFinalizerLogicMap: - entry: [] - defaultTask: - name: CreateSubscriptionRequestTask - version: 0.0.1 - taskReferences: - entry: - - key: - name: CreateSubscriptionRequestTask - version: 0.0.1 - value: - key: - parentKeyName: ReceiveEventPolicy - parentKeyVersion: 0.0.1 - parentLocalName: CreateSubscription - localName: ReceiveEventPolicy - outputType: DIRECT - output: - parentKeyName: ReceiveEventPolicy - parentKeyVersion: 0.0.1 - parentLocalName: CreateSubscription - localName: IssueCreateSubscriptionRequestOutput - - key: DeleteSubscription - value: - stateKey: - parentKeyName: ReceiveEventPolicy - parentKeyVersion: 0.0.1 - parentLocalName: 'NULL' - localName: DeleteSubscription - trigger: - name: DeleteSubscriptionPayloadEvent - version: 0.0.1 - stateOutputs: - entry: - - key: IssueDeleteSubscriptionRequestOutput - value: - key: - parentKeyName: ReceiveEventPolicy - parentKeyVersion: 0.0.1 - parentLocalName: DeleteSubscription - localName: IssueDeleteSubscriptionRequestOutput - outgoingEvent: - name: CDSDeleteSubscriptionRequestEvent - version: 0.0.1 - nextState: - parentKeyName: 'NULL' - parentKeyVersion: 0.0.0 - parentLocalName: 'NULL' - localName: 'NULL' - contextAlbumReference: - - name: PMSubscriptionAlbum - version: 0.0.1 - taskSelectionLogic: - key: 'NULL' - logicFlavour: UNDEFINED - logic: '' - stateFinalizerLogicMap: - entry: [] - defaultTask: - name: DeleteSubscriptionRequestTask - version: 0.0.1 - taskReferences: - entry: - - key: - name: DeleteSubscriptionRequestTask - version: 0.0.1 - value: - key: - parentKeyName: ReceiveEventPolicy - parentKeyVersion: 0.0.1 - parentLocalName: DeleteSubscription - localName: ReceiveEventPolicy - outputType: DIRECT - output: - parentKeyName: ReceiveEventPolicy - parentKeyVersion: 0.0.1 - parentLocalName: DeleteSubscription - localName: IssueDeleteSubscriptionRequestOutput - - key: ReceiveSubscriptionState - value: - stateKey: - parentKeyName: ReceiveEventPolicy - parentKeyVersion: 0.0.1 - parentLocalName: 'NULL' - localName: ReceiveSubscriptionState - trigger: - name: pmsh-operational-policy - version: 0.0.1 - stateOutputs: - entry: - - key: ReceivePMSubscriptionOutput - value: - key: - parentKeyName: ReceiveEventPolicy - parentKeyVersion: 0.0.1 - parentLocalName: ReceiveSubscriptionState - localName: ReceivePMSubscriptionOutput - outgoingEvent: - name: PMSubscriptionOutputEvent - version: 0.0.1 - nextState: - parentKeyName: ReceiveEventPolicy - parentKeyVersion: 0.0.1 - parentLocalName: 'NULL' - localName: CreateOrDeleteState - contextAlbumReference: - - name: PMSubscriptionAlbum - version: 0.0.1 - taskSelectionLogic: - key: 'NULL' - logicFlavour: UNDEFINED - logic: '' - stateFinalizerLogicMap: - entry: [] - defaultTask: - name: ReceiveSubscriptionTask - version: 0.0.1 - taskReferences: - entry: - - key: - name: ReceiveSubscriptionTask - version: 0.0.1 - value: - key: - parentKeyName: ReceiveEventPolicy - parentKeyVersion: 0.0.1 - parentLocalName: ReceiveSubscriptionState - localName: ReceiveEventPolicy - outputType: DIRECT - output: - parentKeyName: ReceiveEventPolicy - parentKeyVersion: 0.0.1 - parentLocalName: ReceiveSubscriptionState - localName: ReceivePMSubscriptionOutput - firstState: ReceiveSubscriptionState - tasks: - key: - name: PMControlPolicy_Tasks - version: 0.0.1 - taskMap: - entry: - - key: - name: CDSCreateResponseTask - version: 0.0.1 - value: - key: - name: CDSCreateResponseTask - version: 0.0.1 - inputFields: - entry: - - key: actionIdentifiers - value: - key: actionIdentifiers - fieldSchemaKey: - name: CDSActionIdentifiersType - version: 0.0.1 - optional: false - - key: commonHeader - value: - key: commonHeader - fieldSchemaKey: - name: CDSResponseCommonHeaderType - version: 0.0.1 - optional: false - - key: payload - value: - key: payload - fieldSchemaKey: - name: CDSCreateResponsePayloadType - version: 0.0.1 - optional: false - - key: status - value: - key: status - fieldSchemaKey: - name: CDSResponseStatusType - version: 0.0.1 - optional: false - outputFields: - entry: - - key: status - value: - key: status - fieldSchemaKey: - name: SubscriptionStatusType - version: 0.0.1 - optional: false - taskParameters: - entry: [] - contextAlbumReference: - - name: PMSubscriptionAlbum - version: 0.0.1 - taskLogic: - key: TaskLogic - logicFlavour: JAVASCRIPT - logic: |- - /* - * ============LICENSE_START======================================================= - * Copyright (C) 2020 Nordix. 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); - - var commonHeader = executor.inFields.get("commonHeader") - var response = executor.inFields.get("payload") - var albumID = commonHeader.get("requestId") - - var pmSubscriptionInfo = executor.getContextAlbum("PMSubscriptionAlbum").get(albumID.toString()); - var responseStatus = executor.subject.getOutFieldSchemaHelper("status").createNewInstance(); - - responseStatus.put("subscriptionName", pmSubscriptionInfo.get("subscription").get("subscriptionName")) - responseStatus.put("nfName", pmSubscriptionInfo.get("nfName")) - responseStatus.put("changeType", pmSubscriptionInfo.get("changeType")) - - var status = response.get(pmSubscriptionInfo.get("changeType").toLowerCase() + "_DasH_subscription_DasH_response").get("odl_DasH_response").get("status") - - executor.logger.info("RESPONSE STATUS = " + status) - - if(status == "success") { - responseStatus.put("message", "success") - } else { - responseStatus.put("message", "failed") - } - - executor.outFields.put("status", responseStatus) - - //var returnValue = executor.isTrue; - true; - - key: - name: CDSDeleteResponseTask - version: 0.0.1 - value: - key: - name: CDSDeleteResponseTask - version: 0.0.1 - inputFields: - entry: - - key: actionIdentifiers - value: - key: actionIdentifiers - fieldSchemaKey: - name: CDSActionIdentifiersType - version: 0.0.1 - optional: false - - key: commonHeader - value: - key: commonHeader - fieldSchemaKey: - name: CDSResponseCommonHeaderType - version: 0.0.1 - optional: false - - key: payload - value: - key: payload - fieldSchemaKey: - name: CDSDeleteResponsePayloadType - version: 0.0.1 - optional: false - - key: status - value: - key: status - fieldSchemaKey: - name: CDSResponseStatusType - version: 0.0.1 - optional: false - outputFields: - entry: - - key: status - value: - key: status - fieldSchemaKey: - name: SubscriptionStatusType - version: 0.0.1 - optional: false - taskParameters: - entry: [] - contextAlbumReference: - - name: PMSubscriptionAlbum - version: 0.0.1 - taskLogic: - key: TaskLogic - logicFlavour: JAVASCRIPT - logic: |- - /* - * ============LICENSE_START======================================================= - * Copyright (C) 2020 Nordix. 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); - - var commonHeader = executor.inFields.get("commonHeader") - var response = executor.inFields.get("payload") - var albumID = commonHeader.get("requestId") - - var pmSubscriptionInfo = executor.getContextAlbum("PMSubscriptionAlbum").get(albumID.toString()); - var responseStatus = executor.subject.getOutFieldSchemaHelper("status").createNewInstance(); - - responseStatus.put("subscriptionName", pmSubscriptionInfo.get("subscription").get("subscriptionName")) - responseStatus.put("nfName", pmSubscriptionInfo.get("nfName")) - responseStatus.put("changeType", pmSubscriptionInfo.get("changeType")) - - var status = response.get(pmSubscriptionInfo.get("changeType").toLowerCase() + "_DasH_subscription_DasH_response").get("odl_DasH_response").get("status") - - executor.logger.info("RESPONSE STATUS = " + status) - - if(status == "success") { - responseStatus.put("message", "success") - } else { - responseStatus.put("message", "failed") - } - - executor.outFields.put("status", responseStatus) - - //var returnValue = executor.isTrue; - true; - - key: - name: CreateSubscriptionPayloadTask - version: 0.0.1 - value: - key: - name: CreateSubscriptionPayloadTask - version: 0.0.1 - inputFields: - entry: - - key: albumID - value: - key: albumID - fieldSchemaKey: - name: UUIDType - version: 0.0.1 - optional: false - outputFields: - entry: - - key: albumID - value: - key: albumID - fieldSchemaKey: - name: UUIDType - version: 0.0.1 - optional: false - - key: payload - value: - key: payload - fieldSchemaKey: - name: CDSCreateSubscriptionPayloadType - version: 0.0.1 - optional: false - taskParameters: - entry: [] - contextAlbumReference: - - name: PMSubscriptionAlbum - version: 0.0.1 - taskLogic: - key: TaskLogic - logicFlavour: JAVASCRIPT - logic: |- - /* - * ============LICENSE_START======================================================= - * Copyright (C) 2020 Nordix. 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); - - var pmSubscriptionInfo = executor.getContextAlbum("PMSubscriptionAlbum").get(executor.inFields.get("albumID").toString()) - - var changeType = pmSubscriptionInfo.get("changeType").toLowerCase() - - var payloadProperties = executor.subject.getOutFieldSchemaHelper("payload").createNewSubInstance(changeType + "_DasH_subscription_DasH_properties_record"); - - payloadProperties.put("nfName", pmSubscriptionInfo.get("nfName")) - payloadProperties.put("subscriptionName", pmSubscriptionInfo.get("subscription").get("subscriptionName")) - payloadProperties.put("administrativeState", pmSubscriptionInfo.get("subscription").get("administrativeState")) - payloadProperties.put("fileBasedGP", pmSubscriptionInfo.get("subscription").get("fileBasedGP").toString()) - payloadProperties.put("fileLocation", pmSubscriptionInfo.get("subscription").get("fileLocation")) - payloadProperties.put("measurementGroups", pmSubscriptionInfo.get("subscription").get("measurementGroups")) - - var payloadEntry = executor.subject.getOutFieldSchemaHelper("payload").createNewSubInstance("CDSRequestPayloadEntry"); - payloadEntry.put(changeType + "_DasH_subscription_DasH_properties", payloadProperties) - - var payload = executor.subject.getOutFieldSchemaHelper("payload").createNewInstance(); - payload.put(changeType + "_DasH_subscription_DasH_request", payloadEntry); - - executor.outFields.put("albumID", executor.inFields.get("albumID")) - executor.outFields.put("payload", payload); - - //var returnValue = executor.isTrue; - true; - - key: - name: CreateSubscriptionRequestTask - version: 0.0.1 - value: - key: - name: CreateSubscriptionRequestTask - version: 0.0.1 - inputFields: - entry: - - key: albumID - value: - key: albumID - fieldSchemaKey: - name: UUIDType - version: 0.0.1 - optional: false - - key: payload - value: - key: payload - fieldSchemaKey: - name: CDSCreateSubscriptionPayloadType - version: 0.0.1 - optional: false - outputFields: - entry: - - key: actionIdentifiers - value: - key: actionIdentifiers - fieldSchemaKey: - name: CDSActionIdentifiersType - version: 0.0.1 - optional: false - - key: commonHeader - value: - key: commonHeader - fieldSchemaKey: - name: CDSRequestCommonHeaderType - version: 0.0.1 - optional: false - - key: payload - value: - key: payload - fieldSchemaKey: - name: CDSCreateSubscriptionPayloadType - version: 0.0.1 - optional: false - taskParameters: - entry: [] - contextAlbumReference: - - name: PMSubscriptionAlbum - version: 0.0.1 - taskLogic: - key: TaskLogic - logicFlavour: JAVASCRIPT - logic: |- - /* - * ============LICENSE_START======================================================= - * Copyright (C) 2020 Nordix. 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); - - var pmSubscriptionInfo = executor.getContextAlbum("PMSubscriptionAlbum").get(executor.inFields.get("albumID").toString()) - - var changeType = pmSubscriptionInfo.get("changeType").toLowerCase() - var blueprintName = pmSubscriptionInfo.get("blueprintName").toLowerCase() - var blueprintVersion = pmSubscriptionInfo.get("blueprintVersion").toLowerCase() - var payload = executor.inFields.get("payload") - var actionName = changeType + "-subscription" - - var commonHeader = executor.subject.getOutFieldSchemaHelper("commonHeader").createNewInstance(); - commonHeader.put("originatorId", "sdnc"); - commonHeader.put("requestId", executor.inFields.get("albumID").toString()); - commonHeader.put("subRequestId", "sub-123456-1000"); - - var actionIdentifiers = executor.subject.getOutFieldSchemaHelper("actionIdentifiers").createNewInstance(); - actionIdentifiers.put("actionName", actionName); - actionIdentifiers.put("blueprintName", blueprintName); - actionIdentifiers.put("blueprintVersion", blueprintVersion); - actionIdentifiers.put("mode", "sync"); - - executor.outFields.put("commonHeader", commonHeader); - executor.outFields.put("actionIdentifiers", actionIdentifiers); - executor.outFields.put("payload", payload); - - //var returnValue = executor.isTrue; - true; - - key: - name: DeleteSubscriptionPayloadTask - version: 0.0.1 - value: - key: - name: DeleteSubscriptionPayloadTask - version: 0.0.1 - inputFields: - entry: - - key: albumID - value: - key: albumID - fieldSchemaKey: - name: UUIDType - version: 0.0.1 - optional: false - outputFields: - entry: - - key: albumID - value: - key: albumID - fieldSchemaKey: - name: UUIDType - version: 0.0.1 - optional: false - - key: payload - value: - key: payload - fieldSchemaKey: - name: CDSDeleteSubscriptionPayloadType - version: 0.0.1 - optional: false - taskParameters: - entry: [] - contextAlbumReference: - - name: PMSubscriptionAlbum - version: 0.0.1 - taskLogic: - key: TaskLogic - logicFlavour: JAVASCRIPT - logic: |- - /* - * ============LICENSE_START======================================================= - * Copyright (C) 2020 Nordix. 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); - - var pmSubscriptionInfo = executor.getContextAlbum("PMSubscriptionAlbum").get(executor.inFields.get("albumID").toString()) - - var changeType = pmSubscriptionInfo.get("changeType").toLowerCase() - - var payloadProperties = executor.subject.getOutFieldSchemaHelper("payload").createNewSubInstance(changeType + "_DasH_subscription_DasH_properties_record"); - - payloadProperties.put("nfName", pmSubscriptionInfo.get("nfName")) - payloadProperties.put("subscriptionName", pmSubscriptionInfo.get("subscription").get("subscriptionName")) - payloadProperties.put("administrativeState", pmSubscriptionInfo.get("subscription").get("administrativeState")) - payloadProperties.put("fileBasedGP", pmSubscriptionInfo.get("subscription").get("fileBasedGP").toString()) - payloadProperties.put("fileLocation", pmSubscriptionInfo.get("subscription").get("fileLocation")) - payloadProperties.put("measurementGroups", pmSubscriptionInfo.get("subscription").get("measurementGroups")) - - var payloadEntry = executor.subject.getOutFieldSchemaHelper("payload").createNewSubInstance("CDSRequestPayloadEntry"); - payloadEntry.put(changeType + "_DasH_subscription_DasH_properties", payloadProperties) - - var payload = executor.subject.getOutFieldSchemaHelper("payload").createNewInstance(); - payload.put(changeType + "_DasH_subscription_DasH_request", payloadEntry); - - executor.outFields.put("albumID", executor.inFields.get("albumID")) - executor.outFields.put("payload", payload); - - //var returnValue = executor.isTrue; - true; - - key: - name: DeleteSubscriptionRequestTask - version: 0.0.1 - value: - key: - name: DeleteSubscriptionRequestTask - version: 0.0.1 - inputFields: - entry: - - key: albumID - value: - key: albumID - fieldSchemaKey: - name: UUIDType - version: 0.0.1 - optional: false - - key: payload - value: - key: payload - fieldSchemaKey: - name: CDSDeleteSubscriptionPayloadType - version: 0.0.1 - optional: false - outputFields: - entry: - - key: actionIdentifiers - value: - key: actionIdentifiers - fieldSchemaKey: - name: CDSActionIdentifiersType - version: 0.0.1 - optional: false - - key: commonHeader - value: - key: commonHeader - fieldSchemaKey: - name: CDSRequestCommonHeaderType - version: 0.0.1 - optional: false - - key: payload - value: - key: payload - fieldSchemaKey: - name: CDSDeleteSubscriptionPayloadType - version: 0.0.1 - optional: false - taskParameters: - entry: [] - contextAlbumReference: - - name: PMSubscriptionAlbum - version: 0.0.1 - taskLogic: - key: TaskLogic - logicFlavour: JAVASCRIPT - logic: |- - /* - * ============LICENSE_START======================================================= - * Copyright (C) 2020 Nordix. 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); - - var pmSubscriptionInfo = executor.getContextAlbum("PMSubscriptionAlbum").get(executor.inFields.get("albumID").toString()) - - var changeType = pmSubscriptionInfo.get("changeType").toLowerCase() - var blueprintName = pmSubscriptionInfo.get("blueprintName").toLowerCase() - var blueprintVersion = pmSubscriptionInfo.get("blueprintVersion").toLowerCase() - var payload = executor.inFields.get("payload") - var actionName = changeType + "-subscription" - - var commonHeader = executor.subject.getOutFieldSchemaHelper("commonHeader").createNewInstance(); - commonHeader.put("originatorId", "sdnc"); - commonHeader.put("requestId", executor.inFields.get("albumID").toString()); - commonHeader.put("subRequestId", "sub-123456-1000"); - - var actionIdentifiers = executor.subject.getOutFieldSchemaHelper("actionIdentifiers").createNewInstance(); - actionIdentifiers.put("actionName", actionName); - actionIdentifiers.put("blueprintName", blueprintName); - actionIdentifiers.put("blueprintVersion", blueprintVersion); - actionIdentifiers.put("mode", "sync"); - - executor.outFields.put("commonHeader", commonHeader); - executor.outFields.put("actionIdentifiers", actionIdentifiers); - executor.outFields.put("payload", payload); - - //var returnValue = executor.isTrue; - true; - - key: - name: ReceiveSubscriptionTask - version: 0.0.1 - value: - key: - name: ReceiveSubscriptionTask - version: 0.0.1 - inputFields: - entry: - - key: blueprintName - value: - key: blueprintName - fieldSchemaKey: - name: SimpleStringType - version: 0.0.1 - optional: false - - key: blueprintVersion - value: - key: blueprintVersion - fieldSchemaKey: - name: SimpleStringType - version: 0.0.1 - optional: false - - key: changeType - value: - key: changeType - fieldSchemaKey: - name: SimpleStringType - version: 0.0.1 - optional: false - - key: closedLoopControlName - value: - key: closedLoopControlName - fieldSchemaKey: - name: SimpleStringType - version: 0.0.1 - optional: false - - key: nfName - value: - key: nfName - fieldSchemaKey: - name: SimpleStringType - version: 0.0.1 - optional: false - - key: policyName - value: - key: policyName - fieldSchemaKey: - name: SimpleStringType - version: 0.0.1 - optional: false - - key: subscription - value: - key: subscription - fieldSchemaKey: - name: SubscriptionType - version: 0.0.1 - optional: false - outputFields: - entry: - - key: albumID - value: - key: albumID - fieldSchemaKey: - name: UUIDType - version: 0.0.1 - optional: false - taskParameters: - entry: [] - contextAlbumReference: - - name: PMSubscriptionAlbum - version: 0.0.1 - taskLogic: - key: TaskLogic - logicFlavour: JAVASCRIPT - logic: |- - /* - * ============LICENSE_START======================================================= - * Copyright (C) 2020 Nordix. 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========================================================= - */ - var uuidType = java.util.UUID; - - executor.logger.info(executor.subject.id); - - //albumID will be used to fetch info from our album later - var albumID = uuidType.randomUUID(); - var pmSubscriptionInfo = executor.getContextAlbum("PMSubscriptionAlbum").getSchemaHelper().createNewInstance(); - var returnValue = true; - - if(executor.inFields.get("policyName") != null) { - executor.logger.info("nfName in receive sub event " + executor.inFields.get("nfName")); - - var changeType = executor.inFields.get("changeType") - var nfName = executor.inFields.get("nfName") - var policyName = executor.inFields.get("policyName") - var closedLoopControlName = executor.inFields.get("closedLoopControlName") - var subscription = executor.inFields.get("subscription") - var blueprintName = executor.inFields.get("blueprintName") - var blueprintVersion = executor.inFields.get("blueprintVersion") - - pmSubscriptionInfo.put("nfName", executor.inFields.get("nfName")); - pmSubscriptionInfo.put("changeType", executor.inFields.get("changeType")) - pmSubscriptionInfo.put("policyName", executor.inFields.get("policyName")) - pmSubscriptionInfo.put("closedLoopControlName", executor.inFields.get("closedLoopControlName")) - pmSubscriptionInfo.put("subscription", subscription) - pmSubscriptionInfo.put("blueprintName", blueprintName) - pmSubscriptionInfo.put("blueprintVersion", blueprintVersion) - - - executor.getContextAlbum("PMSubscriptionAlbum").put(albumID.toString(), pmSubscriptionInfo); - - executor.outFields.put("albumID", albumID) - } else { - executor.message = "Received invalid event" - returnValue = false; - } - - returnValue; - events: - key: - name: PMControlPolicy_Events - version: 0.0.1 - eventMap: - entry: - - key: - name: CDSCreateResponseEvent - version: 0.0.1 - value: - key: - name: CDSCreateResponseEvent - version: 0.0.1 - nameSpace: org.onap.policy.apex.onap.pmcontrol - source: CDS - target: APEX - parameter: - entry: - - key: actionIdentifiers - value: - key: actionIdentifiers - fieldSchemaKey: - name: CDSActionIdentifiersType - version: 0.0.1 - optional: false - - key: commonHeader - value: - key: commonHeader - fieldSchemaKey: - name: CDSResponseCommonHeaderType - version: 0.0.1 - optional: false - - key: payload - value: - key: payload - fieldSchemaKey: - name: CDSCreateResponsePayloadType - version: 0.0.1 - optional: false - - key: status - value: - key: status - fieldSchemaKey: - name: CDSResponseStatusType - version: 0.0.1 - optional: false - - key: - name: CDSCreateSubscriptionRequestEvent - version: 0.0.1 - value: - key: - name: CDSCreateSubscriptionRequestEvent - version: 0.0.1 - nameSpace: org.onap.policy.apex.onap.pmcontrol - source: APEX - target: APEX - parameter: - entry: - - key: actionIdentifiers - value: - key: actionIdentifiers - fieldSchemaKey: - name: CDSActionIdentifiersType - version: 0.0.1 - optional: false - - key: commonHeader - value: - key: commonHeader - fieldSchemaKey: - name: CDSRequestCommonHeaderType - version: 0.0.1 - optional: false - - key: payload - value: - key: payload - fieldSchemaKey: - name: CDSCreateSubscriptionPayloadType - version: 0.0.1 - optional: false - - key: - name: CDSDeleteResponseEvent - version: 0.0.1 - value: - key: - name: CDSDeleteResponseEvent - version: 0.0.1 - nameSpace: org.onap.policy.apex.onap.pmcontrol - source: CDS - target: APEX - parameter: - entry: - - key: actionIdentifiers - value: - key: actionIdentifiers - fieldSchemaKey: - name: CDSActionIdentifiersType - version: 0.0.1 - optional: false - - key: commonHeader - value: - key: commonHeader - fieldSchemaKey: - name: CDSResponseCommonHeaderType - version: 0.0.1 - optional: false - - key: payload - value: - key: payload - fieldSchemaKey: - name: CDSDeleteResponsePayloadType - version: 0.0.1 - optional: false - - key: status - value: - key: status - fieldSchemaKey: - name: CDSResponseStatusType - version: 0.0.1 - optional: false - - key: - name: CDSDeleteSubscriptionRequestEvent - version: 0.0.1 - value: - key: - name: CDSDeleteSubscriptionRequestEvent - version: 0.0.1 - nameSpace: org.onap.policy.apex.onap.pmcontrol - source: APEX - target: APEX - parameter: - entry: - - key: actionIdentifiers - value: - key: actionIdentifiers - fieldSchemaKey: - name: CDSActionIdentifiersType - version: 0.0.1 - optional: false - - key: commonHeader - value: - key: commonHeader - fieldSchemaKey: - name: CDSRequestCommonHeaderType - version: 0.0.1 - optional: false - - key: payload - value: - key: payload - fieldSchemaKey: - name: CDSDeleteSubscriptionPayloadType - version: 0.0.1 - optional: false - - key: - name: CDSResponseStatusEvent - version: 0.0.1 - value: - key: - name: CDSResponseStatusEvent - version: 0.0.1 - nameSpace: org.onap.policy.apex.onap.pmcontrol - source: APEX - target: DCAE - parameter: - entry: - - key: status - value: - key: status - fieldSchemaKey: - name: SubscriptionStatusType - version: 0.0.1 - optional: false - - key: - name: CreateSubscriptionPayloadEvent - version: 0.0.1 - value: - key: - name: CreateSubscriptionPayloadEvent - version: 0.0.1 - nameSpace: org.onap.policy.apex.onap.pmcontrol - source: APEX - target: APEX - parameter: - entry: - - key: albumID - value: - key: albumID - fieldSchemaKey: - name: UUIDType - version: 0.0.1 - optional: false - - key: payload - value: - key: payload - fieldSchemaKey: - name: CDSCreateSubscriptionPayloadType - version: 0.0.1 - optional: false - - key: - name: DeleteSubscriptionPayloadEvent - version: 0.0.1 - value: - key: - name: DeleteSubscriptionPayloadEvent - version: 0.0.1 - nameSpace: org.onap.policy.apex.onap.pmcontrol - source: APEX - target: APEX - parameter: - entry: - - key: albumID - value: - key: albumID - fieldSchemaKey: - name: UUIDType - version: 0.0.1 - optional: false - - key: payload - value: - key: payload - fieldSchemaKey: - name: CDSDeleteSubscriptionPayloadType - version: 0.0.1 - optional: false - - key: - name: MRResponseEvent - version: 0.0.1 - value: - key: - name: MRResponseEvent - version: 0.0.1 - nameSpace: org.onap.policy.apex.onap.pmcontrol - source: DCAE - target: APEX - parameter: - entry: - - key: count - value: - key: count - fieldSchemaKey: - name: SimpleIntType - version: 0.0.1 - optional: false - - key: serverTimeMs - value: - key: serverTimeMs - fieldSchemaKey: - name: SimpleIntType - version: 0.0.1 - optional: false - - key: - name: PMSubscriptionOutputEvent - version: 0.0.1 - value: - key: - name: PMSubscriptionOutputEvent - version: 0.0.1 - nameSpace: org.onap.policy.apex.onap.pmcontrol - source: APEX - target: APEX - parameter: - entry: - - key: albumID - value: - key: albumID - fieldSchemaKey: - name: UUIDType - version: 0.0.1 - optional: false - - key: - name: pmsh-operational-policy - version: 0.0.1 - value: - key: - name: pmsh-operational-policy - version: 0.0.1 - nameSpace: org.onap.policy.apex.onap.pmcontrol - source: DCAE - target: APEX - parameter: - entry: - - key: blueprintName - value: - key: blueprintName - fieldSchemaKey: - name: SimpleStringType - version: 0.0.1 - optional: false - - key: blueprintVersion - value: - key: blueprintVersion - fieldSchemaKey: - name: SimpleStringType - version: 0.0.1 - optional: false - - key: changeType - value: - key: changeType - fieldSchemaKey: - name: SimpleStringType - version: 0.0.1 - optional: false - - key: closedLoopControlName - value: - key: closedLoopControlName - fieldSchemaKey: - name: SimpleStringType - version: 0.0.1 - optional: false - - key: nfName - value: - key: nfName - fieldSchemaKey: - name: SimpleStringType - version: 0.0.1 - optional: false - - key: policyName - value: - key: policyName - fieldSchemaKey: - name: SimpleStringType - version: 0.0.1 - optional: false - - key: subscription - value: - key: subscription - fieldSchemaKey: - name: SubscriptionType - version: 0.0.1 - optional: false - albums: - key: - name: PMControlPolicy_Albums - version: 0.0.1 - albums: - entry: - - key: - name: PMSubscriptionAlbum - version: 0.0.1 - value: - key: - name: PMSubscriptionAlbum - version: 0.0.1 - scope: policy - isWritable: true - itemSchema: - name: PMSubscriptionType - version: 0.0.1 - schemas: - key: - name: PMControlPolicy_Schemas - version: 0.0.1 - schemas: - entry: - - key: - name: CDSActionIdentifiersType - version: 0.0.1 - value: - key: - name: CDSActionIdentifiersType - version: 0.0.1 - schemaFlavour: Avro - schemaDefinition: |- - { - "type": "record", - "name": "ActionIdentifiers_Type", - "namespace": "org.onap.policy.apex.onap.helloworld", - "fields": [ - { - "name": "actionName", - "type": "string" - }, - { - "name": "blueprintName", - "type": "string" - }, - { - "name": "blueprintVersion", - "type": "string" - }, - { - "name": "mode", - "type": "string" - } - ] - } - - key: - name: CDSCreateResponsePayloadType - version: 0.0.1 - value: - key: - name: CDSCreateResponsePayloadType - version: 0.0.1 - schemaFlavour: Avro - schemaDefinition: |- - { - "name": "CreateResponsePayloadEntry", - "type": "record", - "namespace": "org.onap.policy.apex.onap.helloworld", - "fields": [ - { - "name": "create_DasH_subscription_DasH_response", - "type": { - "name": "create_DasH_subscription_DasH_response", - "type": "record", - "fields": [ - { - "name": "odl_DasH_response", - "type": { - "name": "odl_DasH_response", - "type": "record", - "fields": [ - { - "name": "status", - "type": "string" - } - ] - } - } - ] - } - } - ] - } - - key: - name: CDSCreateSubscriptionPayloadType - version: 0.0.1 - value: - key: - name: CDSCreateSubscriptionPayloadType - version: 0.0.1 - schemaFlavour: Avro - schemaDefinition: |- - { - "type": "map", - "values": { - "type": "record", - "name": "CDSRequestPayloadEntry", - "fields": [ - { - "name": "create_DasH_subscription_DasH_properties", - "type": { - "name": "create_DasH_subscription_DasH_properties_record", - "type": "record", - "fields": [ - { - "name": "nfName", - "type": "string" - }, - { - "name": "subscriptionName", - "type": "string" - }, - { - "name": "administrativeState", - "type": "string" - }, - { - "name": "fileBasedGP", - "type": "string" - }, - { - "name": "fileLocation", - "type": "string" - }, - { - "name": "measurementGroups", - "type": { - "type": "array", - "items": { - "name": "measurementGroups_record", - "type": "record", - "fields": [ - { - "name": "measurementGroup", - "type": { - "name": "measurementGroup", - "type": "record", - "fields": [ - { - "name": "measurementTypes", - "type": { - "type": "array", - "items": { - "name": "measurementTypes_record", - "type": "record", - "fields": [ - { - "name": "measurementType", - "type": "string" - } - ] - } - } - }, - { - "name": "managedObjectDNsBasic", - "type": { - "type": "array", - "items": { - "name": "managedObjectDNsBasic_record", - "type": "record", - "fields": [ - { - "name": "DN", - "type": "string" - } - ] - } - } - } - ] - } - } - ] - } - } - } - ] - } - } - ] - } - } - - key: - name: CDSDeleteResponsePayloadType - version: 0.0.1 - value: - key: - name: CDSDeleteResponsePayloadType - version: 0.0.1 - schemaFlavour: Avro - schemaDefinition: |- - { - "name": "DeleteResponsePayloadEntry", - "type": "record", - "namespace": "com.acme.avro", - "fields": [ - { - "name": "delete_DasH_subscription_DasH_response", - "type": { - "name": "delete_DasH_subscription_DasH_response", - "type": "record", - "fields": [ - { - "name": "odl_DasH_response", - "type": { - "name": "odl_DasH_response", - "type": "record", - "fields": [ - { - "name": "status", - "type": "string" - } - ] - } - } - ] - } - } - ] - } - - key: - name: CDSDeleteSubscriptionPayloadType - version: 0.0.1 - value: - key: - name: CDSDeleteSubscriptionPayloadType - version: 0.0.1 - schemaFlavour: Avro - schemaDefinition: |- - { - "type": "map", - "values": { - "type": "record", - "name": "CDSRequestPayloadEntry", - "fields": [ - { - "name": "delete_DasH_subscription_DasH_properties", - "type": { - "name": "delete_DasH_subscription_DasH_properties_record", - "type": "record", - "fields": [ - { - "name": "nfName", - "type": "string" - }, - { - "name": "subscriptionName", - "type": "string" - }, - { - "name": "administrativeState", - "type": "string" - }, - { - "name": "fileBasedGP", - "type": "string" - }, - { - "name": "fileLocation", - "type": "string" - }, - { - "name": "measurementGroups", - "type": { - "type": "array", - "items": { - "name": "measurementGroups_record", - "type": "record", - "fields": [ - { - "name": "measurementGroup", - "type": { - "name": "measurementGroup", - "type": "record", - "fields": [ - { - "name": "measurementTypes", - "type": { - "type": "array", - "items": { - "name": "measurementTypes_record", - "type": "record", - "fields": [ - { - "name": "measurementType", - "type": "string" - } - ] - } - } - }, - { - "name": "managedObjectDNsBasic", - "type": { - "type": "array", - "items": { - "name": "managedObjectDNsBasic_record", - "type": "record", - "fields": [ - { - "name": "DN", - "type": "string" - } - ] - } - } - } - ] - } - } - ] - } - } - } - ] - } - } - ] - } - } - - key: - name: CDSRequestCommonHeaderType - version: 0.0.1 - value: - key: - name: CDSRequestCommonHeaderType - version: 0.0.1 - schemaFlavour: Avro - schemaDefinition: |- - { - "type": "record", - "name": "RequestCommonHeader_Type", - "namespace": "org.onap.policy.apex.onap.helloworld", - "fields": [ - { - "name": "originatorId", - "type": "string" - }, - { - "name": "requestId", - "type": "string" - }, - { - "name": "subRequestId", - "type": "string" - } - ] - } - - key: - name: CDSResponseCommonHeaderType - version: 0.0.1 - value: - key: - name: CDSResponseCommonHeaderType - version: 0.0.1 - schemaFlavour: Avro - schemaDefinition: |- - { - "type": "record", - "name": "ResponseCommonHeader_Type", - "namespace": "org.onap.policy.apex.onap.helloworld", - "fields": [ - { - "name": "originatorId", - "type": "string" - }, - { - "name": "requestId", - "type": "string" - }, - { - "name": "subRequestId", - "type": "string" - }, - { - "name": "timestamp", - "type": "string" - }, - { - "name": "flags", - "type": ["null", "string"] - } - ] - } - - key: - name: CDSResponseStatusType - version: 0.0.1 - value: - key: - name: CDSResponseStatusType - version: 0.0.1 - schemaFlavour: Avro - schemaDefinition: |- - { - "type": "record", - "name": "ResponseStatus_Type", - "namespace": "org.onap.policy.apex.onap.helloworld", - "fields": [ - { - "name": "code", - "type": "int" - }, - { - "name": "eventType", - "type": "string" - }, - { - "name": "timestamp", - "type": "string" - }, - { - "name": "message", - "type": "string" - } - ] - } - - key: - name: PMSubscriptionType - version: 0.0.1 - value: - key: - name: PMSubscriptionType - version: 0.0.1 - schemaFlavour: Avro - schemaDefinition: "{\n\t\"name\": \"PMSubscription\",\n\t\"type\": \"record\",\n\t\"namespace\": \"\ - org.onap.policy.apex.onap.pmcontrol\",\n\t\"fields\": [\n {\n \"name\": \"nfName\"\ - ,\n \"type\": \"string\"\n },\n\t {\n\t\t\t\"name\": \"changeType\",\n\t\t\t\"\ - type\": \"string\"\n\t\t},\n\t\t{\n\t\t\t\"name\": \"closedLoopControlName\",\n\t\t\t\"type\": \"\ - string\"\n\t\t},\n\t\t{\n\t\t\t\"name\": \"policyName\",\n\t\t\t\"type\": \"string\"\n\t\t},\n\t\t\ - {\n\t\t \"name\": \"blueprintName\",\n\t\t \"type\": \"string\"\n\t\t},\n\t\t{\n\t\t \"name\"\ - : \"blueprintVersion\",\n\t\t \"type\": \"string\"\n\t\t},\n\t\t{\n\t\t\t\"name\": \"subscription\"\ - ,\n\t\t\t\"type\": {\n\t\t\t\t\"name\": \"subscription\",\n\t\t\t\t\"type\": \"record\",\n\t\t\t\t\ - \"fields\": [{\n\t\t\t\t\t\t\"name\": \"subscriptionName\",\n\t\t\t\t\t\t\"type\": \"string\"\n\t\t\ - \t\t\t},\n\t\t\t\t\t{\n\t\t\t\t\t\t\"name\": \"administrativeState\",\n\t\t\t\t\t\t\"type\": \"string\"\ - \n\t\t\t\t\t},\n\t\t\t\t\t{\n\t\t\t\t\t\t\"name\": \"fileBasedGP\",\n\t\t\t\t\t\t\"type\": \"int\"\ - \n\t\t\t\t\t},\n\t\t\t\t\t{\n\t\t\t\t\t\t\"name\": \"fileLocation\",\n\t\t\t\t\t\t\"type\": \"string\"\ - \n\t\t\t\t\t},\n\t\t\t\t\t{\n\t\t\t\t\t\t\"name\": \"measurementGroups\",\n\t\t\t\t\t\t\"type\": {\n\ - \t\t\t\t\t\t\t\"type\": \"array\",\n\t\t\t\t\t\t\t\"items\": {\n\t\t\t\t\t\t\t\t\"name\": \"Measurement_Groups_Type\"\ - ,\n\t\t\t\t\t\t\t\t\"type\": \"record\",\n\t\t\t\t\t\t\t\t\"fields\": [{\n\t\t\t\t\t\t\t\t\t\"name\"\ - : \"measurementGroup\",\n\t\t\t\t\t\t\t\t\t\"type\": {\n\t\t\t\t\t\t\t\t\t\t\"name\": \"Measurement_Group_Type\"\ - ,\n\t\t\t\t\t\t\t\t\t\t\"type\": \"record\",\n\t\t\t\t\t\t\t\t\t\t\"fields\": [{\n\t\t\t\t\t\t\t\t\ - \t\t\t\t\"name\": \"measurementTypes\",\n\t\t\t\t\t\t\t\t\t\t\t\t\"type\": {\n\t\t\t\t\t\t\t\t\t\t\ - \t\t\t\"type\": \"array\",\n\t\t\t\t\t\t\t\t\t\t\t\t\t\"items\": {\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\"\ - name\": \"Measurement_Types_Type\",\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\"type\": \"record\",\n\t\t\t\t\t\ - \t\t\t\t\t\t\t\t\t\"fields\": [{\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\"name\": \"measurementType\",\n\t\ - \t\t\t\t\t\t\t\t\t\t\t\t\t\t\"type\": \"string\"\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t}]\n\t\t\t\t\t\t\t\t\ - \t\t\t\t\t}\n\t\t\t\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\t\t\t\t{\n\t\t\t\t\ - \t\t\t\t\t\t\t\t\"name\": \"managedObjectDNsBasic\",\n\t\t\t\t\t\t\t\t\t\t\t\t\"type\": {\n\t\t\t\t\ - \t\t\t\t\t\t\t\t\t\"type\": \"array\",\n\t\t\t\t\t\t\t\t\t\t\t\t\t\"items\": {\n\t\t\t\t\t\t\t\t\t\ - \t\t\t\t\t\"name\": \"Managed_Object_Dns_Basic_Type\",\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\"type\": \"record\"\ - ,\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\"fields\": [{\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\"name\": \"DN\",\n\t\ - \t\t\t\t\t\t\t\t\t\t\t\t\t\t\"type\": \"string\"\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t}]\n\t\t\t\t\t\t\t\t\ - \t\t\t\t\t}\n\t\t\t\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\t\t]\n\t\t\t\t\t\ - \t\t\t\t}\n\t\t\t\t\t\t\t\t}]\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t]\n\t\t\t}\n\t\ - \t}\n\t]\n}" - - key: - name: SimpleIntType - version: 0.0.1 - value: - key: - name: SimpleIntType - version: 0.0.1 - schemaFlavour: Java - schemaDefinition: java.lang.Integer - - key: - name: SimpleStringType - version: 0.0.1 - value: - key: - name: SimpleStringType - version: 0.0.1 - schemaFlavour: Java - schemaDefinition: java.lang.String - - key: - name: SubscriptionStatusType - version: 0.0.1 - value: - key: - name: SubscriptionStatusType - version: 0.0.1 - schemaFlavour: Avro - schemaDefinition: |- - { - "type": "record", - "name": "ActivateSubscriptionStatus_Type", - "namespace": "org.onap.policy.apex.onap.helloworld", - "fields": [ - { - "name": "subscriptionName", - "type": "string" - }, - { - "name": "nfName", - "type": "string" - }, - { - "name": "changeType", - "type": "string" - }, - { - "name": "message", - "type": "string" - } - ] - } - - key: - name: SubscriptionType - version: 0.0.1 - value: - key: - name: SubscriptionType - version: 0.0.1 - schemaFlavour: Avro - schemaDefinition: "{\n\t\"name\": \"subscription\",\n\t\"type\": \"record\",\n\t\"fields\": [{\n\t\t\ - \t\"name\": \"subscriptionName\",\n\t\t\t\"type\": \"string\"\n\t\t},\n\t\t{\n\t\t\t\"name\": \"administrativeState\"\ - ,\n\t\t\t\"type\": \"string\"\n\t\t},\n\t\t{\n\t\t\t\"name\": \"fileBasedGP\",\n\t\t\t\"type\": \"\ - int\"\n\t\t},\n\t\t{\n\t\t\t\"name\": \"fileLocation\",\n\t\t\t\"type\": \"string\"\n\t\t},\n\t\t\ - {\n\t\t\t\"name\": \"measurementGroups\",\n\t\t\t\"type\": {\n\t\t\t\t\"type\": \"array\",\n\t\t\t\ - \t\"items\": {\n\t\t\t\t\t\"name\": \"Measurement_Groups_Type\",\n\t\t\t\t\t\"type\": \"record\",\n\ - \t\t\t\t\t\"fields\": [{\n\t\t\t\t\t\t\"name\": \"measurementGroup\",\n\t\t\t\t\t\t\"type\": {\n\t\ - \t\t\t\t\t\t\"name\": \"Measurement_Group_Type\",\n\t\t\t\t\t\t\t\"type\": \"record\",\n\t\t\t\t\t\ - \t\t\"fields\": [{\n\t\t\t\t\t\t\t\t\t\"name\": \"measurementTypes\",\n\t\t\t\t\t\t\t\t\t\"type\"\ - : {\n\t\t\t\t\t\t\t\t\t\t\"type\": \"array\",\n\t\t\t\t\t\t\t\t\t\t\"items\": {\n\t\t\t\t\t\t\t\t\t\ - \t\t\"name\": \"Measurement_Types_Type\",\n\t\t\t\t\t\t\t\t\t\t\t\"type\": \"record\",\n\t\t\t\t\t\ - \t\t\t\t\t\t\"fields\": [{\n\t\t\t\t\t\t\t\t\t\t\t\t\"name\": \"measurementType\",\n\t\t\t\t\t\t\t\ - \t\t\t\t\t\"type\": \"string\"\n\t\t\t\t\t\t\t\t\t\t\t}]\n\t\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\t\ - }\n\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\t\"name\": \"managedObjectDNsBasic\",\n\ - \t\t\t\t\t\t\t\t\t\"type\": {\n\t\t\t\t\t\t\t\t\t\t\"type\": \"array\",\n\t\t\t\t\t\t\t\t\t\t\"items\"\ - : {\n\t\t\t\t\t\t\t\t\t\t\t\"name\": \"Managed_Object_Dns_Basic_Type\",\n\t\t\t\t\t\t\t\t\t\t\t\"\ - type\": \"record\",\n\t\t\t\t\t\t\t\t\t\t\t\"fields\": [{\n\t\t\t\t\t\t\t\t\t\t\t\t\"name\": \"DN\"\ - ,\n\t\t\t\t\t\t\t\t\t\t\t\t\"type\": \"string\"\n\t\t\t\t\t\t\t\t\t\t\t}]\n\t\t\t\t\t\t\t\t\t\t}\n\ - \t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t]\n\t\t\t\t\t\t}\n\t\t\t\t\t}]\n\t\t\t\t}\n\t\ - \t\t}\n\t\t}\n\t]\n}" - - key: - name: UUIDType - version: 0.0.1 - value: - key: - name: UUIDType - version: 0.0.1 - schemaFlavour: Java - schemaDefinition: java.util.UUID - engineParameters: - executorParameters: - JAVASCRIPT: - parameterClassName: org.onap.policy.apex.plugins.executor.javascript.JavascriptExecutorParameters - contextParameters: - parameterClassName: org.onap.policy.apex.context.parameters.ContextParameters - schemaParameters: - Avro: - parameterClassName: org.onap.policy.apex.plugins.context.schema.avro.AvroSchemaHelperParameters - Java: - parameterClassName: org.onap.policy.apex.context.impl.schema.java.JavaSchemaHelperParameters - jsonAdapters: - Instant: - adaptedClass: java.time.Instant - adaptorClass: org.onap.policy.controlloop.util.Serialization$GsonInstantAdapter - eventInputParameters: - DCAEConsumer: - carrierTechnologyParameters: - carrierTechnology: RESTCLIENT - parameterClassName: org.onap.policy.apex.plugins.event.carrier.restclient.RestClientCarrierTechnologyParameters - parameters: - consumerPollTime: '50' - url: https://message-router:3905/events/unauthenticated.DCAE_CL_OUTPUT/cg1/sg1 - eventProtocolParameters: - eventProtocol: JSON - parameters: - nameAlias: policyName - eventName: pmsh-operational-policy - eventNameFilter: pmsh-operational-policy - CDSRequestConsumer: - carrierTechnologyParameters: - carrierTechnology: RESTREQUESTOR - parameterClassName: org.onap.policy.apex.plugins.event.carrier.restrequestor.RestRequestorCarrierTechnologyParameters - parameters: - url: http://10.10.10.184:30254/api/v1/execution-service/process - httpMethod: POST - restRequestTimeout: 2000 - httpHeaders: - - - Authorization - - Basic Y2NzZGthcHBzOmNjc2RrYXBwcw== - eventProtocolParameters: - eventProtocol: JSON - eventName: CDSCreateResponseEvent - eventNameFilter: CDSCreateResponseEvent - requestorMode: true - requestorPeer: CDSRequestProducer - requestorTimeout: 500 - CDSDeleteRequestConsumer: - carrierTechnologyParameters: - carrierTechnology: RESTREQUESTOR - parameterClassName: org.onap.policy.apex.plugins.event.carrier.restrequestor.RestRequestorCarrierTechnologyParameters - parameters: - url: http://10.10.10.184:30254/api/v1/execution-service/process - httpMethod: POST - restRequestTimeout: 2000 - httpHeaders: - - - Authorization - - Basic Y2NzZGthcHBzOmNjc2RrYXBwcw== - eventProtocolParameters: - eventProtocol: JSON - eventName: CDSDeleteResponseEvent - eventNameFilter: CDSDeleteResponseEvent - requestorMode: true - requestorPeer: CDSDeleteRequestProducer - requestorTimeout: 500 - CDSReplyConsumer: - carrierTechnologyParameters: - carrierTechnology: RESTREQUESTOR - parameterClassName: org.onap.policy.apex.plugins.event.carrier.restrequestor.RestRequestorCarrierTechnologyParameters - parameters: - url: https://message-router:3905/events/unauthenticated.PMSH_CL_INPUT - httpMethod: POST - restRequestTimeout: 2000 - eventProtocolParameters: - eventProtocol: JSON - eventName: MRResponseEvent - eventNameFilter: MRResponseEvent - requestorMode: true - requestorPeer: CDSReplyProducer - requestorTimeout: 500 - eventOutputParameters: - logOutputter: - carrierTechnologyParameters: - carrierTechnology: FILE - parameters: - fileName: /tmp/outputevents.log - eventProtocolParameters: - eventProtocol: JSON - StdOutOutputter: - carrierTechnologyParameters: - carrierTechnology: FILE - parameters: - standardIo: true - eventProtocolParameters: - eventProtocol: JSON - CDSRequestProducer: - carrierTechnologyParameters: - carrierTechnology: RESTREQUESTOR - parameterClassName: org.onap.policy.apex.plugins.event.carrier.restrequestor.RestRequestorCarrierTechnologyParameters - eventProtocolParameters: - eventProtocol: JSON - eventNameFilter: CDSCreateSubscriptionRequestEvent - requestorMode: true - requestorPeer: CDSRequestConsumer - requestorTimeout: 500 - CDSDeleteRequestProducer: - carrierTechnologyParameters: - carrierTechnology: RESTREQUESTOR - parameterClassName: org.onap.policy.apex.plugins.event.carrier.restrequestor.RestRequestorCarrierTechnologyParameters - eventProtocolParameters: - eventProtocol: JSON - eventNameFilter: CDSDeleteSubscriptionRequestEvent - requestorMode: true - requestorPeer: CDSDeleteRequestConsumer - requestorTimeout: 500 - CDSReplyProducer: - carrierTechnologyParameters: - carrierTechnology: RESTREQUESTOR - parameterClassName: org.onap.policy.apex.plugins.event.carrier.restrequestor.RestRequestorCarrierTechnologyParameters - eventProtocolParameters: - eventProtocol: JSON - eventNameFilter: CDSResponseStatusEvent - requestorMode: true - requestorPeer: CDSReplyConsumer - requestorTimeout: 500 diff --git a/common/src/test/resources/examples/controlloop/PMSubscriptionHandling_GuilinFormat.yaml b/common/src/test/resources/examples/controlloop/PMSubscriptionHandling_GuilinFormat.yaml deleted file mode 100644 index 51e369696..000000000 --- a/common/src/test/resources/examples/controlloop/PMSubscriptionHandling_GuilinFormat.yaml +++ /dev/null @@ -1,455 +0,0 @@ -# ============LICENSE_START======================================================= -# Copyright (C) 2021 Nordix Foundation. -# ================================================================================ -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# -# SPDX-License-Identifier: Apache-2.0 -# ============LICENSE_END========================================================= - -tosca_definitions_version: tosca_simple_yaml_1_3 -capability_types: - org.onap.EventProducer: - properties: - carrier_protocol_type: - type: string - required: true - constraints: - - valid_values: - - DMAAP_message_router - - SOMETHING_ELSE - - REST - data_format: - type: string - required: true - constraints: - - valid_values: - - JSON - - YAML - - JMS - event_format: - type: string - required: true - event_format_version: - type: string - required: false - config_keys: - type: list - required: false - entry_schema: - type: string - constraints: - - valid_values: - - all valid values should be added here - - if not specified, events of any config key may be generated - - 'examples for config_key: ves-measurement, ves-syslog, tca_handle_out, - etc.' - version: 0.0.1 - derived_from: tosca.capabilities.Root - org.onap.EventConsumer: - properties: - responding_capability: - type: string - required: false - carrier_protocol_type: - type: string - required: true - constraints: - - valid_values: - - DMAAP_message_router - - SOMETHING_ELSE - - REST - data_format: - type: string - required: true - constraints: - - valid_values: - - JSON - - YAML - - JMS - - all valid values should be added here - event_format: - type: string - description: 'examples for event_format: Ves_specification, LinkUp, VnfConfigured, - etc.' - required: true - event_format_version: - type: string - description: 'examples for event_format_version: 5.28.4, 7.30.1, etc.' - required: false - config_keys: - type: list - required: false - entry_schema: - type: string - constraints: - - valid_values: - - all valid values should be added here - - if not specified, events of any config key may be generated - - 'examples for config_key: ves-measurement, ves-syslog, tca_handle_out, - etc.' - version: 0.0.1 - derived_from: tosca.capabilities.Root -node_types: - org.onap.DynamicConfig: - properties: - application_name: - type: string - description: Value used to tie the config to an application ? should we be - using a relationship here instead? - required: true - application_version: - type: string - required: true - application_provider: - type: string - required: false - data_types: - type: object - required: false - schema: - type: object - required: false - version: 0.0.1 - derived_from: tosca.nodes.Root - org.onap.APP: - properties: - application_name: - type: string - description: Human readable name for the application Product - required: false - provider: - type: string - description: Provider of the application and of the descriptor - required: true - application_version: - type: string - description: Software version of the application - required: true - blueprint_id: - type: string - description: A reference to the app blueprint - required: false - monitoring_policy: - type: string - description: A reference to the monitoring policy - required: false - requirements: - - receive: - capability: org.onap.EventProducer - relationship: org.onap.PropagateEvent - occurrences: - - 0 - - UNBOUNDED - - send: - capability: org.onap.EventConsumer - relationship: org.onap.PropagateEvent - occurrences: - - 0 - - UNBOUNDED - version: 0.0.1 - derived_from: tosca.nodes.Root - org.onap.EventRelay: - properties: - event_format: - type: string - description: 'examples for event_format: Ves_specification, etc.' - required: true - event_format_version: - type: string - description: 'examples for event_format_version: 5.28.4, 7.30.1, etc.' - required: true - config_keys: - type: list - required: false - entry_schema: - type: string - constraints: - - valid_values: - - all valid values should be added here - - if not specified, events of any config key is relayed - - 'examples for config_key: ves-measurement, ves-syslog, tca_handle_out, - etc.' - supported_carrier_protocols: - type: map - description: 'A map describing supported carrier protocols and translations. - The tuples define what protocol combinations are supported on the producer - and consumer side: e.g. { REST: REST, DMAAP: REST, DMAAP: DMAAP}' - required: true - key_schema: - type: string - constraints: - - valid_values: - - DMAAP_message_router - - SOMETHING_ELSE - - REST - - all valid values should be added here - entry_schema: - type: string - constraints: - - valid_values: - - DMAAP_message_router - - SOMETHING_ELSE - - REST - - all valid values should be added here - supported_data_formats: - type: map - description: 'Is a map describing supported data formats and translation. - The tuples define what protocol combinations are supported on the producer - and consumer side: e.g. { JSON: JSON, JMS: JSON, YAML:YAML }' - required: true - key_schema: - type: string - constraints: - - valid_values: - - JSON - - JMS - - YAML - - etc - - all valid values should be added here - entry_schema: - type: string - constraints: - - valid_values: - - JSON - - JMS - - YAML - - etc - - all valid values should be added here - requirements: - - receive: - capability: org.onap.EventProducer - relationship: org.onap.PropagateEvent - occurrences: - - 0 - - UNBOUNDED - - send: - capability: org.onap.EventConsumer - relationship: org.onap.PropagateEvent - occurrences: - - 0 - - UNBOUNDED - version: 0.0.1 - derived_from: tosca.nodes.Root -relationship_types: - org.onap.PropagateEvent: - properties: - config_keys: - type: list - description: The relationship type used on requirements to org.onap.EventProducer - and org.onap.EventConsumer capabilities. Filters events by specific config_keys - to be transferred by this relationship. That is, any event with a specific - config_key found in the list is transferred. If list is not defined or is - empty, events with all config_keys are transferred. - required: false - entry_schema: - type: string - version: 0.0.1 - derived_from: tosca.relationships.Root -topology_template: - inputs: - pm_subscription_topic: - type: string - pm_subscription_response_topic: - type: string - pm_subscription_handler_blueprint_id: - type: string - pm_subscription_operational_policy_id: - type: string - pm_subscription_cds_blueprint_id: - type: string - enable_tls: - type: string - node_templates: - org.onap.PM_Subscription_Handler: - type: org.onap.polcy.clamp.ControlLoopElement - properties: - application_name: PM Subscription Handler - provider: Ericsson - application_version: 1.0.0 - artifact_id: - get_input: pm_subscription_handler_blueprint_id - description: Is this a reference to the DCAE Cloudify Blueprint that is - already stored(or will be stored before CL configuration & instatiation) - in DCAE Inventory? - artifact_config: - enable_tls: - get_input: enable_tls - pmsh_publish_topic_name: - get_input: pm_subscription_topic - capabilities: - pm-subscription-event-publisher: - properties: - carrier_protocol_type: DMAAP_message_router - data_format: JSON - event_format: pm-subscription-event-format - event_format_version: 1.0.0 - attributes: - type: org.onap.EventProducer - occurrences: - - 0 - - UNBOUNDED - pm-subscription-event-receiver: - properties: - carrier_protocol_type: DMAAP_message_router - data_format: JSON - event_format: pm-subscription-event-response-format - event_format_version: 1.0.0 - relationships: - - type: tosca.relationships.DependsOn - - description: any ideas on a better realtionship ? or is it better to - just use the root realtionship ? - - target: org.onap.PM_Monitoring_Policy - attributes: - type: org.onap.EventConsumer - occurrences: - - 0 - - UNBOUNDED - org.onap.PM_Monitoring_Policy: - type: org.onap.DynamicConfig - properties: - application_name: PM Subscription Handler - application_version: 1.0.0 - provider: Ericsson - data_types: - measurementType: - type: string - DN: - type: string - nfFilter: - properties: - nfNames: - type: list - entry_schema: string - modelInvariantIDs: - type: list - entry_schema: - type: string - modelVersionIDs: - type: list - entry_schema: - type: string - measurementGroup: - properties: - masurementTypes: - type: list - entry_schema: - type: measurementType - managedObjectDNsBasic: - type: list - entry_schema: - type: DN - schema: - subscription: - subscriptionName: - type: string - required: true - administrativeState: - type: string - required: true - filebasedGP: - type: integer - required: true - fileLocation: - type: string - required: true - nfFilter: - type: nfFilter - measurementGroups: - type: list - entry_schema: - type: measurementGroup - description: Should I be showing a dependency between PM Subscription Handler - and the PM Monitoring Policy - org.onap.PM_Policy: - type: org.onap.APP - properties: - application_name: PM Subscription Operational Policy - provider: Ericsson - application_version: 1.0.0 - artifact_id: - get_input: pm_subscription_operational_policy_id - artifact_config: NOT_DEFINED - requirements: - - receive_0: - capability: pm-subscription-event-publisher - node: org.onap.PM_Subscription_Handler - relationship: NOT_DEFINED - properties: - config_keys: - - topic_name: - get_input: pm_subscription_topic - - send_0: - capability: cds-rest-receive - node: org.onap.CDS - - receive_1: - capability: cds-rest-response - node: org.onap.CDS - - send_1: - capability: pm-subscription-event-receiver - node: org.onap.PM_Subscription_Handler - relationship: NOT_DEFINED - properties: - config_keys: - - topic_name: - get_input: pm_subscription_response_topic - capabilities: - pm-subscription-response-event-publisher: - properties: - type: org.onap.EventProducer - carrier_protocol_type: DMAAP_message_router - data_format: JSON - event_format: pm-subscription-event-response-format - event_format_version: 1.0.0 - occurrences: - - 0 - - UNBOUNDED - org.onap.PM_CDS_Blueprint: - type: org.onap.APP - properties: - application_name: PM Subscription CDS Blueprint - provider: Ericsson - application_version: 1.0.0 - artifact_id: - get_input: pm_subscription_cds_blueprint_id - capabilities: - cds-rest-receive: - properties: - type: org.onap.EventConsumer - protocol_type: REST - data_format: JSON - event_format: cds_action_format - event_format_version: 1.0.0 - responding_capability: cds-rest-response - occurrences: - - 0 - - UNBOUNDED - cds-rest-response: - properties: - type: org.onap.EventProducer - protocol_type: REST - data_format: JSON - event_format: cds_action_response_format - event_format_version: 1.0.0 - occurrences: - - 0 - org.onap.controlloop0: - version: 1.2.3 - type: org.onap.policy.clamp.ControlLoop - properties: - application_name: Test Control Loop - provider: Ericsson - application_version: 1.0.0 - status: NOT_DEPLOYED - elements: - element1: org.onap.PM_Monitoring_Policy - diff --git a/common/src/test/resources/examples/controlloop/http-participant/http.postman2.0_collection.json b/common/src/test/resources/examples/controlloop/http-participant/http.postman2.0_collection.json deleted file mode 100644 index 798b0edd6..000000000 --- a/common/src/test/resources/examples/controlloop/http-participant/http.postman2.0_collection.json +++ /dev/null @@ -1,254 +0,0 @@ -{ - "info": { - "name": "CL-http-participant", - "_postman_id": "cd83c1ac-bc96-41f2-a5a4-f021015461b7", - "description": "", - "schema": "https://schema.getpostman.com/json/collection/v2.0.0/collection.json" - }, - "item": [ - { - "id": "45fed070-6a8f-4e0a-a3cf-904db5596984", - "name": "Get Instantiated Control loops", - "request": { - "url": { - "protocol": "https", - "host": "localhost", - "path": [ - "onap", - "controlloop", - "v2", - "instantiation" - ], - "port": "6969" - }, - "method": "GET", - "header": [ - { - "key": "Accept", - "value": "*/*", - "disabled": false - } - ], - "body": { - "mode": "raw", - "disabled": false - }, - "description": "" - }, - "response": [ - { - "header": [], - "code": 200, - "name": "Response_200", - "id": "5727aa3e-5f62-426b-9a37-ddae2d346165" - } - ] - }, - { - "id": "1bf1a143-38fd-49b8-afab-4c801546ba3b", - "name": "Update a Control loop", - "request": { - "url": { - "protocol": "https", - "host": "localhost", - "path": [ - "onap", - "controlloop", - "v2", - "instantiation/command" - ], - "port": "6969" - }, - "method": "PUT", - "header": [ - { - "key": "Content-Type", - "value": "application/json", - "description": "", - "disabled": false - }, - { - "key": "X-ONAP-RequestID", - "value": "709c62b3-8918-41b9-a747-d21eb79c6c20", - "description": "", - "disabled": false - }, - { - "key": "Accept", - "value": "*/*", - "disabled": false - } - ], - "body": { - "mode": "raw", - "raw": "{\r\n \"orderedState\": \"PASSIVE\",\r\n \"controlLoopIdentifierList\": [\r\n {\r\n \"name\": \"K8SInstance0\",\r\n \"version\": \"1.0.1\"\r\n }\r\n ]\r\n}", - "disabled": false - }, - "description": "" - }, - "response": [ - { - "header": [], - "code": 200, - "name": "Response_200", - "id": "f619f68b-4dbe-4c3d-8236-e90ea85c4094" - } - ] - }, - { - "id": "e5b64f76-c4f5-4c23-b273-e2d6cfb48cd7", - "name": "UnInitialise a Control loop", - "request": { - "url": { - "protocol": "https", - "host": "localhost", - "path": [ - "onap", - "controlloop", - "v2", - "instantiation/command" - ], - "port": "6969" - }, - "method": "PUT", - "header": [ - { - "key": "Content-Type", - "value": "application/json", - "description": "", - "disabled": false - }, - { - "key": "Accept", - "value": "*/*", - "disabled": false - } - ], - "body": { - "mode": "raw", - "raw": "{\r\n \"orderedState\": \"UNINTIALISED\",\r\n \"controlLoopIdentifierList\": [\r\n {\r\n \"name\": \"K8SInstance0\",\r\n \"version\": \"1.0.1\"\r\n }\r\n ]\r\n}", - "disabled": false - }, - "description": "" - }, - "response": [ - { - "header": [], - "code": 200, - "name": "Response_200", - "id": "bc8e0792-85df-4934-9f55-69eaf8535fe3" - } - ] - }, - { - "id": "4f359a02-cd9a-4ffd-b594-3478bf32cc2f", - "name": "Instantiate a Control loop", - "request": { - "url": { - "protocol": "https", - "host": "localhost", - "path": [ - "onap", - "controlloop", - "v2", - "instantiation" - ], - "port": "6969" - }, - "method": "POST", - "header": [ - { - "key": "X-ONAP-RequestID", - "value": "709c62b3-8918-41b9-a747-d21eb79c6c20", - "description": "", - "disabled": false - }, - { - "key": "Content-Type", - "value": "application/json", - "description": "", - "disabled": false - }, - { - "key": "Accept", - "value": "*/*", - "disabled": false - } - ], - "body": { - "mode": "raw", - "raw": "{\r\n \"controlLoopList\": [\r\n {\r\n \"name\": \"ConsulInstance0\",\r\n \"version\": \"1.0.1\",\r\n \"definition\": {\r\n \"name\": \"org.onap.domain.sample.PMSH_Http_ControlLoopDefinition\",\r\n \"version\": \"1.2.3\"\r\n },\r\n \"state\": \"UNINITIALISED\",\r\n \"orderedState\": \"UNINITIALISED\",\r\n \"description\": \"PMSH control loop instance 0\",\r\n \"elements\": {\r\n \"709c62b3-8918-41b9-a747-d21eb79c6c25\": {\r\n \"id\": \"709c62b3-8918-41b9-a747-d21eb79c6c25\",\r\n \"definition\": {\r\n \"name\": \"org.onap.domain.database.Http_PMSHMicroserviceControlLoopElement\",\r\n \"version\": \"1.2.3\"\r\n },\r\n \"participantId\": {\r\n \"name\": \"org.onap.controlloop.HttpControlLoopParticipant\",\r\n \"version\": \"2.3.4\"\r\n },\r\n \"participantType\": {\r\n \"name\": \"org.onap.controlloop.HttpControlLoopParticipant\",\r\n \"version\": \"2.3.4\"\r\n },\r\n \"state\": \"UNINITIALISED\",\r\n \"orderedState\": \"UNINITIALISED\",\r\n \"description\": \"DCAE Control Loop Element for the PMSH instance 0 control loop\"\r\n }\r\n }\r\n }\r\n ]\r\n}", - "disabled": false - }, - "description": "" - }, - "response": [ - { - "header": [], - "code": 200, - "name": "Response_200", - "id": "dbdea1c3-05fe-4757-b9a2-74a16d065a12" - } - ] - }, - { - "id": "ad24b4ac-c6f2-4444-97a7-90b007814ba6", - "name": "Commission a Control loop", - "request": { - "url": { - "protocol": "https", - "host": "localhost", - "path": [ - "onap", - "controlloop", - "v2", - "commission" - ], - "port": "6969" - }, - "method": "POST", - "header": [ - { - "key": "Content-Type", - "value": "application/yaml", - "description": "", - "disabled": false - }, - { - "key": "X-ONAP-RequestID", - "value": "709c62b3-8918-41b9-a747-d21eb79c6c20", - "description": "", - "disabled": false - }, - { - "key": "Accept", - "value": "*/*", - "disabled": false - } - ], - "body": { - "mode": "raw", - "raw": "tosca_definitions_version: tosca_simple_yaml_1_3\ndata_types:\n onap.datatypes.ToscaConceptIdentifier:\n derived_from: tosca.datatypes.Root\n properties:\n name:\n type: string\n required: true\n version:\n type: string\n required: true\n\n org.onap.datatypes.policy.clamp.controlloop.httpControlLoopElement.RestRequest:\n version: 1.0.0\n derived_from: tosca.datatypes.Root\n properties:\n restRequestId:\n type: onap.datatypes.ToscaConceptIdentifier\n typeVersion: 1.0.0\n required: true\n description: The name and version of a REST request to be sent to a REST endpoint\n httpMethod:\n type: string\n required: true\n constraints:\n - valid_values: [POST, PUT, GET, DELETE]\n description: The REST method to use\n path:\n type: string\n required: true\n description: The path of the REST request relative to the base URL\n body:\n type: string\n required: false\n description: The body of the REST request for PUT and POST requests\n expectedResponse:\n type: integer\n required: true\n constraints:\n - in_range: [100, 599]\n description: THe expected HTTP status code for the REST request\n org.onap.datatypes.policy.clamp.controlloop.httpControlLoopElement.ConfigurationEntity:\n version: 1.0.0\n derived_from: tosca.datatypes.Root\n properties:\n configurationEntityId:\n type: onap.datatypes.ToscaConceptIdentifier\n typeVersion: 1.0.0\n required: true\n description: The name and version of a Configuration Entity to be handled by the HTTP Control Loop Element\n restSequence:\n type: list\n entry_schema:\n type: org.onap.datatypes.policy.clamp.controlloop.httpControlLoopElement.RestRequest\n typeVersion: 1.0.0\n description: A sequence of REST commands to send to the REST endpoint\n\n\nnode_types:\n org.onap.policy.clamp.controlloop.Participant:\n version: 1.0.1\n derived_from: tosca.nodetypes.Root\n properties:\n provider:\n type: string\n requred: false\n org.onap.policy.clamp.controlloop.ControlLoopElement:\n version: 1.0.1\n derived_from: tosca.nodetypes.Root\n properties:\n provider:\n type: string\n requred: false\n participant_id:\n type: onap.datatypes.ToscaConceptIdentifier\n requred: true\n org.onap.policy.clamp.controlloop.ControlLoop:\n version: 1.0.1\n derived_from: tosca.nodetypes.Root\n properties:\n provider:\n type: string\n requred: false\n elements:\n type: list\n required: true\n entry_schema:\n type: onap.datatypes.ToscaConceptIdentifier\n org.onap.policy.clamp.controlloop.HttpControlLoopElement:\n version: 1.0.1\n derived_from: org.onap.policy.clamp.controlloop.ControlLoopElement\n properties:\n baseUrl:\n type: string\n required: true\n description: The base URL to be prepended to each path, identifies the host for the REST endpoints.\n httpHeaders:\n type: map\n required: false\n entry_schema:\n type: string\n description: HTTP headers to send on REST requests\n configurationEntities:\n type: map\n required: true\n entry_schema:\n type: org.onap.datatypes.policy.clamp.controlloop.httpControlLoopElement.ConfigurationEntity\n typeVersion: 1.0.0\n description: The connfiguration entities the Control Loop Element is managing and their associated REST requests\ntopology_template:\n node_templates:\n org.onap.controlloop.HttpControlLoopParticipant:\n version: 2.3.4\n type: org.onap.policy.clamp.controlloop.Participant\n type_version: 1.0.1\n description: Participant for Http requests\n properties:\n provider: ONAP\n\n org.onap.domain.database.Http_PMSHMicroserviceControlLoopElement:\n # Http config for PMSH.\n version: 1.2.3\n type: org.onap.policy.clamp.controlloop.HttpControlLoopElement\n type_version: 1.0.1\n description: Control loop element for the http requests of PMSH microservice\n properties:\n provider: ONAP\n participant_id:\n name: org.onap.controlloop.HttpControlLoopParticipant\n version: 2.3.4\n uninitializedToPassiveTimeout: 180\n baseUrl: http://10.152.183.51:8500\n httpHeaders:\n Content-Type: application/json\n configurationEntities:\n - configurationEntityId:\n name: entity1\n version: 1.0.1\n restSequence:\n - restRequestId:\n name: request1\n version: 1.0.1\n httpMethod: PUT\n path: v1/kv/dcae-pmsh\n body: '{\n \"control_loop_name\":\"pmsh-control-loop\",\n \"operational_policy_name\":\"pmsh-operational-policy\",\n \"aaf_password\":\"demo123456!\",\n \"aaf_identity\":\"dcae@dcae.onap.org\",\n \"cert_path\":\"/opt/app/pmsh/etc/certs/cert.pem\",\n \"key_path\":\"/opt/app/pmsh/etc/certs/key.pem\",\n \"ca_cert_path\":\"/opt/app/pmsh/etc/certs/cacert.pem\",\n \"enable_tls\":\"true\",\n \"pmsh_policy\":{\n \"subscription\":{\n \"subscriptionName\":\"ExtraPM-All-gNB-R2B\",\n \"administrativeState\":\"UNLOCKED\",\n \"fileBasedGP\":15,\n \"fileLocation\":\"\\/pm\\/pm.xml\",\n \"nfFilter\":{\n \"nfNames\":[\n \"^pnf.*\",\n \"^vnf.*\"\n ],\n \"modelInvariantIDs\":[\n ],\n \"modelVersionIDs\":[\n ],\n \"modelNames\":[\n ]\n },\n \"measurementGroups\":[\n {\n \"measurementGroup\":{\n \"measurementTypes\":[\n {\n \"measurementType\":\"countera\"\n },\n {\n \"measurementType\":\"counterb\"\n }\n ],\n \"managedObjectDNsBasic\":[\n {\n \"DN\":\"dna\"\n },\n {\n \"DN\":\"dnb\"\n }\n ]\n }\n },\n {\n \"measurementGroup\":{\n \"measurementTypes\":[\n {\n \"measurementType\":\"counterc\"\n },\n {\n \"measurementType\":\"counterd\"\n }\n ],\n \"managedObjectDNsBasic\":[\n {\n \"DN\":\"dnc\"\n },\n {\n \"DN\":\"dnd\"\n }\n ]\n }\n }\n ]\n }\n },\n \"streams_subscribes\":{\n \"aai_subscriber\":{\n \"type\":\"message_router\",\n \"dmaap_info\":{\n \"topic_url\":\"https://10.152.183.151:3905/events/AAI_EVENT\",\n \"client_role\":\"org.onap.dcae.aaiSub\",\n \"location\":\"san-francisco\",\n \"client_id\":\"1575976809466\"\n }\n },\n \"policy_pm_subscriber\":{\n \"type\":\"message_router\",\n \"dmaap_info\":{\n \"topic_url\":\"https://10.152.183.151:3905/events/org.onap.dmaap.mr.PM_SUBSCRIPTIONS\",\n \"client_role\":\"org.onap.dcae.pmSubscriber\",\n \"location\":\"san-francisco\",\n \"client_id\":\"1575876809456\"\n }\n }\n },\n \"streams_publishes\":{\n \"policy_pm_publisher\":{\n \"type\":\"message_router\",\n \"dmaap_info\":{\n \"topic_url\":\"https://10.152.183.151:3905/events/org.onap.dmaap.mr.PM_SUBSCRIPTIONS\",\n \"client_role\":\"org.onap.dcae.pmPublisher\",\n \"location\":\"san-francisco\",\n \"client_id\":\"1475976809466\"\n }\n },\n \"other_publisher\":{\n \"type\":\"message_router\",\n \"dmaap_info\":{\n \"topic_url\":\"https://10.152.183.151:3905/events/org.onap.dmaap.mr.SOME_OTHER_TOPIC\",\n \"client_role\":\"org.onap.dcae.pmControlPub\",\n \"location\":\"san-francisco\",\n \"client_id\":\"1875976809466\"\n }\n }\n }\n }'\n expectedResponse: 200\n\n\n org.onap.domain.sample.PMSH_Http_ControlLoopDefinition:\n version: 1.2.3\n type: org.onap.policy.clamp.controlloop.ControlLoop\n type_version: 1.0.0\n description: Control loop for HTTP request to Consul\n properties:\n provider: ONAP\n elements:\n - name: org.onap.domain.database.Http_PMSHMicroserviceControlLoopElement\n version: 1.2.3", - "disabled": false - }, - "description": "" - }, - "response": [ - { - "header": [], - "code": 200, - "name": "Response_200", - "id": "0e98286f-2143-4af9-a291-4f3719b2cedb" - } - ] - } - ], - "variable": [], - "auth": { - "type": "basic", - "basic": { - "username": "runtimeUser", - "password": "zb!XztG34" - } - } -} \ No newline at end of file diff --git a/common/src/test/resources/examples/controlloop/k8s-participant/k8s.postman2.0_collection.json b/common/src/test/resources/examples/controlloop/k8s-participant/k8s.postman2.0_collection.json deleted file mode 100644 index e83bc2594..000000000 --- a/common/src/test/resources/examples/controlloop/k8s-participant/k8s.postman2.0_collection.json +++ /dev/null @@ -1,254 +0,0 @@ -{ - "info": { - "name": "CL-K8s-participant", - "_postman_id": "90ac155d-08ff-4dce-a4f0-24e8d8aefa70", - "description": "", - "schema": "https://schema.getpostman.com/json/collection/v2.0.0/collection.json" - }, - "item": [ - { - "id": "711b8171-7b0f-4461-b5ad-fb00bc03b1a3", - "name": "Get Instantiated Control loops", - "request": { - "url": { - "protocol": "https", - "host": "localhost", - "path": [ - "onap", - "controlloop", - "v2", - "instantiation" - ], - "port": "6969" - }, - "method": "GET", - "header": [ - { - "key": "Accept", - "value": "*/*", - "disabled": false - } - ], - "body": { - "mode": "raw", - "disabled": false - }, - "description": "" - }, - "response": [ - { - "header": [], - "code": 200, - "name": "Response_200", - "id": "d10bdd1f-ff18-49ed-9798-1705bb579668" - } - ] - }, - { - "id": "3b0c5920-42b4-4647-8a15-bfcb02cfbd54", - "name": "Update a Control loop", - "request": { - "url": { - "protocol": "https", - "host": "localhost", - "path": [ - "onap", - "controlloop", - "v2", - "instantiation/command" - ], - "port": "6969" - }, - "method": "PUT", - "header": [ - { - "key": "Content-Type", - "value": "application/json", - "description": "", - "disabled": false - }, - { - "key": "X-ONAP-RequestID", - "value": "709c62b3-8918-41b9-a747-d21eb79c6c20", - "description": "", - "disabled": false - }, - { - "key": "Accept", - "value": "*/*", - "disabled": false - } - ], - "body": { - "mode": "raw", - "raw": "{\r\n \"orderedState\": \"PASSIVE\",\r\n \"controlLoopIdentifierList\": [\r\n {\r\n \"name\": \"K8SInstance0\",\r\n \"version\": \"1.0.1\"\r\n }\r\n ]\r\n}", - "disabled": false - }, - "description": "" - }, - "response": [ - { - "header": [], - "code": 200, - "name": "Response_200", - "id": "9b6719f4-d325-45ee-9951-ac50bc8e4d38" - } - ] - }, - { - "id": "d9c9a188-3fe1-4950-b851-9f76b0c72f63", - "name": "UnInitialise a Control loop", - "request": { - "url": { - "protocol": "https", - "host": "localhost", - "path": [ - "onap", - "controlloop", - "v2", - "instantiation/command" - ], - "port": "6969" - }, - "method": "PUT", - "header": [ - { - "key": "Content-Type", - "value": "application/json", - "description": "", - "disabled": false - }, - { - "key": "Accept", - "value": "*/*", - "disabled": false - } - ], - "body": { - "mode": "raw", - "raw": "{\r\n \"orderedState\": \"UNINTIALISED\",\r\n \"controlLoopIdentifierList\": [\r\n {\r\n \"name\": \"K8SInstance0\",\r\n \"version\": \"1.0.1\"\r\n }\r\n ]\r\n}", - "disabled": false - }, - "description": "" - }, - "response": [ - { - "header": [], - "code": 200, - "name": "Response_200", - "id": "69ae3508-0fef-42c7-b96b-28f3b98f599e" - } - ] - }, - { - "id": "3626da99-5645-4386-85cf-0bbe296adf6d", - "name": "Instantiate a Control loop", - "request": { - "url": { - "protocol": "https", - "host": "localhost", - "path": [ - "onap", - "controlloop", - "v2", - "instantiation" - ], - "port": "6969" - }, - "method": "POST", - "header": [ - { - "key": "X-ONAP-RequestID", - "value": "709c62b3-8918-41b9-a747-d21eb79c6c20", - "description": "", - "disabled": false - }, - { - "key": "Content-Type", - "value": "application/json", - "description": "", - "disabled": false - }, - { - "key": "Accept", - "value": "*/*", - "disabled": false - } - ], - "body": { - "mode": "raw", - "raw": "{\r\n \"controlLoopList\": [\r\n {\r\n \"name\": \"K8SInstance0\",\r\n \"version\": \"1.0.1\",\r\n \"definition\": {\r\n \"name\": \"org.onap.domain.sample.GenericK8s_ControlLoopDefinition\",\r\n \"version\": \"1.2.3\"\r\n },\r\n \"state\": \"UNINITIALISED\",\r\n \"orderedState\": \"UNINITIALISED\",\r\n \"description\": \"K8s control loop instance 0\",\r\n \"elements\": {\r\n \"709c62b3-8918-41b9-a747-d21eb79c6c20\": {\r\n \"id\": \"709c62b3-8918-41b9-a747-d21eb79c6c20\",\r\n \"definition\": {\r\n \"name\": \"org.onap.domain.database.HelloWorld_K8SMicroserviceControlLoopElement\",\r\n \"version\": \"1.2.3\"\r\n },\r\n \"participantId\": {\r\n \"name\": \"org.onap.k8s.controlloop.K8SControlLoopParticipant\",\r\n \"version\": \"2.3.4\"\r\n },\r\n \"participantType\": {\r\n \"name\": \"org.onap.k8s.controlloop.K8SControlLoopParticipant\",\r\n \"version\": \"2.3.4\"\r\n },\r\n \"state\": \"UNINITIALISED\",\r\n \"orderedState\": \"UNINITIALISED\",\r\n \"description\": \"K8s Control Loop Element for the k8s instance 0 control loop\"\r\n },\r\n \"709c62b3-8918-41b9-a747-d21eb79c6c21\": {\r\n \"id\": \"709c62b3-8918-41b9-a747-d21eb79c6c21\",\r\n \"definition\": {\r\n \"name\": \"org.onap.domain.database.PMSH_K8SMicroserviceControlLoopElement\",\r\n \"version\": \"1.2.3\"\r\n },\r\n \"participantId\": {\r\n \"name\": \"org.onap.k8s.controlloop.K8SControlLoopParticipant\",\r\n \"version\": \"2.3.4\"\r\n },\r\n \"participantType\": {\r\n \"name\": \"org.onap.k8s.controlloop.K8SControlLoopParticipant\",\r\n \"version\": \"2.3.4\"\r\n },\r\n \"state\": \"UNINITIALISED\",\r\n \"orderedState\": \"UNINITIALISED\",\r\n \"description\": \"K8s Control Loop Element for the PMSH instance 0 control loop\"\r\n },\r\n \"709c62b3-8918-41b9-a747-d21eb79c6c22\": {\r\n \"id\": \"709c62b3-8918-41b9-a747-d21eb79c6c22\",\r\n \"definition\": {\r\n \"name\": \"org.onap.domain.database.Local_K8SMicroserviceControlLoopElement\",\r\n \"version\": \"1.2.3\"\r\n },\r\n \"participantId\": {\r\n \"name\": \"org.onap.k8s.controlloop.K8SControlLoopParticipant\",\r\n \"version\": \"2.3.4\"\r\n },\r\n \"participantType\": {\r\n \"name\": \"org.onap.k8s.controlloop.K8SControlLoopParticipant\",\r\n \"version\": \"2.3.4\"\r\n },\r\n \"state\": \"UNINITIALISED\",\r\n \"orderedState\": \"UNINITIALISED\",\r\n \"description\": \"K8s Control Loop Element for the local instance 0 control loop\"\r\n }\r\n }\r\n }\r\n ]\r\n}", - "disabled": false - }, - "description": "" - }, - "response": [ - { - "header": [], - "code": 200, - "name": "Response_200", - "id": "76e0d5e8-f5c9-456e-b908-c9f24ebc5613" - } - ] - }, - { - "id": "9e88fc2f-6a65-4693-ab78-d69139d06d02", - "name": "Commission a Control loop", - "request": { - "url": { - "protocol": "https", - "host": "localhost", - "path": [ - "onap", - "controlloop", - "v2", - "commission" - ], - "port": "6969" - }, - "method": "POST", - "header": [ - { - "key": "Content-Type", - "value": "application/yaml", - "description": "", - "disabled": false - }, - { - "key": "X-ONAP-RequestID", - "value": "709c62b3-8918-41b9-a747-d21eb79c6c20", - "description": "", - "disabled": false - }, - { - "key": "Accept", - "value": "*/*", - "disabled": false - } - ], - "body": { - "mode": "raw", - "raw": "tosca_definitions_version: tosca_simple_yaml_1_3\ndata_types:\n onap.datatypes.ToscaConceptIdentifier:\n derived_from: tosca.datatypes.Root\n properties:\n name:\n type: string\n required: true\n version:\n type: string\n required: true\nnode_types:\n org.onap.policy.clamp.controlloop.Participant:\n version: 1.0.1\n derived_from: tosca.nodetypes.Root\n properties:\n provider:\n type: string\n requred: false\n org.onap.policy.clamp.controlloop.ControlLoopElement:\n version: 1.0.1\n derived_from: tosca.nodetypes.Root\n properties:\n provider:\n type: string\n requred: false\n participant_id:\n type: onap.datatypes.ToscaConceptIdentifier\n requred: true\n org.onap.policy.clamp.controlloop.ControlLoop:\n version: 1.0.1\n derived_from: tosca.nodetypes.Root\n properties:\n provider:\n type: string\n requred: false\n elements:\n type: list\n required: true\n entry_schema:\n type: onap.datatypes.ToscaConceptIdentifier\n org.onap.policy.clamp.controlloop.K8SMicroserviceControlLoopElement:\n version: 1.0.1\n derived_from: org.onap.policy.clamp.controlloop.ControlLoopElement\n properties:\n chart:\n type: string\n required: true\n configs:\n type: list\n required: false\n requirements:\n type: string\n requred: false\n templates:\n type: list\n required: false\n entry_schema:\n values:\n type: string\n requred: true\ntopology_template:\n node_templates:\n org.onap.k8s.controlloop.K8SControlLoopParticipant:\n version: 2.3.4\n type: org.onap.policy.clamp.controlloop.Participant\n type_version: 1.0.1\n description: Participant for K8S\n properties:\n provider: ONAP\n \n org.onap.domain.database.HelloWorld_K8SMicroserviceControlLoopElement:\n # Chart from any chart repository configured on helm client.\n version: 1.2.3\n type: org.onap.policy.clamp.controlloop.K8SMicroserviceControlLoopElement\n type_version: 1.0.0\n description: Control loop element for the K8S microservice for Hello World\n properties:\n provider: ONAP\n participant_id:\n name: org.onap.k8s.controlloop.K8SControlLoopParticipant\n version: 2.3.4\n chart: \n chartId: \n name: dummy\n version: 0.1.0 \n releaseName: test \n namespace: test \n\n org.onap.domain.database.PMSH_K8SMicroserviceControlLoopElement: \n # Chart from local file system \n version: 1.2.3\n type: org.onap.policy.clamp.controlloop.K8SMicroserviceControlLoopElement\n type_version: 1.0.0\n description: Control loop element for the K8S microservice for PMSH\n properties:\n provider: ONAP\n participant_id:\n name: org.onap.k8s.controlloop.K8SControlLoopParticipant\n version: 2.3.4\n chart: \n chartId: \n name: dcae-pmsh \n version: 8.0.0\n namespace: onap \n releaseName: pmshms\n repository:\n repoName: chartmuseum\n protocol: http\n address: 10.152.183.120\n port: 80\n userName: onapinitializer\n password: demo123456!\n overrideParams:\n global.masterPassword: test\n \n \n\n org.onap.domain.database.Local_K8SMicroserviceControlLoopElement: \n # Chart installation without passing repository name \n version: 1.2.3\n type: org.onap.policy.clamp.controlloop.K8SMicroserviceControlLoopElement\n type_version: 1.0.0\n description: Control loop element for the K8S microservice for local chart\n properties:\n provider: ONAP\n participant_id:\n name: org.onap.k8s.controlloop.K8SControlLoopParticipant\n version: 2.3.4\n chart:\n chartId: \n name: nginx-ingress\n version: 0.9.1 \n releaseName: nginxms\n namespace: test \n repository:\n repoName: nginx-stable \n\n org.onap.domain.sample.GenericK8s_ControlLoopDefinition:\n version: 1.2.3\n type: org.onap.policy.clamp.controlloop.ControlLoop\n type_version: 1.0.0\n description: Control loop for Hello World\n properties:\n provider: ONAP\n elements: \n - name: org.onap.domain.database.HelloWorld_K8SMicroserviceControlLoopElement\n version: 1.2.3 \n - name: org.onap.domain.database.PMSH_K8SMicroserviceControlLoopElement\n version: 1.2.3 \n - name: org.onap.domain.database.Local_K8SMicroserviceControlLoopElement\n version: 1.2.3 \n ", - "disabled": false - }, - "description": "" - }, - "response": [ - { - "header": [], - "code": 200, - "name": "Response_200", - "id": "ab57b923-a484-486c-a03a-b1ad6bf64d09" - } - ] - } - ], - "variable": [], - "auth": { - "type": "basic", - "basic": { - "username": "runtimeUser", - "password": "zb!XztG34" - } - } -} \ No newline at end of file diff --git a/common/src/test/resources/examples/controlloop/original/cloop_DCAE_VES_TCA_substitution.yaml b/common/src/test/resources/examples/controlloop/original/cloop_DCAE_VES_TCA_substitution.yaml deleted file mode 100644 index 96ea133c2..000000000 --- a/common/src/test/resources/examples/controlloop/original/cloop_DCAE_VES_TCA_substitution.yaml +++ /dev/null @@ -1,83 +0,0 @@ -# ============LICENSE_START======================================================= -# Copyright (C) 2021 Nordix Foundation. -# ================================================================================ -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# -# SPDX-License-Identifier: Apache-2.0 -# ============LICENSE_END========================================================= - -tosca_definitions_version: tosca_simple_yaml_1_3 - -imports: - - cloop_base_types.yaml - - cloop_dcae_types.yaml - -topology_template: - inputs: - some_property_input: - type: string - - substitution_mappings: - node_type: org.onap.DCAE_VES_TCA - properties: - some_property: { get_input: some_property_input } - capabilities: - VES-5.28.4-publisher: [ node1_VES_Collector, VES-5.28.4-publisher ] - VES-7.30.1-publisher: [ node1_VES_Collector, VES-7.30.1-publisher ] - TCA-handle-out-publisher: [ node2_TCA_GEN_2, TCA-handle-out-publisher ] - VES_specification-subscriber: [ node2_TCA_GEN_2, VES_specification-subscriber ] - - node_templates: - ################################################################################ - #alt1: without relay - - node1_VES_Collector: - type: org.onap.VESCollector - - node2_TCA_GEN_2: - type: org.onap.TCA_GEN_2 - requirements: - - receive: - capability: VES-5.28.4-publisher - node: node1_VES_Collector - relationship: - type: org.onap.PropagateEvent - properties: - config-keys: [ ves-measurement ] - - - ################################################################################ - #alt2: with relay - - node1_VES_Collector: - type: org.onap.VESCollector - - node2_TCA_GEN_2: - type: org.onap.TCA_GEN_2 - - node3_Relay: - type: org.onap.EventRelay - properties: - event_format: "VES_specification" - event_format_version: "5.28.4" - supported_carrier_protocols: [{ DMAAP_message_router: DMAAP_message_router }] - supported_data_formats: [{ JSON: JSON }] - requirements: - - receive: - node: node1_VES_Collector - properties: - config_keys: [ ves-measurement ] - - send: - node: node2_TCA_GEN_2 - properties: - config_keys: [ ves-measurement ] diff --git a/common/src/test/resources/examples/controlloop/original/cloop_base_types.yaml b/common/src/test/resources/examples/controlloop/original/cloop_base_types.yaml deleted file mode 100644 index 4f29e5635..000000000 --- a/common/src/test/resources/examples/controlloop/original/cloop_base_types.yaml +++ /dev/null @@ -1,210 +0,0 @@ -# ============LICENSE_START======================================================= -# Copyright (C) 2021 Nordix Foundation. -# ================================================================================ -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# -# SPDX-License-Identifier: Apache-2.0 -# ============LICENSE_END========================================================= - -tosca_definitions_version: tosca_simple_yaml_1_2 - -capability_types: - #producer capability type - org.onap.EventProducer: - derived_from: tosca.capabilities.Root - properties: - carrier_protocol_type: - type: string - required: true - constraints: - valid_values: [ DMAAP_message_router, REST ] - #all valid values should be added here - data_format: - type: string - required: true - constraints: - valid_values: [ JSON, YAML, JMS ] - #all valid values should be added here - event_format: - type: string - required: true - #examples for event_format: Ves_specification, etc. - event_format_version: - type: string - #examples for event_format_version: 5.28.4, 7.30.1, etc. - config_keys: - type: list - required: false - entry_schema: - type: string - constraints: - #valid_values: [ ] - #all valid values should be added here - #if not specified, events of any config key may be generated - #examples for config_key: ves-measurement, ves-syslog, tca_handle_out, etc. - - - #consumer capability type - org.onap.EventConsumer: - derived_from: tosca.capabilities.Root - properties: - carrier_protocol_type: - type: string - required: true - constraints: - valid_values: [ DMAAP_message_router, REST ] - #all valid values should be added here - data_format: - type: string - required: true - constraints: - valid_values: [ JSON, YAML, JMS ] - #all valid values should be added here - event_format: - type: string - required: true - #examples for event_format: Ves_specification, LinkUp, VnfConfigured, etc. - event_format_version: - type: string - #examples for event_format_version: 5.28.4, 7.30.1, etc. - config_keys: - type: list - required: false - entry_schema: - type: string - constraints: - #valid_values: [ ] - #all valid values should be added here - #if not specified, events of any config key may be generated - #examples for config_key: ves-measurement, ves-syslog, tca_handle_out, etc. - - -relationship_types: - #the relationship type used on requirements to org.onap.EventProducer and org.onap.EventConsumer capabilities - org.onap.PropagateEvent: - derived_from: tosca.relationships.Root - properties: - config_keys: - type: list - required: false - description: > - Filters events by specific config_keys to be transferred by this relationship. - That is, any event with a specific config_key found in the list is transferred. - If list is not defined or is empty, events with all config_keys are transferred. - entry_schema: string - - - -node_types: - #base app node type - org.onap.APP: - derived_from: tosca.nodes.Root - properties: - application_name: - type: string - description: Human readable name for the application Product - required: false - provider: - type: string - description: Provider of the application and of the descriptor - required: true - application_version: - type: string - description: Software version of the application - required: true - blueprint_id: - type: string - description: A reference to the app blueprint - monitoring_policy: - type: string - required: false - description: A reference to the monitoring policy - requirements: - - receive: - capability: org.onap.EventProducer - relationship: org.onap.PropagateEvent - occurrences: [0, UNBOUNDED] - - send: - capability: org.onap.EventConsumer - relationship: org.onap.PropagateEvent - occurrences: [0, UNBOUNDED] - - #the event relay node type - org.onap.EventRelay: - derived_from: tosca.nodes.Root - properties: - event_format: - type: string - required: true - #examples for event_format: Ves_specification, etc. - event_format_version: - type: string - required: true - #examples for event_format_version: 5.28.4, 7.30.1, etc. - config_keys: - type: list - required: false - entry_schema: - type: string - constraints: - #valid_values: [ ] - #all valid values should be added here - #if not specified, events of any config key is relayed - #examples for config_key: ves-measurement, ves-syslog, tca_handle_out, etc. - supported_carrier_protocols: - type: map - required: true - description: > - A map describing supported carrier protocols and translations. The - tuples define what protocol combinations are supported on the producer - and consumer side: e.g. { REST: REST, DMAAP: REST, DMAAP: DMAAP} - key_schema: - type: string - constraints: - valid_values: [ DMAAP_message_router, REST ] - #all valid values should be added here - entry_schema: - type: string - constraints: - valid_values: [ DMAAP_message_router, REST ] - #all valid values should be added here - supported_data_formats: - type: map - required: true - description: > - Is a map describing supported data formats and translation. The tuples - define what protocol combinations are supported on the producer and - consumer side: e.g. { JSON: JSON, JMS: JSON, YAML:YAML } - key_schema: - type: string - constraints: - valid_values: [ JSON, JMS, YAML, etc ] - #all valid values should be added here - entry_schema: - type: string - constraints: - valid_values: [ JSON, JMS, YAML, etc ] - #all valid values should be added here - requirements: - - receive: - capability: org.onap.EventProducer - relationship: org.onap.PropagateEvent - occurrences: [1, UNBOUNDED] - - send: - capability: org.onap.EventConsumer - relationship: org.onap.PropagateEvent - occurrences: [1, UNBOUNDED] - - - - diff --git a/common/src/test/resources/examples/controlloop/original/cloop_dcae_example.yaml b/common/src/test/resources/examples/controlloop/original/cloop_dcae_example.yaml deleted file mode 100644 index 4629f6f75..000000000 --- a/common/src/test/resources/examples/controlloop/original/cloop_dcae_example.yaml +++ /dev/null @@ -1,50 +0,0 @@ -# ============LICENSE_START======================================================= -# Copyright (C) 2021 Nordix Foundation. -# ================================================================================ -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# -# SPDX-License-Identifier: Apache-2.0 -# ============LICENSE_END========================================================= - -tosca_definitions_version: tosca_simple_yaml_1_3 - -imports: - - cloop_base_types.yaml - - cloop_dcae_types.yaml - - cloop_other_types.yaml - -topology_template: - node_templates: - - node1_DCAE_VES_TCA: - type: org.onap.DCAE_VES_TCA - directives: - - substitute - - node2_PolicyFramework: - type: org.onap.ApexPolicyFramework - requirements: - - receive: - capability: TCA-handle-out-publisher - node: node1_DCAE_VES_TCA - relationship: - properties: - config_keys: [ ves-measurement ] - - send: - capability: SelfService - node: org.onap.CDS - relationship: - properties: - config_keys: [ ves-measurement ] - - #if this closed loop to subscribe to other events via the VesCollector, should we not add that? diff --git a/common/src/test/resources/examples/controlloop/original/cloop_dcae_types.yaml b/common/src/test/resources/examples/controlloop/original/cloop_dcae_types.yaml deleted file mode 100644 index 5f96cd5df..000000000 --- a/common/src/test/resources/examples/controlloop/original/cloop_dcae_types.yaml +++ /dev/null @@ -1,140 +0,0 @@ -# ============LICENSE_START======================================================= -# Copyright (C) 2021 Nordix Foundation. -# ================================================================================ -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# -# SPDX-License-Identifier: Apache-2.0 -# ============LICENSE_END========================================================= - -tosca_definitions_version: tosca_simple_yaml_1_3 - -imports: - - cloop_types.yaml - -node_types: - - #node type for VES_Collector - org.onap.VES_Collector: - derived_from: org.onap.APP - capabilities: - VES-5.28.4-publisher: - type: org.onap.EventProducer - occurrences: [ 0, UNBOUNDED ] - properties: - carrier_protocol_type: "DMAAP_message_router" - data_format: "JSON" - event_format: "VES_specification" - event_format_version: "5.28.4" - config_keys: - - "ves-fault" - - "ves-measurement" - - "ves-syslog" - - "ves-heartbeat" - - "ves-other" - - "ves-mobileflow" - - "ves-statechange" - - "ves-thresholdCrossingAlert" - - "ves-voicequality" - - "ves-sipsignaling" - VES-7.30.1-publisher: - type: org.onap.EventProducer - occurrences: [ 0, UNBOUNDED ] - properties: - carrier_protocol_type: "DMAAP_message_router" - data_format: "JSON" - event_format: "VES_specification" - event_format_version: "7.30.1" - config_keys: - - "ves-fault" - - "ves-pnfRegistration" - - "ves-notification" - - "ves-perf3gpp" - - #node type for TCA_GEN_2 - org.onap.TCA_GEN_2: - derived_from: org.onap.APP - capabilities: - TCA-handle-out-publisher: - type: org.onap.EventProducer - occurrences: [ 0, UNBOUNDED ] - properties: - carrier_protocol_type: "DMAAP_message_router" - data_format: "JSON" - event_format: "DCAE_CL_Output" - event_format_version: "1.0.1" - config_keys: [ "tca_handle_out" ] - VES_specification-subscriber: - type: org.onap.EventConsumer - occurrences: [ 0, UNBOUNDED ] - properties: - carrier_protocol_type: "DMAAP_message_router" - data_format: "JSON" - event_format: "VES_specification" - event_format_version: "5.28.4" - config_keys: [ "tca_handle_in" ] - - - - #node type for the composed VES_Collector and TCA_GEN_2 - org.onap.DCAE_VES_TCA: - derived_from: org.onap.APP - capabilities: - VES-5.28.4-publisher: - type: org.onap.EventProducer - occurrences: [ 0, UNBOUNDED ] - properties: - carrier_protocol_type: "DMAAP_message_router" - data_format: "JSON" - event_format: "VES_specification" - event_format_version: "5.28.4" - config_keys: - - "ves-fault" - - "ves-measurement" - - "ves-syslog" - - "ves-heartbeat" - - "ves-other" - - "ves-mobileflow" - - "ves-statechange" - - "ves-thresholdCrossingAlert" - - "ves-voicequality" - - "ves-sipsignaling" - VES-7.30.1-publisher: - type: org.onap.EventProducer - occurrences: [ 0, UNBOUNDED ] - properties: - carrier_protocol_type: "DMAAP_message_router" - data_format: "JSON" - event_format: "VES_specification" - event_format_version: "7.30.1" - config_keys: - - "ves-pnfRegistration" - - "ves-notification" - - "ves-perf3gpp" - TCA-handle-out-publisher: - type: org.onap.EventProducer - occurrences: [ 0, UNBOUNDED ] - properties: - carrier_protocol_type: "DMAAP_message_router" - data_format: "JSON" - event_format: "DCAE_CL_Output" - event_format_version: "1.0.1" - config_keys: [ "tca_handle_out" ] - VES_specification-subscriber: - type: org.onap.EventConsumer - occurrences: [ 0, UNBOUNDED ] - properties: - carrier_protocol_type: "DMAAP_message_router" - data_format: "JSON" - event_format: "VES_specification" - event_format_version: "5.28.4" - config_keys: [ "tca_handle_in" ] diff --git a/common/src/test/resources/examples/controlloop/original/cloop_other_types.yaml b/common/src/test/resources/examples/controlloop/original/cloop_other_types.yaml deleted file mode 100644 index d743f499f..000000000 --- a/common/src/test/resources/examples/controlloop/original/cloop_other_types.yaml +++ /dev/null @@ -1,63 +0,0 @@ -# ============LICENSE_START======================================================= -# Copyright (C) 2021 Nordix Foundation. -# ================================================================================ -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# -# SPDX-License-Identifier: Apache-2.0 -# ============LICENSE_END========================================================= - -tosca_definitions_version: tosca_simple_yaml_1_2 - -imports: - - cloop_base_types.yaml - -node_types: - #node type for Policy - org.onap.PolicyFramework: - derived_from: org.onap.APP - - #node type for Apex Policy - org.onap.ApexPolicyFramework: - derived_from: org.onap.PolicyFramework - - #node type for CDS - org.onap.CDS: - derived_from: org.onap.APP - capabilities: - #consumer capability for CDS for events of type ResourceAndTemplate management API - ResourceAndTemplateManagement: - type: org.onap.EventConsumer - properties: - carrier_protocol_type: "DMAAP_message_router" - data_format: "JSON" - event_format: "ResourceAndTemplate" - event_format_version: "x.xx.x" - occurrences: [ 0, UNBOUNDED ] - #consumer capability for CDS for events of type SelfService API - SelfService: - type: org.onap.EventConsumer - properties: - carrier_protocol_type: "DMAAP_message_router" - data_format: "JSON" - event_format: "SelfService" - event_format_version: "x.xx.x" - occurrences: [ 0, UNBOUNDED ] - #producer capability for CDS for events of type PNFControl - PNFcontrolEventsProducer: - type: org.onap.EventProducer - properties: - carrier_protocol_type: "DMAAP_message_router" - data_format: "JSON" - event_format: "PNFcontrol" - event_format_version: "x.xx.x" - occurrences: [ 0, UNBOUNDED ] diff --git a/models/src/main/java/org/onap/policy/clamp/controlloop/models/controlloop/concepts/ClElementStatistics.java b/models/src/main/java/org/onap/policy/clamp/controlloop/models/controlloop/concepts/ClElementStatistics.java deleted file mode 100644 index 4ef9bdcd9..000000000 --- a/models/src/main/java/org/onap/policy/clamp/controlloop/models/controlloop/concepts/ClElementStatistics.java +++ /dev/null @@ -1,53 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * Copyright (C) 2021 Nordix Foundation. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - * SPDX-License-Identifier: Apache-2.0 - * ============LICENSE_END========================================================= - */ - -package org.onap.policy.clamp.controlloop.models.controlloop.concepts; - -import java.io.Serializable; -import java.time.Instant; -import java.util.UUID; -import lombok.Data; -import lombok.NoArgsConstructor; -import lombok.NonNull; -import lombok.ToString; -import org.onap.policy.models.tosca.authorative.concepts.ToscaConceptIdentifier; - -@NoArgsConstructor -@Data -@ToString -public class ClElementStatistics implements Serializable { - - private static final long serialVersionUID = 3284285693112271055L; - - @NonNull - private UUID id = UUID.randomUUID(); - - @NonNull - private ToscaConceptIdentifier participantId; - - @NonNull - private Instant timeStamp; - - @NonNull - private ControlLoopState controlLoopState; - - private long clElementUptime; - -} diff --git a/models/src/main/java/org/onap/policy/clamp/controlloop/models/controlloop/concepts/ClElementStatisticsList.java b/models/src/main/java/org/onap/policy/clamp/controlloop/models/controlloop/concepts/ClElementStatisticsList.java deleted file mode 100644 index 166f1e48f..000000000 --- a/models/src/main/java/org/onap/policy/clamp/controlloop/models/controlloop/concepts/ClElementStatisticsList.java +++ /dev/null @@ -1,33 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * Copyright (C) 2021 Nordix Foundation. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - * SPDX-License-Identifier: Apache-2.0 - * ============LICENSE_END========================================================= - */ - -package org.onap.policy.clamp.controlloop.models.controlloop.concepts; - -import java.util.List; -import lombok.Getter; -import lombok.Setter; -import lombok.ToString; - -@Getter -@Setter -@ToString -public class ClElementStatisticsList { - private List clElementStatistics; -} diff --git a/models/src/main/java/org/onap/policy/clamp/controlloop/models/controlloop/concepts/ControlLoop.java b/models/src/main/java/org/onap/policy/clamp/controlloop/models/controlloop/concepts/ControlLoop.java deleted file mode 100644 index cf22b7228..000000000 --- a/models/src/main/java/org/onap/policy/clamp/controlloop/models/controlloop/concepts/ControlLoop.java +++ /dev/null @@ -1,116 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * Copyright (C) 2021 Nordix Foundation. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - * SPDX-License-Identifier: Apache-2.0 - * ============LICENSE_END========================================================= - */ - -package org.onap.policy.clamp.controlloop.models.controlloop.concepts; - -import java.util.List; -import java.util.Map; -import java.util.UUID; -import java.util.stream.Collectors; -import lombok.Data; -import lombok.EqualsAndHashCode; -import lombok.NoArgsConstructor; -import lombok.NonNull; -import org.apache.commons.collections4.MapUtils; -import org.onap.policy.models.base.PfConceptKey; -import org.onap.policy.models.base.PfUtils; -import org.onap.policy.models.tosca.authorative.concepts.ToscaConceptIdentifier; -import org.onap.policy.models.tosca.authorative.concepts.ToscaEntity; - -/** - * Class to represent a control loop instance. - */ -@NoArgsConstructor -@Data -@EqualsAndHashCode(callSuper = true) -public class ControlLoop extends ToscaEntity implements Comparable { - @NonNull - private ToscaConceptIdentifier definition = new ToscaConceptIdentifier(PfConceptKey.getNullKey()); - - @NonNull - private ControlLoopState state = ControlLoopState.UNINITIALISED; - - @NonNull - private ControlLoopOrderedState orderedState = ControlLoopOrderedState.UNINITIALISED; - - private Map elements; - - @NonNull - private Boolean primed = false; - - @Override - public String getType() { - return definition.getName(); - } - - @Override - public String getTypeVersion() { - return definition.getVersion(); - } - - /** - * Copy contructor, does a deep copy. - * - * @param otherControlLoop the other element to copy from - */ - public ControlLoop(final ControlLoop otherControlLoop) { - super(otherControlLoop); - this.definition = new ToscaConceptIdentifier(otherControlLoop.definition); - this.state = otherControlLoop.state; - this.orderedState = otherControlLoop.orderedState; - this.elements = PfUtils.mapMap(otherControlLoop.elements, ControlLoopElement::new); - this.primed = otherControlLoop.primed; - } - - @Override - public int compareTo(final ControlLoop other) { - return compareNameVersion(this, other); - } - - /** - * Set the ordered state on the control loop and on all its control loop elements. - * - * @param orderedState the state we want the control loop to transition to - */ - public void setCascadedOrderedState(final ControlLoopOrderedState orderedState) { - this.orderedState = orderedState; - - if (MapUtils.isEmpty(elements)) { - return; - } - - elements.values().forEach(element -> element.setOrderedState(orderedState)); - } - - /** - * Get a list of control loop element statistics. - * - * @param controlLoop the control loop - * @return List of ClElementStatistics - */ - public List getControlLoopElementStatisticsList(final ControlLoop controlLoop) { - if (MapUtils.isEmpty(controlLoop.elements)) { - return List.of(); - } - - return controlLoop.elements.values().stream().map(ControlLoopElement::getClElementStatistics) - .collect(Collectors.toList()); - } -} diff --git a/models/src/main/java/org/onap/policy/clamp/controlloop/models/controlloop/concepts/ControlLoopElement.java b/models/src/main/java/org/onap/policy/clamp/controlloop/models/controlloop/concepts/ControlLoopElement.java deleted file mode 100644 index c7d85e4b6..000000000 --- a/models/src/main/java/org/onap/policy/clamp/controlloop/models/controlloop/concepts/ControlLoopElement.java +++ /dev/null @@ -1,89 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * Copyright (C) 2021 Nordix Foundation. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - * SPDX-License-Identifier: Apache-2.0 - * ============LICENSE_END========================================================= - */ - -package org.onap.policy.clamp.controlloop.models.controlloop.concepts; - -import java.util.LinkedHashMap; -import java.util.Map; -import java.util.UUID; -import java.util.function.UnaryOperator; -import lombok.Data; -import lombok.NoArgsConstructor; -import lombok.NonNull; -import lombok.ToString; -import org.onap.policy.models.base.PfConceptKey; -import org.onap.policy.models.base.PfUtils; -import org.onap.policy.models.tosca.authorative.concepts.ToscaConceptIdentifier; -import org.onap.policy.models.tosca.authorative.concepts.ToscaProperty; -import org.onap.policy.models.tosca.authorative.concepts.ToscaServiceTemplate; - -/** - * Class to represent a control loop instance. - */ -@NoArgsConstructor -@Data -@ToString -public class ControlLoopElement { - @NonNull - private UUID id = UUID.randomUUID(); - - @NonNull - private ToscaConceptIdentifier definition = new ToscaConceptIdentifier(PfConceptKey.getNullKey()); - - @NonNull - private ToscaConceptIdentifier participantType = new ToscaConceptIdentifier(PfConceptKey.getNullKey()); - - @NonNull - private ToscaConceptIdentifier participantId = new ToscaConceptIdentifier(PfConceptKey.getNullKey()); - - @NonNull - private ControlLoopState state = ControlLoopState.UNINITIALISED; - - @NonNull - private ControlLoopOrderedState orderedState = ControlLoopOrderedState.UNINITIALISED; - - private ToscaServiceTemplate toscaServiceTemplateFragment; - - private String description; - - private ClElementStatistics clElementStatistics; - - // A map indexed by the property name. Each map entry is the serialized value of the property, - // which can be deserialized into an instance of the type of the property. - private Map propertiesMap = new LinkedHashMap<>(); - - /** - * Copy constructor, does a deep copy but as all fields here are immutable, it's just a regular copy. - * - * @param otherElement the other element to copy from - */ - public ControlLoopElement(final ControlLoopElement otherElement) { - this.id = otherElement.id; - this.definition = new ToscaConceptIdentifier(otherElement.definition); - this.participantType = new ToscaConceptIdentifier(otherElement.participantType); - this.participantId = new ToscaConceptIdentifier(otherElement.participantId); - this.state = otherElement.state; - this.orderedState = otherElement.orderedState; - this.toscaServiceTemplateFragment = otherElement.toscaServiceTemplateFragment; - this.description = otherElement.description; - this.clElementStatistics = otherElement.clElementStatistics; - this.propertiesMap = PfUtils.mapMap(otherElement.propertiesMap, UnaryOperator.identity()); - } -} diff --git a/models/src/main/java/org/onap/policy/clamp/controlloop/models/controlloop/concepts/ControlLoopElementAck.java b/models/src/main/java/org/onap/policy/clamp/controlloop/models/controlloop/concepts/ControlLoopElementAck.java deleted file mode 100644 index 61b90c9e9..000000000 --- a/models/src/main/java/org/onap/policy/clamp/controlloop/models/controlloop/concepts/ControlLoopElementAck.java +++ /dev/null @@ -1,42 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * Copyright (C) 2021 Nordix Foundation. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - * SPDX-License-Identifier: Apache-2.0 - * ============LICENSE_END========================================================= - */ - -package org.onap.policy.clamp.controlloop.models.controlloop.concepts; - -import lombok.AllArgsConstructor; -import lombok.Getter; -import lombok.Setter; -import lombok.ToString; - -@Getter -@Setter -@AllArgsConstructor -@ToString -public class ControlLoopElementAck { - - // State of the controlLoopElement - private ControlLoopState state; - - // Result: Success/Fail. - private Boolean result; - - // Message indicating reason for failure - private String message; -} diff --git a/models/src/main/java/org/onap/policy/clamp/controlloop/models/controlloop/concepts/ControlLoopElementDefinition.java b/models/src/main/java/org/onap/policy/clamp/controlloop/models/controlloop/concepts/ControlLoopElementDefinition.java deleted file mode 100644 index ae50b40ce..000000000 --- a/models/src/main/java/org/onap/policy/clamp/controlloop/models/controlloop/concepts/ControlLoopElementDefinition.java +++ /dev/null @@ -1,64 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * Copyright (C) 2021 Nordix Foundation. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - * SPDX-License-Identifier: Apache-2.0 - * ============LICENSE_END========================================================= - */ - -package org.onap.policy.clamp.controlloop.models.controlloop.concepts; - -import java.util.LinkedHashMap; -import java.util.Map; -import java.util.function.UnaryOperator; -import lombok.Data; -import lombok.Getter; -import lombok.NoArgsConstructor; -import lombok.ToString; -import org.onap.policy.models.base.PfUtils; -import org.onap.policy.models.tosca.authorative.concepts.ToscaConceptIdentifier; -import org.onap.policy.models.tosca.authorative.concepts.ToscaNodeTemplate; -import org.onap.policy.models.tosca.authorative.concepts.ToscaProperty; - -/** - * Class to represent a control loop element definition instance. - */ -@Getter -@NoArgsConstructor -@Data -@ToString -public class ControlLoopElementDefinition { - - private ToscaConceptIdentifier clElementDefinitionId; - - // The definition of the Control Loop Element in TOSCA - private ToscaNodeTemplate controlLoopElementToscaNodeTemplate; - - // A map indexed by the property name. Each map entry is the serialized value of the property, - // which can be deserialized into an instance of the type of the property. - private Map commonPropertiesMap = new LinkedHashMap<>(); - - /** - * Copy constructor, does a deep copy but as all fields here are immutable, it's just a regular copy. - * - * @param clElementDefinition the controlloop element definition to copy from - */ - public ControlLoopElementDefinition(final ControlLoopElementDefinition clElementDefinition) { - this.clElementDefinitionId = clElementDefinition.clElementDefinitionId; - this.controlLoopElementToscaNodeTemplate = - new ToscaNodeTemplate(clElementDefinition.controlLoopElementToscaNodeTemplate); - this.commonPropertiesMap = PfUtils.mapMap(clElementDefinition.commonPropertiesMap, UnaryOperator.identity()); - } -} diff --git a/models/src/main/java/org/onap/policy/clamp/controlloop/models/controlloop/concepts/ControlLoopInfo.java b/models/src/main/java/org/onap/policy/clamp/controlloop/models/controlloop/concepts/ControlLoopInfo.java deleted file mode 100644 index 0c33606db..000000000 --- a/models/src/main/java/org/onap/policy/clamp/controlloop/models/controlloop/concepts/ControlLoopInfo.java +++ /dev/null @@ -1,52 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * Copyright (C) 2021 Nordix Foundation. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - * SPDX-License-Identifier: Apache-2.0 - * ============LICENSE_END========================================================= - */ - -package org.onap.policy.clamp.controlloop.models.controlloop.concepts; - -import lombok.Data; -import lombok.NoArgsConstructor; -import lombok.ToString; -import org.onap.policy.models.tosca.authorative.concepts.ToscaConceptIdentifier; - -/** - * Class to represent a control loop info instance. - */ -@NoArgsConstructor -@Data -@ToString -public class ControlLoopInfo { - - private ToscaConceptIdentifier controlLoopId; - - private ControlLoopState state = ControlLoopState.UNINITIALISED; - - private ControlLoopStatistics controlLoopStatistics; - - /** - * Copy constructor, does a deep copy but as all fields here are immutable, it's just a regular copy. - * - * @param otherElement the other element to copy from - */ - public ControlLoopInfo(final ControlLoopInfo otherElement) { - this.controlLoopId = otherElement.controlLoopId; - this.state = otherElement.state; - this.controlLoopStatistics = otherElement.controlLoopStatistics; - } -} diff --git a/models/src/main/java/org/onap/policy/clamp/controlloop/models/controlloop/concepts/ControlLoopOrderedState.java b/models/src/main/java/org/onap/policy/clamp/controlloop/models/controlloop/concepts/ControlLoopOrderedState.java deleted file mode 100644 index 91f90275e..000000000 --- a/models/src/main/java/org/onap/policy/clamp/controlloop/models/controlloop/concepts/ControlLoopOrderedState.java +++ /dev/null @@ -1,44 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * Copyright (C) 2021 Nordix Foundation. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - * SPDX-License-Identifier: Apache-2.0 - * ============LICENSE_END========================================================= - */ - -package org.onap.policy.clamp.controlloop.models.controlloop.concepts; - -public enum ControlLoopOrderedState { - /** - * The control loop or control loop element should become uninitialised on participants, it should not exist on - * participants. - */ - UNINITIALISED, - /** - * The control loop or control loop element should initialised on the participants and be passive, that is, it is - * not handling control loop messages yet. - */ - PASSIVE, - /** The control loop or control loop element should running and is executing control loops. */ - RUNNING; - - public boolean equalsControlLoopState(final ControlLoopState controlLoopState) { - return this.name().equals(controlLoopState.name()); - } - - public ControlLoopState asState() { - return ControlLoopState.valueOf(this.name()); - } -} diff --git a/models/src/main/java/org/onap/policy/clamp/controlloop/models/controlloop/concepts/ControlLoopState.java b/models/src/main/java/org/onap/policy/clamp/controlloop/models/controlloop/concepts/ControlLoopState.java deleted file mode 100644 index ff0d553af..000000000 --- a/models/src/main/java/org/onap/policy/clamp/controlloop/models/controlloop/concepts/ControlLoopState.java +++ /dev/null @@ -1,63 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * Copyright (C) 2021 Nordix Foundation. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - * SPDX-License-Identifier: Apache-2.0 - * ============LICENSE_END========================================================= - */ - -package org.onap.policy.clamp.controlloop.models.controlloop.concepts; - -public enum ControlLoopState { - /** - * The control loop or control loop element is not initialised on participants, it does not exist on participants. - */ - UNINITIALISED, - /** - * The control loop or control loop element is changing from unitialised to passive, it is being initialised onto - * participants. - */ - UNINITIALISED2PASSIVE, - /** - * The control loop or control loop element is initialised on the participants but is passive, that is, it is not - * handling control loop messages yet. - */ - PASSIVE, - /** - * The control loop or control loop element is changing from passive to running, the participants are preparing to - * execute control loops. - */ - PASSIVE2RUNNING, - /** The control loop or control loop element is running and is executing control loops. */ - RUNNING, - /** - * The control loop or control loop element is completing execution of current control loops but will not start - * running any more control loops and will become passive. - */ - RUNNING2PASSIVE, - /** - * The control loop or control loop element is changing from passive to unitialised, the control loop is being - * removed from participants. - */ - PASSIVE2UNINITIALISED; - - public boolean equalsControlLoopOrderedState(final ControlLoopOrderedState controlLoopOrderedState) { - return this.name().equals(controlLoopOrderedState.name()); - } - - public ControlLoopOrderedState asOrderedState() { - return ControlLoopOrderedState.valueOf(this.name()); - } -} diff --git a/models/src/main/java/org/onap/policy/clamp/controlloop/models/controlloop/concepts/ControlLoopStatistics.java b/models/src/main/java/org/onap/policy/clamp/controlloop/models/controlloop/concepts/ControlLoopStatistics.java deleted file mode 100644 index 685947b13..000000000 --- a/models/src/main/java/org/onap/policy/clamp/controlloop/models/controlloop/concepts/ControlLoopStatistics.java +++ /dev/null @@ -1,50 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * Copyright (C) 2021 Nordix Foundation. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - * SPDX-License-Identifier: Apache-2.0 - * ============LICENSE_END========================================================= - */ - -package org.onap.policy.clamp.controlloop.models.controlloop.concepts; - -import java.time.Instant; -import lombok.Data; -import lombok.NoArgsConstructor; -import lombok.NonNull; -import lombok.ToString; -import org.onap.policy.models.tosca.authorative.concepts.ToscaConceptIdentifier; - -@NoArgsConstructor -@Data -@ToString -public class ControlLoopStatistics { - - @NonNull - private ToscaConceptIdentifier controlLoopId; - - @NonNull - private Instant timeStamp; - - @NonNull - private ClElementStatisticsList clElementStatisticsList; - - private long eventCount; - private long lastExecutionTime; - private double averageExecutionTime; - private long upTime; - private long lastEnterTime; - private long lastStart; -} diff --git a/models/src/main/java/org/onap/policy/clamp/controlloop/models/controlloop/concepts/ControlLoops.java b/models/src/main/java/org/onap/policy/clamp/controlloop/models/controlloop/concepts/ControlLoops.java deleted file mode 100644 index 4ab406f3b..000000000 --- a/models/src/main/java/org/onap/policy/clamp/controlloop/models/controlloop/concepts/ControlLoops.java +++ /dev/null @@ -1,48 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * Copyright (C) 2021 Nordix Foundation. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============LICENSE_END========================================================= - */ - -package org.onap.policy.clamp.controlloop.models.controlloop.concepts; - -import java.util.ArrayList; -import java.util.List; -import lombok.AllArgsConstructor; -import lombok.EqualsAndHashCode; -import lombok.Getter; -import lombok.NoArgsConstructor; -import lombok.Setter; -import lombok.ToString; -import org.onap.policy.models.base.PfUtils; - -@Getter -@Setter -@ToString -@NoArgsConstructor -@AllArgsConstructor -@EqualsAndHashCode -public class ControlLoops { - private List controlLoopList = new ArrayList<>(); - - /** - * Copy constructor, does a deep copy. - * - * @param otherControlLoops the other element to copy from - */ - public ControlLoops(final ControlLoops otherControlLoops) { - this.controlLoopList = PfUtils.mapList(controlLoopList, ControlLoop::new); - } -} diff --git a/models/src/main/java/org/onap/policy/clamp/controlloop/models/controlloop/concepts/Participant.java b/models/src/main/java/org/onap/policy/clamp/controlloop/models/controlloop/concepts/Participant.java deleted file mode 100644 index 198cf1a16..000000000 --- a/models/src/main/java/org/onap/policy/clamp/controlloop/models/controlloop/concepts/Participant.java +++ /dev/null @@ -1,77 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * Copyright (C) 2021 Nordix Foundation. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - * SPDX-License-Identifier: Apache-2.0 - * ============LICENSE_END========================================================= - */ - -package org.onap.policy.clamp.controlloop.models.controlloop.concepts; - -import lombok.Data; -import lombok.EqualsAndHashCode; -import lombok.NoArgsConstructor; -import lombok.NonNull; -import org.onap.policy.models.base.PfConceptKey; -import org.onap.policy.models.tosca.authorative.concepts.ToscaConceptIdentifier; -import org.onap.policy.models.tosca.authorative.concepts.ToscaEntity; - -/** - * Class to represent details of a running participant instance. - */ -@NoArgsConstructor -@Data -@EqualsAndHashCode(callSuper = true) -public class Participant extends ToscaEntity implements Comparable { - @NonNull - private ToscaConceptIdentifier definition = new ToscaConceptIdentifier(PfConceptKey.getNullKey()); - - @NonNull - private ParticipantState participantState = ParticipantState.UNKNOWN; - - @NonNull - private ParticipantHealthStatus healthStatus = ParticipantHealthStatus.UNKNOWN; - - @NonNull - private ToscaConceptIdentifier participantType = new ToscaConceptIdentifier(); - - @Override - public String getType() { - return definition.getName(); - } - - @Override - public String getTypeVersion() { - return definition.getVersion(); - } - - @Override - public int compareTo(final Participant other) { - return compareNameVersion(this, other); - } - - /** - * Copy constructor. - * - * @param otherParticipant the participant to copy from - */ - public Participant(Participant otherParticipant) { - super(otherParticipant); - this.definition = new ToscaConceptIdentifier(otherParticipant.definition); - this.participantState = otherParticipant.participantState; - this.healthStatus = otherParticipant.healthStatus; - this.participantType = otherParticipant.participantType; - } -} diff --git a/models/src/main/java/org/onap/policy/clamp/controlloop/models/controlloop/concepts/ParticipantDefinition.java b/models/src/main/java/org/onap/policy/clamp/controlloop/models/controlloop/concepts/ParticipantDefinition.java deleted file mode 100644 index 336b309ce..000000000 --- a/models/src/main/java/org/onap/policy/clamp/controlloop/models/controlloop/concepts/ParticipantDefinition.java +++ /dev/null @@ -1,59 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * Copyright (C) 2021 Nordix Foundation. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - * SPDX-License-Identifier: Apache-2.0 - * ============LICENSE_END========================================================= - */ - -package org.onap.policy.clamp.controlloop.models.controlloop.concepts; - -import java.util.ArrayList; -import java.util.List; -import lombok.Data; -import lombok.Getter; -import lombok.NoArgsConstructor; -import lombok.ToString; -import org.onap.policy.models.base.PfUtils; -import org.onap.policy.models.tosca.authorative.concepts.ToscaConceptIdentifier; - -/** - * Class to represent a participant definition update instance. - */ -@Getter -@NoArgsConstructor -@Data -@ToString -public class ParticipantDefinition { - - private ToscaConceptIdentifier participantId; - - private ToscaConceptIdentifier participantType; - - // List of ControlLoopElementDefinition values for a particular participant - private List controlLoopElementDefinitionList = new ArrayList<>(); - - /** - * Copy constructor, does a deep copy but as all fields here are immutable, it's just a regular copy. - * - * @param participantDefinition the participant definition to copy from - */ - public ParticipantDefinition(final ParticipantDefinition participantDefinition) { - this.participantId = participantDefinition.participantId; - this.participantType = participantDefinition.participantType; - this.controlLoopElementDefinitionList = PfUtils.mapList( - participantDefinition.controlLoopElementDefinitionList, ControlLoopElementDefinition::new); - } -} diff --git a/models/src/main/java/org/onap/policy/clamp/controlloop/models/controlloop/concepts/ParticipantHealthStatus.java b/models/src/main/java/org/onap/policy/clamp/controlloop/models/controlloop/concepts/ParticipantHealthStatus.java deleted file mode 100644 index e7c5fecda..000000000 --- a/models/src/main/java/org/onap/policy/clamp/controlloop/models/controlloop/concepts/ParticipantHealthStatus.java +++ /dev/null @@ -1,52 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * Copyright (C) 2021 Nordix Foundation. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - * SPDX-License-Identifier: Apache-2.0 - * ============LICENSE_END========================================================= - */ - -package org.onap.policy.clamp.controlloop.models.controlloop.concepts; - -/** - * Class to hold the possible values for health status of Participant. - */ -public enum ParticipantHealthStatus { - - /** - * Participant is healthy and working fine. - */ - HEALTHY, - - /** - * Participant is not healthy. - */ - NOT_HEALTHY, - - /** - * Participant is currently under test state and performing tests. - */ - TEST_IN_PROGRESS, - - /** - * The health status of the Participant is unknown. - */ - UNKNOWN, - - /** - * The health status of the Participant is off line. - */ - OFF_LINE -} diff --git a/models/src/main/java/org/onap/policy/clamp/controlloop/models/controlloop/concepts/ParticipantState.java b/models/src/main/java/org/onap/policy/clamp/controlloop/models/controlloop/concepts/ParticipantState.java deleted file mode 100644 index 1af32660d..000000000 --- a/models/src/main/java/org/onap/policy/clamp/controlloop/models/controlloop/concepts/ParticipantState.java +++ /dev/null @@ -1,61 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * Copyright (C) 2021 Nordix Foundation. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - * SPDX-License-Identifier: Apache-2.0 - * ============LICENSE_END========================================================= - */ - -package org.onap.policy.clamp.controlloop.models.controlloop.concepts; - -/** - * Class to hold the possible values for mode of participant. - */ -public enum ParticipantState { - - /** - * Control Loop execution is unknown. - */ - UNKNOWN, - - /** - * Control Loop execution is always rejected. - */ - PASSIVE, - - /** - * Control Loop execution execution proceeds, but changes to domain state or context are not carried out. The - * participant returns an indication that it is running in SAFE mode together with the action it would have - * performed if it was operating in ACTIVE mode. - */ - SAFE, - - /** - * Control Loop execution execution proceeds and changes to domain and state are carried out in a test environment. - * The participant returns an indication that it is running in TEST mode together with the action it has performed - * on the test environment. - */ - TEST, - - /** - * Control Loop execution execution is executed in the live environment by the participant. - */ - ACTIVE, - - /** - * Control Loop execution execution is terminated and not available. - */ - TERMINATED -} diff --git a/models/src/main/java/org/onap/policy/clamp/controlloop/models/controlloop/concepts/ParticipantStatistics.java b/models/src/main/java/org/onap/policy/clamp/controlloop/models/controlloop/concepts/ParticipantStatistics.java deleted file mode 100644 index 3a7b21fa1..000000000 --- a/models/src/main/java/org/onap/policy/clamp/controlloop/models/controlloop/concepts/ParticipantStatistics.java +++ /dev/null @@ -1,52 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * Copyright (C) 2021 Nordix Foundation. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - * SPDX-License-Identifier: Apache-2.0 - * ============LICENSE_END========================================================= - */ - -package org.onap.policy.clamp.controlloop.models.controlloop.concepts; - -import java.io.Serializable; -import java.time.Instant; -import lombok.Data; -import lombok.NoArgsConstructor; -import lombok.NonNull; -import lombok.ToString; -import org.onap.policy.models.tosca.authorative.concepts.ToscaConceptIdentifier; - -@NoArgsConstructor -@Data -@ToString -public class ParticipantStatistics implements Serializable { - private static final long serialVersionUID = 744036598792333124L; - - - @NonNull - private ToscaConceptIdentifier participantId; - - @NonNull - private Instant timeStamp; - - private ParticipantState state; - private ParticipantHealthStatus healthStatus; - private long eventCount; - private long lastExecutionTime; - private double averageExecutionTime; - private long upTime; - private long lastEnterTime; - private long lastStart; -} diff --git a/models/src/main/java/org/onap/policy/clamp/controlloop/models/controlloop/concepts/ParticipantStatisticsList.java b/models/src/main/java/org/onap/policy/clamp/controlloop/models/controlloop/concepts/ParticipantStatisticsList.java deleted file mode 100644 index a69f96f85..000000000 --- a/models/src/main/java/org/onap/policy/clamp/controlloop/models/controlloop/concepts/ParticipantStatisticsList.java +++ /dev/null @@ -1,33 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * Copyright (C) 2021 Nordix Foundation. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - * SPDX-License-Identifier: Apache-2.0 - * ============LICENSE_END========================================================= - */ - -package org.onap.policy.clamp.controlloop.models.controlloop.concepts; - -import java.util.List; -import lombok.Getter; -import lombok.Setter; -import lombok.ToString; - -@Getter -@Setter -@ToString -public class ParticipantStatisticsList { - private List statisticsList; -} diff --git a/models/src/main/java/org/onap/policy/clamp/controlloop/models/controlloop/concepts/ParticipantUpdates.java b/models/src/main/java/org/onap/policy/clamp/controlloop/models/controlloop/concepts/ParticipantUpdates.java deleted file mode 100644 index ea851b8c5..000000000 --- a/models/src/main/java/org/onap/policy/clamp/controlloop/models/controlloop/concepts/ParticipantUpdates.java +++ /dev/null @@ -1,56 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * Copyright (C) 2021 Nordix Foundation. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - * SPDX-License-Identifier: Apache-2.0 - * ============LICENSE_END========================================================= - */ - -package org.onap.policy.clamp.controlloop.models.controlloop.concepts; - -import java.util.ArrayList; -import java.util.List; -import lombok.Data; -import lombok.Getter; -import lombok.NoArgsConstructor; -import lombok.ToString; -import org.onap.policy.models.base.PfUtils; -import org.onap.policy.models.tosca.authorative.concepts.ToscaConceptIdentifier; - -/** - * Class to represent a participant definition update instance. - */ -@Getter -@NoArgsConstructor -@Data -@ToString -public class ParticipantUpdates { - - private ToscaConceptIdentifier participantId; - - // List of ControlLoopElement values for a particular participant - private List controlLoopElementList = new ArrayList<>(); - - /** - * Copy constructor, does a deep copy but as all fields here are immutable, it's just a regular copy. - * - * @param participantUpdates the participant with updates to copy from - */ - public ParticipantUpdates(final ParticipantUpdates participantUpdates) { - this.participantId = participantUpdates.participantId; - this.controlLoopElementList = PfUtils.mapList( - participantUpdates.controlLoopElementList, ControlLoopElement::new); - } -} diff --git a/models/src/main/java/org/onap/policy/clamp/controlloop/models/controlloop/concepts/ParticipantUtils.java b/models/src/main/java/org/onap/policy/clamp/controlloop/models/controlloop/concepts/ParticipantUtils.java deleted file mode 100644 index c05311892..000000000 --- a/models/src/main/java/org/onap/policy/clamp/controlloop/models/controlloop/concepts/ParticipantUtils.java +++ /dev/null @@ -1,119 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * Copyright (C) 2021 Nordix Foundation. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - * SPDX-License-Identifier: Apache-2.0 - * ============LICENSE_END========================================================= - */ - -package org.onap.policy.clamp.controlloop.models.controlloop.concepts; - -import java.util.Map; -import javax.ws.rs.core.Response; -import lombok.AccessLevel; -import lombok.NoArgsConstructor; -import org.onap.policy.common.utils.coder.Coder; -import org.onap.policy.common.utils.coder.CoderException; -import org.onap.policy.common.utils.coder.StandardCoder; -import org.onap.policy.models.base.PfModelRuntimeException; -import org.onap.policy.models.tosca.authorative.concepts.ToscaConceptIdentifier; -import org.onap.policy.models.tosca.authorative.concepts.ToscaNodeTemplate; -import org.onap.policy.models.tosca.authorative.concepts.ToscaServiceTemplate; - -@NoArgsConstructor(access = AccessLevel.PRIVATE) -public final class ParticipantUtils { - - private static final Coder CODER = new StandardCoder(); - private static final String CONTROL_LOOP_ELEMENT = "org.onap.policy.clamp.controlloop.ControlLoopElement"; - - /** - * Finds participantType from a map of properties. - * - * @param properties Map of properties - * @return participantType - */ - public static ToscaConceptIdentifier findParticipantType(Map properties) { - var objParticipantType = properties.get("participantType"); - if (objParticipantType != null) { - try { - return CODER.decode(objParticipantType.toString(), ToscaConceptIdentifier.class); - } catch (CoderException e) { - throw new PfModelRuntimeException(Response.Status.BAD_REQUEST, e.getMessage(), e); - } - } - return null; - } - - /** - * Get the First StartPhase - * it depend of the state of the Control Loop - * and also from the all startPhase defined into the ToscaServiceTemplate. - * @param controlLoop the ControlLoop - * @param toscaServiceTemplate the ToscaServiceTemplate - * @return the First StartPhase - */ - public static int getFirstStartPhase(ControlLoop controlLoop, ToscaServiceTemplate toscaServiceTemplate) { - var minStartPhase = 1000; - var maxStartPhase = 0; - for (var element : controlLoop.getElements().values()) { - ToscaNodeTemplate toscaNodeTemplate = toscaServiceTemplate.getToscaTopologyTemplate().getNodeTemplates() - .get(element.getDefinition().getName()); - int startPhase = ParticipantUtils.findStartPhase(toscaNodeTemplate.getProperties()); - minStartPhase = Math.min(minStartPhase, startPhase); - maxStartPhase = Math.max(maxStartPhase, startPhase); - } - - return ControlLoopState.UNINITIALISED2PASSIVE.equals(controlLoop.getState()) - || ControlLoopState.PASSIVE2RUNNING.equals(controlLoop.getState()) ? minStartPhase - : maxStartPhase; - } - - /** - * Finds startPhase from a map of properties. - * - * @param properties Map of properties - * @return startPhase - */ - public static int findStartPhase(Map properties) { - var objParticipantType = properties.get("startPhase"); - if (objParticipantType != null) { - return Integer.valueOf(objParticipantType.toString()); - } - return 0; - } - - /** - * Checks If NodeTemplate Is ControlLoopElement. - * - * @param nodeTemplate the ToscaNodeTemplate - * @param toscaServiceTemplate the ToscaServiceTemplate - * @return true if NodeTemplate Is ControlLoopElement - */ - public static boolean checkIfNodeTemplateIsControlLoopElement(ToscaNodeTemplate nodeTemplate, - ToscaServiceTemplate toscaServiceTemplate) { - if (nodeTemplate.getType().contains(CONTROL_LOOP_ELEMENT)) { - return true; - } else { - var nodeType = toscaServiceTemplate.getNodeTypes().get(nodeTemplate.getType()); - if (nodeType != null) { - var derivedFrom = nodeType.getDerivedFrom(); - if (derivedFrom != null) { - return derivedFrom.contains(CONTROL_LOOP_ELEMENT); - } - } - } - return false; - } -} diff --git a/models/src/main/java/org/onap/policy/clamp/controlloop/models/controlloop/persistence/concepts/JpaClElementStatistics.java b/models/src/main/java/org/onap/policy/clamp/controlloop/models/controlloop/persistence/concepts/JpaClElementStatistics.java deleted file mode 100644 index 956f1db02..000000000 --- a/models/src/main/java/org/onap/policy/clamp/controlloop/models/controlloop/persistence/concepts/JpaClElementStatistics.java +++ /dev/null @@ -1,196 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * Copyright (C) 2021 Nordix Foundation. - * ================================================================================ - * Modifications Copyright (C) 2021 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - * SPDX-License-Identifier: Apache-2.0 - * ============LICENSE_END========================================================= - */ - -package org.onap.policy.clamp.controlloop.models.controlloop.persistence.concepts; - -import java.io.Serializable; -import java.util.List; -import java.util.UUID; -import javax.persistence.AttributeOverride; -import javax.persistence.Column; -import javax.persistence.EmbeddedId; -import javax.persistence.Entity; -import javax.persistence.Inheritance; -import javax.persistence.InheritanceType; -import javax.persistence.Table; -import lombok.AllArgsConstructor; -import lombok.Data; -import lombok.EqualsAndHashCode; -import lombok.NonNull; -import org.apache.commons.lang3.builder.CompareToBuilder; -import org.onap.policy.clamp.controlloop.models.controlloop.concepts.ClElementStatistics; -import org.onap.policy.clamp.controlloop.models.controlloop.concepts.ControlLoopState; -import org.onap.policy.common.parameters.annotations.NotNull; -import org.onap.policy.models.base.PfAuthorative; -import org.onap.policy.models.base.PfConcept; -import org.onap.policy.models.base.PfConceptKey; -import org.onap.policy.models.base.PfKey; -import org.onap.policy.models.base.PfReferenceTimestampKey; -import org.onap.policy.models.base.validation.annotations.VerifyKey; -import org.onap.policy.models.tosca.authorative.concepts.ToscaConceptIdentifier; - -/** - * Class to represent a controlloop element statistics in the database. - * - * @author Ramesh Murugan Iyer (ramesh.murugan.iyer@est.tech) - */ -@Entity -@Table(name = "ClElementStatistics") -@Inheritance(strategy = InheritanceType.TABLE_PER_CLASS) -@Data -@AllArgsConstructor -@EqualsAndHashCode(callSuper = false) -public class JpaClElementStatistics extends PfConcept implements PfAuthorative, Serializable { - - private static final long serialVersionUID = 621426717868738629L; - - @EmbeddedId - @VerifyKey - @NotNull - private PfReferenceTimestampKey key = new PfReferenceTimestampKey(); - - - @VerifyKey - @NotNull - // @formatter:off - @AttributeOverride(name = "name", column = @Column(name = "participant_name")) - @AttributeOverride(name = "version", column = @Column(name = "participant_version")) - private PfConceptKey participantId; - // @formatter: on - - @Column - @NotNull - private ControlLoopState state; - - @Column - private long clElementUptime; - - - /** - * The Default Constructor creates a {@link JpaClElementStatistics} object with a null key. - */ - public JpaClElementStatistics() { - this(new PfReferenceTimestampKey()); - } - - - /** - * The Key Constructor creates a {@link JpaClElementStatistics} object with the given Reference Timestamp key. - * - * @param key the key - */ - public JpaClElementStatistics(@NonNull final PfReferenceTimestampKey key) { - this(key, new PfConceptKey(), ControlLoopState.PASSIVE, 0L); - } - - /** - * The Key Constructor creates a {@link JpaClElementStatistics} object with all mandatory fields. - * - * @param key the key - * @param participantId the TOSCA definition of the control loop element - */ - public JpaClElementStatistics(@NonNull final PfReferenceTimestampKey key, - @NonNull final PfConceptKey participantId) { - this.key = key; - this.participantId = participantId; - } - - /** - * Copy constructor. - * - * @param copyConcept the concept to copy from - */ - public JpaClElementStatistics(@NonNull final JpaClElementStatistics copyConcept) { - super(copyConcept); - this.key = new PfReferenceTimestampKey(copyConcept.key); - this.participantId = new PfConceptKey(copyConcept.participantId); - this.state = copyConcept.state; - this.clElementUptime = copyConcept.clElementUptime; - } - - - /** - * Authorative constructor. - * - * @param authorativeConcept the authorative concept to copy from - */ - public JpaClElementStatistics(@NonNull final ClElementStatistics authorativeConcept) { - this.fromAuthorative(authorativeConcept); - } - - - - @Override - public ClElementStatistics toAuthorative() { - var clElementStatistics = new ClElementStatistics(); - clElementStatistics.setId(UUID.fromString(getKey().getReferenceKey().getLocalName())); - clElementStatistics.setTimeStamp(key.getInstant()); - clElementStatistics.setParticipantId(new ToscaConceptIdentifier(participantId)); - clElementStatistics.setControlLoopState(state); - clElementStatistics.setClElementUptime(clElementUptime); - - return clElementStatistics; - } - - @Override - public void fromAuthorative(@NonNull ClElementStatistics clElementStatistics) { - // @formatter:off - if (this.key == null || this.getKey().isNullKey()) { - this.setKey(new PfReferenceTimestampKey(clElementStatistics.getParticipantId().getName(), - clElementStatistics.getParticipantId().getVersion(), clElementStatistics.getId().toString(), - clElementStatistics.getTimeStamp())); - } - // @formatter:on - this.setParticipantId(clElementStatistics.getParticipantId().asConceptKey()); - this.setState(clElementStatistics.getControlLoopState()); - this.setClElementUptime(clElementStatistics.getClElementUptime()); - } - - @Override - public List getKeys() { - return getKey().getKeys(); - } - - @Override - public void clean() { - key.clean(); - participantId.clean(); - } - - - @Override - public int compareTo(PfConcept otherConcept) { - if (otherConcept == null) { - return -1; - } - if (this == otherConcept) { - return 0; - } - if (getClass() != otherConcept.getClass()) { - return getClass().getName().compareTo(otherConcept.getClass().getName()); - } - - final JpaClElementStatistics other = (JpaClElementStatistics) otherConcept; - return new CompareToBuilder().append(this.key, other.key).append(this.state, other.state) - .append(this.clElementUptime, other.clElementUptime).toComparison(); - } -} diff --git a/models/src/main/java/org/onap/policy/clamp/controlloop/models/controlloop/persistence/concepts/JpaControlLoop.java b/models/src/main/java/org/onap/policy/clamp/controlloop/models/controlloop/persistence/concepts/JpaControlLoop.java deleted file mode 100644 index adc300607..000000000 --- a/models/src/main/java/org/onap/policy/clamp/controlloop/models/controlloop/persistence/concepts/JpaControlLoop.java +++ /dev/null @@ -1,263 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * Copyright (C) 2021 Nordix Foundation. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - * SPDX-License-Identifier: Apache-2.0 - * ============LICENSE_END========================================================= - */ - -package org.onap.policy.clamp.controlloop.models.controlloop.persistence.concepts; - -import java.util.LinkedHashMap; -import java.util.List; -import java.util.Map; -import java.util.Map.Entry; -import java.util.UUID; -import javax.persistence.AttributeOverride; -import javax.persistence.CascadeType; -import javax.persistence.Column; -import javax.persistence.EmbeddedId; -import javax.persistence.Entity; -import javax.persistence.FetchType; -import javax.persistence.Inheritance; -import javax.persistence.InheritanceType; -import javax.persistence.ManyToMany; -import javax.persistence.Table; -import lombok.Data; -import lombok.EqualsAndHashCode; -import lombok.NonNull; -import org.apache.commons.lang3.ObjectUtils; -import org.onap.policy.clamp.controlloop.models.controlloop.concepts.ControlLoop; -import org.onap.policy.clamp.controlloop.models.controlloop.concepts.ControlLoopElement; -import org.onap.policy.clamp.controlloop.models.controlloop.concepts.ControlLoopOrderedState; -import org.onap.policy.clamp.controlloop.models.controlloop.concepts.ControlLoopState; -import org.onap.policy.common.parameters.annotations.NotNull; -import org.onap.policy.common.parameters.annotations.Valid; -import org.onap.policy.models.base.PfAuthorative; -import org.onap.policy.models.base.PfConcept; -import org.onap.policy.models.base.PfConceptKey; -import org.onap.policy.models.base.PfKey; -import org.onap.policy.models.base.PfReferenceKey; -import org.onap.policy.models.base.PfUtils; -import org.onap.policy.models.base.validation.annotations.VerifyKey; -import org.onap.policy.models.tosca.authorative.concepts.ToscaConceptIdentifier; - -/** - * Class to represent a control loop in the database. - * - * @author Liam Fallon (liam.fallon@est.tech) - */ -@Entity -@Table(name = "ControlLoop") -@Inheritance(strategy = InheritanceType.TABLE_PER_CLASS) -@Data -@EqualsAndHashCode(callSuper = false) -public class JpaControlLoop extends PfConcept implements PfAuthorative { - private static final long serialVersionUID = -4725410933242154805L; - - @EmbeddedId - @VerifyKey - @NotNull - private PfConceptKey key; - - // @formatter:off - @VerifyKey - @NotNull - @AttributeOverride(name = "name", column = @Column(name = "definition_name")) - @AttributeOverride(name = "version", column = @Column(name = "definition_version")) - private PfConceptKey definition; - // @formatter:on - - @Column - @NotNull - private ControlLoopState state; - - @Column - @NotNull - private ControlLoopOrderedState orderedState; - - @Column - private String description; - - @Column - private Boolean primed; - - @ManyToMany(fetch = FetchType.EAGER, cascade = CascadeType.ALL) - @NotNull - private Map<@NotNull UUID, @NotNull @Valid JpaControlLoopElement> elements; - - /** - * The Default Constructor creates a {@link JpaControlLoop} object with a null key. - */ - public JpaControlLoop() { - this(new PfConceptKey()); - } - - /** - * The Key Constructor creates a {@link JpaControlLoop} object with the given concept key. - * - * @param key the key - */ - public JpaControlLoop(@NonNull final PfConceptKey key) { - this(key, new PfConceptKey(), ControlLoopState.UNINITIALISED, new LinkedHashMap<>()); - } - - /** - * The Key Constructor creates a {@link JpaControlLoop} object with all mandatory fields. - * - * @param key the key - * @param definition the TOSCA definition of the control loop - * @param state the state of the control loop - * @param elements the elements of the control looop in participants - */ - public JpaControlLoop(@NonNull final PfConceptKey key, @NonNull final PfConceptKey definition, - @NonNull final ControlLoopState state, @NonNull final Map elements) { - this.key = key; - this.definition = definition; - this.state = state; - this.elements = elements; - } - - /** - * Copy constructor. - * - * @param copyConcept the concept to copy from - */ - public JpaControlLoop(@NonNull final JpaControlLoop copyConcept) { - super(copyConcept); - this.key = new PfConceptKey(copyConcept.key); - this.definition = new PfConceptKey(copyConcept.definition); - this.state = copyConcept.state; - this.orderedState = copyConcept.orderedState; - this.description = copyConcept.description; - this.elements = PfUtils.mapMap(copyConcept.elements, JpaControlLoopElement::new, new LinkedHashMap<>(0)); - this.primed = copyConcept.primed; - } - - /** - * Authorative constructor. - * - * @param authorativeConcept the authorative concept to copy from - */ - public JpaControlLoop(@NonNull final ControlLoop authorativeConcept) { - this.fromAuthorative(authorativeConcept); - } - - @Override - public ControlLoop toAuthorative() { - var controlLoop = new ControlLoop(); - - controlLoop.setName(getKey().getName()); - controlLoop.setVersion(getKey().getVersion()); - controlLoop.setDefinition(new ToscaConceptIdentifier(definition)); - controlLoop.setState(state); - controlLoop.setOrderedState(orderedState != null ? orderedState : state.asOrderedState()); - controlLoop.setDescription(description); - controlLoop.setElements(PfUtils.mapMap(elements, JpaControlLoopElement::toAuthorative, new LinkedHashMap<>(0))); - controlLoop.setPrimed(primed); - - return controlLoop; - } - - @Override - public void fromAuthorative(@NonNull final ControlLoop controlLoop) { - if (this.key == null || this.getKey().isNullKey()) { - this.setKey(new PfConceptKey(controlLoop.getName(), controlLoop.getVersion())); - } - - this.definition = controlLoop.getDefinition().asConceptKey(); - this.state = controlLoop.getState(); - this.orderedState = controlLoop.getOrderedState(); - this.description = controlLoop.getDescription(); - this.primed = controlLoop.getPrimed(); - - this.elements = new LinkedHashMap<>(controlLoop.getElements().size()); - for (Entry elementEntry : controlLoop.getElements().entrySet()) { - var jpaControlLoopElement = new JpaControlLoopElement(); - jpaControlLoopElement.setKey(new PfReferenceKey(getKey(), elementEntry.getValue().getId().toString())); - jpaControlLoopElement.fromAuthorative(elementEntry.getValue()); - this.elements.put(elementEntry.getKey(), jpaControlLoopElement); - } - } - - @Override - public List getKeys() { - List keyList = getKey().getKeys(); - - keyList.add(definition); - - for (JpaControlLoopElement element : elements.values()) { - keyList.addAll(element.getKeys()); - } - - return keyList; - } - - @Override - public void clean() { - key.clean(); - definition.clean(); - description = (description == null ? null : description.trim()); - - for (JpaControlLoopElement element : elements.values()) { - element.clean(); - } - } - - @Override - public int compareTo(final PfConcept otherConcept) { - if (otherConcept == null) { - return -1; - } - if (this == otherConcept) { - return 0; - } - if (getClass() != otherConcept.getClass()) { - return this.getClass().getName().compareTo(otherConcept.getClass().getName()); - } - - final JpaControlLoop other = (JpaControlLoop) otherConcept; - int result = key.compareTo(other.key); - if (result != 0) { - return result; - } - - result = definition.compareTo(other.definition); - if (result != 0) { - return result; - } - - result = ObjectUtils.compare(state, other.state); - if (result != 0) { - return result; - } - - result = ObjectUtils.compare(orderedState, other.orderedState); - if (result != 0) { - return result; - } - - result = ObjectUtils.compare(description, other.description); - if (result != 0) { - return result; - } - - result = ObjectUtils.compare(primed, other.primed); - if (result != 0) { - return result; - } - return PfUtils.compareObjects(elements, other.elements); - } -} diff --git a/models/src/main/java/org/onap/policy/clamp/controlloop/models/controlloop/persistence/concepts/JpaControlLoopElement.java b/models/src/main/java/org/onap/policy/clamp/controlloop/models/controlloop/persistence/concepts/JpaControlLoopElement.java deleted file mode 100644 index 22773e064..000000000 --- a/models/src/main/java/org/onap/policy/clamp/controlloop/models/controlloop/persistence/concepts/JpaControlLoopElement.java +++ /dev/null @@ -1,253 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * Copyright (C) 2021 Nordix Foundation. - * ================================================================================ - * Modifications Copyright (C) 2021 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - * SPDX-License-Identifier: Apache-2.0 - * ============LICENSE_END========================================================= - */ - -package org.onap.policy.clamp.controlloop.models.controlloop.persistence.concepts; - -import java.util.List; -import java.util.UUID; -import javax.persistence.AttributeOverride; -import javax.persistence.Column; -import javax.persistence.EmbeddedId; -import javax.persistence.Entity; -import javax.persistence.Inheritance; -import javax.persistence.InheritanceType; -import javax.persistence.Table; -import lombok.Data; -import lombok.EqualsAndHashCode; -import lombok.NonNull; -import org.apache.commons.lang3.ObjectUtils; -import org.onap.policy.clamp.controlloop.models.controlloop.concepts.ControlLoopElement; -import org.onap.policy.clamp.controlloop.models.controlloop.concepts.ControlLoopOrderedState; -import org.onap.policy.clamp.controlloop.models.controlloop.concepts.ControlLoopState; -import org.onap.policy.common.parameters.annotations.NotNull; -import org.onap.policy.models.base.PfAuthorative; -import org.onap.policy.models.base.PfConcept; -import org.onap.policy.models.base.PfConceptKey; -import org.onap.policy.models.base.PfKey; -import org.onap.policy.models.base.PfReferenceKey; -import org.onap.policy.models.base.validation.annotations.VerifyKey; -import org.onap.policy.models.tosca.authorative.concepts.ToscaConceptIdentifier; - -/** - * Class to represent a participant control loop element in the database. - * - * @author Liam Fallon (liam.fallon@est.tech) - */ -@Entity -@Table(name = "ControlLoopElement") -@Inheritance(strategy = InheritanceType.TABLE_PER_CLASS) -@Data -@EqualsAndHashCode(callSuper = false) -public class JpaControlLoopElement extends PfConcept implements PfAuthorative { - private static final long serialVersionUID = -1791732273187890213L; - - @EmbeddedId - @VerifyKey - @NotNull - private PfReferenceKey key; - - // @formatter:off - @VerifyKey - @NotNull - @AttributeOverride(name = "name", column = @Column(name = "definition_name")) - @AttributeOverride(name = "version", column = @Column(name = "definition_version")) - private PfConceptKey definition; - - @VerifyKey - @NotNull - @AttributeOverride(name = "name", column = @Column(name = "participant_type_name")) - @AttributeOverride(name = "version", column = @Column(name = "participant_type_version")) - private PfConceptKey participantType; - - @NotNull - @AttributeOverride(name = "name", column = @Column(name = "participant_name")) - @AttributeOverride(name = "version", column = @Column(name = "participant_version")) - private PfConceptKey participantId; - // @formatter:on - - @Column - @NotNull - private ControlLoopState state; - - @Column - @NotNull - private ControlLoopOrderedState orderedState; - - @Column - private String description; - - /** - * The Default Constructor creates a {@link JpaControlLoopElement} object with a null key. - */ - public JpaControlLoopElement() { - this(new PfReferenceKey()); - } - - /** - * The Key Constructor creates a {@link JpaControlLoopElement} object with the given concept key. - * - * @param key the key - */ - public JpaControlLoopElement(@NonNull final PfReferenceKey key) { - this(key, new PfConceptKey(), new PfConceptKey(), ControlLoopState.UNINITIALISED); - } - - /** - * The Key Constructor creates a {@link JpaControlLoopElement} object with all mandatory fields. - * - * @param key the key - * @param definition the TOSCA definition of the control loop element - * @param participantType the TOSCA definition of the participant running the control loop element - * @param state the state of the control loop - */ - public JpaControlLoopElement(@NonNull final PfReferenceKey key, @NonNull final PfConceptKey definition, - @NonNull final PfConceptKey participantType, @NonNull final ControlLoopState state) { - this.key = key; - this.definition = definition; - this.participantType = participantType; - this.state = state; - } - - /** - * Copy constructor. - * - * @param copyConcept the concept to copy from - */ - public JpaControlLoopElement(@NonNull final JpaControlLoopElement copyConcept) { - super(copyConcept); - this.key = new PfReferenceKey(copyConcept.key); - this.definition = new PfConceptKey(copyConcept.definition); - this.participantType = new PfConceptKey(copyConcept.participantType); - this.participantId = new PfConceptKey(copyConcept.participantId); - this.state = copyConcept.state; - this.orderedState = copyConcept.orderedState; - this.description = copyConcept.description; - } - - /** - * Authorative constructor. - * - * @param authorativeConcept the authorative concept to copy from - */ - public JpaControlLoopElement(@NonNull final ControlLoopElement authorativeConcept) { - this.fromAuthorative(authorativeConcept); - } - - @Override - public ControlLoopElement toAuthorative() { - var element = new ControlLoopElement(); - - element.setId(UUID.fromString(getKey().getLocalName())); - element.setDefinition(new ToscaConceptIdentifier(definition)); - element.setParticipantType(new ToscaConceptIdentifier(participantType)); - element.setParticipantId(new ToscaConceptIdentifier(participantId)); - element.setState(state); - element.setOrderedState(orderedState != null ? orderedState : state.asOrderedState()); - element.setDescription(description); - - return element; - } - - @Override - public void fromAuthorative(@NonNull final ControlLoopElement element) { - if (this.key == null || this.getKey().isNullKey()) { - this.setKey(new PfReferenceKey()); - getKey().setLocalName(element.getId().toString()); - } - - this.definition = element.getDefinition().asConceptKey(); - this.participantType = element.getParticipantType().asConceptKey(); - this.participantId = element.getParticipantId().asConceptKey(); - this.state = element.getState(); - this.orderedState = element.getOrderedState(); - this.description = element.getDescription(); - } - - @Override - public List getKeys() { - List keyList = getKey().getKeys(); - - keyList.add(definition); - keyList.add(participantType); - keyList.add(participantId); - - return keyList; - } - - @Override - public void clean() { - key.clean(); - definition.clean(); - participantType.clean(); - participantId.clean(); - - if (description != null) { - description = description.trim(); - } - } - - @Override - public int compareTo(final PfConcept otherConcept) { - if (otherConcept == null) { - return -1; - } - if (this == otherConcept) { - return 0; - } - if (getClass() != otherConcept.getClass()) { - return this.getClass().getName().compareTo(otherConcept.getClass().getName()); - } - - final JpaControlLoopElement other = (JpaControlLoopElement) otherConcept; - int result = key.compareTo(other.key); - if (result != 0) { - return result; - } - - result = definition.compareTo(other.definition); - if (result != 0) { - return result; - } - - result = participantType.compareTo(other.participantType); - if (result != 0) { - return result; - } - - result = participantId.compareTo(other.participantId); - if (result != 0) { - return result; - } - - result = ObjectUtils.compare(state, other.state); - if (result != 0) { - return result; - } - - result = ObjectUtils.compare(orderedState, other.orderedState); - if (result != 0) { - return result; - } - - return ObjectUtils.compare(description, other.description); - } -} diff --git a/models/src/main/java/org/onap/policy/clamp/controlloop/models/controlloop/persistence/concepts/JpaParticipant.java b/models/src/main/java/org/onap/policy/clamp/controlloop/models/controlloop/persistence/concepts/JpaParticipant.java deleted file mode 100644 index c8c26a8de..000000000 --- a/models/src/main/java/org/onap/policy/clamp/controlloop/models/controlloop/persistence/concepts/JpaParticipant.java +++ /dev/null @@ -1,231 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * Copyright (C) 2021 Nordix Foundation. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - * SPDX-License-Identifier: Apache-2.0 - * ============LICENSE_END========================================================= - */ - -package org.onap.policy.clamp.controlloop.models.controlloop.persistence.concepts; - -import java.io.Serializable; -import java.util.List; -import javax.persistence.AttributeOverride; -import javax.persistence.Column; -import javax.persistence.EmbeddedId; -import javax.persistence.Entity; -import javax.persistence.Inheritance; -import javax.persistence.InheritanceType; -import javax.persistence.Table; -import lombok.Data; -import lombok.EqualsAndHashCode; -import lombok.NonNull; -import org.apache.commons.lang3.ObjectUtils; -import org.onap.policy.clamp.controlloop.models.controlloop.concepts.Participant; -import org.onap.policy.clamp.controlloop.models.controlloop.concepts.ParticipantHealthStatus; -import org.onap.policy.clamp.controlloop.models.controlloop.concepts.ParticipantState; -import org.onap.policy.common.parameters.annotations.NotNull; -import org.onap.policy.models.base.PfAuthorative; -import org.onap.policy.models.base.PfConcept; -import org.onap.policy.models.base.PfConceptKey; -import org.onap.policy.models.base.PfKey; -import org.onap.policy.models.base.validation.annotations.VerifyKey; -import org.onap.policy.models.tosca.authorative.concepts.ToscaConceptIdentifier; - -/** - * Class to represent a participant in the database. - * - * @author Liam Fallon (liam.fallon@est.tech) - */ -@Entity -@Table(name = "Participant") -@Inheritance(strategy = InheritanceType.TABLE_PER_CLASS) -@Data -@EqualsAndHashCode(callSuper = false) -public class JpaParticipant extends PfConcept implements PfAuthorative, Serializable { - private static final long serialVersionUID = -4697758484642403483L; - - @EmbeddedId - @VerifyKey - @NotNull - private PfConceptKey key; - - // @formatter:off - @VerifyKey - @NotNull - @AttributeOverride(name = "name", column = @Column(name = "definition_name")) - @AttributeOverride(name = "version", column = @Column(name = "definition_version")) - private PfConceptKey definition; - // @formatter:on - - @NotNull - @AttributeOverride(name = "name", column = @Column(name = "participant_type_name")) - @AttributeOverride(name = "version", column = @Column(name = "participant_type_version")) - private PfConceptKey participantType; - - @Column - @NotNull - private ParticipantState participantState; - - @Column - @NotNull - private ParticipantHealthStatus healthStatus; - - @Column - private String description; - - /** - * The Default Constructor creates a {@link JpaParticipant} object with a null key. - */ - public JpaParticipant() { - this(new PfConceptKey()); - } - - /** - * The Key Constructor creates a {@link JpaParticipant} object with the given concept key. - * - * @param key the key - */ - public JpaParticipant(@NonNull final PfConceptKey key) { - this(key, new PfConceptKey(), ParticipantState.PASSIVE, ParticipantHealthStatus.UNKNOWN); - } - - /** - * The Key Constructor creates a {@link JpaParticipant} object with all mandatory fields. - * - * @param key the key - * @param definition the TOSCA definition of the participant - * @param participantState the state of the participant - * @param healthStatus the health state of the participant - */ - public JpaParticipant(@NonNull final PfConceptKey key, @NonNull final PfConceptKey definition, - @NonNull final ParticipantState participantState, @NonNull ParticipantHealthStatus healthStatus) { - this.key = key; - this.definition = definition; - this.participantState = participantState; - this.healthStatus = healthStatus; - } - - /** - * Copy constructor. - * - * @param copyConcept the concept to copy from - */ - public JpaParticipant(@NonNull final JpaParticipant copyConcept) { - super(copyConcept); - this.key = new PfConceptKey(copyConcept.key); - this.definition = new PfConceptKey(copyConcept.definition); - this.participantState = copyConcept.participantState; - this.healthStatus = copyConcept.healthStatus; - this.description = copyConcept.description; - this.participantType = copyConcept.participantType; - } - - /** - * Authorative constructor. - * - * @param authorativeConcept the authorative concept to copy from - */ - public JpaParticipant(@NonNull final Participant authorativeConcept) { - this.fromAuthorative(authorativeConcept); - } - - @Override - public Participant toAuthorative() { - var participant = new Participant(); - - participant.setName(key.getName()); - participant.setVersion(key.getVersion()); - participant.setDefinition(new ToscaConceptIdentifier(definition)); - participant.setParticipantState(participantState); - participant.setHealthStatus(healthStatus); - participant.setDescription(description); - participant.setParticipantType(new ToscaConceptIdentifier(participantType)); - - return participant; - } - - @Override - public void fromAuthorative(@NonNull final Participant participant) { - if (this.key == null || this.getKey().isNullKey()) { - this.setKey(new PfConceptKey(participant.getName(), participant.getVersion())); - } - - this.definition = participant.getDefinition().asConceptKey(); - this.setParticipantState(participant.getParticipantState()); - this.setHealthStatus(participant.getHealthStatus()); - this.setDescription(participant.getDescription()); - this.participantType = participant.getParticipantType().asConceptKey(); - } - - @Override - public List getKeys() { - List keyList = getKey().getKeys(); - - keyList.add(definition); - keyList.add(participantType); - - return keyList; - } - - @Override - public void clean() { - key.clean(); - definition.clean(); - description = (description == null ? null : description.trim()); - participantType.clean(); - } - - @Override - public int compareTo(final PfConcept otherConcept) { - if (otherConcept == null) { - return -1; - } - if (this == otherConcept) { - return 0; - } - if (getClass() != otherConcept.getClass()) { - return getClass().getName().compareTo(otherConcept.getClass().getName()); - } - - final JpaParticipant other = (JpaParticipant) otherConcept; - int result = key.compareTo(other.key); - if (result != 0) { - return result; - } - - result = definition.compareTo(other.definition); - if (result != 0) { - return result; - } - - result = ObjectUtils.compare(participantState, other.participantState); - if (result != 0) { - return result; - } - - result = ObjectUtils.compare(healthStatus, other.healthStatus); - if (result != 0) { - return result; - } - - result = ObjectUtils.compare(participantType, other.participantType); - if (result != 0) { - return result; - } - - return ObjectUtils.compare(description, other.description); - } -} diff --git a/models/src/main/java/org/onap/policy/clamp/controlloop/models/controlloop/persistence/concepts/JpaParticipantStatistics.java b/models/src/main/java/org/onap/policy/clamp/controlloop/models/controlloop/persistence/concepts/JpaParticipantStatistics.java deleted file mode 100644 index 2e5188abe..000000000 --- a/models/src/main/java/org/onap/policy/clamp/controlloop/models/controlloop/persistence/concepts/JpaParticipantStatistics.java +++ /dev/null @@ -1,239 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * Copyright (C) 2021 Nordix Foundation. - * ================================================================================ - * Modifications Copyright (C) 2021 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - * SPDX-License-Identifier: Apache-2.0 - * ============LICENSE_END========================================================= - */ - - -package org.onap.policy.clamp.controlloop.models.controlloop.persistence.concepts; - -import java.io.Serializable; -import java.util.List; -import javax.persistence.AttributeOverride; -import javax.persistence.Column; -import javax.persistence.EmbeddedId; -import javax.persistence.Entity; -import javax.persistence.Inheritance; -import javax.persistence.InheritanceType; -import javax.persistence.Table; -import lombok.AllArgsConstructor; -import lombok.Data; -import lombok.EqualsAndHashCode; -import lombok.NonNull; -import org.apache.commons.lang3.builder.CompareToBuilder; -import org.onap.policy.clamp.controlloop.models.controlloop.concepts.ParticipantHealthStatus; -import org.onap.policy.clamp.controlloop.models.controlloop.concepts.ParticipantState; -import org.onap.policy.clamp.controlloop.models.controlloop.concepts.ParticipantStatistics; -import org.onap.policy.common.parameters.annotations.NotNull; -import org.onap.policy.models.base.PfAuthorative; -import org.onap.policy.models.base.PfConcept; -import org.onap.policy.models.base.PfConceptKey; -import org.onap.policy.models.base.PfKey; -import org.onap.policy.models.base.PfTimestampKey; -import org.onap.policy.models.base.validation.annotations.VerifyKey; -import org.onap.policy.models.tosca.authorative.concepts.ToscaConceptIdentifier; - -/** - * Class to represent a control loop statistics in the database. - * - * @author Ramesh Murugan Iyer (ramesh.murugan.iyer@est.tech) - */ -@Entity -@Table(name = "ParticipantStatistics") -@Inheritance(strategy = InheritanceType.TABLE_PER_CLASS) -@Data -@AllArgsConstructor -@EqualsAndHashCode(callSuper = false) -public class JpaParticipantStatistics extends PfConcept implements PfAuthorative, Serializable { - - private static final long serialVersionUID = -5992214428190133190L; - - @EmbeddedId - @VerifyKey - @NotNull - private PfTimestampKey key; - - @VerifyKey - @NotNull - @AttributeOverride(name = "name", column = @Column(name = "participant_name")) - @AttributeOverride(name = "version", column = @Column(name = "participant_version")) - private PfConceptKey participantId; - - @Column - @NotNull - private ParticipantState state; - - @Column - @NotNull - private ParticipantHealthStatus healthStatus; - - @Column - private long eventCount; - - @Column - private long lastExecutionTime; - - @Column - private double averageExecutionTime; - - @Column - private long upTime; - - @Column - private long lastEnterTime; - - @Column - private long lastStart; - - - /** - * The Default Constructor creates a {@link JpaParticipantStatistics} object with a null key. - */ - public JpaParticipantStatistics() { - this(new PfTimestampKey()); - } - - /** - * The Key Constructor creates a {@link JpaParticipantStatistics} object with the given Timestamp key. - * - * @param key the key - */ - public JpaParticipantStatistics(@NonNull final PfTimestampKey key) { - this(key, new PfConceptKey(), ParticipantState.PASSIVE, ParticipantHealthStatus.HEALTHY, 0L, 0L, 0.0d, 0L, 0L, - 0L); - } - - - /** - * The Key Constructor creates a {@link JpaParticipantStatistics} object with all mandatory fields. - * - * @param key the key - * @param participantId the TOSCA definition of the control loop participant - */ - public JpaParticipantStatistics(@NonNull final PfTimestampKey key, @NonNull final PfConceptKey participantId) { - this.key = key; - this.participantId = participantId; - } - - - /** - * Copy constructor. - * - * @param copyConcept the concept to copy from - */ - public JpaParticipantStatistics(@NonNull final JpaParticipantStatistics copyConcept) { - super(copyConcept); - this.key = new PfTimestampKey(copyConcept.key); - this.participantId = new PfConceptKey(copyConcept.participantId); - this.state = copyConcept.state; - this.healthStatus = copyConcept.healthStatus; - this.eventCount = copyConcept.eventCount; - this.lastExecutionTime = copyConcept.lastExecutionTime; - this.averageExecutionTime = copyConcept.averageExecutionTime; - this.upTime = copyConcept.upTime; - this.lastEnterTime = copyConcept.lastEnterTime; - this.lastStart = copyConcept.lastStart; - } - - /** - * Authorative constructor. - * - * @param authorativeConcept the authorative concept to copy from - */ - public JpaParticipantStatistics(@NonNull final ParticipantStatistics authorativeConcept) { - this.fromAuthorative(authorativeConcept); - } - - - @Override - public int compareTo(PfConcept otherConcept) { - if (otherConcept == null) { - return -1; - } - if (this == otherConcept) { - return 0; - } - if (getClass() != otherConcept.getClass()) { - return getClass().getName().compareTo(otherConcept.getClass().getName()); - } - - final JpaParticipantStatistics other = (JpaParticipantStatistics) otherConcept; - // @formatter:off - return new CompareToBuilder() - .append(this.key, other.key) - .append(this.participantId, other.participantId) - .append(this.state, other.state) - .append(this.healthStatus, other.healthStatus) - .append(this.eventCount, other.eventCount) - .append(this.lastExecutionTime, other.lastExecutionTime) - .append(this.averageExecutionTime, other.averageExecutionTime) - .append(this.upTime, other.upTime) - .append(this.lastEnterTime, other.lastEnterTime) - .append(this.lastStart, other.lastStart).toComparison(); - // @formatter:on - } - - @Override - public ParticipantStatistics toAuthorative() { - var participantStatistics = new ParticipantStatistics(); - participantStatistics.setTimeStamp(key.getTimeStamp().toInstant()); - participantStatistics.setParticipantId(new ToscaConceptIdentifier(participantId)); - participantStatistics.setState(state); - participantStatistics.setHealthStatus(healthStatus); - participantStatistics.setAverageExecutionTime(averageExecutionTime); - participantStatistics.setEventCount(eventCount); - participantStatistics.setLastExecutionTime(lastExecutionTime); - participantStatistics.setUpTime(upTime); - participantStatistics.setLastEnterTime(lastEnterTime); - participantStatistics.setLastStart(lastStart); - - return participantStatistics; - } - - @Override - public void fromAuthorative(@NonNull final ParticipantStatistics participantStatistics) { - if (this.key == null || this.getKey().isNullKey()) { - this.setKey(new PfTimestampKey(participantStatistics.getParticipantId().getName(), - participantStatistics.getParticipantId().getVersion(), participantStatistics.getTimeStamp())); - } - this.setParticipantId(participantStatistics.getParticipantId().asConceptKey()); - this.setState(participantStatistics.getState()); - this.setHealthStatus(participantStatistics.getHealthStatus()); - this.setAverageExecutionTime(participantStatistics.getAverageExecutionTime()); - this.setEventCount(participantStatistics.getEventCount()); - this.setLastExecutionTime(participantStatistics.getLastExecutionTime()); - this.setUpTime(participantStatistics.getUpTime()); - this.setLastEnterTime(participantStatistics.getLastEnterTime()); - this.setLastStart(participantStatistics.getLastStart()); - - } - - @Override - public List getKeys() { - List keyList = getKey().getKeys(); - keyList.addAll(participantId.getKeys()); - return keyList; - } - - @Override - public void clean() { - key.clean(); - participantId.clean(); - } -} diff --git a/models/src/main/java/org/onap/policy/clamp/controlloop/models/controlloop/persistence/provider/ClElementStatisticsProvider.java b/models/src/main/java/org/onap/policy/clamp/controlloop/models/controlloop/persistence/provider/ClElementStatisticsProvider.java deleted file mode 100644 index 3a7fa9c87..000000000 --- a/models/src/main/java/org/onap/policy/clamp/controlloop/models/controlloop/persistence/provider/ClElementStatisticsProvider.java +++ /dev/null @@ -1,137 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * Copyright (C) 2021 Nordix Foundation. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - * SPDX-License-Identifier: Apache-2.0 - * ============LICENSE_END========================================================= - */ - -package org.onap.policy.clamp.controlloop.models.controlloop.persistence.provider; - -import java.time.Instant; -import java.util.List; -import java.util.Map; -import java.util.stream.Collectors; -import javax.ws.rs.core.Response.Status; -import lombok.AllArgsConstructor; -import lombok.NonNull; -import org.onap.policy.clamp.controlloop.models.controlloop.concepts.ClElementStatistics; -import org.onap.policy.clamp.controlloop.models.controlloop.persistence.concepts.JpaClElementStatistics; -import org.onap.policy.clamp.controlloop.models.controlloop.persistence.repository.ClElementStatisticsRepository; -import org.onap.policy.models.base.PfModelException; -import org.onap.policy.models.base.PfReferenceTimestampKey; -import org.onap.policy.models.dao.PfFilterParameters; -import org.springframework.stereotype.Service; -import org.springframework.transaction.annotation.Transactional; - -/** - * This class provides the provision of information on control loop element statistics in the database to callers. - * - * @author Ramesh Murugan Iyer (ramesh.murugan.iyer@est.tech) - */ -@Service -@Transactional -@AllArgsConstructor -public class ClElementStatisticsProvider { - - private ClElementStatisticsRepository clElementStatisticsRepository; - - /** - * Creates control loop element statistics. - * - * @param clElementStatisticsList a specification of the CL element statistics to create - * @return the clElement statistics created - * @throws PfModelException on initiation errors - */ - public List createClElementStatistics( - @NonNull final List clElementStatisticsList) throws PfModelException { - - try { - var jpaClElementStatisticsList = ProviderUtils.getJpaAndValidateList(clElementStatisticsList, - JpaClElementStatistics::new, "control loop element statistics"); - - var jpaClElementStatisticsSaved = clElementStatisticsRepository.saveAll(jpaClElementStatisticsList); - - // Return the saved control loop element statistics - return asClElementStatisticsList(jpaClElementStatisticsSaved); - } catch (IllegalArgumentException e) { - throw new PfModelException(Status.BAD_REQUEST, "Error in save control loop element statistics", e); - } - } - - /** - * Convert JPA clElement statistics list to clElement statistics list. - * - * @param jpaClElementStatistics the list to convert - * @return the clElement statistics list - */ - private List asClElementStatisticsList(List jpaClElementStatistics) { - return jpaClElementStatistics.stream().map(JpaClElementStatistics::toAuthorative).collect(Collectors.toList()); - } - - /** - * Get clElement statistics. - * - * @param name the name of the participant - * @param version version of the participant - * @param id of the control loop element - * @param timestamp timestamp of the statistics - * @return the clElement statistics found - */ - @Transactional(readOnly = true) - public List getClElementStatistics(final String name, final String version, final String id, - final Instant timestamp) { - if (name != null && version != null && timestamp != null && id != null) { - return asClElementStatisticsList(clElementStatisticsRepository - .findAllById(List.of(new PfReferenceTimestampKey(name, version, id, timestamp)))); - } else if (name != null) { - return getFilteredClElementStatistics(name, version, null, null, null, "DESC", 0); - } - return asClElementStatisticsList(clElementStatisticsRepository.findAll()); - } - - /** - * Get filtered clElement statistics. - * - * @param name the clElement name for the statistics to get - * @param version the clElement version for the statistics to get - * @param startTimeStamp startTimeStamp to filter statistics - * @param endTimeStamp endTimeStamp to filter statistics - * @param sortOrder sortOrder to query database - * @param getRecordNum Total query count from database - * @param filterMap the filters to apply to the get operation - * @return the clElement statistics found - */ - @Transactional(readOnly = true) - public List getFilteredClElementStatistics(final String name, final String version, - final Instant startTimeStamp, final Instant endTimeStamp, Map filterMap, - final String sortOrder, final int getRecordNum) { - - // @formatter:off - PfFilterParameters filterParams = PfFilterParameters - .builder() - .name(name) - .version(version) - .startTime(startTimeStamp) - .endTime(endTimeStamp) - .filterMap(filterMap) - .sortOrder(sortOrder) - .recordNum(getRecordNum) - .build(); - // @formatter:on - return asClElementStatisticsList( - clElementStatisticsRepository.getFiltered(JpaClElementStatistics.class, filterParams)); - } -} diff --git a/models/src/main/java/org/onap/policy/clamp/controlloop/models/controlloop/persistence/provider/ControlLoopProvider.java b/models/src/main/java/org/onap/policy/clamp/controlloop/models/controlloop/persistence/provider/ControlLoopProvider.java deleted file mode 100644 index a1b1045eb..000000000 --- a/models/src/main/java/org/onap/policy/clamp/controlloop/models/controlloop/persistence/provider/ControlLoopProvider.java +++ /dev/null @@ -1,279 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * Copyright (C) 2021 Nordix Foundation. - * ================================================================================ - * Modifications Copyright (C) 2021 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - * SPDX-License-Identifier: Apache-2.0 - * ============LICENSE_END========================================================= - */ - -package org.onap.policy.clamp.controlloop.models.controlloop.persistence.provider; - -import java.util.HashMap; -import java.util.List; -import java.util.Map; -import java.util.Optional; -import javax.persistence.EntityNotFoundException; -import javax.ws.rs.core.Response; -import javax.ws.rs.core.Response.Status; -import lombok.AllArgsConstructor; -import lombok.NonNull; -import org.onap.policy.clamp.controlloop.models.controlloop.concepts.ControlLoop; -import org.onap.policy.clamp.controlloop.models.controlloop.persistence.concepts.JpaControlLoop; -import org.onap.policy.clamp.controlloop.models.controlloop.persistence.repository.ControlLoopRepository; -import org.onap.policy.clamp.controlloop.models.controlloop.persistence.repository.ToscaNodeTemplateRepository; -import org.onap.policy.clamp.controlloop.models.controlloop.persistence.repository.ToscaNodeTemplatesRepository; -import org.onap.policy.models.base.PfConceptKey; -import org.onap.policy.models.base.PfModelException; -import org.onap.policy.models.tosca.authorative.concepts.ToscaConceptIdentifier; -import org.onap.policy.models.tosca.authorative.concepts.ToscaNodeTemplate; -import org.onap.policy.models.tosca.authorative.concepts.ToscaServiceTemplate; -import org.onap.policy.models.tosca.authorative.concepts.ToscaTypedEntityFilter; -import org.onap.policy.models.tosca.simple.concepts.JpaToscaNodeTemplate; -import org.onap.policy.models.tosca.simple.concepts.JpaToscaNodeTemplates; -import org.springframework.stereotype.Service; -import org.springframework.transaction.annotation.Transactional; - -/** - * This class provides information on control loop concepts in the database to callers. - */ -@Service -@Transactional -@AllArgsConstructor -public class ControlLoopProvider { - - private final ControlLoopRepository controlLoopRepository; - private final ToscaNodeTemplateRepository toscaNodeTemplateRepository; - private final ToscaNodeTemplatesRepository toscaNodeTemplatesRepository; - - /** - * Get Control Loop. - * - * @param controlLoopId the ID of the control loop to get - * @return the control loop found - * @throws PfModelException on errors getting the control loop - */ - @Transactional(readOnly = true) - public ControlLoop getControlLoop(final ToscaConceptIdentifier controlLoopId) throws PfModelException { - try { - return controlLoopRepository.getById(controlLoopId.asConceptKey()).toAuthorative(); - } catch (EntityNotFoundException e) { - throw new PfModelException(Status.NOT_FOUND, "ControlLoop not found", e); - } - } - - /** - * Find Control Loop by controlLoopId. - * - * @param name the name of the control loop to get, null to get all control loops - * @param version the version of the control loop to get, null to get all control loops - * @return the control loop found - * @throws PfModelException on errors getting the control loop - */ - @Transactional(readOnly = true) - public Optional findControlLoop(@NonNull final String name, @NonNull final String version) - throws PfModelException { - return findControlLoop(new PfConceptKey(name, version)); - } - - /** - * Find Control Loop by controlLoopId. - * - * @param controlLoopId the ID of the control loop to get - * @return the control loop found - * @throws PfModelException on errors getting the control loop - */ - @Transactional(readOnly = true) - public Optional findControlLoop(final ToscaConceptIdentifier controlLoopId) throws PfModelException { - return findControlLoop(controlLoopId.asConceptKey()); - } - - private Optional findControlLoop(@NonNull final PfConceptKey key) throws PfModelException { - try { - return controlLoopRepository.findById(key).map(JpaControlLoop::toAuthorative); - } catch (IllegalArgumentException e) { - throw new PfModelException(Status.BAD_REQUEST, "Not valid parameter", e); - } - } - - /** - * Save Control Loop. - * - * @param controlLoop the control loop to update - * @return the updated control loop - * @throws PfModelException on errors updating the control loop - */ - public ControlLoop saveControlLoop(final ControlLoop controlLoop) throws PfModelException { - try { - var result = controlLoopRepository - .save(ProviderUtils.getJpaAndValidate(controlLoop, JpaControlLoop::new, "control loop")); - - // Return the saved participant - return result.toAuthorative(); - } catch (IllegalArgumentException e) { - throw new PfModelException(Status.BAD_REQUEST, "Error in save controlLoop", e); - } - } - - /** - * Get All Control Loops. - * - * @return all control loops found - * @throws PfModelException on errors getting control loops - */ - @Transactional(readOnly = true) - public List getControlLoops() throws PfModelException { - - return ProviderUtils.asEntityList(controlLoopRepository.findAll()); - } - - /** - * Get Control Loops. - * - * @param name the name of the control loop to get, null to get all control loops - * @param version the version of the control loop to get, null to get all control loops - * @return the control loops found - * @throws PfModelException on errors getting control loops - */ - @Transactional(readOnly = true) - public List getControlLoops(final String name, final String version) throws PfModelException { - - return ProviderUtils.asEntityList(controlLoopRepository.getFiltered(JpaControlLoop.class, name, version)); - } - - /** - * Saves control loops. - * - * @param controlLoops a specification of the control loops to create - * @return the control loops created - * @throws PfModelException on errors creating control loops - */ - public List saveControlLoops(@NonNull final List controlLoops) throws PfModelException { - try { - var result = controlLoopRepository - .saveAll(ProviderUtils.getJpaAndValidateList(controlLoops, JpaControlLoop::new, "control loops")); - - // Return the saved participant - return ProviderUtils.asEntityList(result); - } catch (IllegalArgumentException e) { - throw new PfModelException(Status.BAD_REQUEST, "Error in save ControlLoops", e); - } - } - - /** - * Saves Instance Properties to the database. - * - * @param serviceTemplate the service template - * @return a Map of tosca node templates - */ - public Map saveInstanceProperties(ToscaServiceTemplate serviceTemplate) { - Map savedNodeTemplates = new HashMap<>(); - - var jpaToscaNodeTemplates = new JpaToscaNodeTemplates(); - jpaToscaNodeTemplates.fromAuthorative(List.of(serviceTemplate.getToscaTopologyTemplate().getNodeTemplates())); - - toscaNodeTemplatesRepository.save(jpaToscaNodeTemplates); - serviceTemplate.getToscaTopologyTemplate().getNodeTemplates().forEach(savedNodeTemplates::put); - - return savedNodeTemplates; - } - - /** - * Delete a control loop. - * - * @param name the name of the control loop to delete - * @param version the version of the control loop to delete - * @return the control loop deleted - * @throws PfModelException on errors deleting the control loop - */ - public ControlLoop deleteControlLoop(@NonNull final String name, @NonNull final String version) - throws PfModelException { - - var controlLoopKey = new PfConceptKey(name, version); - var jpaDeleteControlLoop = controlLoopRepository.findById(controlLoopKey); - - if (jpaDeleteControlLoop.isEmpty()) { - String errorMessage = - "delete of control loop \"" + controlLoopKey.getId() + "\" failed, control loop does not exist"; - throw new PfModelException(Response.Status.BAD_REQUEST, errorMessage); - } - - controlLoopRepository.deleteById(controlLoopKey); - - return jpaDeleteControlLoop.get().toAuthorative(); - } - - /** - * Deletes Instance Properties on the database. - * - * @param filteredToscaNodeTemplateMap filtered node templates map to delete - * @param filteredToscaNodeTemplateList filtered node template list to delete - */ - public void deleteInstanceProperties(Map filteredToscaNodeTemplateMap, - List filteredToscaNodeTemplateList) { - - var jpaToscaNodeTemplates = new JpaToscaNodeTemplates(); - jpaToscaNodeTemplates.fromAuthorative(List.of(filteredToscaNodeTemplateMap)); - - toscaNodeTemplatesRepository.save(jpaToscaNodeTemplates); - - filteredToscaNodeTemplateList.forEach(template -> { - var jpaToscaNodeTemplate = new JpaToscaNodeTemplate(template); - - toscaNodeTemplateRepository.delete(jpaToscaNodeTemplate); - }); - } - - /** - * Get All Node Templates. - * - * @return the list of node templates found - * @throws PfModelException on errors getting node templates - */ - @Transactional(readOnly = true) - public List getAllNodeTemplates() { - return ProviderUtils.asEntityList(toscaNodeTemplateRepository.findAll()); - } - - /** - * Get Node Templates. - * - * @param name the name of the node template to get, null to get all node templates - * @param version the version of the node template to get, null to get all node templates - * @return the node templates found - * @throws PfModelException on errors getting node templates - */ - @Transactional(readOnly = true) - public List getNodeTemplates(final String name, final String version) { - return ProviderUtils - .asEntityList(toscaNodeTemplateRepository.getFiltered(JpaToscaNodeTemplate.class, name, version)); - } - - /** - * Get filtered node templates. - * - * @param filter the filter for the node templates to get - * @return the node templates found - * @throws PfModelException on errors getting node templates - */ - @Transactional(readOnly = true) - public List getFilteredNodeTemplates( - @NonNull final ToscaTypedEntityFilter filter) { - - return filter.filter(ProviderUtils.asEntityList(toscaNodeTemplateRepository - .getFiltered(JpaToscaNodeTemplate.class, filter.getName(), filter.getVersion()))); - } -} diff --git a/models/src/main/java/org/onap/policy/clamp/controlloop/models/controlloop/persistence/provider/ParticipantProvider.java b/models/src/main/java/org/onap/policy/clamp/controlloop/models/controlloop/persistence/provider/ParticipantProvider.java deleted file mode 100644 index 0c001c11c..000000000 --- a/models/src/main/java/org/onap/policy/clamp/controlloop/models/controlloop/persistence/provider/ParticipantProvider.java +++ /dev/null @@ -1,152 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * Copyright (C) 2021 Nordix Foundation. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - * SPDX-License-Identifier: Apache-2.0 - * ============LICENSE_END========================================================= - */ - -package org.onap.policy.clamp.controlloop.models.controlloop.persistence.provider; - -import java.util.List; -import java.util.Optional; -import javax.ws.rs.core.Response.Status; -import lombok.AllArgsConstructor; -import lombok.NonNull; -import org.onap.policy.clamp.controlloop.models.controlloop.concepts.Participant; -import org.onap.policy.clamp.controlloop.models.controlloop.persistence.concepts.JpaParticipant; -import org.onap.policy.clamp.controlloop.models.controlloop.persistence.repository.ParticipantRepository; -import org.onap.policy.models.base.PfConceptKey; -import org.onap.policy.models.base.PfModelException; -import org.onap.policy.models.base.PfModelRuntimeException; -import org.onap.policy.models.tosca.authorative.concepts.ToscaTypedEntityFilter; -import org.springframework.stereotype.Service; -import org.springframework.transaction.annotation.Transactional; - -/** - * This class provides information on participant concepts in the database to callers. - */ -@Service -@Transactional -@AllArgsConstructor -public class ParticipantProvider { - - private ParticipantRepository participantRepository; - - /** - * Get participants. - * - * @param name the name of the participant to get, null to get all participants - * @param version the version of the participant to get, null to get all participants - * @return the participants found - * @throws PfModelException on errors getting participants - */ - @Transactional(readOnly = true) - public List getParticipants(final String name, final String version) throws PfModelException { - - return ProviderUtils.asEntityList(participantRepository.getFiltered(JpaParticipant.class, name, version)); - } - - /** - * Get all participants. - * - * @return the participants found - * @throws PfModelException on errors getting policies - */ - @Transactional(readOnly = true) - public List getParticipants() throws PfModelException { - return ProviderUtils.asEntityList(participantRepository.findAll()); - } - - /** - * Get participant. - * - * @param name the name of the participant to get - * @param version the version of the participant to get - * @return the participant found - * @throws PfModelException on errors getting participant - */ - @Transactional(readOnly = true) - public Optional findParticipant(@NonNull final String name, @NonNull final String version) - throws PfModelException { - try { - return participantRepository.findById(new PfConceptKey(name, version)).map(JpaParticipant::toAuthorative); - } catch (IllegalArgumentException e) { - throw new PfModelException(Status.BAD_REQUEST, "Error in find Participant", e); - } - } - - /** - * Get filtered participants. - * - * @param filter the filter for the participants to get - * @return the participants found - * @throws PfModelException on errors getting policies - */ - @Transactional(readOnly = true) - public List getFilteredParticipants(@NonNull final ToscaTypedEntityFilter filter) - throws PfModelException { - - return filter.filter(ProviderUtils.asEntityList( - participantRepository.getFiltered(JpaParticipant.class, filter.getName(), filter.getVersion()))); - } - - /** - * Saves participant. - * - * @param participant participant to save - * @return the participant created - * @throws PfModelException on errors creating participants - */ - public Participant saveParticipant(@NonNull final Participant participant) throws PfModelException { - try { - var result = participantRepository - .save(ProviderUtils.getJpaAndValidate(participant, JpaParticipant::new, "participant")); - - // Return the saved participant - return result.toAuthorative(); - } catch (IllegalArgumentException e) { - throw new PfModelException(Status.BAD_REQUEST, "Error in save Participant", e); - } - } - - /** - * Delete a participant. - * - * @param name the name of the participant to delete - * @param version the version of the participant to get - * @return the participant deleted - * @throws PfModelRuntimeException on errors deleting participants - */ - public Participant deleteParticipant(@NonNull final String name, @NonNull final String version) - throws PfModelException { - try { - var participantKey = new PfConceptKey(name, version); - - var jpaDeleteParticipantOpt = participantRepository.findById(participantKey); - - if (jpaDeleteParticipantOpt.isEmpty()) { - String errorMessage = - "delete of participant \"" + participantKey.getId() + "\" failed, participant does not exist"; - throw new PfModelRuntimeException(Status.BAD_REQUEST, errorMessage); - } - participantRepository.delete(jpaDeleteParticipantOpt.get()); - - return jpaDeleteParticipantOpt.get().toAuthorative(); - } catch (IllegalArgumentException e) { - throw new PfModelException(Status.BAD_REQUEST, "Error in delete Participant", e); - } - } -} diff --git a/models/src/main/java/org/onap/policy/clamp/controlloop/models/controlloop/persistence/provider/ParticipantStatisticsProvider.java b/models/src/main/java/org/onap/policy/clamp/controlloop/models/controlloop/persistence/provider/ParticipantStatisticsProvider.java deleted file mode 100644 index bb4f3a5dd..000000000 --- a/models/src/main/java/org/onap/policy/clamp/controlloop/models/controlloop/persistence/provider/ParticipantStatisticsProvider.java +++ /dev/null @@ -1,138 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * Copyright (C) 2021 Nordix Foundation. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - * SPDX-License-Identifier: Apache-2.0 - * ============LICENSE_END========================================================= - */ - -package org.onap.policy.clamp.controlloop.models.controlloop.persistence.provider; - -import java.time.Instant; -import java.util.List; -import java.util.Map; -import java.util.stream.Collectors; -import javax.ws.rs.core.Response.Status; -import lombok.AllArgsConstructor; -import lombok.NonNull; -import org.onap.policy.clamp.controlloop.models.controlloop.concepts.ParticipantStatistics; -import org.onap.policy.clamp.controlloop.models.controlloop.persistence.concepts.JpaParticipantStatistics; -import org.onap.policy.clamp.controlloop.models.controlloop.persistence.repository.ParticipantStatisticsRepository; -import org.onap.policy.models.base.PfModelException; -import org.onap.policy.models.base.PfTimestampKey; -import org.onap.policy.models.dao.PfFilterParameters; -import org.springframework.stereotype.Service; -import org.springframework.transaction.annotation.Transactional; - -/** - * This class provides the provision of information on participant statistics in the database to callers. - */ -@Service -@Transactional -@AllArgsConstructor -public class ParticipantStatisticsProvider { - - private ParticipantStatisticsRepository participantStatisticsRepository; - - /** - * Get Participant statistics. - * - * @param name the name of the participant statistics to get, null to get all stats - * @param version the version of the participant statistics to get, null to get all stats for a name - * @param timestamp the time stamp for the stats to get - * @return the participant statistics found - */ - @Transactional(readOnly = true) - public List getParticipantStatistics(final String name, final String version, - final Instant timestamp) { - if (name != null && version != null && timestamp != null) { - return asParticipantStatisticsList( - participantStatisticsRepository.findAllById(List.of(new PfTimestampKey(name, version, timestamp)))); - } else if (name != null) { - return getFilteredParticipantStatistics(name, version, timestamp, null, null, "DESC", 0); - } - return asParticipantStatisticsList(participantStatisticsRepository.findAll()); - } - - /** - * Get filtered participant statistics. - * - * @param name the participant name for the statistics to get - * @param version the participant version for the statistics to get - * @param startTimeStamp startTimeStamp to filter statistics - * @param endTimeStamp endTimeStamp to filter statistics - * @param sortOrder sortOrder to query database - * @param getRecordNum Total query count from database - * @param filterMap the filters to apply to the get operation - * @return the participant statistics found - */ - @Transactional(readOnly = true) - public List getFilteredParticipantStatistics(final String name, final String version, - final Instant startTimeStamp, final Instant endTimeStamp, Map filterMap, - final String sortOrder, final int getRecordNum) { - - // @formatter:off - PfFilterParameters filterParams = PfFilterParameters - .builder() - .name(name) - .version(version) - .startTime(startTimeStamp) - .endTime(endTimeStamp) - .filterMap(filterMap) - .sortOrder(sortOrder) - .recordNum(getRecordNum) - .build(); - // @formatter:on - - return asParticipantStatisticsList( - participantStatisticsRepository.getFiltered(JpaParticipantStatistics.class, filterParams)); - } - - /** - * Creates Participant statistics. - * - * @param participantStatisticsList a specification of the CL statistics to create - * @return the participant statistics created - * @throws PfModelException on errors creating participant statistics - */ - public List createParticipantStatistics( - @NonNull final List participantStatisticsList) throws PfModelException { - - try { - var jpaParticipantStatisticsList = ProviderUtils.getJpaAndValidateList(participantStatisticsList, - JpaParticipantStatistics::new, "Participant Statistics"); - - var jpaParticipantStatisticsSaved = participantStatisticsRepository.saveAll(jpaParticipantStatisticsList); - - // Return the saved participant statistics - return asParticipantStatisticsList(jpaParticipantStatisticsSaved); - } catch (IllegalArgumentException e) { - throw new PfModelException(Status.BAD_REQUEST, "Error in save participant statistics", e); - } - } - - /** - * Convert JPA participant statistics list to participant statistics list. - * - * @param jpaParticipantStatisticsList the list to convert - * @return the participant statistics list - */ - private List asParticipantStatisticsList( - List jpaParticipantStatisticsList) { - - return jpaParticipantStatisticsList.stream().map(JpaParticipantStatistics::toAuthorative) - .collect(Collectors.toList()); - } -} diff --git a/models/src/main/java/org/onap/policy/clamp/controlloop/models/controlloop/persistence/provider/ProviderUtils.java b/models/src/main/java/org/onap/policy/clamp/controlloop/models/controlloop/persistence/provider/ProviderUtils.java deleted file mode 100644 index 3b0400b4f..000000000 --- a/models/src/main/java/org/onap/policy/clamp/controlloop/models/controlloop/persistence/provider/ProviderUtils.java +++ /dev/null @@ -1,93 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * Copyright (C) 2021 Nordix Foundation. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - * SPDX-License-Identifier: Apache-2.0 - * ============LICENSE_END========================================================= - */ - -package org.onap.policy.clamp.controlloop.models.controlloop.persistence.provider; - -import java.util.ArrayList; -import java.util.List; -import java.util.function.Supplier; -import java.util.stream.Collectors; -import javax.ws.rs.core.Response; -import lombok.AccessLevel; -import lombok.NoArgsConstructor; -import org.onap.policy.common.parameters.BeanValidationResult; -import org.onap.policy.models.base.PfAuthorative; -import org.onap.policy.models.base.PfConcept; -import org.onap.policy.models.base.PfModelRuntimeException; -import org.onap.policy.models.tosca.authorative.concepts.ToscaEntity; - -@NoArgsConstructor(access = AccessLevel.PRIVATE) -public final class ProviderUtils { - - /** - * Convert a list of concepts to a list of Jpa objects. - * - * @param authorativeConceptList the list of concepts - * @param jpaSupplier the Jpa Supplier - * @param conceptDescription the description used for validation result - * @return the list of Jpa objects - */ - public static > List getJpaAndValidateList( - List authorativeConceptList, Supplier jpaSupplier, String conceptDescription) { - var validationResult = new BeanValidationResult(conceptDescription + " List", authorativeConceptList); - - List jpaConceptList = new ArrayList<>(authorativeConceptList.size()); - - for (A authorativeConcept : authorativeConceptList) { - var jpaConcept = jpaSupplier.get(); - jpaConcept.fromAuthorative(authorativeConcept); - jpaConceptList.add(jpaConcept); - - validationResult.addResult(jpaConcept.validate(conceptDescription)); - } - - if (!validationResult.isValid()) { - throw new PfModelRuntimeException(Response.Status.BAD_REQUEST, validationResult.getResult()); - } - return jpaConceptList; - } - - protected static > J getJpaAndValidate(A authorativeConcept, - Supplier jpaSupplier, String conceptDescription) { - var validationResult = new BeanValidationResult(conceptDescription, authorativeConcept); - - var jpaConcept = jpaSupplier.get(); - jpaConcept.fromAuthorative(authorativeConcept); - - validationResult.addResult(jpaConcept.validate(conceptDescription)); - - if (!validationResult.isValid()) { - throw new PfModelRuntimeException(Response.Status.BAD_REQUEST, validationResult.getResult()); - } - return jpaConcept; - } - - /** - * Convert JPA control loop list to an authorative control loop list. - * - * @param the type of TOSCA entity - * @param the type of JPA TOSCA entity - * @param jpaEntityList the list to convert - * @return the authorative list - */ - public static > List asEntityList(List jpaEntityList) { - return jpaEntityList.stream().map(J::toAuthorative).collect(Collectors.toList()); - } -} diff --git a/models/src/main/java/org/onap/policy/clamp/controlloop/models/controlloop/persistence/provider/ServiceTemplateProvider.java b/models/src/main/java/org/onap/policy/clamp/controlloop/models/controlloop/persistence/provider/ServiceTemplateProvider.java deleted file mode 100644 index 8ff0dd102..000000000 --- a/models/src/main/java/org/onap/policy/clamp/controlloop/models/controlloop/persistence/provider/ServiceTemplateProvider.java +++ /dev/null @@ -1,261 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * Copyright (C) 2021 Nordix Foundation. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - * SPDX-License-Identifier: Apache-2.0 - * ============LICENSE_END========================================================= - */ - -package org.onap.policy.clamp.controlloop.models.controlloop.persistence.provider; - -import java.util.HashMap; -import java.util.List; -import java.util.Map; -import javax.ws.rs.core.Response; -import javax.ws.rs.core.Response.Status; -import lombok.RequiredArgsConstructor; -import org.onap.policy.clamp.controlloop.models.controlloop.persistence.repository.ToscaServiceTemplateRepository; -import org.onap.policy.models.base.PfConceptKey; -import org.onap.policy.models.base.PfModelException; -import org.onap.policy.models.tosca.authorative.concepts.ToscaNodeTemplate; -import org.onap.policy.models.tosca.authorative.concepts.ToscaNodeType; -import org.onap.policy.models.tosca.authorative.concepts.ToscaProperty; -import org.onap.policy.models.tosca.authorative.concepts.ToscaServiceTemplate; -import org.onap.policy.models.tosca.simple.concepts.JpaToscaServiceTemplate; -import org.springframework.stereotype.Service; -import org.springframework.transaction.annotation.Transactional; - -@Service -@Transactional -@RequiredArgsConstructor -public class ServiceTemplateProvider { - - private final ToscaServiceTemplateRepository serviceTemplateRepository; - - /** - * Create service template. - * - * @param serviceTemplate the service template to be created - * @return the created service template - * @throws PfModelException on errors creating the service template - */ - public ToscaServiceTemplate createServiceTemplate(final ToscaServiceTemplate serviceTemplate) - throws PfModelException { - try { - var result = serviceTemplateRepository.save(ProviderUtils.getJpaAndValidate(serviceTemplate, - JpaToscaServiceTemplate::new, "toscaServiceTemplate")); - return result.toAuthorative(); - } catch (IllegalArgumentException e) { - throw new PfModelException(Status.BAD_REQUEST, "Error in save serviceTemplate", e); - } - } - - /** - * Delete service template. - * - * @param name the name of the service template to delete. - * @param version the version of the service template to delete. - * @return the TOSCA service template that was deleted - * @throws PfModelException on errors deleting policy types - */ - public ToscaServiceTemplate deleteServiceTemplate(final String name, final String version) throws PfModelException { - var serviceTemplateKey = new PfConceptKey(name, version); - var jpaDelete = serviceTemplateRepository.findById(serviceTemplateKey); - if (jpaDelete.isEmpty()) { - String errorMessage = "delete of serviceTemplate \"" + serviceTemplateKey.getId() - + "\" failed, serviceTemplate does not exist"; - throw new PfModelException(Response.Status.BAD_REQUEST, errorMessage); - } - serviceTemplateRepository.deleteById(serviceTemplateKey); - return jpaDelete.get().toAuthorative(); - } - - /** - * Get the requested control loop definitions. - * - * @param name the name of the definition to get, null for all definitions - * @param version the version of the definition to get, null for all definitions - * @return the control loop definitions - * @throws PfModelException on errors getting control loop definitions - */ - @Transactional(readOnly = true) - public ToscaServiceTemplate getToscaServiceTemplate(String name, String version) throws PfModelException { - var serviceTemplateKey = new PfConceptKey(name, version); - var jpaServiceTemplates = serviceTemplateRepository.findById(serviceTemplateKey); - if (jpaServiceTemplates.isEmpty()) { - throw new PfModelException(Status.NOT_FOUND, "Control Loop definitions not found"); - } - return jpaServiceTemplates.get().toAuthorative(); - } - - /** - * Get service templates. - * - * @return the topology templates found - * @throws PfModelException on errors getting service templates - */ - @Transactional(readOnly = true) - public List getAllServiceTemplates() throws PfModelException { - var jpaList = serviceTemplateRepository.findAll(); - return ProviderUtils.asEntityList(jpaList); - } - - /** - * Get service templates. - * - * @param name the name of the topology template to get, set to null to get all service templates - * @param version the version of the service template to get, set to null to get all service templates - * @return the topology templates found - * @throws PfModelException on errors getting service templates - */ - @Transactional(readOnly = true) - public List getServiceTemplateList(final String name, final String version) - throws PfModelException { - var jpaList = serviceTemplateRepository.getFiltered(JpaToscaServiceTemplate.class, name, version); - return ProviderUtils.asEntityList(jpaList); - } - - /** - * Get the initial node types with common or instance properties. - * - * @param fullNodeTypes map of all the node types in the specified template - * @param common boolean to indicate whether common or instance properties are required - * @return node types map that only has common properties - * @throws PfModelException on errors getting node type with common properties - */ - private Map getInitialNodeTypesMap(Map fullNodeTypes, - boolean common) { - - var tempNodeTypesMap = new HashMap(); - - fullNodeTypes.forEach((key, nodeType) -> { - var tempToscaNodeType = new ToscaNodeType(); - tempToscaNodeType.setName(key); - - var resultantPropertyMap = findCommonOrInstancePropsInNodeTypes(nodeType, common); - - if (!resultantPropertyMap.isEmpty()) { - tempToscaNodeType.setProperties(resultantPropertyMap); - tempNodeTypesMap.put(key, tempToscaNodeType); - } - }); - return tempNodeTypesMap; - } - - private Map findCommonOrInstancePropsInNodeTypes(ToscaNodeType nodeType, boolean common) { - - var tempCommonPropertyMap = new HashMap(); - var tempInstancePropertyMap = new HashMap(); - - nodeType.getProperties().forEach((propKey, prop) -> { - - if (prop.getMetadata() != null) { - prop.getMetadata().forEach((k, v) -> { - if (k.equals("common") && v.equals("true") && common) { - tempCommonPropertyMap.put(propKey, prop); - } else if (k.equals("common") && v.equals("false") && !common) { - tempInstancePropertyMap.put(propKey, prop); - } - - }); - } else { - tempInstancePropertyMap.put(propKey, prop); - } - }); - - if (tempCommonPropertyMap.isEmpty() && !common) { - return tempInstancePropertyMap; - } else { - return tempCommonPropertyMap; - } - } - - /** - * Get the node types derived from those that have common properties. - * - * @param initialNodeTypes map of all the node types in the specified template - * @param filteredNodeTypes map of all the node types that have common or instance properties - * @return all node types that have common properties including their children - * @throws PfModelException on errors getting node type with common properties - */ - private Map getFinalNodeTypesMap(Map initialNodeTypes, - Map filteredNodeTypes) { - for (var i = 0; i < initialNodeTypes.size(); i++) { - initialNodeTypes.forEach((key, nodeType) -> { - var tempToscaNodeType = new ToscaNodeType(); - tempToscaNodeType.setName(key); - - if (filteredNodeTypes.get(nodeType.getDerivedFrom()) != null) { - tempToscaNodeType.setName(key); - - var finalProps = new HashMap( - filteredNodeTypes.get(nodeType.getDerivedFrom()).getProperties()); - - tempToscaNodeType.setProperties(finalProps); - } else { - return; - } - filteredNodeTypes.putIfAbsent(key, tempToscaNodeType); - - }); - } - return filteredNodeTypes; - } - - /** - * Get the requested node types with common or instance properties. - * - * @param common boolean indicating common or instance properties - * @param serviceTemplate the ToscaServiceTemplate - * @return the node types with common or instance properties - * @throws PfModelException on errors getting node type properties - */ - public Map getCommonOrInstancePropertiesFromNodeTypes(boolean common, - ToscaServiceTemplate serviceTemplate) throws PfModelException { - var tempNodeTypesMap = this.getInitialNodeTypesMap(serviceTemplate.getNodeTypes(), common); - - return this.getFinalNodeTypesMap(serviceTemplate.getNodeTypes(), tempNodeTypesMap); - - } - - /** - * Get node templates with appropriate common or instance properties added. - * - * @param initialNodeTemplates map of all the node templates in the specified template - * @param nodeTypeProps map of all the node types that have common or instance properties including children - * @return all node templates with appropriate common or instance properties added - * @throws PfModelException on errors getting map of node templates with common or instance properties added - */ - public Map getDerivedCommonOrInstanceNodeTemplates( - Map initialNodeTemplates, Map nodeTypeProps) { - - var finalNodeTemplatesMap = new HashMap(); - - initialNodeTemplates.forEach((templateKey, template) -> { - if (nodeTypeProps.containsKey(template.getType())) { - var finalMergedProps = new HashMap(); - - nodeTypeProps.get(template.getType()).getProperties().forEach(finalMergedProps::putIfAbsent); - - template.setProperties(finalMergedProps); - - finalNodeTemplatesMap.put(templateKey, template); - } else { - return; - } - }); - return finalNodeTemplatesMap; - } -} diff --git a/models/src/main/java/org/onap/policy/clamp/controlloop/models/controlloop/persistence/repository/ClElementStatisticsRepository.java b/models/src/main/java/org/onap/policy/clamp/controlloop/models/controlloop/persistence/repository/ClElementStatisticsRepository.java deleted file mode 100644 index 1e07a4fe6..000000000 --- a/models/src/main/java/org/onap/policy/clamp/controlloop/models/controlloop/persistence/repository/ClElementStatisticsRepository.java +++ /dev/null @@ -1,32 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * Copyright (C) 2021 Nordix Foundation. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - * SPDX-License-Identifier: Apache-2.0 - * ============LICENSE_END========================================================= - */ - -package org.onap.policy.clamp.controlloop.models.controlloop.persistence.repository; - -import org.onap.policy.clamp.controlloop.models.controlloop.persistence.concepts.JpaClElementStatistics; -import org.onap.policy.models.base.PfReferenceTimestampKey; -import org.springframework.data.jpa.repository.JpaRepository; -import org.springframework.stereotype.Repository; - -@Repository -public interface ClElementStatisticsRepository - extends JpaRepository, FilterRepository { - -} diff --git a/models/src/main/java/org/onap/policy/clamp/controlloop/models/controlloop/persistence/repository/ControlLoopRepository.java b/models/src/main/java/org/onap/policy/clamp/controlloop/models/controlloop/persistence/repository/ControlLoopRepository.java deleted file mode 100644 index 1a5fd5a56..000000000 --- a/models/src/main/java/org/onap/policy/clamp/controlloop/models/controlloop/persistence/repository/ControlLoopRepository.java +++ /dev/null @@ -1,31 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * Copyright (C) 2021 Nordix Foundation. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - * SPDX-License-Identifier: Apache-2.0 - * ============LICENSE_END========================================================= - */ - -package org.onap.policy.clamp.controlloop.models.controlloop.persistence.repository; - -import org.onap.policy.clamp.controlloop.models.controlloop.persistence.concepts.JpaControlLoop; -import org.onap.policy.models.base.PfConceptKey; -import org.springframework.data.jpa.repository.JpaRepository; -import org.springframework.stereotype.Repository; - -@Repository -public interface ControlLoopRepository extends JpaRepository, FilterRepository { - -} diff --git a/models/src/main/java/org/onap/policy/clamp/controlloop/models/controlloop/persistence/repository/FilterRepository.java b/models/src/main/java/org/onap/policy/clamp/controlloop/models/controlloop/persistence/repository/FilterRepository.java deleted file mode 100644 index ce1f3d8c3..000000000 --- a/models/src/main/java/org/onap/policy/clamp/controlloop/models/controlloop/persistence/repository/FilterRepository.java +++ /dev/null @@ -1,53 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * Copyright (C) 2021 Nordix Foundation. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - * SPDX-License-Identifier: Apache-2.0 - * ============LICENSE_END========================================================= - */ - -package org.onap.policy.clamp.controlloop.models.controlloop.persistence.repository; - -import java.util.List; -import org.onap.policy.models.base.PfConcept; -import org.onap.policy.models.dao.PfFilterParametersIntfc; - -public interface FilterRepository { - - /** - * Get an object from the database, referred to by concept key. - * - * @param the type of the object to get, a subclass of {@link PfConcept} - * @param someClass the class of the object to get, a subclass of {@link PfConcept}, if name is null, all concepts - * of type T are returned, if name is not null and version is null, all versions of that concept matching the - * name are returned. - * @param filterParams filter parameters - * @return the objects that was retrieved from the database - */ - List getFiltered(Class someClass, PfFilterParametersIntfc filterParams); - - /** - * Get an object from the database, referred to by concept key. - * - * @param the type of the object to get, a subclass of {@link PfConcept} - * @param someClass the class of the object to get, a subclass of {@link PfConcept}, if name is null, all concepts - * of type T are returned, if name is not null and version is null, all versions of that concept matching the - * name are returned. - * @param name the name of the object to get, null returns all objects - * @param version the version the object to get, null returns all objects for a specified name - * @return the objects that was retrieved from the database - */ - List getFiltered(Class someClass, String name, String version); -} diff --git a/models/src/main/java/org/onap/policy/clamp/controlloop/models/controlloop/persistence/repository/FilterRepositoryImpl.java b/models/src/main/java/org/onap/policy/clamp/controlloop/models/controlloop/persistence/repository/FilterRepositoryImpl.java deleted file mode 100644 index 0dc8fc373..000000000 --- a/models/src/main/java/org/onap/policy/clamp/controlloop/models/controlloop/persistence/repository/FilterRepositoryImpl.java +++ /dev/null @@ -1,51 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * Copyright (C) 2021 Nordix Foundation. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - * SPDX-License-Identifier: Apache-2.0 - * ============LICENSE_END========================================================= - */ - -package org.onap.policy.clamp.controlloop.models.controlloop.persistence.repository; - -import java.util.List; -import javax.persistence.EntityManager; -import javax.persistence.PersistenceContext; -import org.onap.policy.models.base.PfConcept; -import org.onap.policy.models.dao.PfDao; -import org.onap.policy.models.dao.PfFilterParametersIntfc; -import org.onap.policy.models.dao.impl.ProxyDao; -import org.springframework.stereotype.Repository; - -@Repository -public class FilterRepositoryImpl implements FilterRepository { - - @PersistenceContext - private EntityManager entityManager; - - protected PfDao getPfDao() { - return new ProxyDao(entityManager); - } - - @Override - public List getFiltered(Class someClass, PfFilterParametersIntfc filterParams) { - return getPfDao().getFiltered(someClass, filterParams); - } - - @Override - public List getFiltered(Class someClass, String name, String version) { - return getPfDao().getFiltered(someClass, name, version); - } -} diff --git a/models/src/main/java/org/onap/policy/clamp/controlloop/models/controlloop/persistence/repository/ParticipantRepository.java b/models/src/main/java/org/onap/policy/clamp/controlloop/models/controlloop/persistence/repository/ParticipantRepository.java deleted file mode 100644 index 671d23bbe..000000000 --- a/models/src/main/java/org/onap/policy/clamp/controlloop/models/controlloop/persistence/repository/ParticipantRepository.java +++ /dev/null @@ -1,31 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * Copyright (C) 2021 Nordix Foundation. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - * SPDX-License-Identifier: Apache-2.0 - * ============LICENSE_END========================================================= - */ - -package org.onap.policy.clamp.controlloop.models.controlloop.persistence.repository; - -import org.onap.policy.clamp.controlloop.models.controlloop.persistence.concepts.JpaParticipant; -import org.onap.policy.models.base.PfConceptKey; -import org.springframework.data.jpa.repository.JpaRepository; -import org.springframework.stereotype.Repository; - -@Repository -public interface ParticipantRepository extends JpaRepository, FilterRepository { - -} diff --git a/models/src/main/java/org/onap/policy/clamp/controlloop/models/controlloop/persistence/repository/ParticipantStatisticsRepository.java b/models/src/main/java/org/onap/policy/clamp/controlloop/models/controlloop/persistence/repository/ParticipantStatisticsRepository.java deleted file mode 100644 index 6fecd6143..000000000 --- a/models/src/main/java/org/onap/policy/clamp/controlloop/models/controlloop/persistence/repository/ParticipantStatisticsRepository.java +++ /dev/null @@ -1,32 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * Copyright (C) 2021 Nordix Foundation. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - * SPDX-License-Identifier: Apache-2.0 - * ============LICENSE_END========================================================= - */ - -package org.onap.policy.clamp.controlloop.models.controlloop.persistence.repository; - -import org.onap.policy.clamp.controlloop.models.controlloop.persistence.concepts.JpaParticipantStatistics; -import org.onap.policy.models.base.PfTimestampKey; -import org.springframework.data.jpa.repository.JpaRepository; -import org.springframework.stereotype.Repository; - -@Repository -public interface ParticipantStatisticsRepository - extends JpaRepository, FilterRepository { - -} diff --git a/models/src/main/java/org/onap/policy/clamp/controlloop/models/controlloop/persistence/repository/ToscaNodeTemplateRepository.java b/models/src/main/java/org/onap/policy/clamp/controlloop/models/controlloop/persistence/repository/ToscaNodeTemplateRepository.java deleted file mode 100644 index a8f830fed..000000000 --- a/models/src/main/java/org/onap/policy/clamp/controlloop/models/controlloop/persistence/repository/ToscaNodeTemplateRepository.java +++ /dev/null @@ -1,30 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * Copyright (C) 2021 Nordix Foundation. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - * SPDX-License-Identifier: Apache-2.0 - * ============LICENSE_END========================================================= - */ - -package org.onap.policy.clamp.controlloop.models.controlloop.persistence.repository; - -import org.onap.policy.models.base.PfConceptKey; -import org.onap.policy.models.tosca.simple.concepts.JpaToscaNodeTemplate; -import org.springframework.data.jpa.repository.JpaRepository; - -public interface ToscaNodeTemplateRepository - extends JpaRepository, FilterRepository { - -} diff --git a/models/src/main/java/org/onap/policy/clamp/controlloop/models/controlloop/persistence/repository/ToscaNodeTemplatesRepository.java b/models/src/main/java/org/onap/policy/clamp/controlloop/models/controlloop/persistence/repository/ToscaNodeTemplatesRepository.java deleted file mode 100644 index 7bd7d1013..000000000 --- a/models/src/main/java/org/onap/policy/clamp/controlloop/models/controlloop/persistence/repository/ToscaNodeTemplatesRepository.java +++ /dev/null @@ -1,29 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * Copyright (C) 2021 Nordix Foundation. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - * SPDX-License-Identifier: Apache-2.0 - * ============LICENSE_END========================================================= - */ - -package org.onap.policy.clamp.controlloop.models.controlloop.persistence.repository; - -import org.onap.policy.models.base.PfConceptKey; -import org.onap.policy.models.tosca.simple.concepts.JpaToscaNodeTemplates; -import org.springframework.data.jpa.repository.JpaRepository; - -public interface ToscaNodeTemplatesRepository extends JpaRepository { - -} diff --git a/models/src/main/java/org/onap/policy/clamp/controlloop/models/controlloop/persistence/repository/ToscaServiceTemplateRepository.java b/models/src/main/java/org/onap/policy/clamp/controlloop/models/controlloop/persistence/repository/ToscaServiceTemplateRepository.java deleted file mode 100644 index a5d5fe766..000000000 --- a/models/src/main/java/org/onap/policy/clamp/controlloop/models/controlloop/persistence/repository/ToscaServiceTemplateRepository.java +++ /dev/null @@ -1,30 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * Copyright (C) 2021 Nordix Foundation. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - * SPDX-License-Identifier: Apache-2.0 - * ============LICENSE_END========================================================= - */ - -package org.onap.policy.clamp.controlloop.models.controlloop.persistence.repository; - -import org.onap.policy.models.base.PfConceptKey; -import org.onap.policy.models.tosca.simple.concepts.JpaToscaServiceTemplate; -import org.springframework.data.jpa.repository.JpaRepository; - -public interface ToscaServiceTemplateRepository - extends JpaRepository, FilterRepository { - -} diff --git a/models/src/main/java/org/onap/policy/clamp/controlloop/models/messages/dmaap/notification/ControlLoopNotification.java b/models/src/main/java/org/onap/policy/clamp/controlloop/models/messages/dmaap/notification/ControlLoopNotification.java deleted file mode 100644 index c6bbd81d6..000000000 --- a/models/src/main/java/org/onap/policy/clamp/controlloop/models/messages/dmaap/notification/ControlLoopNotification.java +++ /dev/null @@ -1,56 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * Copyright (C) 2021 Nordix Foundation. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============LICENSE_END========================================================= - */ - -package org.onap.policy.clamp.controlloop.models.messages.dmaap.notification; - -import com.google.gson.annotations.SerializedName; -import java.util.ArrayList; -import java.util.List; -import lombok.AllArgsConstructor; -import lombok.Data; -import lombok.NoArgsConstructor; -import org.apache.commons.collections4.CollectionUtils; - -@Data -@NoArgsConstructor -@AllArgsConstructor -public class ControlLoopNotification { - - /** - * Status of control loops that are being added to participants. - */ - @SerializedName("deployed-control-loops") - private List added = new ArrayList<>(); - - /** - * Status of policies that are being deleted from PDPs. - */ - @SerializedName("undeployed-control-loops") - private List deleted = new ArrayList<>(); - - - /** - * Determines if the notification is empty (i.e., has no added or delete control loop - * notifications). - * - * @return {@code true} if the notification is empty, {@code false} otherwise - */ - public boolean isEmpty() { - return (CollectionUtils.isEmpty(added) && CollectionUtils.isEmpty(deleted)); - } -} diff --git a/models/src/main/java/org/onap/policy/clamp/controlloop/models/messages/dmaap/notification/ControlLoopStatus.java b/models/src/main/java/org/onap/policy/clamp/controlloop/models/messages/dmaap/notification/ControlLoopStatus.java deleted file mode 100644 index 033843e75..000000000 --- a/models/src/main/java/org/onap/policy/clamp/controlloop/models/messages/dmaap/notification/ControlLoopStatus.java +++ /dev/null @@ -1,36 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * Copyright (C) 2021 Nordix Foundation. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============LICENSE_END========================================================= - */ - -package org.onap.policy.clamp.controlloop.models.messages.dmaap.notification; - -import com.google.gson.annotations.SerializedName; -import java.util.UUID; -import lombok.AllArgsConstructor; -import lombok.Data; -import lombok.NoArgsConstructor; -import org.onap.policy.models.tosca.authorative.concepts.ToscaConceptIdentifier; - -@Data -@NoArgsConstructor -@AllArgsConstructor -public class ControlLoopStatus { - @SerializedName("control-loop-id") - private UUID id; - - private ToscaConceptIdentifier definition; -} diff --git a/models/src/main/java/org/onap/policy/clamp/controlloop/models/messages/dmaap/participant/ControlLoopAck.java b/models/src/main/java/org/onap/policy/clamp/controlloop/models/messages/dmaap/participant/ControlLoopAck.java deleted file mode 100644 index cdbfea4e2..000000000 --- a/models/src/main/java/org/onap/policy/clamp/controlloop/models/messages/dmaap/participant/ControlLoopAck.java +++ /dev/null @@ -1,69 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * Copyright (C) 2021 Nordix Foundation. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - * SPDX-License-Identifier: Apache-2.0 - * ============LICENSE_END========================================================= - */ - -package org.onap.policy.clamp.controlloop.models.messages.dmaap.participant; - -import java.util.LinkedHashMap; -import java.util.Map; -import java.util.UUID; -import java.util.function.UnaryOperator; -import lombok.Getter; -import lombok.Setter; -import lombok.ToString; -import org.onap.policy.clamp.controlloop.models.controlloop.concepts.ControlLoopElementAck; -import org.onap.policy.models.base.PfUtils; -import org.onap.policy.models.tosca.authorative.concepts.ToscaConceptIdentifier; - -/** - * Class to represent the CONTROLLOOP_ACK message that a participant sends - * to control loop runtime as an acknowledgement to either ControlLoopUpdate - * or ControlLoopStateChange message. - */ -@Getter -@Setter -@ToString(callSuper = true) -public class ControlLoopAck extends ParticipantAckMessage { - - private ToscaConceptIdentifier controlLoopId; - private Integer startPhase; - - // A map with ControlLoopElementID as its key, and a pair of result and message as value per - // ControlLoopElement. - private Map controlLoopResultMap = new LinkedHashMap<>(); - - /** - * Constructor for instantiating ParticipantRegisterAck class with message name. - * - */ - public ControlLoopAck(final ParticipantMessageType messageType) { - super(messageType); - } - - /** - * Constructs the object, making a deep copy. - * - * @param source source from which to copy - */ - public ControlLoopAck(final ControlLoopAck source) { - super(source); - this.controlLoopId = source.controlLoopId; - this.controlLoopResultMap = PfUtils.mapMap(source.controlLoopResultMap, UnaryOperator.identity()); - } -} diff --git a/models/src/main/java/org/onap/policy/clamp/controlloop/models/messages/dmaap/participant/ControlLoopStateChange.java b/models/src/main/java/org/onap/policy/clamp/controlloop/models/messages/dmaap/participant/ControlLoopStateChange.java deleted file mode 100644 index e3b7049e1..000000000 --- a/models/src/main/java/org/onap/policy/clamp/controlloop/models/messages/dmaap/participant/ControlLoopStateChange.java +++ /dev/null @@ -1,60 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * Copyright (C) 2021 Nordix Foundation. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - * SPDX-License-Identifier: Apache-2.0 - * ============LICENSE_END========================================================= - */ - -package org.onap.policy.clamp.controlloop.models.messages.dmaap.participant; - -import lombok.Getter; -import lombok.Setter; -import lombok.ToString; -import org.onap.policy.clamp.controlloop.models.controlloop.concepts.ControlLoopOrderedState; -import org.onap.policy.clamp.controlloop.models.controlloop.concepts.ControlLoopState; - -/** - * Class to represent the CONTROL_LOOP_STATE_CHANGE message that the control loop runtime will send to - * participants to change the state of a control loop they are running. - */ -@Getter -@Setter -@ToString(callSuper = true) -public class ControlLoopStateChange extends ParticipantMessage { - private ControlLoopOrderedState orderedState; - private ControlLoopState currentState; - private Integer startPhase; - - /** - * Constructor for instantiating ControlLoopStateChange class with message name. - * - */ - public ControlLoopStateChange() { - super(ParticipantMessageType.CONTROL_LOOP_STATE_CHANGE); - } - - /** - * Constructs the object, making a deep copy. - * - * @param source source from which to copy - */ - public ControlLoopStateChange(ControlLoopStateChange source) { - super(source); - - this.orderedState = source.orderedState; - this.currentState = source.currentState; - } -} diff --git a/models/src/main/java/org/onap/policy/clamp/controlloop/models/messages/dmaap/participant/ControlLoopUpdate.java b/models/src/main/java/org/onap/policy/clamp/controlloop/models/messages/dmaap/participant/ControlLoopUpdate.java deleted file mode 100644 index f8a47c7c9..000000000 --- a/models/src/main/java/org/onap/policy/clamp/controlloop/models/messages/dmaap/participant/ControlLoopUpdate.java +++ /dev/null @@ -1,64 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * Copyright (C) 2021 Nordix Foundation. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - * SPDX-License-Identifier: Apache-2.0 - * ============LICENSE_END========================================================= - */ - -package org.onap.policy.clamp.controlloop.models.messages.dmaap.participant; - -import java.util.ArrayList; -import java.util.List; -import lombok.Getter; -import lombok.Setter; -import lombok.ToString; -import org.onap.policy.clamp.controlloop.models.controlloop.concepts.ParticipantUpdates; -import org.onap.policy.models.base.PfUtils; - -/** - * Class to represent the CONTROL_LOOP_UPDATE message that the control loop runtime sends to a participant. - * When a participant receives this message, it creates the control loop elements contained in the message and sets them - * to state PASSIVE. subsequent CONTROL_LOOP_STATE_CHANGE messages are used to activate the control loops. - */ -@Getter -@Setter -@ToString(callSuper = true) -public class ControlLoopUpdate extends ParticipantMessage { - - // A list of ParticipantUpdates instances which carries details of an updated participant. - private List participantUpdatesList = new ArrayList<>(); - private Integer startPhase = 0; - - /** - * Constructor for instantiating ControlLoopUpdate class with message name. - * - */ - public ControlLoopUpdate() { - super(ParticipantMessageType.CONTROL_LOOP_UPDATE); - } - - /** - * Constructs the object, making a deep copy. - * - * @param source source from which to copy - */ - public ControlLoopUpdate(ControlLoopUpdate source) { - super(source); - - this.participantUpdatesList = PfUtils.mapList(source.participantUpdatesList, - ParticipantUpdates::new); - } -} diff --git a/models/src/main/java/org/onap/policy/clamp/controlloop/models/messages/dmaap/participant/ParticipantAckMessage.java b/models/src/main/java/org/onap/policy/clamp/controlloop/models/messages/dmaap/participant/ParticipantAckMessage.java deleted file mode 100644 index 8a1be69bd..000000000 --- a/models/src/main/java/org/onap/policy/clamp/controlloop/models/messages/dmaap/participant/ParticipantAckMessage.java +++ /dev/null @@ -1,115 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * Copyright (C) 2021 Nordix Foundation. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - * SPDX-License-Identifier: Apache-2.0 - * ============LICENSE_END========================================================= - */ - -package org.onap.policy.clamp.controlloop.models.messages.dmaap.participant; - -import java.util.UUID; -import lombok.Getter; -import lombok.NonNull; -import lombok.Setter; -import lombok.ToString; -import org.onap.policy.clamp.controlloop.models.controlloop.concepts.ParticipantState; -import org.onap.policy.models.tosca.authorative.concepts.ToscaConceptIdentifier; - -/** - * Class to represent participant Ack message. - */ -@Getter -@Setter -@ToString -public class ParticipantAckMessage { - - // The responseTo field should match the original request id in the request. - private UUID responseTo; - - // Result: Success/Fail. - private Boolean result; - - // Message indicating reason for failure - private String message; - - private ParticipantMessageType messageType; - - /** - * Participant Type, or {@code null} for messages from participants. - */ - private ToscaConceptIdentifier participantType; - - /** - * Participant ID, or {@code null} for messages from participants. - */ - private ToscaConceptIdentifier participantId; - - /** - * Participant State, or {@code null} for messages from participants. - */ - private ParticipantState state; - - /** - * Constructor for instantiating a participant ack message class. - * - * @param messageType the message type - */ - public ParticipantAckMessage(final ParticipantMessageType messageType) { - this.messageType = messageType; - } - - /** - * Constructs the object, making a deep copy. - * - * @param source source from which to copy - */ - public ParticipantAckMessage(ParticipantAckMessage source) { - this.responseTo = source.responseTo; - this.result = source.result; - this.message = source.message; - this.messageType = source.messageType; - this.participantType = source.participantType; - this.participantId = source.participantId; - this.state = source.state; - } - - /** - * Determines if this message applies to this participant type. - * - * @param participantType type of the participant to match against - * @param participantId id of the participant to match against - * @return {@code true} if this message applies to this participant, {@code false} otherwise - */ - public boolean appliesTo(@NonNull final ToscaConceptIdentifier participantType, - @NonNull final ToscaConceptIdentifier participantId) { - // Broadcast message to all participants - if (this.participantType == null) { - return true; - } - - if (!participantType.equals(this.participantType)) { - return false; - } - - // Broadcast message to all control loop elements on this participant - if (this.participantId == null) { - return true; - } - - // Targeted message at this specific participant - return participantId.equals(this.participantId); - } -} diff --git a/models/src/main/java/org/onap/policy/clamp/controlloop/models/messages/dmaap/participant/ParticipantDeregister.java b/models/src/main/java/org/onap/policy/clamp/controlloop/models/messages/dmaap/participant/ParticipantDeregister.java deleted file mode 100644 index 7705e3d0c..000000000 --- a/models/src/main/java/org/onap/policy/clamp/controlloop/models/messages/dmaap/participant/ParticipantDeregister.java +++ /dev/null @@ -1,51 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * Copyright (C) 2021 Nordix Foundation. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - * SPDX-License-Identifier: Apache-2.0 - * ============LICENSE_END========================================================= - */ - -package org.onap.policy.clamp.controlloop.models.messages.dmaap.participant; - -import lombok.Getter; -import lombok.Setter; -import lombok.ToString; - -/** - * Class to represent the PARTICIPANT_DEREGISTER message that all the participants send to control loop runtime. - */ -@Getter -@Setter -@ToString(callSuper = true) -public class ParticipantDeregister extends ParticipantMessage { - - /** - * Constructor for instantiating ParticipantDeregister class with message name. - * - */ - public ParticipantDeregister() { - super(ParticipantMessageType.PARTICIPANT_DEREGISTER); - } - - /** - * Constructs the object, making a deep copy. - * - * @param source source from which to copy - */ - public ParticipantDeregister(final ParticipantDeregister source) { - super(source); - } -} diff --git a/models/src/main/java/org/onap/policy/clamp/controlloop/models/messages/dmaap/participant/ParticipantDeregisterAck.java b/models/src/main/java/org/onap/policy/clamp/controlloop/models/messages/dmaap/participant/ParticipantDeregisterAck.java deleted file mode 100644 index 69406beb7..000000000 --- a/models/src/main/java/org/onap/policy/clamp/controlloop/models/messages/dmaap/participant/ParticipantDeregisterAck.java +++ /dev/null @@ -1,51 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * Copyright (C) 2021 Nordix Foundation. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - * SPDX-License-Identifier: Apache-2.0 - * ============LICENSE_END========================================================= - */ - -package org.onap.policy.clamp.controlloop.models.messages.dmaap.participant; - -import lombok.Getter; -import lombok.Setter; -import lombok.ToString; - -/** - * Class to represent the PARTICIPANT_DEREGISTER_ACK message that control loop runtime sends to the participant. - */ -@Getter -@Setter -@ToString(callSuper = true) -public class ParticipantDeregisterAck extends ParticipantAckMessage { - - /** - * Constructor for instantiating ParticipantDeregisterAck class with message name. - * - */ - public ParticipantDeregisterAck() { - super(ParticipantMessageType.PARTICIPANT_DEREGISTER_ACK); - } - - /** - * Constructs the object, making a deep copy. - * - * @param source source from which to copy - */ - public ParticipantDeregisterAck(final ParticipantDeregisterAck source) { - super(source); - } -} diff --git a/models/src/main/java/org/onap/policy/clamp/controlloop/models/messages/dmaap/participant/ParticipantMessage.java b/models/src/main/java/org/onap/policy/clamp/controlloop/models/messages/dmaap/participant/ParticipantMessage.java deleted file mode 100644 index f98a88c3b..000000000 --- a/models/src/main/java/org/onap/policy/clamp/controlloop/models/messages/dmaap/participant/ParticipantMessage.java +++ /dev/null @@ -1,112 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * Copyright (C) 2021 Nordix Foundation. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - * SPDX-License-Identifier: Apache-2.0 - * ============LICENSE_END========================================================= - */ - -package org.onap.policy.clamp.controlloop.models.messages.dmaap.participant; - -import java.time.Instant; -import java.util.UUID; -import lombok.AccessLevel; -import lombok.Getter; -import lombok.NonNull; -import lombok.Setter; -import lombok.ToString; -import org.onap.policy.models.tosca.authorative.concepts.ToscaConceptIdentifier; - -/** - * Class to represent the base class for various messages that will be exchanged between the control loop runtime and - * participants. - */ -@Getter -@Setter -@ToString -public class ParticipantMessage { - @Setter(AccessLevel.NONE) - private ParticipantMessageType messageType; - - private UUID messageId = UUID.randomUUID(); - - /** - * Time-stamp, in milliseconds, when the message was created. Defaults to the current time. - */ - private Instant timestamp = Instant.now(); - - /** - * Participant Type, or {@code null} for messages from participants. - */ - private ToscaConceptIdentifier participantType; - - /** - * Participant ID, or {@code null} for messages from participants. - */ - private ToscaConceptIdentifier participantId; - - /** - * Control loop ID, or {@code null} for messages to participants. - */ - private ToscaConceptIdentifier controlLoopId; - - /** - * Constructor for instantiating a participant message class. - * - * @param messageType the message type - */ - public ParticipantMessage(final ParticipantMessageType messageType) { - this.messageType = messageType; - } - - /** - * Constructs the object, making a deep copy. Does not copy the request id or the time stamp. - * - * @param source source from which to copy - */ - public ParticipantMessage(final ParticipantMessage source) { - this.messageType = source.messageType; - this.participantType = source.participantType; - this.participantId = source.participantId; - this.controlLoopId = source.controlLoopId; - } - - /** - * Determines if this message applies to this participant type. - * - * @param participantType type of the participant to match against - * @param participantId id of the participant to match against - * @return {@code true} if this message applies to this participant, {@code false} otherwise - */ - public boolean appliesTo(@NonNull final ToscaConceptIdentifier participantType, - @NonNull final ToscaConceptIdentifier participantId) { - // Broadcast message to all participants - if (this.participantType == null) { - return true; - } - - if (!participantType.equals(this.participantType)) { - return false; - } - - // Broadcast message to all control loop elements on this participant - if (this.participantId == null) { - return true; - } - - // Targeted message at this specific participant - return participantId.equals(this.participantId); - } -} diff --git a/models/src/main/java/org/onap/policy/clamp/controlloop/models/messages/dmaap/participant/ParticipantMessageType.java b/models/src/main/java/org/onap/policy/clamp/controlloop/models/messages/dmaap/participant/ParticipantMessageType.java deleted file mode 100644 index 62b8d20b0..000000000 --- a/models/src/main/java/org/onap/policy/clamp/controlloop/models/messages/dmaap/participant/ParticipantMessageType.java +++ /dev/null @@ -1,104 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * Copyright (C) 2021 Nordix Foundation. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - * SPDX-License-Identifier: Apache-2.0 - * ============LICENSE_END========================================================= - */ - -package org.onap.policy.clamp.controlloop.models.messages.dmaap.participant; - -/** - * Class to hold the possible values for the type of participant messages. - */ -public enum ParticipantMessageType { - - /** - * Used by participants to report status to the control loop runtime. - */ - PARTICIPANT_STATUS, - - /** - * Used by the controlloop runtime to change the state of participants, triggers a - * PARTICIPANT_STATUS message with the result of the PARTICIPANT_STATE_CHANGE operation. - */ - PARTICIPANT_STATE_CHANGE, - - /** - * Used by controlloop runtime to update the controlloops running on participants, triggers a - * PARTICIPANT_STATUS message with the result of the CONTROL_LOOP_UPDATE operation. - */ - CONTROL_LOOP_UPDATE, - - /** - * Used by controlloop runtime to change the state of controlloops in participants, triggers a - * PARTICIPANT_STATUS message with result of CONTROL_LOOP_STATE_CHANGE operation. - */ - CONTROL_LOOP_STATE_CHANGE, - - /** - * Used by the control loop runtime to order a health check on participants, triggers a - * PARTICIPANT_STATUS message with the result of the PARTICIPANT_HEALTH_CHECK operation. - */ - PARTICIPANT_HEALTH_CHECK, - - /** - * Used by participant to register itself with control loop runtime. - */ - PARTICIPANT_REGISTER, - - /** - * Used by control loop runtime to respond to participant registration. - */ - PARTICIPANT_REGISTER_ACK, - - /** - * Used by participant to deregister itself with control loop runtime. - */ - PARTICIPANT_DEREGISTER, - - /** - * Used by control loop runtime to respond to participant deregistration. - */ - PARTICIPANT_DEREGISTER_ACK, - - /** - * Used by control loop runtime to send ToscaServiceTemplate to participant. - */ - PARTICIPANT_UPDATE, - - /** - * Used by participant to acknowledge the receipt of Participant_Update message - * from control loop runtime. - */ - PARTICIPANT_UPDATE_ACK, - - /** - * Used by participant to acknowledge the receipt of ControlLoop_Update message - * from control loop runtime. - */ - CONTROLLOOP_UPDATE_ACK, - - /** - * Used by participant to acknowledge the receipt of ControlLoop_StateChange message - * from control loop runtime. - */ - CONTROLLOOP_STATECHANGE_ACK, - - /** - * Used by control loop runtime to request for ParticipantStatus message immediately. - */ - PARTICIPANT_STATUS_REQ -} diff --git a/models/src/main/java/org/onap/policy/clamp/controlloop/models/messages/dmaap/participant/ParticipantRegister.java b/models/src/main/java/org/onap/policy/clamp/controlloop/models/messages/dmaap/participant/ParticipantRegister.java deleted file mode 100644 index af0149189..000000000 --- a/models/src/main/java/org/onap/policy/clamp/controlloop/models/messages/dmaap/participant/ParticipantRegister.java +++ /dev/null @@ -1,51 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * Copyright (C) 2021 Nordix Foundation. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - * SPDX-License-Identifier: Apache-2.0 - * ============LICENSE_END========================================================= - */ - -package org.onap.policy.clamp.controlloop.models.messages.dmaap.participant; - -import lombok.Getter; -import lombok.Setter; -import lombok.ToString; - -/** - * Class to represent the PARTICIPANT_REGISTER message that all the participants send to control loop runtime. - */ -@Getter -@Setter -@ToString(callSuper = true) -public class ParticipantRegister extends ParticipantMessage { - - /** - * Constructor for instantiating ParticipantRegister class with message name. - * - */ - public ParticipantRegister() { - super(ParticipantMessageType.PARTICIPANT_REGISTER); - } - - /** - * Constructs the object, making a deep copy. - * - * @param source source from which to copy - */ - public ParticipantRegister(final ParticipantRegister source) { - super(source); - } -} diff --git a/models/src/main/java/org/onap/policy/clamp/controlloop/models/messages/dmaap/participant/ParticipantRegisterAck.java b/models/src/main/java/org/onap/policy/clamp/controlloop/models/messages/dmaap/participant/ParticipantRegisterAck.java deleted file mode 100644 index 28d51be93..000000000 --- a/models/src/main/java/org/onap/policy/clamp/controlloop/models/messages/dmaap/participant/ParticipantRegisterAck.java +++ /dev/null @@ -1,51 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * Copyright (C) 2021 Nordix Foundation. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - * SPDX-License-Identifier: Apache-2.0 - * ============LICENSE_END========================================================= - */ - -package org.onap.policy.clamp.controlloop.models.messages.dmaap.participant; - -import lombok.Getter; -import lombok.Setter; -import lombok.ToString; - -/** - * Class to represent the PARTICIPANT_REGISTER_ACK message that control loop runtime sends to registered participant. - */ -@Getter -@Setter -@ToString(callSuper = true) -public class ParticipantRegisterAck extends ParticipantAckMessage { - - /** - * Constructor for instantiating ParticipantRegisterAck class with message name. - * - */ - public ParticipantRegisterAck() { - super(ParticipantMessageType.PARTICIPANT_REGISTER_ACK); - } - - /** - * Constructs the object, making a deep copy. - * - * @param source source from which to copy - */ - public ParticipantRegisterAck(final ParticipantRegisterAck source) { - super(source); - } -} diff --git a/models/src/main/java/org/onap/policy/clamp/controlloop/models/messages/dmaap/participant/ParticipantResponseStatus.java b/models/src/main/java/org/onap/policy/clamp/controlloop/models/messages/dmaap/participant/ParticipantResponseStatus.java deleted file mode 100644 index f014529b3..000000000 --- a/models/src/main/java/org/onap/policy/clamp/controlloop/models/messages/dmaap/participant/ParticipantResponseStatus.java +++ /dev/null @@ -1,42 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * Copyright (C) 2021 Nordix Foundation. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - * SPDX-License-Identifier: Apache-2.0 - * ============LICENSE_END========================================================= - */ - -package org.onap.policy.clamp.controlloop.models.messages.dmaap.participant; - -/** - * Class to hold the possible values for participant response status. - */ -public enum ParticipantResponseStatus { - - /** - * participant operation was successful. - */ - SUCCESS, - - /** - * participant operation failed. - */ - FAIL, - - /** - * periodic response. - */ - PERIODIC -} diff --git a/models/src/main/java/org/onap/policy/clamp/controlloop/models/messages/dmaap/participant/ParticipantStatus.java b/models/src/main/java/org/onap/policy/clamp/controlloop/models/messages/dmaap/participant/ParticipantStatus.java deleted file mode 100644 index 8600b4b5b..000000000 --- a/models/src/main/java/org/onap/policy/clamp/controlloop/models/messages/dmaap/participant/ParticipantStatus.java +++ /dev/null @@ -1,78 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * Copyright (C) 2021 Nordix Foundation. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - * SPDX-License-Identifier: Apache-2.0 - * ============LICENSE_END========================================================= - */ - -package org.onap.policy.clamp.controlloop.models.messages.dmaap.participant; - -import java.util.ArrayList; -import java.util.List; -import lombok.Getter; -import lombok.Setter; -import lombok.ToString; -import org.onap.policy.clamp.controlloop.models.controlloop.concepts.ControlLoopInfo; -import org.onap.policy.clamp.controlloop.models.controlloop.concepts.ParticipantDefinition; -import org.onap.policy.clamp.controlloop.models.controlloop.concepts.ParticipantHealthStatus; -import org.onap.policy.clamp.controlloop.models.controlloop.concepts.ParticipantState; -import org.onap.policy.clamp.controlloop.models.controlloop.concepts.ParticipantStatistics; -import org.onap.policy.models.base.PfUtils; - -/** - * Class to represent the PARTICIPANT_STATUS message that all the participants send to the control loop runtime. - */ -@Getter -@Setter -@ToString(callSuper = true) -public class ParticipantStatus extends ParticipantMessage { - - // State and health status of the participant - private ParticipantState state; - private ParticipantHealthStatus healthStatus; - - private ParticipantStatistics participantStatistics; - - // A list of ParticipantDefinition updates, returned in response to ParticipantStatusReq only - private List participantDefinitionUpdates = new ArrayList<>(); - - // List of ControlLoopInfo types with ControlLoopId, its state and statistics - private List controlLoopInfoList = new ArrayList<>(); - - /** - * Constructor for instantiating ParticipantStatus class with message name. - * - */ - public ParticipantStatus() { - super(ParticipantMessageType.PARTICIPANT_STATUS); - } - - /** - * Constructs the object, making a deep copy. - * - * @param source source from which to copy - */ - public ParticipantStatus(final ParticipantStatus source) { - super(source); - - this.state = source.state; - this.healthStatus = source.healthStatus; - this.participantStatistics = (source.participantStatistics == null ? null : new ParticipantStatistics()); - this.participantDefinitionUpdates = PfUtils.mapList(source.participantDefinitionUpdates, - ParticipantDefinition::new); - this.controlLoopInfoList = PfUtils.mapList(source.controlLoopInfoList, ControlLoopInfo::new); - } -} diff --git a/models/src/main/java/org/onap/policy/clamp/controlloop/models/messages/dmaap/participant/ParticipantStatusReq.java b/models/src/main/java/org/onap/policy/clamp/controlloop/models/messages/dmaap/participant/ParticipantStatusReq.java deleted file mode 100644 index 9242cea02..000000000 --- a/models/src/main/java/org/onap/policy/clamp/controlloop/models/messages/dmaap/participant/ParticipantStatusReq.java +++ /dev/null @@ -1,51 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * Copyright (C) 2021 Nordix Foundation. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - * SPDX-License-Identifier: Apache-2.0 - * ============LICENSE_END========================================================= - */ - -package org.onap.policy.clamp.controlloop.models.messages.dmaap.participant; - -import lombok.Getter; -import lombok.Setter; -import lombok.ToString; - -/** - * Class to represent the PARTICIPANT_STATUS_REQ message that controlloop runtime - * sends to participants for an immediate ParticipantStatus from participants. - */ -@Getter -@Setter -@ToString(callSuper = true) -public class ParticipantStatusReq extends ParticipantMessage { - - /** - * Constructor for instantiating a participant status request class. - */ - public ParticipantStatusReq() { - super(ParticipantMessageType.PARTICIPANT_STATUS_REQ); - } - - /** - * Constructs the object, making a deep copy. - * - * @param source source from which to copy - */ - public ParticipantStatusReq(final ParticipantStatusReq source) { - super(source); - } -} diff --git a/models/src/main/java/org/onap/policy/clamp/controlloop/models/messages/dmaap/participant/ParticipantUpdate.java b/models/src/main/java/org/onap/policy/clamp/controlloop/models/messages/dmaap/participant/ParticipantUpdate.java deleted file mode 100644 index 72db7d97e..000000000 --- a/models/src/main/java/org/onap/policy/clamp/controlloop/models/messages/dmaap/participant/ParticipantUpdate.java +++ /dev/null @@ -1,63 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * Copyright (C) 2021 Nordix Foundation. - * Modifications Copyright (C) 2021 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - * SPDX-License-Identifier: Apache-2.0 - * ============LICENSE_END========================================================= - */ - -package org.onap.policy.clamp.controlloop.models.messages.dmaap.participant; - -import java.util.ArrayList; -import java.util.List; -import lombok.Getter; -import lombok.Setter; -import lombok.ToString; -import org.onap.policy.clamp.controlloop.models.controlloop.concepts.ParticipantDefinition; -import org.onap.policy.models.base.PfUtils; - -/** - * Class to represent the PARTICIPANT_UPDATE message that the control loop runtime sends to a participant. - * ControlLoop Runtime sends Control Loop Element Definitions and Common Parameter Values to Participants. - */ -@Getter -@Setter -@ToString(callSuper = true) -public class ParticipantUpdate extends ParticipantMessage { - - // A list of updates to ParticipantDefinitions - private List participantDefinitionUpdates = new ArrayList<>(); - - /** - * Constructor for instantiating ParticipantUpdate class with message name. - * - */ - public ParticipantUpdate() { - super(ParticipantMessageType.PARTICIPANT_UPDATE); - } - - /** - * Constructs the object, making a deep copy. - * - * @param source source from which to copy - */ - public ParticipantUpdate(ParticipantUpdate source) { - super(source); - - this.participantDefinitionUpdates = PfUtils.mapList(source.participantDefinitionUpdates, - ParticipantDefinition::new); - } -} diff --git a/models/src/main/java/org/onap/policy/clamp/controlloop/models/messages/dmaap/participant/ParticipantUpdateAck.java b/models/src/main/java/org/onap/policy/clamp/controlloop/models/messages/dmaap/participant/ParticipantUpdateAck.java deleted file mode 100644 index d38fa4bb2..000000000 --- a/models/src/main/java/org/onap/policy/clamp/controlloop/models/messages/dmaap/participant/ParticipantUpdateAck.java +++ /dev/null @@ -1,53 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * Copyright (C) 2021 Nordix Foundation. - * ================================================================================ - * Modifications Copyright (C) 2021 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - * SPDX-License-Identifier: Apache-2.0 - * ============LICENSE_END========================================================= - */ - -package org.onap.policy.clamp.controlloop.models.messages.dmaap.participant; - -import lombok.Getter; -import lombok.Setter; -import lombok.ToString; - -/** - * Class to represent the PARTICIPANT_UPDATE_ACK message that registered participant sends to controlloop runtime. - */ -@Getter -@Setter -@ToString(callSuper = true) -public class ParticipantUpdateAck extends ParticipantAckMessage { - - /** - * Constructor for instantiating ParticipantUpdateAck class with message name. - * - */ - public ParticipantUpdateAck() { - super(ParticipantMessageType.PARTICIPANT_UPDATE_ACK); - } - - /** - * Constructs the object, making a deep copy. - * - * @param source source from which to copy - */ - public ParticipantUpdateAck(final ParticipantUpdateAck source) { - super(source); - } -} diff --git a/models/src/main/java/org/onap/policy/clamp/controlloop/models/messages/rest/GenericNameVersion.java b/models/src/main/java/org/onap/policy/clamp/controlloop/models/messages/rest/GenericNameVersion.java deleted file mode 100644 index a48af9223..000000000 --- a/models/src/main/java/org/onap/policy/clamp/controlloop/models/messages/rest/GenericNameVersion.java +++ /dev/null @@ -1,30 +0,0 @@ -/* - * ============LICENSE_START======================================================= - * Copyright (C) 2021 Nordix Foundation. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - * SPDX-License-Identifier: Apache-2.0 - * ============LICENSE_END========================================================= - */ - -package org.onap.policy.clamp.controlloop.models.messages.rest; - -import lombok.Data; - -@Data -public class GenericNameVersion { - - private String name; - - private String version; -} diff --git a/models/src/main/java/org/onap/policy/clamp/controlloop/models/messages/rest/SimpleResponse.java b/models/src/main/java/org/onap/policy/clamp/controlloop/models/messages/rest/SimpleResponse.java deleted file mode 100644 index 2bd09c632..000000000 --- a/models/src/main/java/org/onap/policy/clamp/controlloop/models/messages/rest/SimpleResponse.java +++ /dev/null @@ -1,37 +0,0 @@ -/* - * ============LICENSE_START======================================================= - * Copyright (C) 2021 Nordix Foundation. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============LICENSE_END========================================================= - */ - -package org.onap.policy.clamp.controlloop.models.messages.rest; - -import lombok.Getter; -import lombok.Setter; -import lombok.ToString; - -/** - * Response returned when no extra output fields are needed. - */ -@Getter -@Setter -@ToString -public class SimpleResponse { - - /** - * Optional detailed message in error cases. - */ - private String errorDetails; -} diff --git a/models/src/main/java/org/onap/policy/clamp/controlloop/models/messages/rest/TypedSimpleResponse.java b/models/src/main/java/org/onap/policy/clamp/controlloop/models/messages/rest/TypedSimpleResponse.java deleted file mode 100644 index 199ac8ee1..000000000 --- a/models/src/main/java/org/onap/policy/clamp/controlloop/models/messages/rest/TypedSimpleResponse.java +++ /dev/null @@ -1,35 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * Copyright (C) 2021 Nordix Foundation. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - * SPDX-License-Identifier: Apache-2.0 - * ============LICENSE_END========================================================= - */ - -package org.onap.policy.clamp.controlloop.models.messages.rest; - -import lombok.Getter; -import lombok.Setter; -import lombok.ToString; - -/** - * Response returned when no extra output fields are needed. - */ -@Getter -@Setter -@ToString -public class TypedSimpleResponse extends SimpleResponse { - private T response; -} diff --git a/models/src/main/java/org/onap/policy/clamp/controlloop/models/messages/rest/commissioning/CommissioningResponse.java b/models/src/main/java/org/onap/policy/clamp/controlloop/models/messages/rest/commissioning/CommissioningResponse.java deleted file mode 100644 index 6363db8d2..000000000 --- a/models/src/main/java/org/onap/policy/clamp/controlloop/models/messages/rest/commissioning/CommissioningResponse.java +++ /dev/null @@ -1,38 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * Copyright (C) 2021 Nordix Foundation. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - * SPDX-License-Identifier: Apache-2.0 - * ============LICENSE_END========================================================= - */ - -package org.onap.policy.clamp.controlloop.models.messages.rest.commissioning; - -import java.util.List; -import lombok.Getter; -import lombok.Setter; -import lombok.ToString; -import org.onap.policy.clamp.controlloop.models.messages.rest.SimpleResponse; -import org.onap.policy.models.tosca.authorative.concepts.ToscaConceptIdentifier; - -/** - * Response to Commissioning requests that affect a change. - */ -@Getter -@Setter -@ToString(callSuper = true) -public class CommissioningResponse extends SimpleResponse { - private List affectedControlLoopDefinitions; -} diff --git a/models/src/main/java/org/onap/policy/clamp/controlloop/models/messages/rest/instantiation/ControlLoopOrderStateResponse.java b/models/src/main/java/org/onap/policy/clamp/controlloop/models/messages/rest/instantiation/ControlLoopOrderStateResponse.java deleted file mode 100644 index dcc63a538..000000000 --- a/models/src/main/java/org/onap/policy/clamp/controlloop/models/messages/rest/instantiation/ControlLoopOrderStateResponse.java +++ /dev/null @@ -1,43 +0,0 @@ -/* - * ============LICENSE_START======================================================= - * Copyright (C) 2021 Nordix Foundation. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - * SPDX-License-Identifier: Apache-2.0 - * ============LICENSE_END========================================================= - */ - -package org.onap.policy.clamp.controlloop.models.messages.rest.instantiation; - -import java.util.ArrayList; -import java.util.List; -import lombok.Getter; -import lombok.Setter; -import lombok.ToString; -import org.onap.policy.clamp.controlloop.models.controlloop.concepts.ControlLoopOrderedState; -import org.onap.policy.clamp.controlloop.models.messages.rest.GenericNameVersion; -import org.onap.policy.clamp.controlloop.models.messages.rest.SimpleResponse; - - -/** - * Response to Commissioning requests that affect a change. - */ -@Getter -@Setter -@ToString(callSuper = true) -public class ControlLoopOrderStateResponse extends SimpleResponse { - - private ControlLoopOrderedState orderedState = ControlLoopOrderedState.UNINITIALISED; - - private List controlLoopIdentifierList = new ArrayList<>(); -} diff --git a/models/src/main/java/org/onap/policy/clamp/controlloop/models/messages/rest/instantiation/ControlLoopPrimed.java b/models/src/main/java/org/onap/policy/clamp/controlloop/models/messages/rest/instantiation/ControlLoopPrimed.java deleted file mode 100644 index d6e670060..000000000 --- a/models/src/main/java/org/onap/policy/clamp/controlloop/models/messages/rest/instantiation/ControlLoopPrimed.java +++ /dev/null @@ -1,32 +0,0 @@ -/* - * ============LICENSE_START======================================================= - * Copyright (C) 2021 Nordix Foundation. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - * SPDX-License-Identifier: Apache-2.0 - * ============LICENSE_END========================================================= - */ - -package org.onap.policy.clamp.controlloop.models.messages.rest.instantiation; - -import lombok.Data; - -@Data -public class ControlLoopPrimed { - - private String name; - - private String version; - - private boolean primed; -} diff --git a/models/src/main/java/org/onap/policy/clamp/controlloop/models/messages/rest/instantiation/ControlLoopPrimedResponse.java b/models/src/main/java/org/onap/policy/clamp/controlloop/models/messages/rest/instantiation/ControlLoopPrimedResponse.java deleted file mode 100644 index 4d2dfaf01..000000000 --- a/models/src/main/java/org/onap/policy/clamp/controlloop/models/messages/rest/instantiation/ControlLoopPrimedResponse.java +++ /dev/null @@ -1,39 +0,0 @@ -/* - * ============LICENSE_START======================================================= - * Copyright (C) 2021 Nordix Foundation. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - * SPDX-License-Identifier: Apache-2.0 - * ============LICENSE_END========================================================= - */ - -package org.onap.policy.clamp.controlloop.models.messages.rest.instantiation; - -import java.util.ArrayList; -import java.util.List; -import lombok.Getter; -import lombok.Setter; -import lombok.ToString; -import org.onap.policy.clamp.controlloop.models.messages.rest.SimpleResponse; - - -/** - * Response to provide all primed controlLoops. - */ -@Getter -@Setter -@ToString(callSuper = true) -public class ControlLoopPrimedResponse extends SimpleResponse { - - private List primedControlLoopsList = new ArrayList<>(); -} diff --git a/models/src/main/java/org/onap/policy/clamp/controlloop/models/messages/rest/instantiation/InstancePropertiesResponse.java b/models/src/main/java/org/onap/policy/clamp/controlloop/models/messages/rest/instantiation/InstancePropertiesResponse.java deleted file mode 100644 index d8974d6e3..000000000 --- a/models/src/main/java/org/onap/policy/clamp/controlloop/models/messages/rest/instantiation/InstancePropertiesResponse.java +++ /dev/null @@ -1,38 +0,0 @@ -/* - * ============LICENSE_START======================================================= - * Copyright (C) 2021 Nordix Foundation. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - * SPDX-License-Identifier: Apache-2.0 - * ============LICENSE_END========================================================= - */ - -package org.onap.policy.clamp.controlloop.models.messages.rest.instantiation; - -import java.util.ArrayList; -import java.util.List; -import lombok.Getter; -import lombok.Setter; -import lombok.ToString; -import org.onap.policy.clamp.controlloop.models.messages.rest.SimpleResponse; -import org.onap.policy.models.tosca.authorative.concepts.ToscaConceptIdentifier; - -/** - * Response to Instance Properties requests that affect a change. - */ -@Getter -@Setter -@ToString(callSuper = true) -public class InstancePropertiesResponse extends SimpleResponse { - private List affectedInstanceProperties = new ArrayList<>(); -} diff --git a/models/src/main/java/org/onap/policy/clamp/controlloop/models/messages/rest/instantiation/InstantiationCommand.java b/models/src/main/java/org/onap/policy/clamp/controlloop/models/messages/rest/instantiation/InstantiationCommand.java deleted file mode 100644 index 71b7ab92c..000000000 --- a/models/src/main/java/org/onap/policy/clamp/controlloop/models/messages/rest/instantiation/InstantiationCommand.java +++ /dev/null @@ -1,35 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * Copyright (C) 2021 Nordix Foundation. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - * SPDX-License-Identifier: Apache-2.0 - * ============LICENSE_END========================================================= - */ - -package org.onap.policy.clamp.controlloop.models.messages.rest.instantiation; - -import java.util.List; -import lombok.Data; -import org.onap.policy.clamp.controlloop.models.controlloop.concepts.ControlLoopOrderedState; -import org.onap.policy.models.tosca.authorative.concepts.ToscaConceptIdentifier; - -@Data -public class InstantiationCommand { - // The state to which the control loops are to be set - private ControlLoopOrderedState orderedState; - - // The list of control loops on which the command is to be issued - private List controlLoopIdentifierList; -} diff --git a/models/src/main/java/org/onap/policy/clamp/controlloop/models/messages/rest/instantiation/InstantiationOrderStateResponse.java b/models/src/main/java/org/onap/policy/clamp/controlloop/models/messages/rest/instantiation/InstantiationOrderStateResponse.java deleted file mode 100644 index 1ddce7840..000000000 --- a/models/src/main/java/org/onap/policy/clamp/controlloop/models/messages/rest/instantiation/InstantiationOrderStateResponse.java +++ /dev/null @@ -1,39 +0,0 @@ -/* - * ============LICENSE_START======================================================= - * Copyright (C) 2021 Nordix Foundation. - * ================================================================================ - * Modifications Copyright (C) 2021 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - * SPDX-License-Identifier: Apache-2.0 - * ============LICENSE_END========================================================= - */ - -package org.onap.policy.clamp.controlloop.models.messages.rest.instantiation; - -import lombok.Getter; -import lombok.Setter; -import lombok.ToString; -import org.onap.policy.clamp.controlloop.models.controlloop.concepts.ControlLoopOrderedState; -import org.onap.policy.clamp.controlloop.models.messages.rest.SimpleResponse; - -/** - * Response to instantiation OrderState. - */ -@Getter -@Setter -@ToString(callSuper = true) -public class InstantiationOrderStateResponse extends SimpleResponse { - - private ControlLoopOrderedState orderedState; -} diff --git a/models/src/main/java/org/onap/policy/clamp/controlloop/models/messages/rest/instantiation/InstantiationResponse.java b/models/src/main/java/org/onap/policy/clamp/controlloop/models/messages/rest/instantiation/InstantiationResponse.java deleted file mode 100644 index d932f29ac..000000000 --- a/models/src/main/java/org/onap/policy/clamp/controlloop/models/messages/rest/instantiation/InstantiationResponse.java +++ /dev/null @@ -1,38 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * Copyright (C) 2021 Nordix Foundation. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - * SPDX-License-Identifier: Apache-2.0 - * ============LICENSE_END========================================================= - */ - -package org.onap.policy.clamp.controlloop.models.messages.rest.instantiation; - -import java.util.List; -import lombok.Getter; -import lombok.Setter; -import lombok.ToString; -import org.onap.policy.clamp.controlloop.models.messages.rest.SimpleResponse; -import org.onap.policy.models.tosca.authorative.concepts.ToscaConceptIdentifier; - -/** - * Response to Commissioning requests that affect a change. - */ -@Getter -@Setter -@ToString(callSuper = true) -public class InstantiationResponse extends SimpleResponse { - private List affectedControlLoops; -} diff --git a/models/src/main/java/org/onap/policy/clamp/controlloop/models/rest/RestUtils.java b/models/src/main/java/org/onap/policy/clamp/controlloop/models/rest/RestUtils.java deleted file mode 100644 index 6c12c2de7..000000000 --- a/models/src/main/java/org/onap/policy/clamp/controlloop/models/rest/RestUtils.java +++ /dev/null @@ -1,43 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * Copyright (C) 2021 Nordix Foundation. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - * SPDX-License-Identifier: Apache-2.0 - * ============LICENSE_END========================================================= - */ - -package org.onap.policy.clamp.controlloop.models.rest; - -import lombok.AccessLevel; -import lombok.NoArgsConstructor; -import org.onap.policy.clamp.controlloop.models.messages.rest.SimpleResponse; -import org.onap.policy.models.errors.concepts.ErrorResponseInfo; -import org.springframework.http.ResponseEntity; - -@NoArgsConstructor(access = AccessLevel.PRIVATE) -public final class RestUtils { - - /** - * Convert an ErrorResponseInfo to a ResponseEntity. - * - * @param ex the ErrorResponseInfo - * @return the ResponseEntity - */ - public static ResponseEntity toSimpleResponse(ErrorResponseInfo ex) { - var resp = new SimpleResponse(); - resp.setErrorDetails(ex.getErrorResponse().getErrorMessage()); - return ResponseEntity.status(ex.getErrorResponse().getResponseCode().getStatusCode()).body(resp); - } -} diff --git a/models/src/main/java/org/onap/policy/clamp/models/acm/concepts/AcElementStatistics.java b/models/src/main/java/org/onap/policy/clamp/models/acm/concepts/AcElementStatistics.java new file mode 100644 index 000000000..d1b1e31e8 --- /dev/null +++ b/models/src/main/java/org/onap/policy/clamp/models/acm/concepts/AcElementStatistics.java @@ -0,0 +1,53 @@ +/*- + * ============LICENSE_START======================================================= + * Copyright (C) 2021 Nordix Foundation. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * SPDX-License-Identifier: Apache-2.0 + * ============LICENSE_END========================================================= + */ + +package org.onap.policy.clamp.models.acm.concepts; + +import java.io.Serializable; +import java.time.Instant; +import java.util.UUID; +import lombok.Data; +import lombok.NoArgsConstructor; +import lombok.NonNull; +import lombok.ToString; +import org.onap.policy.models.tosca.authorative.concepts.ToscaConceptIdentifier; + +@NoArgsConstructor +@Data +@ToString +public class AcElementStatistics implements Serializable { + + private static final long serialVersionUID = 3284285693112271055L; + + @NonNull + private UUID id = UUID.randomUUID(); + + @NonNull + private ToscaConceptIdentifier participantId; + + @NonNull + private Instant timeStamp; + + @NonNull + private AutomationCompositionState state; + + private long acElementUptime; + +} diff --git a/models/src/main/java/org/onap/policy/clamp/models/acm/concepts/AcElementStatisticsList.java b/models/src/main/java/org/onap/policy/clamp/models/acm/concepts/AcElementStatisticsList.java new file mode 100644 index 000000000..3b8feb5f6 --- /dev/null +++ b/models/src/main/java/org/onap/policy/clamp/models/acm/concepts/AcElementStatisticsList.java @@ -0,0 +1,33 @@ +/*- + * ============LICENSE_START======================================================= + * Copyright (C) 2021 Nordix Foundation. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * SPDX-License-Identifier: Apache-2.0 + * ============LICENSE_END========================================================= + */ + +package org.onap.policy.clamp.models.acm.concepts; + +import java.util.List; +import lombok.Getter; +import lombok.Setter; +import lombok.ToString; + +@Getter +@Setter +@ToString +public class AcElementStatisticsList { + private List acElementStatistics; +} diff --git a/models/src/main/java/org/onap/policy/clamp/models/acm/concepts/AutomationComposition.java b/models/src/main/java/org/onap/policy/clamp/models/acm/concepts/AutomationComposition.java new file mode 100644 index 000000000..f6134782b --- /dev/null +++ b/models/src/main/java/org/onap/policy/clamp/models/acm/concepts/AutomationComposition.java @@ -0,0 +1,117 @@ +/*- + * ============LICENSE_START======================================================= + * Copyright (C) 2021 Nordix Foundation. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * SPDX-License-Identifier: Apache-2.0 + * ============LICENSE_END========================================================= + */ + +package org.onap.policy.clamp.models.acm.concepts; + +import java.util.List; +import java.util.Map; +import java.util.UUID; +import java.util.stream.Collectors; +import lombok.Data; +import lombok.EqualsAndHashCode; +import lombok.NoArgsConstructor; +import lombok.NonNull; +import org.apache.commons.collections4.MapUtils; +import org.onap.policy.models.base.PfConceptKey; +import org.onap.policy.models.base.PfUtils; +import org.onap.policy.models.tosca.authorative.concepts.ToscaConceptIdentifier; +import org.onap.policy.models.tosca.authorative.concepts.ToscaEntity; + +/** + * Class to represent an automation composition instance. + */ +@NoArgsConstructor +@Data +@EqualsAndHashCode(callSuper = true) +public class AutomationComposition extends ToscaEntity implements Comparable { + @NonNull + private ToscaConceptIdentifier definition = new ToscaConceptIdentifier(PfConceptKey.getNullKey()); + + @NonNull + private AutomationCompositionState state = AutomationCompositionState.UNINITIALISED; + + @NonNull + private AutomationCompositionOrderedState orderedState = AutomationCompositionOrderedState.UNINITIALISED; + + private Map elements; + + @NonNull + private Boolean primed = false; + + @Override + public String getType() { + return definition.getName(); + } + + @Override + public String getTypeVersion() { + return definition.getVersion(); + } + + /** + * Copy contructor, does a deep copy. + * + * @param otherAutomationComposition the other element to copy from + */ + public AutomationComposition(final AutomationComposition otherAutomationComposition) { + super(otherAutomationComposition); + this.definition = new ToscaConceptIdentifier(otherAutomationComposition.definition); + this.state = otherAutomationComposition.state; + this.orderedState = otherAutomationComposition.orderedState; + this.elements = PfUtils.mapMap(otherAutomationComposition.elements, AutomationCompositionElement::new); + this.primed = otherAutomationComposition.primed; + } + + @Override + public int compareTo(final AutomationComposition other) { + return compareNameVersion(this, other); + } + + /** + * Set the ordered state on the automation composition and on all its automation composition elements. + * + * @param orderedState the state we want the automation composition to transition to + */ + public void setCascadedOrderedState(final AutomationCompositionOrderedState orderedState) { + this.orderedState = orderedState; + + if (MapUtils.isEmpty(elements)) { + return; + } + + elements.values().forEach(element -> element.setOrderedState(orderedState)); + } + + /** + * Get a list of automation composition element statistics. + * + * @param automationComposition the automation composition + * @return List of AcElementStatistics + */ + public List getAutomationCompositionElementStatisticsList( + final AutomationComposition automationComposition) { + if (MapUtils.isEmpty(automationComposition.elements)) { + return List.of(); + } + + return automationComposition.elements.values().stream() + .map(AutomationCompositionElement::getAcElementStatistics).collect(Collectors.toList()); + } +} diff --git a/models/src/main/java/org/onap/policy/clamp/models/acm/concepts/AutomationCompositionElement.java b/models/src/main/java/org/onap/policy/clamp/models/acm/concepts/AutomationCompositionElement.java new file mode 100644 index 000000000..046b77f76 --- /dev/null +++ b/models/src/main/java/org/onap/policy/clamp/models/acm/concepts/AutomationCompositionElement.java @@ -0,0 +1,89 @@ +/*- + * ============LICENSE_START======================================================= + * Copyright (C) 2021 Nordix Foundation. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * SPDX-License-Identifier: Apache-2.0 + * ============LICENSE_END========================================================= + */ + +package org.onap.policy.clamp.models.acm.concepts; + +import java.util.LinkedHashMap; +import java.util.Map; +import java.util.UUID; +import java.util.function.UnaryOperator; +import lombok.Data; +import lombok.NoArgsConstructor; +import lombok.NonNull; +import lombok.ToString; +import org.onap.policy.models.base.PfConceptKey; +import org.onap.policy.models.base.PfUtils; +import org.onap.policy.models.tosca.authorative.concepts.ToscaConceptIdentifier; +import org.onap.policy.models.tosca.authorative.concepts.ToscaProperty; +import org.onap.policy.models.tosca.authorative.concepts.ToscaServiceTemplate; + +/** + * Class to represent a automation composition instance. + */ +@NoArgsConstructor +@Data +@ToString +public class AutomationCompositionElement { + @NonNull + private UUID id = UUID.randomUUID(); + + @NonNull + private ToscaConceptIdentifier definition = new ToscaConceptIdentifier(PfConceptKey.getNullKey()); + + @NonNull + private ToscaConceptIdentifier participantType = new ToscaConceptIdentifier(PfConceptKey.getNullKey()); + + @NonNull + private ToscaConceptIdentifier participantId = new ToscaConceptIdentifier(PfConceptKey.getNullKey()); + + @NonNull + private AutomationCompositionState state = AutomationCompositionState.UNINITIALISED; + + @NonNull + private AutomationCompositionOrderedState orderedState = AutomationCompositionOrderedState.UNINITIALISED; + + private ToscaServiceTemplate toscaServiceTemplateFragment; + + private String description; + + private AcElementStatistics acElementStatistics; + + // A map indexed by the property name. Each map entry is the serialized value of the property, + // which can be deserialized into an instance of the type of the property. + private Map propertiesMap = new LinkedHashMap<>(); + + /** + * Copy constructor, does a deep copy but as all fields here are immutable, it's just a regular copy. + * + * @param otherElement the other element to copy from + */ + public AutomationCompositionElement(final AutomationCompositionElement otherElement) { + this.id = otherElement.id; + this.definition = new ToscaConceptIdentifier(otherElement.definition); + this.participantType = new ToscaConceptIdentifier(otherElement.participantType); + this.participantId = new ToscaConceptIdentifier(otherElement.participantId); + this.state = otherElement.state; + this.orderedState = otherElement.orderedState; + this.toscaServiceTemplateFragment = otherElement.toscaServiceTemplateFragment; + this.description = otherElement.description; + this.acElementStatistics = otherElement.acElementStatistics; + this.propertiesMap = PfUtils.mapMap(otherElement.propertiesMap, UnaryOperator.identity()); + } +} diff --git a/models/src/main/java/org/onap/policy/clamp/models/acm/concepts/AutomationCompositionElementAck.java b/models/src/main/java/org/onap/policy/clamp/models/acm/concepts/AutomationCompositionElementAck.java new file mode 100644 index 000000000..b100f28c0 --- /dev/null +++ b/models/src/main/java/org/onap/policy/clamp/models/acm/concepts/AutomationCompositionElementAck.java @@ -0,0 +1,42 @@ +/*- + * ============LICENSE_START======================================================= + * Copyright (C) 2021 Nordix Foundation. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * SPDX-License-Identifier: Apache-2.0 + * ============LICENSE_END========================================================= + */ + +package org.onap.policy.clamp.models.acm.concepts; + +import lombok.AllArgsConstructor; +import lombok.Getter; +import lombok.Setter; +import lombok.ToString; + +@Getter +@Setter +@AllArgsConstructor +@ToString +public class AutomationCompositionElementAck { + + // State of the AutomationCompositionElement + private AutomationCompositionState state; + + // Result: Success/Fail. + private Boolean result; + + // Message indicating reason for failure + private String message; +} diff --git a/models/src/main/java/org/onap/policy/clamp/models/acm/concepts/AutomationCompositionElementDefinition.java b/models/src/main/java/org/onap/policy/clamp/models/acm/concepts/AutomationCompositionElementDefinition.java new file mode 100644 index 000000000..aebee0e2c --- /dev/null +++ b/models/src/main/java/org/onap/policy/clamp/models/acm/concepts/AutomationCompositionElementDefinition.java @@ -0,0 +1,64 @@ +/*- + * ============LICENSE_START======================================================= + * Copyright (C) 2021-2022 Nordix Foundation. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * SPDX-License-Identifier: Apache-2.0 + * ============LICENSE_END========================================================= + */ + +package org.onap.policy.clamp.models.acm.concepts; + +import java.util.LinkedHashMap; +import java.util.Map; +import java.util.function.UnaryOperator; +import lombok.Data; +import lombok.Getter; +import lombok.NoArgsConstructor; +import lombok.ToString; +import org.onap.policy.models.base.PfUtils; +import org.onap.policy.models.tosca.authorative.concepts.ToscaConceptIdentifier; +import org.onap.policy.models.tosca.authorative.concepts.ToscaNodeTemplate; +import org.onap.policy.models.tosca.authorative.concepts.ToscaProperty; + +/** + * Class to represent an automation composition element definition instance. + */ +@Getter +@NoArgsConstructor +@Data +@ToString +public class AutomationCompositionElementDefinition { + + private ToscaConceptIdentifier acElementDefinitionId; + + // The definition of the Automation Composition Element in TOSCA + private ToscaNodeTemplate automationCompositionElementToscaNodeTemplate; + + // A map indexed by the property name. Each map entry is the serialized value of the property, + // which can be deserialized into an instance of the type of the property. + private Map commonPropertiesMap = new LinkedHashMap<>(); + + /** + * Copy constructor, does a deep copy but as all fields here are immutable, it's just a regular copy. + * + * @param acElementDefinition the automation composition element definition to copy from + */ + public AutomationCompositionElementDefinition(final AutomationCompositionElementDefinition acElementDefinition) { + this.acElementDefinitionId = acElementDefinition.acElementDefinitionId; + this.automationCompositionElementToscaNodeTemplate = + new ToscaNodeTemplate(acElementDefinition.automationCompositionElementToscaNodeTemplate); + this.commonPropertiesMap = PfUtils.mapMap(acElementDefinition.commonPropertiesMap, UnaryOperator.identity()); + } +} diff --git a/models/src/main/java/org/onap/policy/clamp/models/acm/concepts/AutomationCompositionInfo.java b/models/src/main/java/org/onap/policy/clamp/models/acm/concepts/AutomationCompositionInfo.java new file mode 100644 index 000000000..dba8f553c --- /dev/null +++ b/models/src/main/java/org/onap/policy/clamp/models/acm/concepts/AutomationCompositionInfo.java @@ -0,0 +1,52 @@ +/*- + * ============LICENSE_START======================================================= + * Copyright (C) 2021 Nordix Foundation. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * SPDX-License-Identifier: Apache-2.0 + * ============LICENSE_END========================================================= + */ + +package org.onap.policy.clamp.models.acm.concepts; + +import lombok.Data; +import lombok.NoArgsConstructor; +import lombok.ToString; +import org.onap.policy.models.tosca.authorative.concepts.ToscaConceptIdentifier; + +/** + * Class to represent a automation composition info instance. + */ +@NoArgsConstructor +@Data +@ToString +public class AutomationCompositionInfo { + + private ToscaConceptIdentifier automationCompositionId; + + private AutomationCompositionState state = AutomationCompositionState.UNINITIALISED; + + private AutomationCompositionStatistics automationCompositionStatistics; + + /** + * Copy constructor, does a deep copy but as all fields here are immutable, it's just a regular copy. + * + * @param otherElement the other element to copy from + */ + public AutomationCompositionInfo(final AutomationCompositionInfo otherElement) { + this.automationCompositionId = otherElement.automationCompositionId; + this.state = otherElement.state; + this.automationCompositionStatistics = otherElement.automationCompositionStatistics; + } +} diff --git a/models/src/main/java/org/onap/policy/clamp/models/acm/concepts/AutomationCompositionOrderedState.java b/models/src/main/java/org/onap/policy/clamp/models/acm/concepts/AutomationCompositionOrderedState.java new file mode 100644 index 000000000..3be5ffa2f --- /dev/null +++ b/models/src/main/java/org/onap/policy/clamp/models/acm/concepts/AutomationCompositionOrderedState.java @@ -0,0 +1,47 @@ +/*- + * ============LICENSE_START======================================================= + * Copyright (C) 2021 Nordix Foundation. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * SPDX-License-Identifier: Apache-2.0 + * ============LICENSE_END========================================================= + */ + +package org.onap.policy.clamp.models.acm.concepts; + +public enum AutomationCompositionOrderedState { + /** + * The automation composition or automation composition element should become uninitialised on participants, it + * should not exist on participants. + */ + UNINITIALISED, + /** + * The automation composition or automation composition element should initialised on the participants and be + * passive, that is, it is not handling automation composition messages yet. + */ + PASSIVE, + /** + * The automation composition or automation composition element should running and is executing automation + * compositions. + */ + RUNNING; + + public boolean equalsAutomationCompositionState(final AutomationCompositionState automationCompositionState) { + return this.name().equals(automationCompositionState.name()); + } + + public AutomationCompositionState asState() { + return AutomationCompositionState.valueOf(this.name()); + } +} diff --git a/models/src/main/java/org/onap/policy/clamp/models/acm/concepts/AutomationCompositionState.java b/models/src/main/java/org/onap/policy/clamp/models/acm/concepts/AutomationCompositionState.java new file mode 100644 index 000000000..aa6fcfd1d --- /dev/null +++ b/models/src/main/java/org/onap/policy/clamp/models/acm/concepts/AutomationCompositionState.java @@ -0,0 +1,67 @@ +/*- + * ============LICENSE_START======================================================= + * Copyright (C) 2021 Nordix Foundation. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * SPDX-License-Identifier: Apache-2.0 + * ============LICENSE_END========================================================= + */ + +package org.onap.policy.clamp.models.acm.concepts; + +public enum AutomationCompositionState { + /** + * The automation composition or automation composition element is not initialised on participants, it does not + * exist on participants. + */ + UNINITIALISED, + /** + * The automation composition or automation composition element is changing from unitialised to passive, it is being + * initialised onto participants. + */ + UNINITIALISED2PASSIVE, + /** + * The automation composition or automation composition element is initialised on the participants but is passive, + * that is, it is not handling automation composition messages yet. + */ + PASSIVE, + /** + * The automation composition or automation composition element is changing from passive to running, the + * participants are preparing to execute automation compositions. + */ + PASSIVE2RUNNING, + /** + * The automation composition or automation composition element is running and is executing automation compositions. + */ + RUNNING, + /** + * The automation composition or automation composition element is completing execution of current automation + * compositions but will not start running any more automation compositions and will become passive. + */ + RUNNING2PASSIVE, + /** + * The automation composition or automation composition element is changing from passive to unitialised, the + * automation composition is being removed from participants. + */ + PASSIVE2UNINITIALISED; + + public boolean equalsAutomationCompositionOrderedState( + final AutomationCompositionOrderedState automationCompositionOrderedState) { + return this.name().equals(automationCompositionOrderedState.name()); + } + + public AutomationCompositionOrderedState asOrderedState() { + return AutomationCompositionOrderedState.valueOf(this.name()); + } +} diff --git a/models/src/main/java/org/onap/policy/clamp/models/acm/concepts/AutomationCompositionStatistics.java b/models/src/main/java/org/onap/policy/clamp/models/acm/concepts/AutomationCompositionStatistics.java new file mode 100644 index 000000000..8f73328ad --- /dev/null +++ b/models/src/main/java/org/onap/policy/clamp/models/acm/concepts/AutomationCompositionStatistics.java @@ -0,0 +1,50 @@ +/*- + * ============LICENSE_START======================================================= + * Copyright (C) 2021 Nordix Foundation. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * SPDX-License-Identifier: Apache-2.0 + * ============LICENSE_END========================================================= + */ + +package org.onap.policy.clamp.models.acm.concepts; + +import java.time.Instant; +import lombok.Data; +import lombok.NoArgsConstructor; +import lombok.NonNull; +import lombok.ToString; +import org.onap.policy.models.tosca.authorative.concepts.ToscaConceptIdentifier; + +@NoArgsConstructor +@Data +@ToString +public class AutomationCompositionStatistics { + + @NonNull + private ToscaConceptIdentifier automationCompositionId; + + @NonNull + private Instant timeStamp; + + @NonNull + private AcElementStatisticsList acElementStatisticsList; + + private long eventCount; + private long lastExecutionTime; + private double averageExecutionTime; + private long upTime; + private long lastEnterTime; + private long lastStart; +} diff --git a/models/src/main/java/org/onap/policy/clamp/models/acm/concepts/AutomationCompositions.java b/models/src/main/java/org/onap/policy/clamp/models/acm/concepts/AutomationCompositions.java new file mode 100644 index 000000000..1802f814c --- /dev/null +++ b/models/src/main/java/org/onap/policy/clamp/models/acm/concepts/AutomationCompositions.java @@ -0,0 +1,48 @@ +/*- + * ============LICENSE_START======================================================= + * Copyright (C) 2021 Nordix Foundation. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.onap.policy.clamp.models.acm.concepts; + +import java.util.ArrayList; +import java.util.List; +import lombok.AllArgsConstructor; +import lombok.EqualsAndHashCode; +import lombok.Getter; +import lombok.NoArgsConstructor; +import lombok.Setter; +import lombok.ToString; +import org.onap.policy.models.base.PfUtils; + +@Getter +@Setter +@ToString +@NoArgsConstructor +@AllArgsConstructor +@EqualsAndHashCode +public class AutomationCompositions { + private List automationCompositionList = new ArrayList<>(); + + /** + * Copy constructor, does a deep copy. + * + * @param otherAutomationCompositions the other element to copy from + */ + public AutomationCompositions(final AutomationCompositions otherAutomationCompositions) { + this.automationCompositionList = PfUtils.mapList(automationCompositionList, AutomationComposition::new); + } +} diff --git a/models/src/main/java/org/onap/policy/clamp/models/acm/concepts/Participant.java b/models/src/main/java/org/onap/policy/clamp/models/acm/concepts/Participant.java new file mode 100644 index 000000000..1a8fbc409 --- /dev/null +++ b/models/src/main/java/org/onap/policy/clamp/models/acm/concepts/Participant.java @@ -0,0 +1,77 @@ +/*- + * ============LICENSE_START======================================================= + * Copyright (C) 2021 Nordix Foundation. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * SPDX-License-Identifier: Apache-2.0 + * ============LICENSE_END========================================================= + */ + +package org.onap.policy.clamp.models.acm.concepts; + +import lombok.Data; +import lombok.EqualsAndHashCode; +import lombok.NoArgsConstructor; +import lombok.NonNull; +import org.onap.policy.models.base.PfConceptKey; +import org.onap.policy.models.tosca.authorative.concepts.ToscaConceptIdentifier; +import org.onap.policy.models.tosca.authorative.concepts.ToscaEntity; + +/** + * Class to represent details of a running participant instance. + */ +@NoArgsConstructor +@Data +@EqualsAndHashCode(callSuper = true) +public class Participant extends ToscaEntity implements Comparable { + @NonNull + private ToscaConceptIdentifier definition = new ToscaConceptIdentifier(PfConceptKey.getNullKey()); + + @NonNull + private ParticipantState participantState = ParticipantState.UNKNOWN; + + @NonNull + private ParticipantHealthStatus healthStatus = ParticipantHealthStatus.UNKNOWN; + + @NonNull + private ToscaConceptIdentifier participantType = new ToscaConceptIdentifier(); + + @Override + public String getType() { + return definition.getName(); + } + + @Override + public String getTypeVersion() { + return definition.getVersion(); + } + + @Override + public int compareTo(final Participant other) { + return compareNameVersion(this, other); + } + + /** + * Copy constructor. + * + * @param otherParticipant the participant to copy from + */ + public Participant(Participant otherParticipant) { + super(otherParticipant); + this.definition = new ToscaConceptIdentifier(otherParticipant.definition); + this.participantState = otherParticipant.participantState; + this.healthStatus = otherParticipant.healthStatus; + this.participantType = otherParticipant.participantType; + } +} diff --git a/models/src/main/java/org/onap/policy/clamp/models/acm/concepts/ParticipantDefinition.java b/models/src/main/java/org/onap/policy/clamp/models/acm/concepts/ParticipantDefinition.java new file mode 100644 index 000000000..949a7c47d --- /dev/null +++ b/models/src/main/java/org/onap/policy/clamp/models/acm/concepts/ParticipantDefinition.java @@ -0,0 +1,60 @@ +/*- + * ============LICENSE_START======================================================= + * Copyright (C) 2021 Nordix Foundation. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * SPDX-License-Identifier: Apache-2.0 + * ============LICENSE_END========================================================= + */ + +package org.onap.policy.clamp.models.acm.concepts; + +import java.util.ArrayList; +import java.util.List; +import lombok.Data; +import lombok.Getter; +import lombok.NoArgsConstructor; +import lombok.ToString; +import org.onap.policy.models.base.PfUtils; +import org.onap.policy.models.tosca.authorative.concepts.ToscaConceptIdentifier; + +/** + * Class to represent a participant definition update instance. + */ +@Getter +@NoArgsConstructor +@Data +@ToString +public class ParticipantDefinition { + + private ToscaConceptIdentifier participantId; + + private ToscaConceptIdentifier participantType; + + // List of AutomationCompositionElementDefinition values for a particular participant + private List automationCompositionElementDefinitionList = new ArrayList<>(); + + /** + * Copy constructor, does a deep copy but as all fields here are immutable, it's just a regular copy. + * + * @param participantDefinition the participant definition to copy from + */ + public ParticipantDefinition(final ParticipantDefinition participantDefinition) { + this.participantId = participantDefinition.participantId; + this.participantType = participantDefinition.participantType; + this.automationCompositionElementDefinitionList = + PfUtils.mapList(participantDefinition.automationCompositionElementDefinitionList, + AutomationCompositionElementDefinition::new); + } +} diff --git a/models/src/main/java/org/onap/policy/clamp/models/acm/concepts/ParticipantHealthStatus.java b/models/src/main/java/org/onap/policy/clamp/models/acm/concepts/ParticipantHealthStatus.java new file mode 100644 index 000000000..f8cc0a852 --- /dev/null +++ b/models/src/main/java/org/onap/policy/clamp/models/acm/concepts/ParticipantHealthStatus.java @@ -0,0 +1,52 @@ +/*- + * ============LICENSE_START======================================================= + * Copyright (C) 2021 Nordix Foundation. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * SPDX-License-Identifier: Apache-2.0 + * ============LICENSE_END========================================================= + */ + +package org.onap.policy.clamp.models.acm.concepts; + +/** + * Class to hold the possible values for health status of Participant. + */ +public enum ParticipantHealthStatus { + + /** + * Participant is healthy and working fine. + */ + HEALTHY, + + /** + * Participant is not healthy. + */ + NOT_HEALTHY, + + /** + * Participant is currently under test state and performing tests. + */ + TEST_IN_PROGRESS, + + /** + * The health status of the Participant is unknown. + */ + UNKNOWN, + + /** + * The health status of the Participant is off line. + */ + OFF_LINE +} diff --git a/models/src/main/java/org/onap/policy/clamp/models/acm/concepts/ParticipantState.java b/models/src/main/java/org/onap/policy/clamp/models/acm/concepts/ParticipantState.java new file mode 100644 index 000000000..4ab42c697 --- /dev/null +++ b/models/src/main/java/org/onap/policy/clamp/models/acm/concepts/ParticipantState.java @@ -0,0 +1,60 @@ +/*- + * ============LICENSE_START======================================================= + * Copyright (C) 2021 Nordix Foundation. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * SPDX-License-Identifier: Apache-2.0 + * ============LICENSE_END========================================================= + */ + +package org.onap.policy.clamp.models.acm.concepts; + +/** + * Class to hold the possible values for mode of participant. + */ +public enum ParticipantState { + /** + * Participant state is unknown. + */ + UNKNOWN, + + /** + * Participant is passive, automation composition element execution is always rejected. + */ + PASSIVE, + + /** + * Automation composition element execution execution proceeds, but changes to domain state or context are not + * carried out. The participant returns an indication that it is running in SAFE mode together with the action it + * would have performed if it was operating in ACTIVE mode. + */ + SAFE, + + /** + * Automation composition element execution execution proceeds and changes to domain and state are carried out in a + * test environment. The participant returns an indication that it is running in TEST mode together with the action + * it has performed on the test environment. + */ + TEST, + + /** + * Automation composition element execution is executed in the live environment by the participant. + */ + ACTIVE, + + /** + * Automation composition element execution has been terminated. + */ + TERMINATED +} diff --git a/models/src/main/java/org/onap/policy/clamp/models/acm/concepts/ParticipantStatistics.java b/models/src/main/java/org/onap/policy/clamp/models/acm/concepts/ParticipantStatistics.java new file mode 100644 index 000000000..4d3b96db7 --- /dev/null +++ b/models/src/main/java/org/onap/policy/clamp/models/acm/concepts/ParticipantStatistics.java @@ -0,0 +1,52 @@ +/*- + * ============LICENSE_START======================================================= + * Copyright (C) 2021 Nordix Foundation. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * SPDX-License-Identifier: Apache-2.0 + * ============LICENSE_END========================================================= + */ + +package org.onap.policy.clamp.models.acm.concepts; + +import java.io.Serializable; +import java.time.Instant; +import lombok.Data; +import lombok.NoArgsConstructor; +import lombok.NonNull; +import lombok.ToString; +import org.onap.policy.models.tosca.authorative.concepts.ToscaConceptIdentifier; + +@NoArgsConstructor +@Data +@ToString +public class ParticipantStatistics implements Serializable { + private static final long serialVersionUID = 744036598792333124L; + + + @NonNull + private ToscaConceptIdentifier participantId; + + @NonNull + private Instant timeStamp; + + private ParticipantState state; + private ParticipantHealthStatus healthStatus; + private long eventCount; + private long lastExecutionTime; + private double averageExecutionTime; + private long upTime; + private long lastEnterTime; + private long lastStart; +} diff --git a/models/src/main/java/org/onap/policy/clamp/models/acm/concepts/ParticipantStatisticsList.java b/models/src/main/java/org/onap/policy/clamp/models/acm/concepts/ParticipantStatisticsList.java new file mode 100644 index 000000000..4abdf4a63 --- /dev/null +++ b/models/src/main/java/org/onap/policy/clamp/models/acm/concepts/ParticipantStatisticsList.java @@ -0,0 +1,33 @@ +/*- + * ============LICENSE_START======================================================= + * Copyright (C) 2021 Nordix Foundation. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * SPDX-License-Identifier: Apache-2.0 + * ============LICENSE_END========================================================= + */ + +package org.onap.policy.clamp.models.acm.concepts; + +import java.util.List; +import lombok.Getter; +import lombok.Setter; +import lombok.ToString; + +@Getter +@Setter +@ToString +public class ParticipantStatisticsList { + private List statisticsList; +} diff --git a/models/src/main/java/org/onap/policy/clamp/models/acm/concepts/ParticipantUpdates.java b/models/src/main/java/org/onap/policy/clamp/models/acm/concepts/ParticipantUpdates.java new file mode 100644 index 000000000..1872a6144 --- /dev/null +++ b/models/src/main/java/org/onap/policy/clamp/models/acm/concepts/ParticipantUpdates.java @@ -0,0 +1,56 @@ +/*- + * ============LICENSE_START======================================================= + * Copyright (C) 2021 Nordix Foundation. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * SPDX-License-Identifier: Apache-2.0 + * ============LICENSE_END========================================================= + */ + +package org.onap.policy.clamp.models.acm.concepts; + +import java.util.ArrayList; +import java.util.List; +import lombok.Data; +import lombok.Getter; +import lombok.NoArgsConstructor; +import lombok.ToString; +import org.onap.policy.models.base.PfUtils; +import org.onap.policy.models.tosca.authorative.concepts.ToscaConceptIdentifier; + +/** + * Class to represent a participant definition update instance. + */ +@Getter +@NoArgsConstructor +@Data +@ToString +public class ParticipantUpdates { + + private ToscaConceptIdentifier participantId; + + // List of AutomationCompositionElement values for a particular participant + private List automationCompositionElementList = new ArrayList<>(); + + /** + * Copy constructor, does a deep copy but as all fields here are immutable, it's just a regular copy. + * + * @param participantUpdates the participant with updates to copy from + */ + public ParticipantUpdates(final ParticipantUpdates participantUpdates) { + this.participantId = participantUpdates.participantId; + this.automationCompositionElementList = PfUtils.mapList( + participantUpdates.automationCompositionElementList, AutomationCompositionElement::new); + } +} diff --git a/models/src/main/java/org/onap/policy/clamp/models/acm/concepts/ParticipantUtils.java b/models/src/main/java/org/onap/policy/clamp/models/acm/concepts/ParticipantUtils.java new file mode 100644 index 000000000..9d26ce406 --- /dev/null +++ b/models/src/main/java/org/onap/policy/clamp/models/acm/concepts/ParticipantUtils.java @@ -0,0 +1,123 @@ +/*- + * ============LICENSE_START======================================================= + * Copyright (C) 2021 Nordix Foundation. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * SPDX-License-Identifier: Apache-2.0 + * ============LICENSE_END========================================================= + */ + +package org.onap.policy.clamp.models.acm.concepts; + +import java.util.Map; +import javax.ws.rs.core.Response; +import lombok.AccessLevel; +import lombok.NoArgsConstructor; +import org.onap.policy.common.utils.coder.Coder; +import org.onap.policy.common.utils.coder.CoderException; +import org.onap.policy.common.utils.coder.StandardCoder; +import org.onap.policy.models.base.PfModelRuntimeException; +import org.onap.policy.models.tosca.authorative.concepts.ToscaConceptIdentifier; +import org.onap.policy.models.tosca.authorative.concepts.ToscaNodeTemplate; +import org.onap.policy.models.tosca.authorative.concepts.ToscaServiceTemplate; + +@NoArgsConstructor(access = AccessLevel.PRIVATE) +public final class ParticipantUtils { + + private static final Coder CODER = new StandardCoder(); + private static final String AUTOMATION_COMPOSITION_ELEMENT = + "org.onap.policy.clamp.acm.AutomationCompositionElement"; + + /** + * Finds participantType from a map of properties. + * + * @param properties Map of properties + * @return participantType + */ + public static ToscaConceptIdentifier findParticipantType(Map properties) { + var objParticipantType = properties.get("participantType"); + if (objParticipantType != null) { + try { + return CODER.decode(objParticipantType.toString(), ToscaConceptIdentifier.class); + } catch (CoderException e) { + throw new PfModelRuntimeException(Response.Status.BAD_REQUEST, e.getMessage(), e); + } + } + return null; + } + + /** + * Get the First StartPhase. + * + *

This depends on the state of the automation composition and also on all start phases defined in the + * ToscaServiceTemplate. + * + * @param automationComposition the automation composition + * @param toscaServiceTemplate the ToscaServiceTemplate + * @return the First StartPhase + */ + public static int getFirstStartPhase( + AutomationComposition automationComposition, ToscaServiceTemplate toscaServiceTemplate) { + var minStartPhase = 1000; + var maxStartPhase = 0; + for (var element : automationComposition.getElements().values()) { + ToscaNodeTemplate toscaNodeTemplate = toscaServiceTemplate.getToscaTopologyTemplate().getNodeTemplates() + .get(element.getDefinition().getName()); + int startPhase = ParticipantUtils.findStartPhase(toscaNodeTemplate.getProperties()); + minStartPhase = Math.min(minStartPhase, startPhase); + maxStartPhase = Math.max(maxStartPhase, startPhase); + } + + return AutomationCompositionState.UNINITIALISED2PASSIVE.equals(automationComposition.getState()) + || AutomationCompositionState.PASSIVE2RUNNING.equals(automationComposition.getState()) ? minStartPhase + : maxStartPhase; + } + + /** + * Finds startPhase from a map of properties. + * + * @param properties Map of properties + * @return startPhase + */ + public static int findStartPhase(Map properties) { + var objParticipantType = properties.get("startPhase"); + if (objParticipantType != null) { + return Integer.valueOf(objParticipantType.toString()); + } + return 0; + } + + /** + * Checks if a NodeTemplate is an AutomationCompositionElement. + * + * @param nodeTemplate the ToscaNodeTemplate + * @param toscaServiceTemplate the ToscaServiceTemplate + * @return true if the NodeTemplate is an AutomationCompositionElement + */ + public static boolean checkIfNodeTemplateIsAutomationCompositionElement(ToscaNodeTemplate nodeTemplate, + ToscaServiceTemplate toscaServiceTemplate) { + if (nodeTemplate.getType().contains(AUTOMATION_COMPOSITION_ELEMENT)) { + return true; + } else { + var nodeType = toscaServiceTemplate.getNodeTypes().get(nodeTemplate.getType()); + if (nodeType != null) { + var derivedFrom = nodeType.getDerivedFrom(); + if (derivedFrom != null) { + return derivedFrom.contains(AUTOMATION_COMPOSITION_ELEMENT); + } + } + } + return false; + } +} diff --git a/models/src/main/java/org/onap/policy/clamp/models/acm/messages/dmaap/notification/AutomationCompositionNotification.java b/models/src/main/java/org/onap/policy/clamp/models/acm/messages/dmaap/notification/AutomationCompositionNotification.java new file mode 100644 index 000000000..4b898633a --- /dev/null +++ b/models/src/main/java/org/onap/policy/clamp/models/acm/messages/dmaap/notification/AutomationCompositionNotification.java @@ -0,0 +1,56 @@ +/*- + * ============LICENSE_START======================================================= + * Copyright (C) 2021 Nordix Foundation. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.onap.policy.clamp.models.acm.messages.dmaap.notification; + +import com.google.gson.annotations.SerializedName; +import java.util.ArrayList; +import java.util.List; +import lombok.AllArgsConstructor; +import lombok.Data; +import lombok.NoArgsConstructor; +import org.apache.commons.collections4.CollectionUtils; + +@Data +@NoArgsConstructor +@AllArgsConstructor +public class AutomationCompositionNotification { + + /** + * Status of automation compositions that are being added to participants. + */ + @SerializedName("deployed-automation-compositions") + private List added = new ArrayList<>(); + + /** + * Status of policies that are being deleted from PDPs. + */ + @SerializedName("undeployed-automation-compositions") + private List deleted = new ArrayList<>(); + + + /** + * Determines if the notification is empty (i.e., has no added or delete automation composition + * notifications). + * + * @return {@code true} if the notification is empty, {@code false} otherwise + */ + public boolean isEmpty() { + return (CollectionUtils.isEmpty(added) && CollectionUtils.isEmpty(deleted)); + } +} diff --git a/models/src/main/java/org/onap/policy/clamp/models/acm/messages/dmaap/notification/AutomationCompositionStatus.java b/models/src/main/java/org/onap/policy/clamp/models/acm/messages/dmaap/notification/AutomationCompositionStatus.java new file mode 100644 index 000000000..f65c6217b --- /dev/null +++ b/models/src/main/java/org/onap/policy/clamp/models/acm/messages/dmaap/notification/AutomationCompositionStatus.java @@ -0,0 +1,36 @@ +/*- + * ============LICENSE_START======================================================= + * Copyright (C) 2021 Nordix Foundation. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.onap.policy.clamp.models.acm.messages.dmaap.notification; + +import com.google.gson.annotations.SerializedName; +import java.util.UUID; +import lombok.AllArgsConstructor; +import lombok.Data; +import lombok.NoArgsConstructor; +import org.onap.policy.models.tosca.authorative.concepts.ToscaConceptIdentifier; + +@Data +@NoArgsConstructor +@AllArgsConstructor +public class AutomationCompositionStatus { + @SerializedName("automation-composition-id") + private UUID id; + + private ToscaConceptIdentifier definition; +} diff --git a/models/src/main/java/org/onap/policy/clamp/models/acm/messages/dmaap/participant/AutomationCompositionAck.java b/models/src/main/java/org/onap/policy/clamp/models/acm/messages/dmaap/participant/AutomationCompositionAck.java new file mode 100644 index 000000000..c0a21d61a --- /dev/null +++ b/models/src/main/java/org/onap/policy/clamp/models/acm/messages/dmaap/participant/AutomationCompositionAck.java @@ -0,0 +1,70 @@ +/*- + * ============LICENSE_START======================================================= + * Copyright (C) 2021 Nordix Foundation. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * SPDX-License-Identifier: Apache-2.0 + * ============LICENSE_END========================================================= + */ + +package org.onap.policy.clamp.models.acm.messages.dmaap.participant; + +import java.util.LinkedHashMap; +import java.util.Map; +import java.util.UUID; +import java.util.function.UnaryOperator; +import lombok.Getter; +import lombok.Setter; +import lombok.ToString; +import org.onap.policy.clamp.models.acm.concepts.AutomationCompositionElementAck; +import org.onap.policy.models.base.PfUtils; +import org.onap.policy.models.tosca.authorative.concepts.ToscaConceptIdentifier; + +/** + * Class to represent the AUTOMATION_COMPOSITION_ACK message that a participant sends + * to automation composition runtime as an acknowledgement to either AUTOMATION_COMPOSITION_UPDATE + * or AUTOMATION_COMPOSITION_STATE_CHANGE message. + */ +@Getter +@Setter +@ToString(callSuper = true) +public class AutomationCompositionAck extends ParticipantAckMessage { + + private ToscaConceptIdentifier automationCompositionId; + private Integer startPhase; + + // A map with AutomationCompositionElementID as its key, and a pair of result and message as value per + // AutomationCompositionElement. + private Map automationCompositionResultMap = new LinkedHashMap<>(); + + /** + * Constructor for instantiating ParticipantRegisterAck class with message name. + * + */ + public AutomationCompositionAck(final ParticipantMessageType messageType) { + super(messageType); + } + + /** + * Constructs the object, making a deep copy. + * + * @param source source from which to copy + */ + public AutomationCompositionAck(final AutomationCompositionAck source) { + super(source); + this.automationCompositionId = source.automationCompositionId; + this.automationCompositionResultMap = + PfUtils.mapMap(source.automationCompositionResultMap, UnaryOperator.identity()); + } +} diff --git a/models/src/main/java/org/onap/policy/clamp/models/acm/messages/dmaap/participant/AutomationCompositionStateChange.java b/models/src/main/java/org/onap/policy/clamp/models/acm/messages/dmaap/participant/AutomationCompositionStateChange.java new file mode 100644 index 000000000..f8daa36a9 --- /dev/null +++ b/models/src/main/java/org/onap/policy/clamp/models/acm/messages/dmaap/participant/AutomationCompositionStateChange.java @@ -0,0 +1,60 @@ +/*- + * ============LICENSE_START======================================================= + * Copyright (C) 2021 Nordix Foundation. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * SPDX-License-Identifier: Apache-2.0 + * ============LICENSE_END========================================================= + */ + +package org.onap.policy.clamp.models.acm.messages.dmaap.participant; + +import lombok.Getter; +import lombok.Setter; +import lombok.ToString; +import org.onap.policy.clamp.models.acm.concepts.AutomationCompositionOrderedState; +import org.onap.policy.clamp.models.acm.concepts.AutomationCompositionState; + +/** + * Class to represent the AUTOMATION_COMPOSITION_STATE_CHANGE message that the automation composition runtime will send + * to participants to change the state of an automation composition they are running. + */ +@Getter +@Setter +@ToString(callSuper = true) +public class AutomationCompositionStateChange extends ParticipantMessage { + private AutomationCompositionOrderedState orderedState; + private AutomationCompositionState currentState; + private Integer startPhase; + + /** + * Constructor for instantiating class with message name. + * + */ + public AutomationCompositionStateChange() { + super(ParticipantMessageType.AUTOMATION_COMPOSITION_STATE_CHANGE); + } + + /** + * Constructs the object, making a deep copy. + * + * @param source source from which to copy + */ + public AutomationCompositionStateChange(AutomationCompositionStateChange source) { + super(source); + + this.orderedState = source.orderedState; + this.currentState = source.currentState; + } +} diff --git a/models/src/main/java/org/onap/policy/clamp/models/acm/messages/dmaap/participant/AutomationCompositionUpdate.java b/models/src/main/java/org/onap/policy/clamp/models/acm/messages/dmaap/participant/AutomationCompositionUpdate.java new file mode 100644 index 000000000..55fcc7462 --- /dev/null +++ b/models/src/main/java/org/onap/policy/clamp/models/acm/messages/dmaap/participant/AutomationCompositionUpdate.java @@ -0,0 +1,64 @@ +/*- + * ============LICENSE_START======================================================= + * Copyright (C) 2021 Nordix Foundation. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * SPDX-License-Identifier: Apache-2.0 + * ============LICENSE_END========================================================= + */ + +package org.onap.policy.clamp.models.acm.messages.dmaap.participant; + +import java.util.ArrayList; +import java.util.List; +import lombok.Getter; +import lombok.Setter; +import lombok.ToString; +import org.onap.policy.clamp.models.acm.concepts.ParticipantUpdates; +import org.onap.policy.models.base.PfUtils; + +/** + * Class to represent the AUTOMATION_COMPOSITION_UPDATE message that the automation composition runtime sends to a + * participant. When a participant receives this message, it creates the automation composition elements contained in + * the message and sets them to state PASSIVE. subsequent AUTOMATION_COMPOSITION_STATE_CHANGE messages are used to + * activate the automation compositions. + */ +@Getter +@Setter +@ToString(callSuper = true) +public class AutomationCompositionUpdate extends ParticipantMessage { + + // A list of ParticipantUpdates instances which carries details of an updated participant. + private List participantUpdatesList = new ArrayList<>(); + private Integer startPhase = 0; + + /** + * Constructor for instantiating class with message name. + * + */ + public AutomationCompositionUpdate() { + super(ParticipantMessageType.AUTOMATION_COMPOSITION_UPDATE); + } + + /** + * Constructs the object, making a deep copy. + * + * @param source source from which to copy + */ + public AutomationCompositionUpdate(AutomationCompositionUpdate source) { + super(source); + + this.participantUpdatesList = PfUtils.mapList(source.participantUpdatesList, ParticipantUpdates::new); + } +} diff --git a/models/src/main/java/org/onap/policy/clamp/models/acm/messages/dmaap/participant/ParticipantAckMessage.java b/models/src/main/java/org/onap/policy/clamp/models/acm/messages/dmaap/participant/ParticipantAckMessage.java new file mode 100644 index 000000000..8b33d3172 --- /dev/null +++ b/models/src/main/java/org/onap/policy/clamp/models/acm/messages/dmaap/participant/ParticipantAckMessage.java @@ -0,0 +1,115 @@ +/*- + * ============LICENSE_START======================================================= + * Copyright (C) 2021 Nordix Foundation. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * SPDX-License-Identifier: Apache-2.0 + * ============LICENSE_END========================================================= + */ + +package org.onap.policy.clamp.models.acm.messages.dmaap.participant; + +import java.util.UUID; +import lombok.Getter; +import lombok.NonNull; +import lombok.Setter; +import lombok.ToString; +import org.onap.policy.clamp.models.acm.concepts.ParticipantState; +import org.onap.policy.models.tosca.authorative.concepts.ToscaConceptIdentifier; + +/** + * Class to represent participant Ack message. + */ +@Getter +@Setter +@ToString +public class ParticipantAckMessage { + + // The responseTo field should match the original request id in the request. + private UUID responseTo; + + // Result: Success/Fail. + private Boolean result; + + // Message indicating reason for failure + private String message; + + private ParticipantMessageType messageType; + + /** + * Participant Type, or {@code null} for messages from participants. + */ + private ToscaConceptIdentifier participantType; + + /** + * Participant ID, or {@code null} for messages from participants. + */ + private ToscaConceptIdentifier participantId; + + /** + * Participant State, or {@code null} for messages from participants. + */ + private ParticipantState state; + + /** + * Constructor for instantiating a participant ack message class. + * + * @param messageType the message type + */ + public ParticipantAckMessage(final ParticipantMessageType messageType) { + this.messageType = messageType; + } + + /** + * Constructs the object, making a deep copy. + * + * @param source source from which to copy + */ + public ParticipantAckMessage(ParticipantAckMessage source) { + this.responseTo = source.responseTo; + this.result = source.result; + this.message = source.message; + this.messageType = source.messageType; + this.participantType = source.participantType; + this.participantId = source.participantId; + this.state = source.state; + } + + /** + * Determines if this message applies to this participant type. + * + * @param participantType type of the participant to match against + * @param participantId id of the participant to match against + * @return {@code true} if this message applies to this participant, {@code false} otherwise + */ + public boolean appliesTo(@NonNull final ToscaConceptIdentifier participantType, + @NonNull final ToscaConceptIdentifier participantId) { + // Broadcast message to all participants + if (this.participantType == null) { + return true; + } + + if (!participantType.equals(this.participantType)) { + return false; + } + + // Broadcast message to all automation composition elements on this participant + if (this.participantId == null) { + return true; + } + + // Targeted message at this specific participant + return participantId.equals(this.participantId); + } +} diff --git a/models/src/main/java/org/onap/policy/clamp/models/acm/messages/dmaap/participant/ParticipantDeregister.java b/models/src/main/java/org/onap/policy/clamp/models/acm/messages/dmaap/participant/ParticipantDeregister.java new file mode 100644 index 000000000..2e7ed8c52 --- /dev/null +++ b/models/src/main/java/org/onap/policy/clamp/models/acm/messages/dmaap/participant/ParticipantDeregister.java @@ -0,0 +1,51 @@ +/*- + * ============LICENSE_START======================================================= + * Copyright (C) 2021 Nordix Foundation. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * SPDX-License-Identifier: Apache-2.0 + * ============LICENSE_END========================================================= + */ + +package org.onap.policy.clamp.models.acm.messages.dmaap.participant; + +import lombok.Getter; +import lombok.Setter; +import lombok.ToString; + +/** + * Class to represent the PARTICIPANT_DEREGISTER message that all the participants send to the ACM runtime. + */ +@Getter +@Setter +@ToString(callSuper = true) +public class ParticipantDeregister extends ParticipantMessage { + + /** + * Constructor for instantiating ParticipantDeregister class with message name. + * + */ + public ParticipantDeregister() { + super(ParticipantMessageType.PARTICIPANT_DEREGISTER); + } + + /** + * Constructs the object, making a deep copy. + * + * @param source source from which to copy + */ + public ParticipantDeregister(final ParticipantDeregister source) { + super(source); + } +} diff --git a/models/src/main/java/org/onap/policy/clamp/models/acm/messages/dmaap/participant/ParticipantDeregisterAck.java b/models/src/main/java/org/onap/policy/clamp/models/acm/messages/dmaap/participant/ParticipantDeregisterAck.java new file mode 100644 index 000000000..afa987d65 --- /dev/null +++ b/models/src/main/java/org/onap/policy/clamp/models/acm/messages/dmaap/participant/ParticipantDeregisterAck.java @@ -0,0 +1,51 @@ +/*- + * ============LICENSE_START======================================================= + * Copyright (C) 2021 Nordix Foundation. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * SPDX-License-Identifier: Apache-2.0 + * ============LICENSE_END========================================================= + */ + +package org.onap.policy.clamp.models.acm.messages.dmaap.participant; + +import lombok.Getter; +import lombok.Setter; +import lombok.ToString; + +/** + * Class to represent the PARTICIPANT_DEREGISTER_ACK message that the ACM runtime sends to the participant. + */ +@Getter +@Setter +@ToString(callSuper = true) +public class ParticipantDeregisterAck extends ParticipantAckMessage { + + /** + * Constructor for instantiating ParticipantDeregisterAck class with message name. + * + */ + public ParticipantDeregisterAck() { + super(ParticipantMessageType.PARTICIPANT_DEREGISTER_ACK); + } + + /** + * Constructs the object, making a deep copy. + * + * @param source source from which to copy + */ + public ParticipantDeregisterAck(final ParticipantDeregisterAck source) { + super(source); + } +} diff --git a/models/src/main/java/org/onap/policy/clamp/models/acm/messages/dmaap/participant/ParticipantMessage.java b/models/src/main/java/org/onap/policy/clamp/models/acm/messages/dmaap/participant/ParticipantMessage.java new file mode 100644 index 000000000..c358376b2 --- /dev/null +++ b/models/src/main/java/org/onap/policy/clamp/models/acm/messages/dmaap/participant/ParticipantMessage.java @@ -0,0 +1,112 @@ +/*- + * ============LICENSE_START======================================================= + * Copyright (C) 2021 Nordix Foundation. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * SPDX-License-Identifier: Apache-2.0 + * ============LICENSE_END========================================================= + */ + +package org.onap.policy.clamp.models.acm.messages.dmaap.participant; + +import java.time.Instant; +import java.util.UUID; +import lombok.AccessLevel; +import lombok.Getter; +import lombok.NonNull; +import lombok.Setter; +import lombok.ToString; +import org.onap.policy.models.tosca.authorative.concepts.ToscaConceptIdentifier; + +/** + * Class to represent the base class for various messages that will be exchanged between the ACM runtime and + * participants. + */ +@Getter +@Setter +@ToString +public class ParticipantMessage { + @Setter(AccessLevel.NONE) + private ParticipantMessageType messageType; + + private UUID messageId = UUID.randomUUID(); + + /** + * Time-stamp, in milliseconds, when the message was created. Defaults to the current time. + */ + private Instant timestamp = Instant.now(); + + /** + * Participant Type, or {@code null} for messages from participants. + */ + private ToscaConceptIdentifier participantType; + + /** + * Participant ID, or {@code null} for messages from participants. + */ + private ToscaConceptIdentifier participantId; + + /** + * Automation Composition ID, or {@code null} for messages to participants. + */ + private ToscaConceptIdentifier automationCompositionId; + + /** + * Constructor for instantiating a participant message class. + * + * @param messageType the message type + */ + public ParticipantMessage(final ParticipantMessageType messageType) { + this.messageType = messageType; + } + + /** + * Constructs the object, making a deep copy. Does not copy the request id or the time stamp. + * + * @param source source from which to copy + */ + public ParticipantMessage(final ParticipantMessage source) { + this.messageType = source.messageType; + this.participantType = source.participantType; + this.participantId = source.participantId; + this.automationCompositionId = source.automationCompositionId; + } + + /** + * Determines if this message applies to this participant type. + * + * @param participantType type of the participant to match against + * @param participantId id of the participant to match against + * @return {@code true} if this message applies to this participant, {@code false} otherwise + */ + public boolean appliesTo(@NonNull final ToscaConceptIdentifier participantType, + @NonNull final ToscaConceptIdentifier participantId) { + // Broadcast message to all participants + if (this.participantType == null) { + return true; + } + + if (!participantType.equals(this.participantType)) { + return false; + } + + // Broadcast message to all automation composition elements on this participant + if (this.participantId == null) { + return true; + } + + // Targeted message at this specific participant + return participantId.equals(this.participantId); + } +} diff --git a/models/src/main/java/org/onap/policy/clamp/models/acm/messages/dmaap/participant/ParticipantMessageType.java b/models/src/main/java/org/onap/policy/clamp/models/acm/messages/dmaap/participant/ParticipantMessageType.java new file mode 100644 index 000000000..4f6bcdbf3 --- /dev/null +++ b/models/src/main/java/org/onap/policy/clamp/models/acm/messages/dmaap/participant/ParticipantMessageType.java @@ -0,0 +1,104 @@ +/*- + * ============LICENSE_START======================================================= + * Copyright (C) 2021 Nordix Foundation. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * SPDX-License-Identifier: Apache-2.0 + * ============LICENSE_END========================================================= + */ + +package org.onap.policy.clamp.models.acm.messages.dmaap.participant; + +/** + * Class to hold the possible values for the type of participant messages. + */ +public enum ParticipantMessageType { + + /** + * Used by participants to report status to the automation composition runtime. + */ + PARTICIPANT_STATUS, + + /** + * Used by the acm runtime to change the state of participants, triggers a + * PARTICIPANT_STATUS message with the result of the PARTICIPANT_STATE_CHANGE operation. + */ + PARTICIPANT_STATE_CHANGE, + + /** + * Used by acm runtime to update the automation compositions running on participants, triggers a + * PARTICIPANT_STATUS message with the result of the AUTOMATION_COMPOSITION_UPDATE operation. + */ + AUTOMATION_COMPOSITION_UPDATE, + + /** + * Used by acm runtime to change the state of automation compositions in participants, triggers a + * PARTICIPANT_STATUS message with result of AUTOMATION_COMPOSITION_STATE_CHANGE operation. + */ + AUTOMATION_COMPOSITION_STATE_CHANGE, + + /** + * Used by the automation composition runtime to order a health check on participants, triggers a + * PARTICIPANT_STATUS message with the result of the PARTICIPANT_HEALTH_CHECK operation. + */ + PARTICIPANT_HEALTH_CHECK, + + /** + * Used by participant to register itself with automation composition runtime. + */ + PARTICIPANT_REGISTER, + + /** + * Used by automation composition runtime to respond to participant registration. + */ + PARTICIPANT_REGISTER_ACK, + + /** + * Used by participant to deregister itself with automation composition runtime. + */ + PARTICIPANT_DEREGISTER, + + /** + * Used by automation composition runtime to respond to participant deregistration. + */ + PARTICIPANT_DEREGISTER_ACK, + + /** + * Used by automation composition runtime to send ToscaServiceTemplate to participant. + */ + PARTICIPANT_UPDATE, + + /** + * Used by participant to acknowledge the receipt of PARTICIPANT_UPDATE message + * from automation composition runtime. + */ + PARTICIPANT_UPDATE_ACK, + + /** + * Used by participant to acknowledge the receipt of AUTOMATION_COMPOSITION_UPDATE message + * from automation composition runtime. + */ + AUTOMATION_COMPOSITION_UPDATE_ACK, + + /** + * Used by participant to acknowledge the receipt of AUTOMATION_COMPOSITION_STATE_CHANGE message + * from automation composition runtime. + */ + AUTOMATION_COMPOSITION_STATECHANGE_ACK, + + /** + * Used by automation composition runtime to request for PARTICIPANT_STATUS message immediately. + */ + PARTICIPANT_STATUS_REQ +} diff --git a/models/src/main/java/org/onap/policy/clamp/models/acm/messages/dmaap/participant/ParticipantRegister.java b/models/src/main/java/org/onap/policy/clamp/models/acm/messages/dmaap/participant/ParticipantRegister.java new file mode 100644 index 000000000..7b315dbe0 --- /dev/null +++ b/models/src/main/java/org/onap/policy/clamp/models/acm/messages/dmaap/participant/ParticipantRegister.java @@ -0,0 +1,51 @@ +/*- + * ============LICENSE_START======================================================= + * Copyright (C) 2021 Nordix Foundation. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * SPDX-License-Identifier: Apache-2.0 + * ============LICENSE_END========================================================= + */ + +package org.onap.policy.clamp.models.acm.messages.dmaap.participant; + +import lombok.Getter; +import lombok.Setter; +import lombok.ToString; + +/** + * Class to represent the PARTICIPANT_REGISTER message that all the participants send to the ACM runtime. + */ +@Getter +@Setter +@ToString(callSuper = true) +public class ParticipantRegister extends ParticipantMessage { + + /** + * Constructor for instantiating ParticipantRegister class with message name. + * + */ + public ParticipantRegister() { + super(ParticipantMessageType.PARTICIPANT_REGISTER); + } + + /** + * Constructs the object, making a deep copy. + * + * @param source source from which to copy + */ + public ParticipantRegister(final ParticipantRegister source) { + super(source); + } +} diff --git a/models/src/main/java/org/onap/policy/clamp/models/acm/messages/dmaap/participant/ParticipantRegisterAck.java b/models/src/main/java/org/onap/policy/clamp/models/acm/messages/dmaap/participant/ParticipantRegisterAck.java new file mode 100644 index 000000000..60858be4c --- /dev/null +++ b/models/src/main/java/org/onap/policy/clamp/models/acm/messages/dmaap/participant/ParticipantRegisterAck.java @@ -0,0 +1,51 @@ +/*- + * ============LICENSE_START======================================================= + * Copyright (C) 2021 Nordix Foundation. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * SPDX-License-Identifier: Apache-2.0 + * ============LICENSE_END========================================================= + */ + +package org.onap.policy.clamp.models.acm.messages.dmaap.participant; + +import lombok.Getter; +import lombok.Setter; +import lombok.ToString; + +/** + * Class to represent the PARTICIPANT_REGISTER_ACK message that the ACM runtime sends to a registered participant. + */ +@Getter +@Setter +@ToString(callSuper = true) +public class ParticipantRegisterAck extends ParticipantAckMessage { + + /** + * Constructor for instantiating ParticipantRegisterAck class with message name. + * + */ + public ParticipantRegisterAck() { + super(ParticipantMessageType.PARTICIPANT_REGISTER_ACK); + } + + /** + * Constructs the object, making a deep copy. + * + * @param source source from which to copy + */ + public ParticipantRegisterAck(final ParticipantRegisterAck source) { + super(source); + } +} diff --git a/models/src/main/java/org/onap/policy/clamp/models/acm/messages/dmaap/participant/ParticipantResponseStatus.java b/models/src/main/java/org/onap/policy/clamp/models/acm/messages/dmaap/participant/ParticipantResponseStatus.java new file mode 100644 index 000000000..cb0307742 --- /dev/null +++ b/models/src/main/java/org/onap/policy/clamp/models/acm/messages/dmaap/participant/ParticipantResponseStatus.java @@ -0,0 +1,42 @@ +/*- + * ============LICENSE_START======================================================= + * Copyright (C) 2021 Nordix Foundation. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * SPDX-License-Identifier: Apache-2.0 + * ============LICENSE_END========================================================= + */ + +package org.onap.policy.clamp.models.acm.messages.dmaap.participant; + +/** + * Class to hold the possible values for participant response status. + */ +public enum ParticipantResponseStatus { + + /** + * participant operation was successful. + */ + SUCCESS, + + /** + * participant operation failed. + */ + FAIL, + + /** + * periodic response. + */ + PERIODIC +} diff --git a/models/src/main/java/org/onap/policy/clamp/models/acm/messages/dmaap/participant/ParticipantStatus.java b/models/src/main/java/org/onap/policy/clamp/models/acm/messages/dmaap/participant/ParticipantStatus.java new file mode 100644 index 000000000..32b95e11b --- /dev/null +++ b/models/src/main/java/org/onap/policy/clamp/models/acm/messages/dmaap/participant/ParticipantStatus.java @@ -0,0 +1,79 @@ +/*- + * ============LICENSE_START======================================================= + * Copyright (C) 2021 Nordix Foundation. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * SPDX-License-Identifier: Apache-2.0 + * ============LICENSE_END========================================================= + */ + +package org.onap.policy.clamp.models.acm.messages.dmaap.participant; + +import java.util.ArrayList; +import java.util.List; +import lombok.Getter; +import lombok.Setter; +import lombok.ToString; +import org.onap.policy.clamp.models.acm.concepts.AutomationCompositionInfo; +import org.onap.policy.clamp.models.acm.concepts.ParticipantDefinition; +import org.onap.policy.clamp.models.acm.concepts.ParticipantHealthStatus; +import org.onap.policy.clamp.models.acm.concepts.ParticipantState; +import org.onap.policy.clamp.models.acm.concepts.ParticipantStatistics; +import org.onap.policy.models.base.PfUtils; + +/** + * Class to represent the PARTICIPANT_STATUS message that all the participants send to the ACM runtime. + */ +@Getter +@Setter +@ToString(callSuper = true) +public class ParticipantStatus extends ParticipantMessage { + + // State and health status of the participant + private ParticipantState state; + private ParticipantHealthStatus healthStatus; + + private ParticipantStatistics participantStatistics; + + // A list of ParticipantDefinition updates, returned in response to ParticipantStatusReq only + private List participantDefinitionUpdates = new ArrayList<>(); + + // List of AutomationCompositionInfo types with AutomationCompositionId, its state and statistics + private List automationCompositionInfoList = new ArrayList<>(); + + /** + * Constructor for instantiating ParticipantStatus class with message name. + * + */ + public ParticipantStatus() { + super(ParticipantMessageType.PARTICIPANT_STATUS); + } + + /** + * Constructs the object, making a deep copy. + * + * @param source source from which to copy + */ + public ParticipantStatus(final ParticipantStatus source) { + super(source); + + this.state = source.state; + this.healthStatus = source.healthStatus; + this.participantStatistics = (source.participantStatistics == null ? null : new ParticipantStatistics()); + this.participantDefinitionUpdates = + PfUtils.mapList(source.participantDefinitionUpdates, ParticipantDefinition::new); + this.automationCompositionInfoList = + PfUtils.mapList(source.automationCompositionInfoList, AutomationCompositionInfo::new); + } +} diff --git a/models/src/main/java/org/onap/policy/clamp/models/acm/messages/dmaap/participant/ParticipantStatusReq.java b/models/src/main/java/org/onap/policy/clamp/models/acm/messages/dmaap/participant/ParticipantStatusReq.java new file mode 100644 index 000000000..82260ee67 --- /dev/null +++ b/models/src/main/java/org/onap/policy/clamp/models/acm/messages/dmaap/participant/ParticipantStatusReq.java @@ -0,0 +1,51 @@ +/*- + * ============LICENSE_START======================================================= + * Copyright (C) 2021 Nordix Foundation. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * SPDX-License-Identifier: Apache-2.0 + * ============LICENSE_END========================================================= + */ + +package org.onap.policy.clamp.models.acm.messages.dmaap.participant; + +import lombok.Getter; +import lombok.Setter; +import lombok.ToString; + +/** + * Class to represent the PARTICIPANT_STATUS_REQ message that the ACM runtime + * sends to participants for an immediate ParticipantStatus from participants. + */ +@Getter +@Setter +@ToString(callSuper = true) +public class ParticipantStatusReq extends ParticipantMessage { + + /** + * Constructor for instantiating a participant status request class. + */ + public ParticipantStatusReq() { + super(ParticipantMessageType.PARTICIPANT_STATUS_REQ); + } + + /** + * Constructs the object, making a deep copy. + * + * @param source source from which to copy + */ + public ParticipantStatusReq(final ParticipantStatusReq source) { + super(source); + } +} diff --git a/models/src/main/java/org/onap/policy/clamp/models/acm/messages/dmaap/participant/ParticipantUpdate.java b/models/src/main/java/org/onap/policy/clamp/models/acm/messages/dmaap/participant/ParticipantUpdate.java new file mode 100644 index 000000000..36842a8cf --- /dev/null +++ b/models/src/main/java/org/onap/policy/clamp/models/acm/messages/dmaap/participant/ParticipantUpdate.java @@ -0,0 +1,63 @@ +/*- + * ============LICENSE_START======================================================= + * Copyright (C) 2021 Nordix Foundation. + * Modifications Copyright (C) 2021 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * SPDX-License-Identifier: Apache-2.0 + * ============LICENSE_END========================================================= + */ + +package org.onap.policy.clamp.models.acm.messages.dmaap.participant; + +import java.util.ArrayList; +import java.util.List; +import lombok.Getter; +import lombok.Setter; +import lombok.ToString; +import org.onap.policy.clamp.models.acm.concepts.ParticipantDefinition; +import org.onap.policy.models.base.PfUtils; + +/** + * Class to represent the PARTICIPANT_UPDATE message that the ACM runtime sends to a participant. + * the ACM Runtime sends automation composition element Definitions and Common Parameter Values to Participants. + */ +@Getter +@Setter +@ToString(callSuper = true) +public class ParticipantUpdate extends ParticipantMessage { + + // A list of updates to ParticipantDefinitions + private List participantDefinitionUpdates = new ArrayList<>(); + + /** + * Constructor for instantiating ParticipantUpdate class with message name. + * + */ + public ParticipantUpdate() { + super(ParticipantMessageType.PARTICIPANT_UPDATE); + } + + /** + * Constructs the object, making a deep copy. + * + * @param source source from which to copy + */ + public ParticipantUpdate(ParticipantUpdate source) { + super(source); + + this.participantDefinitionUpdates = PfUtils.mapList(source.participantDefinitionUpdates, + ParticipantDefinition::new); + } +} diff --git a/models/src/main/java/org/onap/policy/clamp/models/acm/messages/dmaap/participant/ParticipantUpdateAck.java b/models/src/main/java/org/onap/policy/clamp/models/acm/messages/dmaap/participant/ParticipantUpdateAck.java new file mode 100644 index 000000000..2c3a68e22 --- /dev/null +++ b/models/src/main/java/org/onap/policy/clamp/models/acm/messages/dmaap/participant/ParticipantUpdateAck.java @@ -0,0 +1,53 @@ +/*- + * ============LICENSE_START======================================================= + * Copyright (C) 2021 Nordix Foundation. + * ================================================================================ + * Modifications Copyright (C) 2021 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * SPDX-License-Identifier: Apache-2.0 + * ============LICENSE_END========================================================= + */ + +package org.onap.policy.clamp.models.acm.messages.dmaap.participant; + +import lombok.Getter; +import lombok.Setter; +import lombok.ToString; + +/** + * Class to represent the PARTICIPANT_UPDATE_ACK message that registered participant sends to the ACM runtime. + */ +@Getter +@Setter +@ToString(callSuper = true) +public class ParticipantUpdateAck extends ParticipantAckMessage { + + /** + * Constructor for instantiating ParticipantUpdateAck class with message name. + * + */ + public ParticipantUpdateAck() { + super(ParticipantMessageType.PARTICIPANT_UPDATE_ACK); + } + + /** + * Constructs the object, making a deep copy. + * + * @param source source from which to copy + */ + public ParticipantUpdateAck(final ParticipantUpdateAck source) { + super(source); + } +} diff --git a/models/src/main/java/org/onap/policy/clamp/models/acm/messages/rest/GenericNameVersion.java b/models/src/main/java/org/onap/policy/clamp/models/acm/messages/rest/GenericNameVersion.java new file mode 100644 index 000000000..3e39e970d --- /dev/null +++ b/models/src/main/java/org/onap/policy/clamp/models/acm/messages/rest/GenericNameVersion.java @@ -0,0 +1,30 @@ +/* + * ============LICENSE_START======================================================= + * Copyright (C) 2021 Nordix Foundation. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * SPDX-License-Identifier: Apache-2.0 + * ============LICENSE_END========================================================= + */ + +package org.onap.policy.clamp.models.acm.messages.rest; + +import lombok.Data; + +@Data +public class GenericNameVersion { + + private String name; + + private String version; +} diff --git a/models/src/main/java/org/onap/policy/clamp/models/acm/messages/rest/SimpleResponse.java b/models/src/main/java/org/onap/policy/clamp/models/acm/messages/rest/SimpleResponse.java new file mode 100644 index 000000000..1668652b7 --- /dev/null +++ b/models/src/main/java/org/onap/policy/clamp/models/acm/messages/rest/SimpleResponse.java @@ -0,0 +1,37 @@ +/* + * ============LICENSE_START======================================================= + * Copyright (C) 2021 Nordix Foundation. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.onap.policy.clamp.models.acm.messages.rest; + +import lombok.Getter; +import lombok.Setter; +import lombok.ToString; + +/** + * Response returned when no extra output fields are needed. + */ +@Getter +@Setter +@ToString +public class SimpleResponse { + + /** + * Optional detailed message in error cases. + */ + private String errorDetails; +} diff --git a/models/src/main/java/org/onap/policy/clamp/models/acm/messages/rest/TypedSimpleResponse.java b/models/src/main/java/org/onap/policy/clamp/models/acm/messages/rest/TypedSimpleResponse.java new file mode 100644 index 000000000..871eb3bc2 --- /dev/null +++ b/models/src/main/java/org/onap/policy/clamp/models/acm/messages/rest/TypedSimpleResponse.java @@ -0,0 +1,35 @@ +/*- + * ============LICENSE_START======================================================= + * Copyright (C) 2021 Nordix Foundation. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * SPDX-License-Identifier: Apache-2.0 + * ============LICENSE_END========================================================= + */ + +package org.onap.policy.clamp.models.acm.messages.rest; + +import lombok.Getter; +import lombok.Setter; +import lombok.ToString; + +/** + * Response returned when no extra output fields are needed. + */ +@Getter +@Setter +@ToString +public class TypedSimpleResponse extends SimpleResponse { + private T response; +} diff --git a/models/src/main/java/org/onap/policy/clamp/models/acm/messages/rest/commissioning/CommissioningResponse.java b/models/src/main/java/org/onap/policy/clamp/models/acm/messages/rest/commissioning/CommissioningResponse.java new file mode 100644 index 000000000..42ce79843 --- /dev/null +++ b/models/src/main/java/org/onap/policy/clamp/models/acm/messages/rest/commissioning/CommissioningResponse.java @@ -0,0 +1,38 @@ +/*- + * ============LICENSE_START======================================================= + * Copyright (C) 2021 Nordix Foundation. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * SPDX-License-Identifier: Apache-2.0 + * ============LICENSE_END========================================================= + */ + +package org.onap.policy.clamp.models.acm.messages.rest.commissioning; + +import java.util.List; +import lombok.Getter; +import lombok.Setter; +import lombok.ToString; +import org.onap.policy.clamp.models.acm.messages.rest.SimpleResponse; +import org.onap.policy.models.tosca.authorative.concepts.ToscaConceptIdentifier; + +/** + * Response to Commissioning requests that affect a change. + */ +@Getter +@Setter +@ToString(callSuper = true) +public class CommissioningResponse extends SimpleResponse { + private List affectedAutomationCompositionDefinitions; +} diff --git a/models/src/main/java/org/onap/policy/clamp/models/acm/messages/rest/instantiation/AutomationCompositionOrderStateResponse.java b/models/src/main/java/org/onap/policy/clamp/models/acm/messages/rest/instantiation/AutomationCompositionOrderStateResponse.java new file mode 100644 index 000000000..a87433d4c --- /dev/null +++ b/models/src/main/java/org/onap/policy/clamp/models/acm/messages/rest/instantiation/AutomationCompositionOrderStateResponse.java @@ -0,0 +1,43 @@ +/* + * ============LICENSE_START======================================================= + * Copyright (C) 2021 Nordix Foundation. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * SPDX-License-Identifier: Apache-2.0 + * ============LICENSE_END========================================================= + */ + +package org.onap.policy.clamp.models.acm.messages.rest.instantiation; + +import java.util.ArrayList; +import java.util.List; +import lombok.Getter; +import lombok.Setter; +import lombok.ToString; +import org.onap.policy.clamp.models.acm.concepts.AutomationCompositionOrderedState; +import org.onap.policy.clamp.models.acm.messages.rest.GenericNameVersion; +import org.onap.policy.clamp.models.acm.messages.rest.SimpleResponse; + + +/** + * Response to Commissioning requests that affect a change. + */ +@Getter +@Setter +@ToString(callSuper = true) +public class AutomationCompositionOrderStateResponse extends SimpleResponse { + + private AutomationCompositionOrderedState orderedState = AutomationCompositionOrderedState.UNINITIALISED; + + private List automationCompositionIdentifierList = new ArrayList<>(); +} diff --git a/models/src/main/java/org/onap/policy/clamp/models/acm/messages/rest/instantiation/AutomationCompositionPrimed.java b/models/src/main/java/org/onap/policy/clamp/models/acm/messages/rest/instantiation/AutomationCompositionPrimed.java new file mode 100644 index 000000000..34556653b --- /dev/null +++ b/models/src/main/java/org/onap/policy/clamp/models/acm/messages/rest/instantiation/AutomationCompositionPrimed.java @@ -0,0 +1,32 @@ +/* + * ============LICENSE_START======================================================= + * Copyright (C) 2021 Nordix Foundation. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * SPDX-License-Identifier: Apache-2.0 + * ============LICENSE_END========================================================= + */ + +package org.onap.policy.clamp.models.acm.messages.rest.instantiation; + +import lombok.Data; + +@Data +public class AutomationCompositionPrimed { + + private String name; + + private String version; + + private boolean primed; +} diff --git a/models/src/main/java/org/onap/policy/clamp/models/acm/messages/rest/instantiation/AutomationCompositionPrimedResponse.java b/models/src/main/java/org/onap/policy/clamp/models/acm/messages/rest/instantiation/AutomationCompositionPrimedResponse.java new file mode 100644 index 000000000..fa3e8fad7 --- /dev/null +++ b/models/src/main/java/org/onap/policy/clamp/models/acm/messages/rest/instantiation/AutomationCompositionPrimedResponse.java @@ -0,0 +1,39 @@ +/* + * ============LICENSE_START======================================================= + * Copyright (C) 2021 Nordix Foundation. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * SPDX-License-Identifier: Apache-2.0 + * ============LICENSE_END========================================================= + */ + +package org.onap.policy.clamp.models.acm.messages.rest.instantiation; + +import java.util.ArrayList; +import java.util.List; +import lombok.Getter; +import lombok.Setter; +import lombok.ToString; +import org.onap.policy.clamp.models.acm.messages.rest.SimpleResponse; + + +/** + * Response to provide all primed automation compositions. + */ +@Getter +@Setter +@ToString(callSuper = true) +public class AutomationCompositionPrimedResponse extends SimpleResponse { + + private List primedAutomationCompositionsList = new ArrayList<>(); +} diff --git a/models/src/main/java/org/onap/policy/clamp/models/acm/messages/rest/instantiation/InstancePropertiesResponse.java b/models/src/main/java/org/onap/policy/clamp/models/acm/messages/rest/instantiation/InstancePropertiesResponse.java new file mode 100644 index 000000000..0341d5dae --- /dev/null +++ b/models/src/main/java/org/onap/policy/clamp/models/acm/messages/rest/instantiation/InstancePropertiesResponse.java @@ -0,0 +1,38 @@ +/* + * ============LICENSE_START======================================================= + * Copyright (C) 2021 Nordix Foundation. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * SPDX-License-Identifier: Apache-2.0 + * ============LICENSE_END========================================================= + */ + +package org.onap.policy.clamp.models.acm.messages.rest.instantiation; + +import java.util.ArrayList; +import java.util.List; +import lombok.Getter; +import lombok.Setter; +import lombok.ToString; +import org.onap.policy.clamp.models.acm.messages.rest.SimpleResponse; +import org.onap.policy.models.tosca.authorative.concepts.ToscaConceptIdentifier; + +/** + * Response to Instance Properties requests that affect a change. + */ +@Getter +@Setter +@ToString(callSuper = true) +public class InstancePropertiesResponse extends SimpleResponse { + private List affectedInstanceProperties = new ArrayList<>(); +} diff --git a/models/src/main/java/org/onap/policy/clamp/models/acm/messages/rest/instantiation/InstantiationCommand.java b/models/src/main/java/org/onap/policy/clamp/models/acm/messages/rest/instantiation/InstantiationCommand.java new file mode 100644 index 000000000..a3fb70e15 --- /dev/null +++ b/models/src/main/java/org/onap/policy/clamp/models/acm/messages/rest/instantiation/InstantiationCommand.java @@ -0,0 +1,35 @@ +/*- + * ============LICENSE_START======================================================= + * Copyright (C) 2021 Nordix Foundation. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * SPDX-License-Identifier: Apache-2.0 + * ============LICENSE_END========================================================= + */ + +package org.onap.policy.clamp.models.acm.messages.rest.instantiation; + +import java.util.List; +import lombok.Data; +import org.onap.policy.clamp.models.acm.concepts.AutomationCompositionOrderedState; +import org.onap.policy.models.tosca.authorative.concepts.ToscaConceptIdentifier; + +@Data +public class InstantiationCommand { + // The state to which the automation compositions are to be set + private AutomationCompositionOrderedState orderedState; + + // The list of automation compositions on which the command is to be issued + private List automationCompositionIdentifierList; +} diff --git a/models/src/main/java/org/onap/policy/clamp/models/acm/messages/rest/instantiation/InstantiationOrderStateResponse.java b/models/src/main/java/org/onap/policy/clamp/models/acm/messages/rest/instantiation/InstantiationOrderStateResponse.java new file mode 100644 index 000000000..e6bdaee9d --- /dev/null +++ b/models/src/main/java/org/onap/policy/clamp/models/acm/messages/rest/instantiation/InstantiationOrderStateResponse.java @@ -0,0 +1,39 @@ +/* + * ============LICENSE_START======================================================= + * Copyright (C) 2021 Nordix Foundation. + * ================================================================================ + * Modifications Copyright (C) 2021 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * SPDX-License-Identifier: Apache-2.0 + * ============LICENSE_END========================================================= + */ + +package org.onap.policy.clamp.models.acm.messages.rest.instantiation; + +import lombok.Getter; +import lombok.Setter; +import lombok.ToString; +import org.onap.policy.clamp.models.acm.concepts.AutomationCompositionOrderedState; +import org.onap.policy.clamp.models.acm.messages.rest.SimpleResponse; + +/** + * Response to instantiation OrderState. + */ +@Getter +@Setter +@ToString(callSuper = true) +public class InstantiationOrderStateResponse extends SimpleResponse { + + private AutomationCompositionOrderedState orderedState; +} diff --git a/models/src/main/java/org/onap/policy/clamp/models/acm/messages/rest/instantiation/InstantiationResponse.java b/models/src/main/java/org/onap/policy/clamp/models/acm/messages/rest/instantiation/InstantiationResponse.java new file mode 100644 index 000000000..e7c346498 --- /dev/null +++ b/models/src/main/java/org/onap/policy/clamp/models/acm/messages/rest/instantiation/InstantiationResponse.java @@ -0,0 +1,38 @@ +/*- + * ============LICENSE_START======================================================= + * Copyright (C) 2021 Nordix Foundation. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * SPDX-License-Identifier: Apache-2.0 + * ============LICENSE_END========================================================= + */ + +package org.onap.policy.clamp.models.acm.messages.rest.instantiation; + +import java.util.List; +import lombok.Getter; +import lombok.Setter; +import lombok.ToString; +import org.onap.policy.clamp.models.acm.messages.rest.SimpleResponse; +import org.onap.policy.models.tosca.authorative.concepts.ToscaConceptIdentifier; + +/** + * Response to Commissioning requests that affect a change. + */ +@Getter +@Setter +@ToString(callSuper = true) +public class InstantiationResponse extends SimpleResponse { + private List affectedAutomationCompositions; +} diff --git a/models/src/main/java/org/onap/policy/clamp/models/acm/persistence/concepts/JpaAcElementStatistics.java b/models/src/main/java/org/onap/policy/clamp/models/acm/persistence/concepts/JpaAcElementStatistics.java new file mode 100644 index 000000000..4a046052e --- /dev/null +++ b/models/src/main/java/org/onap/policy/clamp/models/acm/persistence/concepts/JpaAcElementStatistics.java @@ -0,0 +1,196 @@ +/*- + * ============LICENSE_START======================================================= + * Copyright (C) 2021 Nordix Foundation. + * ================================================================================ + * Modifications Copyright (C) 2021 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * SPDX-License-Identifier: Apache-2.0 + * ============LICENSE_END========================================================= + */ + +package org.onap.policy.clamp.models.acm.persistence.concepts; + +import java.io.Serializable; +import java.util.List; +import java.util.UUID; +import javax.persistence.AttributeOverride; +import javax.persistence.Column; +import javax.persistence.EmbeddedId; +import javax.persistence.Entity; +import javax.persistence.Inheritance; +import javax.persistence.InheritanceType; +import javax.persistence.Table; +import lombok.AllArgsConstructor; +import lombok.Data; +import lombok.EqualsAndHashCode; +import lombok.NonNull; +import org.apache.commons.lang3.builder.CompareToBuilder; +import org.onap.policy.clamp.models.acm.concepts.AcElementStatistics; +import org.onap.policy.clamp.models.acm.concepts.AutomationCompositionState; +import org.onap.policy.common.parameters.annotations.NotNull; +import org.onap.policy.models.base.PfAuthorative; +import org.onap.policy.models.base.PfConcept; +import org.onap.policy.models.base.PfConceptKey; +import org.onap.policy.models.base.PfKey; +import org.onap.policy.models.base.PfReferenceTimestampKey; +import org.onap.policy.models.base.validation.annotations.VerifyKey; +import org.onap.policy.models.tosca.authorative.concepts.ToscaConceptIdentifier; + +/** + * Class to represent automation composition element statistics in the database. + * + * @author Ramesh Murugan Iyer (ramesh.murugan.iyer@est.tech) + */ +@Entity +@Table(name = "AcElementStatistics") +@Inheritance(strategy = InheritanceType.TABLE_PER_CLASS) +@Data +@AllArgsConstructor +@EqualsAndHashCode(callSuper = false) +public class JpaAcElementStatistics extends PfConcept implements PfAuthorative, Serializable { + + private static final long serialVersionUID = 621426717868738629L; + + @EmbeddedId + @VerifyKey + @NotNull + private PfReferenceTimestampKey key = new PfReferenceTimestampKey(); + + + @VerifyKey + @NotNull + // @formatter:off + @AttributeOverride(name = "name", column = @Column(name = "participant_name")) + @AttributeOverride(name = "version", column = @Column(name = "participant_version")) + private PfConceptKey participantId; + // @formatter: on + + @Column + @NotNull + private AutomationCompositionState state; + + @Column + private long acElementUptime; + + + /** + * The Default Constructor creates a {@link JpaAcElementStatistics} object with a null key. + */ + public JpaAcElementStatistics() { + this(new PfReferenceTimestampKey()); + } + + + /** + * The Key Constructor creates a {@link JpaAcElementStatistics} object with the given Reference Timestamp key. + * + * @param key the key + */ + public JpaAcElementStatistics(@NonNull final PfReferenceTimestampKey key) { + this(key, new PfConceptKey(), AutomationCompositionState.PASSIVE, 0L); + } + + /** + * The Key Constructor creates a {@link JpaAcElementStatistics} object with all mandatory fields. + * + * @param key the key + * @param participantId the TOSCA definition of the automation composition element + */ + public JpaAcElementStatistics(@NonNull final PfReferenceTimestampKey key, + @NonNull final PfConceptKey participantId) { + this.key = key; + this.participantId = participantId; + } + + /** + * Copy constructor. + * + * @param copyConcept the concept to copy from + */ + public JpaAcElementStatistics(@NonNull final JpaAcElementStatistics copyConcept) { + super(copyConcept); + this.key = new PfReferenceTimestampKey(copyConcept.key); + this.participantId = new PfConceptKey(copyConcept.participantId); + this.state = copyConcept.state; + this.acElementUptime = copyConcept.acElementUptime; + } + + + /** + * Authorative constructor. + * + * @param authorativeConcept the authorative concept to copy from + */ + public JpaAcElementStatistics(@NonNull final AcElementStatistics authorativeConcept) { + this.fromAuthorative(authorativeConcept); + } + + + + @Override + public AcElementStatistics toAuthorative() { + var acElementStatistics = new AcElementStatistics(); + acElementStatistics.setId(UUID.fromString(getKey().getReferenceKey().getLocalName())); + acElementStatistics.setTimeStamp(key.getInstant()); + acElementStatistics.setParticipantId(new ToscaConceptIdentifier(participantId)); + acElementStatistics.setState(state); + acElementStatistics.setAcElementUptime(acElementUptime); + + return acElementStatistics; + } + + @Override + public void fromAuthorative(@NonNull AcElementStatistics acElementStatistics) { + // @formatter:off + if (this.key == null || this.getKey().isNullKey()) { + this.setKey(new PfReferenceTimestampKey(acElementStatistics.getParticipantId().getName(), + acElementStatistics.getParticipantId().getVersion(), acElementStatistics.getId().toString(), + acElementStatistics.getTimeStamp())); + } + // @formatter:on + this.setParticipantId(acElementStatistics.getParticipantId().asConceptKey()); + this.setState(acElementStatistics.getState()); + this.setAcElementUptime(acElementStatistics.getAcElementUptime()); + } + + @Override + public List getKeys() { + return getKey().getKeys(); + } + + @Override + public void clean() { + key.clean(); + participantId.clean(); + } + + + @Override + public int compareTo(PfConcept otherConcept) { + if (otherConcept == null) { + return -1; + } + if (this == otherConcept) { + return 0; + } + if (getClass() != otherConcept.getClass()) { + return getClass().getName().compareTo(otherConcept.getClass().getName()); + } + + final JpaAcElementStatistics other = (JpaAcElementStatistics) otherConcept; + return new CompareToBuilder().append(this.key, other.key).append(this.state, other.state) + .append(this.acElementUptime, other.acElementUptime).toComparison(); + } +} diff --git a/models/src/main/java/org/onap/policy/clamp/models/acm/persistence/concepts/JpaAutomationComposition.java b/models/src/main/java/org/onap/policy/clamp/models/acm/persistence/concepts/JpaAutomationComposition.java new file mode 100644 index 000000000..e5c44d0a2 --- /dev/null +++ b/models/src/main/java/org/onap/policy/clamp/models/acm/persistence/concepts/JpaAutomationComposition.java @@ -0,0 +1,268 @@ +/*- + * ============LICENSE_START======================================================= + * Copyright (C) 2021 Nordix Foundation. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * SPDX-License-Identifier: Apache-2.0 + * ============LICENSE_END========================================================= + */ + +package org.onap.policy.clamp.models.acm.persistence.concepts; + +import java.util.LinkedHashMap; +import java.util.List; +import java.util.Map; +import java.util.Map.Entry; +import java.util.UUID; +import javax.persistence.AttributeOverride; +import javax.persistence.CascadeType; +import javax.persistence.Column; +import javax.persistence.EmbeddedId; +import javax.persistence.Entity; +import javax.persistence.FetchType; +import javax.persistence.Inheritance; +import javax.persistence.InheritanceType; +import javax.persistence.ManyToMany; +import javax.persistence.Table; +import lombok.Data; +import lombok.EqualsAndHashCode; +import lombok.NonNull; +import org.apache.commons.lang3.ObjectUtils; +import org.onap.policy.clamp.models.acm.concepts.AutomationComposition; +import org.onap.policy.clamp.models.acm.concepts.AutomationCompositionElement; +import org.onap.policy.clamp.models.acm.concepts.AutomationCompositionOrderedState; +import org.onap.policy.clamp.models.acm.concepts.AutomationCompositionState; +import org.onap.policy.common.parameters.annotations.NotNull; +import org.onap.policy.common.parameters.annotations.Valid; +import org.onap.policy.models.base.PfAuthorative; +import org.onap.policy.models.base.PfConcept; +import org.onap.policy.models.base.PfConceptKey; +import org.onap.policy.models.base.PfKey; +import org.onap.policy.models.base.PfReferenceKey; +import org.onap.policy.models.base.PfUtils; +import org.onap.policy.models.base.validation.annotations.VerifyKey; +import org.onap.policy.models.tosca.authorative.concepts.ToscaConceptIdentifier; + +/** + * Class to represent a automation composition in the database. + * + * @author Liam Fallon (liam.fallon@est.tech) + */ +@Entity +@Table(name = "AutomationComposition") +@Inheritance(strategy = InheritanceType.TABLE_PER_CLASS) +@Data +@EqualsAndHashCode(callSuper = false) +public class JpaAutomationComposition extends PfConcept implements PfAuthorative { + private static final long serialVersionUID = -4725410933242154805L; + + @EmbeddedId + @VerifyKey + @NotNull + private PfConceptKey key; + + // @formatter:off + @VerifyKey + @NotNull + @AttributeOverride(name = "name", column = @Column(name = "definition_name")) + @AttributeOverride(name = "version", column = @Column(name = "definition_version")) + private PfConceptKey definition; + // @formatter:on + + @Column + @NotNull + private AutomationCompositionState state; + + @Column + @NotNull + private AutomationCompositionOrderedState orderedState; + + @Column + private String description; + + @Column + private Boolean primed; + + @ManyToMany(fetch = FetchType.EAGER, cascade = CascadeType.ALL) + @NotNull + private Map<@NotNull UUID, @NotNull @Valid JpaAutomationCompositionElement> elements; + // @formatter:on + + /** + * The Default Constructor creates a {@link JpaAutomationComposition} object with a null key. + */ + public JpaAutomationComposition() { + this(new PfConceptKey()); + } + + /** + * The Key Constructor creates a {@link JpaAutomationComposition} object with the given concept key. + * + * @param key the key + */ + public JpaAutomationComposition(@NonNull final PfConceptKey key) { + this(key, new PfConceptKey(), AutomationCompositionState.UNINITIALISED, new LinkedHashMap<>()); + } + + /** + * The Key Constructor creates a {@link JpaAutomationComposition} object with all mandatory fields. + * + * @param key the key + * @param definition the TOSCA definition of the automation composition + * @param state the state of the automation composition + * @param elements the elements of the automation composition in participants + */ + public JpaAutomationComposition(@NonNull final PfConceptKey key, @NonNull final PfConceptKey definition, + @NonNull final AutomationCompositionState state, + @NonNull final Map elements) { + this.key = key; + this.definition = definition; + this.state = state; + this.elements = elements; + } + + /** + * Copy constructor. + * + * @param copyConcept the concept to copy from + */ + public JpaAutomationComposition(@NonNull final JpaAutomationComposition copyConcept) { + super(copyConcept); + this.key = new PfConceptKey(copyConcept.key); + this.definition = new PfConceptKey(copyConcept.definition); + this.state = copyConcept.state; + this.orderedState = copyConcept.orderedState; + this.description = copyConcept.description; + this.elements = + PfUtils.mapMap(copyConcept.elements, JpaAutomationCompositionElement::new, new LinkedHashMap<>(0)); + this.primed = copyConcept.primed; + } + + /** + * Authorative constructor. + * + * @param authorativeConcept the authorative concept to copy from + */ + public JpaAutomationComposition(@NonNull final AutomationComposition authorativeConcept) { + this.fromAuthorative(authorativeConcept); + } + + @Override + public AutomationComposition toAuthorative() { + var automationComposition = new AutomationComposition(); + + automationComposition.setName(getKey().getName()); + automationComposition.setVersion(getKey().getVersion()); + automationComposition.setDefinition(new ToscaConceptIdentifier(definition)); + automationComposition.setState(state); + automationComposition.setOrderedState(orderedState != null ? orderedState : state.asOrderedState()); + automationComposition.setDescription(description); + automationComposition.setElements( + PfUtils.mapMap(elements, JpaAutomationCompositionElement::toAuthorative, new LinkedHashMap<>(0))); + automationComposition.setPrimed(primed); + + return automationComposition; + } + + @Override + public void fromAuthorative(@NonNull final AutomationComposition automationComposition) { + if (this.key == null || this.getKey().isNullKey()) { + this.setKey(new PfConceptKey(automationComposition.getName(), automationComposition.getVersion())); + } + + this.definition = automationComposition.getDefinition().asConceptKey(); + this.state = automationComposition.getState(); + this.orderedState = automationComposition.getOrderedState(); + this.description = automationComposition.getDescription(); + this.primed = automationComposition.getPrimed(); + + this.elements = new LinkedHashMap<>(automationComposition.getElements().size()); + for (Entry elementEntry : automationComposition.getElements().entrySet()) { + var jpaAutomationCompositionElement = new JpaAutomationCompositionElement(); + jpaAutomationCompositionElement + .setKey(new PfReferenceKey(getKey(), elementEntry.getValue().getId().toString())); + jpaAutomationCompositionElement.fromAuthorative(elementEntry.getValue()); + this.elements.put(elementEntry.getKey(), jpaAutomationCompositionElement); + } + } + + @Override + public List getKeys() { + List keyList = getKey().getKeys(); + + keyList.add(definition); + + for (JpaAutomationCompositionElement element : elements.values()) { + keyList.addAll(element.getKeys()); + } + + return keyList; + } + + @Override + public void clean() { + key.clean(); + definition.clean(); + description = (description == null ? null : description.trim()); + + for (JpaAutomationCompositionElement element : elements.values()) { + element.clean(); + } + } + + @Override + public int compareTo(final PfConcept otherConcept) { + if (otherConcept == null) { + return -1; + } + if (this == otherConcept) { + return 0; + } + if (getClass() != otherConcept.getClass()) { + return this.getClass().getName().compareTo(otherConcept.getClass().getName()); + } + + final JpaAutomationComposition other = (JpaAutomationComposition) otherConcept; + int result = key.compareTo(other.key); + if (result != 0) { + return result; + } + + result = definition.compareTo(other.definition); + if (result != 0) { + return result; + } + + result = ObjectUtils.compare(state, other.state); + if (result != 0) { + return result; + } + + result = ObjectUtils.compare(orderedState, other.orderedState); + if (result != 0) { + return result; + } + + result = ObjectUtils.compare(description, other.description); + if (result != 0) { + return result; + } + + result = ObjectUtils.compare(primed, other.primed); + if (result != 0) { + return result; + } + return PfUtils.compareObjects(elements, other.elements); + } +} diff --git a/models/src/main/java/org/onap/policy/clamp/models/acm/persistence/concepts/JpaAutomationCompositionElement.java b/models/src/main/java/org/onap/policy/clamp/models/acm/persistence/concepts/JpaAutomationCompositionElement.java new file mode 100644 index 000000000..08d8ee06b --- /dev/null +++ b/models/src/main/java/org/onap/policy/clamp/models/acm/persistence/concepts/JpaAutomationCompositionElement.java @@ -0,0 +1,253 @@ +/*- + * ============LICENSE_START======================================================= + * Copyright (C) 2021 Nordix Foundation. + * ================================================================================ + * Modifications Copyright (C) 2021 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * SPDX-License-Identifier: Apache-2.0 + * ============LICENSE_END========================================================= + */ + +package org.onap.policy.clamp.models.acm.persistence.concepts; + +import java.util.List; +import java.util.UUID; +import javax.persistence.AttributeOverride; +import javax.persistence.Column; +import javax.persistence.EmbeddedId; +import javax.persistence.Entity; +import javax.persistence.Inheritance; +import javax.persistence.InheritanceType; +import javax.persistence.Table; +import lombok.Data; +import lombok.EqualsAndHashCode; +import lombok.NonNull; +import org.apache.commons.lang3.ObjectUtils; +import org.onap.policy.clamp.models.acm.concepts.AutomationCompositionElement; +import org.onap.policy.clamp.models.acm.concepts.AutomationCompositionOrderedState; +import org.onap.policy.clamp.models.acm.concepts.AutomationCompositionState; +import org.onap.policy.common.parameters.annotations.NotNull; +import org.onap.policy.models.base.PfAuthorative; +import org.onap.policy.models.base.PfConcept; +import org.onap.policy.models.base.PfConceptKey; +import org.onap.policy.models.base.PfKey; +import org.onap.policy.models.base.PfReferenceKey; +import org.onap.policy.models.base.validation.annotations.VerifyKey; +import org.onap.policy.models.tosca.authorative.concepts.ToscaConceptIdentifier; + +/** + * Class to represent a participant automation composition element in the database. + * + * @author Liam Fallon (liam.fallon@est.tech) + */ +@Entity +@Table(name = "AutomationCompositionElement") +@Inheritance(strategy = InheritanceType.TABLE_PER_CLASS) +@Data +@EqualsAndHashCode(callSuper = false) +public class JpaAutomationCompositionElement extends PfConcept implements PfAuthorative { + private static final long serialVersionUID = -1791732273187890213L; + + @EmbeddedId + @VerifyKey + @NotNull + private PfReferenceKey key; + + // @formatter:off + @VerifyKey + @NotNull + @AttributeOverride(name = "name", column = @Column(name = "definition_name")) + @AttributeOverride(name = "version", column = @Column(name = "definition_version")) + private PfConceptKey definition; + + @VerifyKey + @NotNull + @AttributeOverride(name = "name", column = @Column(name = "participant_type_name")) + @AttributeOverride(name = "version", column = @Column(name = "participant_type_version")) + private PfConceptKey participantType; + + @NotNull + @AttributeOverride(name = "name", column = @Column(name = "participant_name")) + @AttributeOverride(name = "version", column = @Column(name = "participant_version")) + private PfConceptKey participantId; + // @formatter:on + + @Column + @NotNull + private AutomationCompositionState state; + + @Column + @NotNull + private AutomationCompositionOrderedState orderedState; + + @Column + private String description; + + /** + * The Default Constructor creates a {@link JpaAutomationCompositionElement} object with a null key. + */ + public JpaAutomationCompositionElement() { + this(new PfReferenceKey()); + } + + /** + * The Key Constructor creates a {@link JpaAutomationCompositionElement} object with the given concept key. + * + * @param key the key + */ + public JpaAutomationCompositionElement(@NonNull final PfReferenceKey key) { + this(key, new PfConceptKey(), new PfConceptKey(), AutomationCompositionState.UNINITIALISED); + } + + /** + * The Key Constructor creates a {@link JpaAutomationCompositionElement} object with all mandatory fields. + * + * @param key the key + * @param definition the TOSCA definition of the automation composition element + * @param participantType the TOSCA definition of the participant running the automation composition element + * @param state the state of the automation composition + */ + public JpaAutomationCompositionElement(@NonNull final PfReferenceKey key, @NonNull final PfConceptKey definition, + @NonNull final PfConceptKey participantType, @NonNull final AutomationCompositionState state) { + this.key = key; + this.definition = definition; + this.participantType = participantType; + this.state = state; + } + + /** + * Copy constructor. + * + * @param copyConcept the concept to copy from + */ + public JpaAutomationCompositionElement(@NonNull final JpaAutomationCompositionElement copyConcept) { + super(copyConcept); + this.key = new PfReferenceKey(copyConcept.key); + this.definition = new PfConceptKey(copyConcept.definition); + this.participantType = new PfConceptKey(copyConcept.participantType); + this.participantId = new PfConceptKey(copyConcept.participantId); + this.state = copyConcept.state; + this.orderedState = copyConcept.orderedState; + this.description = copyConcept.description; + } + + /** + * Authorative constructor. + * + * @param authorativeConcept the authorative concept to copy from + */ + public JpaAutomationCompositionElement(@NonNull final AutomationCompositionElement authorativeConcept) { + this.fromAuthorative(authorativeConcept); + } + + @Override + public AutomationCompositionElement toAuthorative() { + var element = new AutomationCompositionElement(); + + element.setId(UUID.fromString(getKey().getLocalName())); + element.setDefinition(new ToscaConceptIdentifier(definition)); + element.setParticipantType(new ToscaConceptIdentifier(participantType)); + element.setParticipantId(new ToscaConceptIdentifier(participantId)); + element.setState(state); + element.setOrderedState(orderedState != null ? orderedState : state.asOrderedState()); + element.setDescription(description); + + return element; + } + + @Override + public void fromAuthorative(@NonNull final AutomationCompositionElement element) { + if (this.key == null || this.getKey().isNullKey()) { + this.setKey(new PfReferenceKey()); + getKey().setLocalName(element.getId().toString()); + } + + this.definition = element.getDefinition().asConceptKey(); + this.participantType = element.getParticipantType().asConceptKey(); + this.participantId = element.getParticipantId().asConceptKey(); + this.state = element.getState(); + this.orderedState = element.getOrderedState(); + this.description = element.getDescription(); + } + + @Override + public List getKeys() { + List keyList = getKey().getKeys(); + + keyList.add(definition); + keyList.add(participantType); + keyList.add(participantId); + + return keyList; + } + + @Override + public void clean() { + key.clean(); + definition.clean(); + participantType.clean(); + participantId.clean(); + + if (description != null) { + description = description.trim(); + } + } + + @Override + public int compareTo(final PfConcept otherConcept) { + if (otherConcept == null) { + return -1; + } + if (this == otherConcept) { + return 0; + } + if (getClass() != otherConcept.getClass()) { + return this.getClass().getName().compareTo(otherConcept.getClass().getName()); + } + + final JpaAutomationCompositionElement other = (JpaAutomationCompositionElement) otherConcept; + int result = key.compareTo(other.key); + if (result != 0) { + return result; + } + + result = definition.compareTo(other.definition); + if (result != 0) { + return result; + } + + result = participantType.compareTo(other.participantType); + if (result != 0) { + return result; + } + + result = participantId.compareTo(other.participantId); + if (result != 0) { + return result; + } + + result = ObjectUtils.compare(state, other.state); + if (result != 0) { + return result; + } + + result = ObjectUtils.compare(orderedState, other.orderedState); + if (result != 0) { + return result; + } + + return ObjectUtils.compare(description, other.description); + } +} diff --git a/models/src/main/java/org/onap/policy/clamp/models/acm/persistence/concepts/JpaParticipant.java b/models/src/main/java/org/onap/policy/clamp/models/acm/persistence/concepts/JpaParticipant.java new file mode 100644 index 000000000..143499c0d --- /dev/null +++ b/models/src/main/java/org/onap/policy/clamp/models/acm/persistence/concepts/JpaParticipant.java @@ -0,0 +1,231 @@ +/*- + * ============LICENSE_START======================================================= + * Copyright (C) 2021 Nordix Foundation. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * SPDX-License-Identifier: Apache-2.0 + * ============LICENSE_END========================================================= + */ + +package org.onap.policy.clamp.models.acm.persistence.concepts; + +import java.io.Serializable; +import java.util.List; +import javax.persistence.AttributeOverride; +import javax.persistence.Column; +import javax.persistence.EmbeddedId; +import javax.persistence.Entity; +import javax.persistence.Inheritance; +import javax.persistence.InheritanceType; +import javax.persistence.Table; +import lombok.Data; +import lombok.EqualsAndHashCode; +import lombok.NonNull; +import org.apache.commons.lang3.ObjectUtils; +import org.onap.policy.clamp.models.acm.concepts.Participant; +import org.onap.policy.clamp.models.acm.concepts.ParticipantHealthStatus; +import org.onap.policy.clamp.models.acm.concepts.ParticipantState; +import org.onap.policy.common.parameters.annotations.NotNull; +import org.onap.policy.models.base.PfAuthorative; +import org.onap.policy.models.base.PfConcept; +import org.onap.policy.models.base.PfConceptKey; +import org.onap.policy.models.base.PfKey; +import org.onap.policy.models.base.validation.annotations.VerifyKey; +import org.onap.policy.models.tosca.authorative.concepts.ToscaConceptIdentifier; + +/** + * Class to represent a participant in the database. + * + * @author Liam Fallon (liam.fallon@est.tech) + */ +@Entity +@Table(name = "Participant") +@Inheritance(strategy = InheritanceType.TABLE_PER_CLASS) +@Data +@EqualsAndHashCode(callSuper = false) +public class JpaParticipant extends PfConcept implements PfAuthorative, Serializable { + private static final long serialVersionUID = -4697758484642403483L; + + @EmbeddedId + @VerifyKey + @NotNull + private PfConceptKey key; + + // @formatter:off + @VerifyKey + @NotNull + @AttributeOverride(name = "name", column = @Column(name = "definition_name")) + @AttributeOverride(name = "version", column = @Column(name = "definition_version")) + private PfConceptKey definition; + // @formatter:on + + @NotNull + @AttributeOverride(name = "name", column = @Column(name = "participant_type_name")) + @AttributeOverride(name = "version", column = @Column(name = "participant_type_version")) + private PfConceptKey participantType; + + @Column + @NotNull + private ParticipantState participantState; + + @Column + @NotNull + private ParticipantHealthStatus healthStatus; + + @Column + private String description; + + /** + * The Default Constructor creates a {@link JpaParticipant} object with a null key. + */ + public JpaParticipant() { + this(new PfConceptKey()); + } + + /** + * The Key Constructor creates a {@link JpaParticipant} object with the given concept key. + * + * @param key the key + */ + public JpaParticipant(@NonNull final PfConceptKey key) { + this(key, new PfConceptKey(), ParticipantState.PASSIVE, ParticipantHealthStatus.UNKNOWN); + } + + /** + * The Key Constructor creates a {@link JpaParticipant} object with all mandatory fields. + * + * @param key the key + * @param definition the TOSCA definition of the participant + * @param participantState the state of the participant + * @param healthStatus the health state of the participant + */ + public JpaParticipant(@NonNull final PfConceptKey key, @NonNull final PfConceptKey definition, + @NonNull final ParticipantState participantState, @NonNull ParticipantHealthStatus healthStatus) { + this.key = key; + this.definition = definition; + this.participantState = participantState; + this.healthStatus = healthStatus; + } + + /** + * Copy constructor. + * + * @param copyConcept the concept to copy from + */ + public JpaParticipant(@NonNull final JpaParticipant copyConcept) { + super(copyConcept); + this.key = new PfConceptKey(copyConcept.key); + this.definition = new PfConceptKey(copyConcept.definition); + this.participantState = copyConcept.participantState; + this.healthStatus = copyConcept.healthStatus; + this.description = copyConcept.description; + this.participantType = copyConcept.participantType; + } + + /** + * Authorative constructor. + * + * @param authorativeConcept the authorative concept to copy from + */ + public JpaParticipant(@NonNull final Participant authorativeConcept) { + this.fromAuthorative(authorativeConcept); + } + + @Override + public Participant toAuthorative() { + var participant = new Participant(); + + participant.setName(key.getName()); + participant.setVersion(key.getVersion()); + participant.setDefinition(new ToscaConceptIdentifier(definition)); + participant.setParticipantState(participantState); + participant.setHealthStatus(healthStatus); + participant.setDescription(description); + participant.setParticipantType(new ToscaConceptIdentifier(participantType)); + + return participant; + } + + @Override + public void fromAuthorative(@NonNull final Participant participant) { + if (this.key == null || this.getKey().isNullKey()) { + this.setKey(new PfConceptKey(participant.getName(), participant.getVersion())); + } + + this.definition = participant.getDefinition().asConceptKey(); + this.setParticipantState(participant.getParticipantState()); + this.setHealthStatus(participant.getHealthStatus()); + this.setDescription(participant.getDescription()); + this.participantType = participant.getParticipantType().asConceptKey(); + } + + @Override + public List getKeys() { + List keyList = getKey().getKeys(); + + keyList.add(definition); + keyList.add(participantType); + + return keyList; + } + + @Override + public void clean() { + key.clean(); + definition.clean(); + description = (description == null ? null : description.trim()); + participantType.clean(); + } + + @Override + public int compareTo(final PfConcept otherConcept) { + if (otherConcept == null) { + return -1; + } + if (this == otherConcept) { + return 0; + } + if (getClass() != otherConcept.getClass()) { + return getClass().getName().compareTo(otherConcept.getClass().getName()); + } + + final JpaParticipant other = (JpaParticipant) otherConcept; + int result = key.compareTo(other.key); + if (result != 0) { + return result; + } + + result = definition.compareTo(other.definition); + if (result != 0) { + return result; + } + + result = ObjectUtils.compare(participantState, other.participantState); + if (result != 0) { + return result; + } + + result = ObjectUtils.compare(healthStatus, other.healthStatus); + if (result != 0) { + return result; + } + + result = ObjectUtils.compare(participantType, other.participantType); + if (result != 0) { + return result; + } + + return ObjectUtils.compare(description, other.description); + } +} diff --git a/models/src/main/java/org/onap/policy/clamp/models/acm/persistence/concepts/JpaParticipantStatistics.java b/models/src/main/java/org/onap/policy/clamp/models/acm/persistence/concepts/JpaParticipantStatistics.java new file mode 100644 index 000000000..a076433bb --- /dev/null +++ b/models/src/main/java/org/onap/policy/clamp/models/acm/persistence/concepts/JpaParticipantStatistics.java @@ -0,0 +1,239 @@ +/*- + * ============LICENSE_START======================================================= + * Copyright (C) 2021 Nordix Foundation. + * ================================================================================ + * Modifications Copyright (C) 2021 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * SPDX-License-Identifier: Apache-2.0 + * ============LICENSE_END========================================================= + */ + + +package org.onap.policy.clamp.models.acm.persistence.concepts; + +import java.io.Serializable; +import java.util.List; +import javax.persistence.AttributeOverride; +import javax.persistence.Column; +import javax.persistence.EmbeddedId; +import javax.persistence.Entity; +import javax.persistence.Inheritance; +import javax.persistence.InheritanceType; +import javax.persistence.Table; +import lombok.AllArgsConstructor; +import lombok.Data; +import lombok.EqualsAndHashCode; +import lombok.NonNull; +import org.apache.commons.lang3.builder.CompareToBuilder; +import org.onap.policy.clamp.models.acm.concepts.ParticipantHealthStatus; +import org.onap.policy.clamp.models.acm.concepts.ParticipantState; +import org.onap.policy.clamp.models.acm.concepts.ParticipantStatistics; +import org.onap.policy.common.parameters.annotations.NotNull; +import org.onap.policy.models.base.PfAuthorative; +import org.onap.policy.models.base.PfConcept; +import org.onap.policy.models.base.PfConceptKey; +import org.onap.policy.models.base.PfKey; +import org.onap.policy.models.base.PfTimestampKey; +import org.onap.policy.models.base.validation.annotations.VerifyKey; +import org.onap.policy.models.tosca.authorative.concepts.ToscaConceptIdentifier; + +/** + * Class to represent a participant statistics in the database. + * + * @author Ramesh Murugan Iyer (ramesh.murugan.iyer@est.tech) + */ +@Entity +@Table(name = "ParticipantStatistics") +@Inheritance(strategy = InheritanceType.TABLE_PER_CLASS) +@Data +@AllArgsConstructor +@EqualsAndHashCode(callSuper = false) +public class JpaParticipantStatistics extends PfConcept implements PfAuthorative, Serializable { + + private static final long serialVersionUID = -5992214428190133190L; + + @EmbeddedId + @VerifyKey + @NotNull + private PfTimestampKey key; + + @VerifyKey + @NotNull + @AttributeOverride(name = "name", column = @Column(name = "participant_name")) + @AttributeOverride(name = "version", column = @Column(name = "participant_version")) + private PfConceptKey participantId; + + @Column + @NotNull + private ParticipantState state; + + @Column + @NotNull + private ParticipantHealthStatus healthStatus; + + @Column + private long eventCount; + + @Column + private long lastExecutionTime; + + @Column + private double averageExecutionTime; + + @Column + private long upTime; + + @Column + private long lastEnterTime; + + @Column + private long lastStart; + + + /** + * The Default Constructor creates a {@link JpaParticipantStatistics} object with a null key. + */ + public JpaParticipantStatistics() { + this(new PfTimestampKey()); + } + + /** + * The Key Constructor creates a {@link JpaParticipantStatistics} object with the given Timestamp key. + * + * @param key the key + */ + public JpaParticipantStatistics(@NonNull final PfTimestampKey key) { + this(key, new PfConceptKey(), ParticipantState.PASSIVE, ParticipantHealthStatus.HEALTHY, 0L, 0L, 0.0d, 0L, 0L, + 0L); + } + + + /** + * The Key Constructor creates a {@link JpaParticipantStatistics} object with all mandatory fields. + * + * @param key the key + * @param participantId the TOSCA definition of the participant + */ + public JpaParticipantStatistics(@NonNull final PfTimestampKey key, @NonNull final PfConceptKey participantId) { + this.key = key; + this.participantId = participantId; + } + + + /** + * Copy constructor. + * + * @param copyConcept the concept to copy from + */ + public JpaParticipantStatistics(@NonNull final JpaParticipantStatistics copyConcept) { + super(copyConcept); + this.key = new PfTimestampKey(copyConcept.key); + this.participantId = new PfConceptKey(copyConcept.participantId); + this.state = copyConcept.state; + this.healthStatus = copyConcept.healthStatus; + this.eventCount = copyConcept.eventCount; + this.lastExecutionTime = copyConcept.lastExecutionTime; + this.averageExecutionTime = copyConcept.averageExecutionTime; + this.upTime = copyConcept.upTime; + this.lastEnterTime = copyConcept.lastEnterTime; + this.lastStart = copyConcept.lastStart; + } + + /** + * Authorative constructor. + * + * @param authorativeConcept the authorative concept to copy from + */ + public JpaParticipantStatistics(@NonNull final ParticipantStatistics authorativeConcept) { + this.fromAuthorative(authorativeConcept); + } + + + @Override + public int compareTo(PfConcept otherConcept) { + if (otherConcept == null) { + return -1; + } + if (this == otherConcept) { + return 0; + } + if (getClass() != otherConcept.getClass()) { + return getClass().getName().compareTo(otherConcept.getClass().getName()); + } + + final JpaParticipantStatistics other = (JpaParticipantStatistics) otherConcept; + // @formatter:off + return new CompareToBuilder() + .append(this.key, other.key) + .append(this.participantId, other.participantId) + .append(this.state, other.state) + .append(this.healthStatus, other.healthStatus) + .append(this.eventCount, other.eventCount) + .append(this.lastExecutionTime, other.lastExecutionTime) + .append(this.averageExecutionTime, other.averageExecutionTime) + .append(this.upTime, other.upTime) + .append(this.lastEnterTime, other.lastEnterTime) + .append(this.lastStart, other.lastStart).toComparison(); + // @formatter:on + } + + @Override + public ParticipantStatistics toAuthorative() { + var participantStatistics = new ParticipantStatistics(); + participantStatistics.setTimeStamp(key.getTimeStamp().toInstant()); + participantStatistics.setParticipantId(new ToscaConceptIdentifier(participantId)); + participantStatistics.setState(state); + participantStatistics.setHealthStatus(healthStatus); + participantStatistics.setAverageExecutionTime(averageExecutionTime); + participantStatistics.setEventCount(eventCount); + participantStatistics.setLastExecutionTime(lastExecutionTime); + participantStatistics.setUpTime(upTime); + participantStatistics.setLastEnterTime(lastEnterTime); + participantStatistics.setLastStart(lastStart); + + return participantStatistics; + } + + @Override + public void fromAuthorative(@NonNull final ParticipantStatistics participantStatistics) { + if (this.key == null || this.getKey().isNullKey()) { + this.setKey(new PfTimestampKey(participantStatistics.getParticipantId().getName(), + participantStatistics.getParticipantId().getVersion(), participantStatistics.getTimeStamp())); + } + this.setParticipantId(participantStatistics.getParticipantId().asConceptKey()); + this.setState(participantStatistics.getState()); + this.setHealthStatus(participantStatistics.getHealthStatus()); + this.setAverageExecutionTime(participantStatistics.getAverageExecutionTime()); + this.setEventCount(participantStatistics.getEventCount()); + this.setLastExecutionTime(participantStatistics.getLastExecutionTime()); + this.setUpTime(participantStatistics.getUpTime()); + this.setLastEnterTime(participantStatistics.getLastEnterTime()); + this.setLastStart(participantStatistics.getLastStart()); + + } + + @Override + public List getKeys() { + List keyList = getKey().getKeys(); + keyList.addAll(participantId.getKeys()); + return keyList; + } + + @Override + public void clean() { + key.clean(); + participantId.clean(); + } +} diff --git a/models/src/main/java/org/onap/policy/clamp/models/acm/persistence/provider/AcElementStatisticsProvider.java b/models/src/main/java/org/onap/policy/clamp/models/acm/persistence/provider/AcElementStatisticsProvider.java new file mode 100644 index 000000000..59ddcc2ea --- /dev/null +++ b/models/src/main/java/org/onap/policy/clamp/models/acm/persistence/provider/AcElementStatisticsProvider.java @@ -0,0 +1,139 @@ +/*- + * ============LICENSE_START======================================================= + * Copyright (C) 2021 Nordix Foundation. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * SPDX-License-Identifier: Apache-2.0 + * ============LICENSE_END========================================================= + */ + +package org.onap.policy.clamp.models.acm.persistence.provider; + +import java.time.Instant; +import java.util.List; +import java.util.Map; +import java.util.stream.Collectors; +import javax.ws.rs.core.Response.Status; +import lombok.AllArgsConstructor; +import lombok.NonNull; +import org.onap.policy.clamp.models.acm.concepts.AcElementStatistics; +import org.onap.policy.clamp.models.acm.persistence.concepts.JpaAcElementStatistics; +import org.onap.policy.clamp.models.acm.persistence.repository.AcElementStatisticsRepository; +import org.onap.policy.models.base.PfModelException; +import org.onap.policy.models.base.PfReferenceTimestampKey; +import org.onap.policy.models.dao.PfFilterParameters; +import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; + +/** + * This class provides the provision of information on automation composition element statistics in the database to + * callers. + * + * @author Ramesh Murugan Iyer (ramesh.murugan.iyer@est.tech) + */ +@Service +@Transactional +@AllArgsConstructor +public class AcElementStatisticsProvider { + + private AcElementStatisticsRepository acElementStatisticsRepository; + + /** + * Creates automation composition element statistics. + * + * @param acElementStatisticsList a specification of the statistics to create + * @return the Element statistics created + * @throws PfModelException on initiation errors + */ + public List createAcElementStatistics( + @NonNull final List acElementStatisticsList) throws PfModelException { + + try { + var jpaAcElementStatisticsList = ProviderUtils.getJpaAndValidateList(acElementStatisticsList, + JpaAcElementStatistics::new, "automation composition element statistics"); + + var jpaAcElementStatisticsSaved = acElementStatisticsRepository.saveAll(jpaAcElementStatisticsList); + + // Return the saved automation composition element statistics + return asAcElementStatisticsList(jpaAcElementStatisticsSaved); + } catch (IllegalArgumentException e) { + throw new PfModelException(Status.BAD_REQUEST, "Error in save automation composition element statistics", + e); + } + } + + /** + * Convert JPA acElement statistics list to acElement statistics list. + * + * @param jpaAcElementStatistics the list to convert + * @return the acElement statistics list + */ + private List asAcElementStatisticsList(List jpaAcElementStatistics) { + return jpaAcElementStatistics.stream().map(JpaAcElementStatistics::toAuthorative).collect(Collectors.toList()); + } + + /** + * Get acElement statistics. + * + * @param name the name of the participant + * @param version version of the participant + * @param id of the automation composition element + * @param timestamp timestamp of the statistics + * @return the acElement statistics found + */ + @Transactional(readOnly = true) + public List getAcElementStatistics(final String name, final String version, final String id, + final Instant timestamp) { + if (name != null && version != null && timestamp != null && id != null) { + return asAcElementStatisticsList(acElementStatisticsRepository + .findAllById(List.of(new PfReferenceTimestampKey(name, version, id, timestamp)))); + } else if (name != null) { + return getFilteredAcElementStatistics(name, version, null, null, null, "DESC", 0); + } + return asAcElementStatisticsList(acElementStatisticsRepository.findAll()); + } + + /** + * Get filtered acElement statistics. + * + * @param name the acElement name for the statistics to get + * @param version the acElement version for the statistics to get + * @param startTimeStamp startTimeStamp to filter statistics + * @param endTimeStamp endTimeStamp to filter statistics + * @param sortOrder sortOrder to query database + * @param getRecordNum Total query count from database + * @param filterMap the filters to apply to the get operation + * @return the acElement statistics found + */ + @Transactional(readOnly = true) + public List getFilteredAcElementStatistics(final String name, final String version, + final Instant startTimeStamp, final Instant endTimeStamp, Map filterMap, final String sortOrder, + final int getRecordNum) { + + // @formatter:off + PfFilterParameters filterParams = PfFilterParameters + .builder() + .name(name) + .version(version) + .startTime(startTimeStamp) + .endTime(endTimeStamp) + .filterMap(filterMap) + .sortOrder(sortOrder) + .recordNum(getRecordNum) + .build(); + // @formatter:on + return asAcElementStatisticsList( + acElementStatisticsRepository.getFiltered(JpaAcElementStatistics.class, filterParams)); + } +} diff --git a/models/src/main/java/org/onap/policy/clamp/models/acm/persistence/provider/AutomationCompositionProvider.java b/models/src/main/java/org/onap/policy/clamp/models/acm/persistence/provider/AutomationCompositionProvider.java new file mode 100644 index 000000000..760613026 --- /dev/null +++ b/models/src/main/java/org/onap/policy/clamp/models/acm/persistence/provider/AutomationCompositionProvider.java @@ -0,0 +1,287 @@ +/*- + * ============LICENSE_START======================================================= + * Copyright (C) 2021 Nordix Foundation. + * ================================================================================ + * Modifications Copyright (C) 2021 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * SPDX-License-Identifier: Apache-2.0 + * ============LICENSE_END========================================================= + */ + +package org.onap.policy.clamp.models.acm.persistence.provider; + +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.Optional; +import javax.persistence.EntityNotFoundException; +import javax.ws.rs.core.Response; +import javax.ws.rs.core.Response.Status; +import lombok.AllArgsConstructor; +import lombok.NonNull; +import org.onap.policy.clamp.models.acm.concepts.AutomationComposition; +import org.onap.policy.clamp.models.acm.persistence.concepts.JpaAutomationComposition; +import org.onap.policy.clamp.models.acm.persistence.repository.AutomationCompositionRepository; +import org.onap.policy.clamp.models.acm.persistence.repository.ToscaNodeTemplateRepository; +import org.onap.policy.clamp.models.acm.persistence.repository.ToscaNodeTemplatesRepository; +import org.onap.policy.models.base.PfConceptKey; +import org.onap.policy.models.base.PfModelException; +import org.onap.policy.models.tosca.authorative.concepts.ToscaConceptIdentifier; +import org.onap.policy.models.tosca.authorative.concepts.ToscaNodeTemplate; +import org.onap.policy.models.tosca.authorative.concepts.ToscaServiceTemplate; +import org.onap.policy.models.tosca.authorative.concepts.ToscaTypedEntityFilter; +import org.onap.policy.models.tosca.simple.concepts.JpaToscaNodeTemplate; +import org.onap.policy.models.tosca.simple.concepts.JpaToscaNodeTemplates; +import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; + +/** + * This class provides information on automation composition concepts in the database to callers. + */ +@Service +@Transactional +@AllArgsConstructor +public class AutomationCompositionProvider { + + private final AutomationCompositionRepository automationCompositionRepository; + private final ToscaNodeTemplateRepository toscaNodeTemplateRepository; + private final ToscaNodeTemplatesRepository toscaNodeTemplatesRepository; + + /** + * Get automation composition. + * + * @param automationCompositionId the ID of the automation composition to get + * @return the automation composition found + * @throws PfModelException on errors getting the automation composition + */ + @Transactional(readOnly = true) + public AutomationComposition getAutomationComposition(final ToscaConceptIdentifier automationCompositionId) + throws PfModelException { + try { + return automationCompositionRepository.getById(automationCompositionId.asConceptKey()).toAuthorative(); + } catch (EntityNotFoundException e) { + throw new PfModelException(Status.NOT_FOUND, "AutomationComposition not found", e); + } + } + + /** + * Find automation composition by automationCompositionId. + * + * @param name the name of the automation composition to get, null to get all automation compositions + * @param version the version of the automation composition to get, null to get all automation compositions + * @return the automation composition found + * @throws PfModelException on errors getting the automation composition + */ + @Transactional(readOnly = true) + public Optional findAutomationComposition(@NonNull final String name, + @NonNull final String version) throws PfModelException { + return findAutomationComposition(new PfConceptKey(name, version)); + } + + /** + * Find automation composition by automationCompositionId. + * + * @param automationCompositionId the ID of the automation composition to get + * @return the automation composition found + * @throws PfModelException on errors getting the automation composition + */ + @Transactional(readOnly = true) + public Optional findAutomationComposition( + final ToscaConceptIdentifier automationCompositionId) throws PfModelException { + return findAutomationComposition(automationCompositionId.asConceptKey()); + } + + private Optional findAutomationComposition(@NonNull final PfConceptKey key) + throws PfModelException { + try { + return automationCompositionRepository.findById(key).map(JpaAutomationComposition::toAuthorative); + } catch (IllegalArgumentException e) { + throw new PfModelException(Status.BAD_REQUEST, "Not valid parameter", e); + } + } + + /** + * Save automation composition. + * + * @param automationComposition the automation composition to update + * @return the updated automation composition + * @throws PfModelException on errors updating the automation composition + */ + public AutomationComposition saveAutomationComposition(final AutomationComposition automationComposition) + throws PfModelException { + try { + var result = automationCompositionRepository.save(ProviderUtils.getJpaAndValidate(automationComposition, + JpaAutomationComposition::new, "automation composition")); + + // Return the saved participant + return result.toAuthorative(); + } catch (IllegalArgumentException e) { + throw new PfModelException(Status.BAD_REQUEST, "Error in save automationComposition", e); + } + } + + /** + * Get all automation compositions. + * + * @return all automation compositions found + * @throws PfModelException on errors getting automation compositions + */ + @Transactional(readOnly = true) + public List getAutomationCompositions() throws PfModelException { + + return ProviderUtils.asEntityList(automationCompositionRepository.findAll()); + } + + /** + * Get automation compositions. + * + * @param name the name of the automation composition to get, null to get all automation compositions + * @param version the version of the automation composition to get, null to get all automation compositions + * @return the automation compositions found + * @throws PfModelException on errors getting automation compositions + */ + @Transactional(readOnly = true) + public List getAutomationCompositions(final String name, final String version) + throws PfModelException { + + return ProviderUtils + .asEntityList(automationCompositionRepository.getFiltered(JpaAutomationComposition.class, name, version)); + } + + /** + * Saves automation compositions. + * + * @param automationCompositions a specification of the automation compositions to create + * @return the automation compositions created + * @throws PfModelException on errors creating automation compositions + */ + public List saveAutomationCompositions( + @NonNull final List automationCompositions) throws PfModelException { + try { + var result = + automationCompositionRepository.saveAll(ProviderUtils.getJpaAndValidateList(automationCompositions, + JpaAutomationComposition::new, "automation compositions")); + + // Return the saved participant + return ProviderUtils.asEntityList(result); + } catch (IllegalArgumentException e) { + throw new PfModelException(Status.BAD_REQUEST, "Error in save AutomationCompositions", e); + } + } + + /** + * Saves Instance Properties to the database. + * + * @param serviceTemplate the service template + * @return a Map of tosca node templates + */ + public Map saveInstanceProperties(ToscaServiceTemplate serviceTemplate) { + Map savedNodeTemplates = new HashMap<>(); + + var jpaToscaNodeTemplates = new JpaToscaNodeTemplates(); + jpaToscaNodeTemplates.fromAuthorative(List.of(serviceTemplate.getToscaTopologyTemplate().getNodeTemplates())); + + toscaNodeTemplatesRepository.save(jpaToscaNodeTemplates); + serviceTemplate.getToscaTopologyTemplate().getNodeTemplates().forEach(savedNodeTemplates::put); + + return savedNodeTemplates; + } + + /** + * Delete a automation composition. + * + * @param name the name of the automation composition to delete + * @param version the version of the automation composition to delete + * @return the automation composition deleted + * @throws PfModelException on errors deleting the automation composition + */ + public AutomationComposition deleteAutomationComposition(@NonNull final String name, @NonNull final String version) + throws PfModelException { + + var automationCompositionKey = new PfConceptKey(name, version); + var jpaDeleteAutomationComposition = automationCompositionRepository.findById(automationCompositionKey); + + if (jpaDeleteAutomationComposition.isEmpty()) { + String errorMessage = "delete of automation composition \"" + automationCompositionKey.getId() + + "\" failed, automation composition does not exist"; + throw new PfModelException(Response.Status.BAD_REQUEST, errorMessage); + } + + automationCompositionRepository.deleteById(automationCompositionKey); + + return jpaDeleteAutomationComposition.get().toAuthorative(); + } + + /** + * Deletes Instance Properties on the database. + * + * @param filteredToscaNodeTemplateMap filtered node templates map to delete + * @param filteredToscaNodeTemplateList filtered node template list to delete + */ + public void deleteInstanceProperties(Map filteredToscaNodeTemplateMap, + List filteredToscaNodeTemplateList) { + + var jpaToscaNodeTemplates = new JpaToscaNodeTemplates(); + jpaToscaNodeTemplates.fromAuthorative(List.of(filteredToscaNodeTemplateMap)); + + toscaNodeTemplatesRepository.save(jpaToscaNodeTemplates); + + filteredToscaNodeTemplateList.forEach(template -> { + var jpaToscaNodeTemplate = new JpaToscaNodeTemplate(template); + + toscaNodeTemplateRepository.delete(jpaToscaNodeTemplate); + }); + } + + /** + * Get All Node Templates. + * + * @return the list of node templates found + * @throws PfModelException on errors getting node templates + */ + @Transactional(readOnly = true) + public List getAllNodeTemplates() { + return ProviderUtils.asEntityList(toscaNodeTemplateRepository.findAll()); + } + + /** + * Get Node Templates. + * + * @param name the name of the node template to get, null to get all node templates + * @param version the version of the node template to get, null to get all node templates + * @return the node templates found + * @throws PfModelException on errors getting node templates + */ + @Transactional(readOnly = true) + public List getNodeTemplates(final String name, final String version) { + return ProviderUtils + .asEntityList(toscaNodeTemplateRepository.getFiltered(JpaToscaNodeTemplate.class, name, version)); + } + + /** + * Get filtered node templates. + * + * @param filter the filter for the node templates to get + * @return the node templates found + * @throws PfModelException on errors getting node templates + */ + @Transactional(readOnly = true) + public List getFilteredNodeTemplates( + @NonNull final ToscaTypedEntityFilter filter) { + + return filter.filter(ProviderUtils.asEntityList(toscaNodeTemplateRepository + .getFiltered(JpaToscaNodeTemplate.class, filter.getName(), filter.getVersion()))); + } +} diff --git a/models/src/main/java/org/onap/policy/clamp/models/acm/persistence/provider/ParticipantProvider.java b/models/src/main/java/org/onap/policy/clamp/models/acm/persistence/provider/ParticipantProvider.java new file mode 100644 index 000000000..1f9e07f8e --- /dev/null +++ b/models/src/main/java/org/onap/policy/clamp/models/acm/persistence/provider/ParticipantProvider.java @@ -0,0 +1,152 @@ +/*- + * ============LICENSE_START======================================================= + * Copyright (C) 2021 Nordix Foundation. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * SPDX-License-Identifier: Apache-2.0 + * ============LICENSE_END========================================================= + */ + +package org.onap.policy.clamp.models.acm.persistence.provider; + +import java.util.List; +import java.util.Optional; +import javax.ws.rs.core.Response.Status; +import lombok.AllArgsConstructor; +import lombok.NonNull; +import org.onap.policy.clamp.models.acm.concepts.Participant; +import org.onap.policy.clamp.models.acm.persistence.concepts.JpaParticipant; +import org.onap.policy.clamp.models.acm.persistence.repository.ParticipantRepository; +import org.onap.policy.models.base.PfConceptKey; +import org.onap.policy.models.base.PfModelException; +import org.onap.policy.models.base.PfModelRuntimeException; +import org.onap.policy.models.tosca.authorative.concepts.ToscaTypedEntityFilter; +import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; + +/** + * This class provides information on participant concepts in the database to callers. + */ +@Service +@Transactional +@AllArgsConstructor +public class ParticipantProvider { + + private ParticipantRepository participantRepository; + + /** + * Get participants. + * + * @param name the name of the participant to get, null to get all participants + * @param version the version of the participant to get, null to get all participants + * @return the participants found + * @throws PfModelException on errors getting participants + */ + @Transactional(readOnly = true) + public List getParticipants(final String name, final String version) throws PfModelException { + + return ProviderUtils.asEntityList(participantRepository.getFiltered(JpaParticipant.class, name, version)); + } + + /** + * Get all participants. + * + * @return the participants found + * @throws PfModelException on errors getting policies + */ + @Transactional(readOnly = true) + public List getParticipants() throws PfModelException { + return ProviderUtils.asEntityList(participantRepository.findAll()); + } + + /** + * Get participant. + * + * @param name the name of the participant to get + * @param version the version of the participant to get + * @return the participant found + * @throws PfModelException on errors getting participant + */ + @Transactional(readOnly = true) + public Optional findParticipant(@NonNull final String name, @NonNull final String version) + throws PfModelException { + try { + return participantRepository.findById(new PfConceptKey(name, version)).map(JpaParticipant::toAuthorative); + } catch (IllegalArgumentException e) { + throw new PfModelException(Status.BAD_REQUEST, "Error in find Participant", e); + } + } + + /** + * Get filtered participants. + * + * @param filter the filter for the participants to get + * @return the participants found + * @throws PfModelException on errors getting policies + */ + @Transactional(readOnly = true) + public List getFilteredParticipants(@NonNull final ToscaTypedEntityFilter filter) + throws PfModelException { + + return filter.filter(ProviderUtils.asEntityList( + participantRepository.getFiltered(JpaParticipant.class, filter.getName(), filter.getVersion()))); + } + + /** + * Saves participant. + * + * @param participant participant to save + * @return the participant created + * @throws PfModelException on errors creating participants + */ + public Participant saveParticipant(@NonNull final Participant participant) throws PfModelException { + try { + var result = participantRepository + .save(ProviderUtils.getJpaAndValidate(participant, JpaParticipant::new, "participant")); + + // Return the saved participant + return result.toAuthorative(); + } catch (IllegalArgumentException e) { + throw new PfModelException(Status.BAD_REQUEST, "Error in save Participant", e); + } + } + + /** + * Delete a participant. + * + * @param name the name of the participant to delete + * @param version the version of the participant to get + * @return the participant deleted + * @throws PfModelRuntimeException on errors deleting participants + */ + public Participant deleteParticipant(@NonNull final String name, @NonNull final String version) + throws PfModelException { + try { + var participantKey = new PfConceptKey(name, version); + + var jpaDeleteParticipantOpt = participantRepository.findById(participantKey); + + if (jpaDeleteParticipantOpt.isEmpty()) { + String errorMessage = + "delete of participant \"" + participantKey.getId() + "\" failed, participant does not exist"; + throw new PfModelRuntimeException(Status.BAD_REQUEST, errorMessage); + } + participantRepository.delete(jpaDeleteParticipantOpt.get()); + + return jpaDeleteParticipantOpt.get().toAuthorative(); + } catch (IllegalArgumentException e) { + throw new PfModelException(Status.BAD_REQUEST, "Error in delete Participant", e); + } + } +} diff --git a/models/src/main/java/org/onap/policy/clamp/models/acm/persistence/provider/ParticipantStatisticsProvider.java b/models/src/main/java/org/onap/policy/clamp/models/acm/persistence/provider/ParticipantStatisticsProvider.java new file mode 100644 index 000000000..a5a0ce176 --- /dev/null +++ b/models/src/main/java/org/onap/policy/clamp/models/acm/persistence/provider/ParticipantStatisticsProvider.java @@ -0,0 +1,138 @@ +/*- + * ============LICENSE_START======================================================= + * Copyright (C) 2021 Nordix Foundation. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * SPDX-License-Identifier: Apache-2.0 + * ============LICENSE_END========================================================= + */ + +package org.onap.policy.clamp.models.acm.persistence.provider; + +import java.time.Instant; +import java.util.List; +import java.util.Map; +import java.util.stream.Collectors; +import javax.ws.rs.core.Response.Status; +import lombok.AllArgsConstructor; +import lombok.NonNull; +import org.onap.policy.clamp.models.acm.concepts.ParticipantStatistics; +import org.onap.policy.clamp.models.acm.persistence.concepts.JpaParticipantStatistics; +import org.onap.policy.clamp.models.acm.persistence.repository.ParticipantStatisticsRepository; +import org.onap.policy.models.base.PfModelException; +import org.onap.policy.models.base.PfTimestampKey; +import org.onap.policy.models.dao.PfFilterParameters; +import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; + +/** + * This class provides the provision of information on participant statistics in the database to callers. + */ +@Service +@Transactional +@AllArgsConstructor +public class ParticipantStatisticsProvider { + + private ParticipantStatisticsRepository participantStatisticsRepository; + + /** + * Get Participant statistics. + * + * @param name the name of the participant statistics to get, null to get all stats + * @param version the version of the participant statistics to get, null to get all stats for a name + * @param timestamp the time stamp for the stats to get + * @return the participant statistics found + */ + @Transactional(readOnly = true) + public List getParticipantStatistics(final String name, final String version, + final Instant timestamp) { + if (name != null && version != null && timestamp != null) { + return asParticipantStatisticsList( + participantStatisticsRepository.findAllById(List.of(new PfTimestampKey(name, version, timestamp)))); + } else if (name != null) { + return getFilteredParticipantStatistics(name, version, timestamp, null, null, "DESC", 0); + } + return asParticipantStatisticsList(participantStatisticsRepository.findAll()); + } + + /** + * Get filtered participant statistics. + * + * @param name the participant name for the statistics to get + * @param version the participant version for the statistics to get + * @param startTimeStamp startTimeStamp to filter statistics + * @param endTimeStamp endTimeStamp to filter statistics + * @param sortOrder sortOrder to query database + * @param getRecordNum Total query count from database + * @param filterMap the filters to apply to the get operation + * @return the participant statistics found + */ + @Transactional(readOnly = true) + public List getFilteredParticipantStatistics(final String name, final String version, + final Instant startTimeStamp, final Instant endTimeStamp, Map filterMap, + final String sortOrder, final int getRecordNum) { + + // @formatter:off + PfFilterParameters filterParams = PfFilterParameters + .builder() + .name(name) + .version(version) + .startTime(startTimeStamp) + .endTime(endTimeStamp) + .filterMap(filterMap) + .sortOrder(sortOrder) + .recordNum(getRecordNum) + .build(); + // @formatter:on + + return asParticipantStatisticsList( + participantStatisticsRepository.getFiltered(JpaParticipantStatistics.class, filterParams)); + } + + /** + * Creates Participant statistics. + * + * @param participantStatisticsList a specification of the statistics to create + * @return the participant statistics created + * @throws PfModelException on errors creating participant statistics + */ + public List createParticipantStatistics( + @NonNull final List participantStatisticsList) throws PfModelException { + + try { + var jpaParticipantStatisticsList = ProviderUtils.getJpaAndValidateList(participantStatisticsList, + JpaParticipantStatistics::new, "Participant Statistics"); + + var jpaParticipantStatisticsSaved = participantStatisticsRepository.saveAll(jpaParticipantStatisticsList); + + // Return the saved participant statistics + return asParticipantStatisticsList(jpaParticipantStatisticsSaved); + } catch (IllegalArgumentException e) { + throw new PfModelException(Status.BAD_REQUEST, "Error in save participant statistics", e); + } + } + + /** + * Convert JPA participant statistics list to participant statistics list. + * + * @param jpaParticipantStatisticsList the list to convert + * @return the participant statistics list + */ + private List asParticipantStatisticsList( + List jpaParticipantStatisticsList) { + + return jpaParticipantStatisticsList.stream().map(JpaParticipantStatistics::toAuthorative) + .collect(Collectors.toList()); + } +} diff --git a/models/src/main/java/org/onap/policy/clamp/models/acm/persistence/provider/ProviderUtils.java b/models/src/main/java/org/onap/policy/clamp/models/acm/persistence/provider/ProviderUtils.java new file mode 100644 index 000000000..9510e5919 --- /dev/null +++ b/models/src/main/java/org/onap/policy/clamp/models/acm/persistence/provider/ProviderUtils.java @@ -0,0 +1,93 @@ +/*- + * ============LICENSE_START======================================================= + * Copyright (C) 2021 Nordix Foundation. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * SPDX-License-Identifier: Apache-2.0 + * ============LICENSE_END========================================================= + */ + +package org.onap.policy.clamp.models.acm.persistence.provider; + +import java.util.ArrayList; +import java.util.List; +import java.util.function.Supplier; +import java.util.stream.Collectors; +import javax.ws.rs.core.Response; +import lombok.AccessLevel; +import lombok.NoArgsConstructor; +import org.onap.policy.common.parameters.BeanValidationResult; +import org.onap.policy.models.base.PfAuthorative; +import org.onap.policy.models.base.PfConcept; +import org.onap.policy.models.base.PfModelRuntimeException; +import org.onap.policy.models.tosca.authorative.concepts.ToscaEntity; + +@NoArgsConstructor(access = AccessLevel.PRIVATE) +public final class ProviderUtils { + + /** + * Convert a list of concepts to a list of Jpa objects. + * + * @param authorativeConceptList the list of concepts + * @param jpaSupplier the Jpa Supplier + * @param conceptDescription the description used for validation result + * @return the list of Jpa objects + */ + public static > List getJpaAndValidateList( + List authorativeConceptList, Supplier jpaSupplier, String conceptDescription) { + var validationResult = new BeanValidationResult(conceptDescription + " List", authorativeConceptList); + + List jpaConceptList = new ArrayList<>(authorativeConceptList.size()); + + for (A authorativeConcept : authorativeConceptList) { + var jpaConcept = jpaSupplier.get(); + jpaConcept.fromAuthorative(authorativeConcept); + jpaConceptList.add(jpaConcept); + + validationResult.addResult(jpaConcept.validate(conceptDescription)); + } + + if (!validationResult.isValid()) { + throw new PfModelRuntimeException(Response.Status.BAD_REQUEST, validationResult.getResult()); + } + return jpaConceptList; + } + + protected static > J getJpaAndValidate(A authorativeConcept, + Supplier jpaSupplier, String conceptDescription) { + var validationResult = new BeanValidationResult(conceptDescription, authorativeConcept); + + var jpaConcept = jpaSupplier.get(); + jpaConcept.fromAuthorative(authorativeConcept); + + validationResult.addResult(jpaConcept.validate(conceptDescription)); + + if (!validationResult.isValid()) { + throw new PfModelRuntimeException(Response.Status.BAD_REQUEST, validationResult.getResult()); + } + return jpaConcept; + } + + /** + * Convert JPA automation composition list to an authorative automation composition list. + * + * @param the type of TOSCA entity + * @param the type of JPA TOSCA entity + * @param jpaEntityList the list to convert + * @return the authorative list + */ + public static > List asEntityList(List jpaEntityList) { + return jpaEntityList.stream().map(J::toAuthorative).collect(Collectors.toList()); + } +} diff --git a/models/src/main/java/org/onap/policy/clamp/models/acm/persistence/provider/ServiceTemplateProvider.java b/models/src/main/java/org/onap/policy/clamp/models/acm/persistence/provider/ServiceTemplateProvider.java new file mode 100644 index 000000000..0de5f480a --- /dev/null +++ b/models/src/main/java/org/onap/policy/clamp/models/acm/persistence/provider/ServiceTemplateProvider.java @@ -0,0 +1,261 @@ +/*- + * ============LICENSE_START======================================================= + * Copyright (C) 2021 Nordix Foundation. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * SPDX-License-Identifier: Apache-2.0 + * ============LICENSE_END========================================================= + */ + +package org.onap.policy.clamp.models.acm.persistence.provider; + +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import javax.ws.rs.core.Response; +import javax.ws.rs.core.Response.Status; +import lombok.RequiredArgsConstructor; +import org.onap.policy.clamp.models.acm.persistence.repository.ToscaServiceTemplateRepository; +import org.onap.policy.models.base.PfConceptKey; +import org.onap.policy.models.base.PfModelException; +import org.onap.policy.models.tosca.authorative.concepts.ToscaNodeTemplate; +import org.onap.policy.models.tosca.authorative.concepts.ToscaNodeType; +import org.onap.policy.models.tosca.authorative.concepts.ToscaProperty; +import org.onap.policy.models.tosca.authorative.concepts.ToscaServiceTemplate; +import org.onap.policy.models.tosca.simple.concepts.JpaToscaServiceTemplate; +import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; + +@Service +@Transactional +@RequiredArgsConstructor +public class ServiceTemplateProvider { + + private final ToscaServiceTemplateRepository serviceTemplateRepository; + + /** + * Create service template. + * + * @param serviceTemplate the service template to be created + * @return the created service template + * @throws PfModelException on errors creating the service template + */ + public ToscaServiceTemplate createServiceTemplate(final ToscaServiceTemplate serviceTemplate) + throws PfModelException { + try { + var result = serviceTemplateRepository.save(ProviderUtils.getJpaAndValidate(serviceTemplate, + JpaToscaServiceTemplate::new, "toscaServiceTemplate")); + return result.toAuthorative(); + } catch (IllegalArgumentException e) { + throw new PfModelException(Status.BAD_REQUEST, "Error in save serviceTemplate", e); + } + } + + /** + * Delete service template. + * + * @param name the name of the service template to delete. + * @param version the version of the service template to delete. + * @return the TOSCA service template that was deleted + * @throws PfModelException on errors deleting policy types + */ + public ToscaServiceTemplate deleteServiceTemplate(final String name, final String version) throws PfModelException { + var serviceTemplateKey = new PfConceptKey(name, version); + var jpaDelete = serviceTemplateRepository.findById(serviceTemplateKey); + if (jpaDelete.isEmpty()) { + String errorMessage = "delete of serviceTemplate \"" + serviceTemplateKey.getId() + + "\" failed, serviceTemplate does not exist"; + throw new PfModelException(Response.Status.BAD_REQUEST, errorMessage); + } + serviceTemplateRepository.deleteById(serviceTemplateKey); + return jpaDelete.get().toAuthorative(); + } + + /** + * Get the requested automation composition definitions. + * + * @param name the name of the definition to get, null for all definitions + * @param version the version of the definition to get, null for all definitions + * @return the automation composition definitions + * @throws PfModelException on errors getting automation composition definitions + */ + @Transactional(readOnly = true) + public ToscaServiceTemplate getToscaServiceTemplate(String name, String version) throws PfModelException { + var serviceTemplateKey = new PfConceptKey(name, version); + var jpaServiceTemplates = serviceTemplateRepository.findById(serviceTemplateKey); + if (jpaServiceTemplates.isEmpty()) { + throw new PfModelException(Status.NOT_FOUND, "Automation composition definitions not found"); + } + return jpaServiceTemplates.get().toAuthorative(); + } + + /** + * Get service templates. + * + * @return the topology templates found + * @throws PfModelException on errors getting service templates + */ + @Transactional(readOnly = true) + public List getAllServiceTemplates() throws PfModelException { + var jpaList = serviceTemplateRepository.findAll(); + return ProviderUtils.asEntityList(jpaList); + } + + /** + * Get service templates. + * + * @param name the name of the topology template to get, set to null to get all service templates + * @param version the version of the service template to get, set to null to get all service templates + * @return the topology templates found + * @throws PfModelException on errors getting service templates + */ + @Transactional(readOnly = true) + public List getServiceTemplateList(final String name, final String version) + throws PfModelException { + var jpaList = serviceTemplateRepository.getFiltered(JpaToscaServiceTemplate.class, name, version); + return ProviderUtils.asEntityList(jpaList); + } + + /** + * Get the initial node types with common or instance properties. + * + * @param fullNodeTypes map of all the node types in the specified template + * @param common boolean to indicate whether common or instance properties are required + * @return node types map that only has common properties + * @throws PfModelException on errors getting node type with common properties + */ + private Map getInitialNodeTypesMap(Map fullNodeTypes, + boolean common) { + + var tempNodeTypesMap = new HashMap(); + + fullNodeTypes.forEach((key, nodeType) -> { + var tempToscaNodeType = new ToscaNodeType(); + tempToscaNodeType.setName(key); + + var resultantPropertyMap = findCommonOrInstancePropsInNodeTypes(nodeType, common); + + if (!resultantPropertyMap.isEmpty()) { + tempToscaNodeType.setProperties(resultantPropertyMap); + tempNodeTypesMap.put(key, tempToscaNodeType); + } + }); + return tempNodeTypesMap; + } + + private Map findCommonOrInstancePropsInNodeTypes(ToscaNodeType nodeType, boolean common) { + + var tempCommonPropertyMap = new HashMap(); + var tempInstancePropertyMap = new HashMap(); + + nodeType.getProperties().forEach((propKey, prop) -> { + + if (prop.getMetadata() != null) { + prop.getMetadata().forEach((k, v) -> { + if (k.equals("common") && v.equals("true") && common) { + tempCommonPropertyMap.put(propKey, prop); + } else if (k.equals("common") && v.equals("false") && !common) { + tempInstancePropertyMap.put(propKey, prop); + } + + }); + } else { + tempInstancePropertyMap.put(propKey, prop); + } + }); + + if (tempCommonPropertyMap.isEmpty() && !common) { + return tempInstancePropertyMap; + } else { + return tempCommonPropertyMap; + } + } + + /** + * Get the node types derived from those that have common properties. + * + * @param initialNodeTypes map of all the node types in the specified template + * @param filteredNodeTypes map of all the node types that have common or instance properties + * @return all node types that have common properties including their children + * @throws PfModelException on errors getting node type with common properties + */ + private Map getFinalNodeTypesMap(Map initialNodeTypes, + Map filteredNodeTypes) { + for (var i = 0; i < initialNodeTypes.size(); i++) { + initialNodeTypes.forEach((key, nodeType) -> { + var tempToscaNodeType = new ToscaNodeType(); + tempToscaNodeType.setName(key); + + if (filteredNodeTypes.get(nodeType.getDerivedFrom()) != null) { + tempToscaNodeType.setName(key); + + var finalProps = new HashMap( + filteredNodeTypes.get(nodeType.getDerivedFrom()).getProperties()); + + tempToscaNodeType.setProperties(finalProps); + } else { + return; + } + filteredNodeTypes.putIfAbsent(key, tempToscaNodeType); + + }); + } + return filteredNodeTypes; + } + + /** + * Get the requested node types with common or instance properties. + * + * @param common boolean indicating common or instance properties + * @param serviceTemplate the ToscaServiceTemplate + * @return the node types with common or instance properties + * @throws PfModelException on errors getting node type properties + */ + public Map getCommonOrInstancePropertiesFromNodeTypes(boolean common, + ToscaServiceTemplate serviceTemplate) throws PfModelException { + var tempNodeTypesMap = this.getInitialNodeTypesMap(serviceTemplate.getNodeTypes(), common); + + return this.getFinalNodeTypesMap(serviceTemplate.getNodeTypes(), tempNodeTypesMap); + + } + + /** + * Get node templates with appropriate common or instance properties added. + * + * @param initialNodeTemplates map of all the node templates in the specified template + * @param nodeTypeProps map of all the node types that have common or instance properties including children + * @return all node templates with appropriate common or instance properties added + * @throws PfModelException on errors getting map of node templates with common or instance properties added + */ + public Map getDerivedCommonOrInstanceNodeTemplates( + Map initialNodeTemplates, Map nodeTypeProps) { + + var finalNodeTemplatesMap = new HashMap(); + + initialNodeTemplates.forEach((templateKey, template) -> { + if (nodeTypeProps.containsKey(template.getType())) { + var finalMergedProps = new HashMap(); + + nodeTypeProps.get(template.getType()).getProperties().forEach(finalMergedProps::putIfAbsent); + + template.setProperties(finalMergedProps); + + finalNodeTemplatesMap.put(templateKey, template); + } else { + return; + } + }); + return finalNodeTemplatesMap; + } +} diff --git a/models/src/main/java/org/onap/policy/clamp/models/acm/persistence/repository/AcElementStatisticsRepository.java b/models/src/main/java/org/onap/policy/clamp/models/acm/persistence/repository/AcElementStatisticsRepository.java new file mode 100644 index 000000000..13001114f --- /dev/null +++ b/models/src/main/java/org/onap/policy/clamp/models/acm/persistence/repository/AcElementStatisticsRepository.java @@ -0,0 +1,32 @@ +/*- + * ============LICENSE_START======================================================= + * Copyright (C) 2021 Nordix Foundation. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * SPDX-License-Identifier: Apache-2.0 + * ============LICENSE_END========================================================= + */ + +package org.onap.policy.clamp.models.acm.persistence.repository; + +import org.onap.policy.clamp.models.acm.persistence.concepts.JpaAcElementStatistics; +import org.onap.policy.models.base.PfReferenceTimestampKey; +import org.springframework.data.jpa.repository.JpaRepository; +import org.springframework.stereotype.Repository; + +@Repository +public interface AcElementStatisticsRepository + extends JpaRepository, FilterRepository { + +} diff --git a/models/src/main/java/org/onap/policy/clamp/models/acm/persistence/repository/AutomationCompositionRepository.java b/models/src/main/java/org/onap/policy/clamp/models/acm/persistence/repository/AutomationCompositionRepository.java new file mode 100644 index 000000000..8eeb77e0d --- /dev/null +++ b/models/src/main/java/org/onap/policy/clamp/models/acm/persistence/repository/AutomationCompositionRepository.java @@ -0,0 +1,31 @@ +/*- + * ============LICENSE_START======================================================= + * Copyright (C) 2021 Nordix Foundation. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * SPDX-License-Identifier: Apache-2.0 + * ============LICENSE_END========================================================= + */ + +package org.onap.policy.clamp.models.acm.persistence.repository; + +import org.onap.policy.clamp.models.acm.persistence.concepts.JpaAutomationComposition; +import org.onap.policy.models.base.PfConceptKey; +import org.springframework.data.jpa.repository.JpaRepository; +import org.springframework.stereotype.Repository; + +@Repository +public interface AutomationCompositionRepository + extends JpaRepository, FilterRepository { +} diff --git a/models/src/main/java/org/onap/policy/clamp/models/acm/persistence/repository/FilterRepository.java b/models/src/main/java/org/onap/policy/clamp/models/acm/persistence/repository/FilterRepository.java new file mode 100644 index 000000000..cdedc5eb5 --- /dev/null +++ b/models/src/main/java/org/onap/policy/clamp/models/acm/persistence/repository/FilterRepository.java @@ -0,0 +1,53 @@ +/*- + * ============LICENSE_START======================================================= + * Copyright (C) 2021 Nordix Foundation. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * SPDX-License-Identifier: Apache-2.0 + * ============LICENSE_END========================================================= + */ + +package org.onap.policy.clamp.models.acm.persistence.repository; + +import java.util.List; +import org.onap.policy.models.base.PfConcept; +import org.onap.policy.models.dao.PfFilterParametersIntfc; + +public interface FilterRepository { + + /** + * Get an object from the database, referred to by concept key. + * + * @param the type of the object to get, a subclass of {@link PfConcept} + * @param someClass the class of the object to get, a subclass of {@link PfConcept}, if name is null, all concepts + * of type T are returned, if name is not null and version is null, all versions of that concept matching the + * name are returned. + * @param filterParams filter parameters + * @return the objects that was retrieved from the database + */ + List getFiltered(Class someClass, PfFilterParametersIntfc filterParams); + + /** + * Get an object from the database, referred to by concept key. + * + * @param the type of the object to get, a subclass of {@link PfConcept} + * @param someClass the class of the object to get, a subclass of {@link PfConcept}, if name is null, all concepts + * of type T are returned, if name is not null and version is null, all versions of that concept matching the + * name are returned. + * @param name the name of the object to get, null returns all objects + * @param version the version the object to get, null returns all objects for a specified name + * @return the objects that was retrieved from the database + */ + List getFiltered(Class someClass, String name, String version); +} diff --git a/models/src/main/java/org/onap/policy/clamp/models/acm/persistence/repository/FilterRepositoryImpl.java b/models/src/main/java/org/onap/policy/clamp/models/acm/persistence/repository/FilterRepositoryImpl.java new file mode 100644 index 000000000..d7e81d4da --- /dev/null +++ b/models/src/main/java/org/onap/policy/clamp/models/acm/persistence/repository/FilterRepositoryImpl.java @@ -0,0 +1,51 @@ +/*- + * ============LICENSE_START======================================================= + * Copyright (C) 2021 Nordix Foundation. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * SPDX-License-Identifier: Apache-2.0 + * ============LICENSE_END========================================================= + */ + +package org.onap.policy.clamp.models.acm.persistence.repository; + +import java.util.List; +import javax.persistence.EntityManager; +import javax.persistence.PersistenceContext; +import org.onap.policy.models.base.PfConcept; +import org.onap.policy.models.dao.PfDao; +import org.onap.policy.models.dao.PfFilterParametersIntfc; +import org.onap.policy.models.dao.impl.ProxyDao; +import org.springframework.stereotype.Repository; + +@Repository +public class FilterRepositoryImpl implements FilterRepository { + + @PersistenceContext + private EntityManager entityManager; + + protected PfDao getPfDao() { + return new ProxyDao(entityManager); + } + + @Override + public List getFiltered(Class someClass, PfFilterParametersIntfc filterParams) { + return getPfDao().getFiltered(someClass, filterParams); + } + + @Override + public List getFiltered(Class someClass, String name, String version) { + return getPfDao().getFiltered(someClass, name, version); + } +} diff --git a/models/src/main/java/org/onap/policy/clamp/models/acm/persistence/repository/ParticipantRepository.java b/models/src/main/java/org/onap/policy/clamp/models/acm/persistence/repository/ParticipantRepository.java new file mode 100644 index 000000000..2279a75cc --- /dev/null +++ b/models/src/main/java/org/onap/policy/clamp/models/acm/persistence/repository/ParticipantRepository.java @@ -0,0 +1,31 @@ +/*- + * ============LICENSE_START======================================================= + * Copyright (C) 2021 Nordix Foundation. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * SPDX-License-Identifier: Apache-2.0 + * ============LICENSE_END========================================================= + */ + +package org.onap.policy.clamp.models.acm.persistence.repository; + +import org.onap.policy.clamp.models.acm.persistence.concepts.JpaParticipant; +import org.onap.policy.models.base.PfConceptKey; +import org.springframework.data.jpa.repository.JpaRepository; +import org.springframework.stereotype.Repository; + +@Repository +public interface ParticipantRepository extends JpaRepository, FilterRepository { + +} diff --git a/models/src/main/java/org/onap/policy/clamp/models/acm/persistence/repository/ParticipantStatisticsRepository.java b/models/src/main/java/org/onap/policy/clamp/models/acm/persistence/repository/ParticipantStatisticsRepository.java new file mode 100644 index 000000000..9cba62a70 --- /dev/null +++ b/models/src/main/java/org/onap/policy/clamp/models/acm/persistence/repository/ParticipantStatisticsRepository.java @@ -0,0 +1,32 @@ +/*- + * ============LICENSE_START======================================================= + * Copyright (C) 2021 Nordix Foundation. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * SPDX-License-Identifier: Apache-2.0 + * ============LICENSE_END========================================================= + */ + +package org.onap.policy.clamp.models.acm.persistence.repository; + +import org.onap.policy.clamp.models.acm.persistence.concepts.JpaParticipantStatistics; +import org.onap.policy.models.base.PfTimestampKey; +import org.springframework.data.jpa.repository.JpaRepository; +import org.springframework.stereotype.Repository; + +@Repository +public interface ParticipantStatisticsRepository + extends JpaRepository, FilterRepository { + +} diff --git a/models/src/main/java/org/onap/policy/clamp/models/acm/persistence/repository/ToscaNodeTemplateRepository.java b/models/src/main/java/org/onap/policy/clamp/models/acm/persistence/repository/ToscaNodeTemplateRepository.java new file mode 100644 index 000000000..20d0f0f7e --- /dev/null +++ b/models/src/main/java/org/onap/policy/clamp/models/acm/persistence/repository/ToscaNodeTemplateRepository.java @@ -0,0 +1,30 @@ +/*- + * ============LICENSE_START======================================================= + * Copyright (C) 2021 Nordix Foundation. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * SPDX-License-Identifier: Apache-2.0 + * ============LICENSE_END========================================================= + */ + +package org.onap.policy.clamp.models.acm.persistence.repository; + +import org.onap.policy.models.base.PfConceptKey; +import org.onap.policy.models.tosca.simple.concepts.JpaToscaNodeTemplate; +import org.springframework.data.jpa.repository.JpaRepository; + +public interface ToscaNodeTemplateRepository + extends JpaRepository, FilterRepository { + +} diff --git a/models/src/main/java/org/onap/policy/clamp/models/acm/persistence/repository/ToscaNodeTemplatesRepository.java b/models/src/main/java/org/onap/policy/clamp/models/acm/persistence/repository/ToscaNodeTemplatesRepository.java new file mode 100644 index 000000000..f0ab40bf7 --- /dev/null +++ b/models/src/main/java/org/onap/policy/clamp/models/acm/persistence/repository/ToscaNodeTemplatesRepository.java @@ -0,0 +1,29 @@ +/*- + * ============LICENSE_START======================================================= + * Copyright (C) 2021 Nordix Foundation. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * SPDX-License-Identifier: Apache-2.0 + * ============LICENSE_END========================================================= + */ + +package org.onap.policy.clamp.models.acm.persistence.repository; + +import org.onap.policy.models.base.PfConceptKey; +import org.onap.policy.models.tosca.simple.concepts.JpaToscaNodeTemplates; +import org.springframework.data.jpa.repository.JpaRepository; + +public interface ToscaNodeTemplatesRepository extends JpaRepository { + +} diff --git a/models/src/main/java/org/onap/policy/clamp/models/acm/persistence/repository/ToscaServiceTemplateRepository.java b/models/src/main/java/org/onap/policy/clamp/models/acm/persistence/repository/ToscaServiceTemplateRepository.java new file mode 100644 index 000000000..b9190d0a7 --- /dev/null +++ b/models/src/main/java/org/onap/policy/clamp/models/acm/persistence/repository/ToscaServiceTemplateRepository.java @@ -0,0 +1,30 @@ +/*- + * ============LICENSE_START======================================================= + * Copyright (C) 2021 Nordix Foundation. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * SPDX-License-Identifier: Apache-2.0 + * ============LICENSE_END========================================================= + */ + +package org.onap.policy.clamp.models.acm.persistence.repository; + +import org.onap.policy.models.base.PfConceptKey; +import org.onap.policy.models.tosca.simple.concepts.JpaToscaServiceTemplate; +import org.springframework.data.jpa.repository.JpaRepository; + +public interface ToscaServiceTemplateRepository + extends JpaRepository, FilterRepository { + +} diff --git a/models/src/main/java/org/onap/policy/clamp/models/acm/rest/RestUtils.java b/models/src/main/java/org/onap/policy/clamp/models/acm/rest/RestUtils.java new file mode 100644 index 000000000..ac19d2a27 --- /dev/null +++ b/models/src/main/java/org/onap/policy/clamp/models/acm/rest/RestUtils.java @@ -0,0 +1,43 @@ +/*- + * ============LICENSE_START======================================================= + * Copyright (C) 2021 Nordix Foundation. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * SPDX-License-Identifier: Apache-2.0 + * ============LICENSE_END========================================================= + */ + +package org.onap.policy.clamp.models.acm.rest; + +import lombok.AccessLevel; +import lombok.NoArgsConstructor; +import org.onap.policy.clamp.models.acm.messages.rest.SimpleResponse; +import org.onap.policy.models.errors.concepts.ErrorResponseInfo; +import org.springframework.http.ResponseEntity; + +@NoArgsConstructor(access = AccessLevel.PRIVATE) +public final class RestUtils { + + /** + * Convert an ErrorResponseInfo to a ResponseEntity. + * + * @param ex the ErrorResponseInfo + * @return the ResponseEntity + */ + public static ResponseEntity toSimpleResponse(ErrorResponseInfo ex) { + var resp = new SimpleResponse(); + resp.setErrorDetails(ex.getErrorResponse().getErrorMessage()); + return ResponseEntity.status(ex.getErrorResponse().getResponseCode().getStatusCode()).body(resp); + } +} diff --git a/models/src/main/java/org/onap/policy/clamp/models/acm/utils/AcmUtils.java b/models/src/main/java/org/onap/policy/clamp/models/acm/utils/AcmUtils.java new file mode 100644 index 000000000..394579aa6 --- /dev/null +++ b/models/src/main/java/org/onap/policy/clamp/models/acm/utils/AcmUtils.java @@ -0,0 +1,152 @@ +/*- + * ============LICENSE_START======================================================= + * Copyright (C) 2021 Nordix Foundation. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * SPDX-License-Identifier: Apache-2.0 + * ============LICENSE_END========================================================= + */ + +package org.onap.policy.clamp.models.acm.utils; + +import java.util.ArrayList; +import java.util.List; +import java.util.Map; +import org.onap.policy.clamp.models.acm.concepts.AutomationCompositionElement; +import org.onap.policy.clamp.models.acm.concepts.AutomationCompositionElementDefinition; +import org.onap.policy.clamp.models.acm.concepts.ParticipantDefinition; +import org.onap.policy.clamp.models.acm.concepts.ParticipantUpdates; +import org.onap.policy.models.tosca.authorative.concepts.ToscaConceptIdentifier; +import org.onap.policy.models.tosca.authorative.concepts.ToscaNodeTemplate; +import org.onap.policy.models.tosca.authorative.concepts.ToscaNodeType; +import org.onap.policy.models.tosca.authorative.concepts.ToscaServiceTemplate; +import org.onap.policy.models.tosca.authorative.concepts.ToscaTopologyTemplate; + +/** + * Utility functions used in acm-runtime and participants. + * + */ +public class AcmUtils { + + private AcmUtils() { + throw new IllegalStateException("Utility class"); + } + + /** + * Prepare participant updates map. + * + * @param acElement automation composition element + * @param participantUpdates list of participantUpdates + */ + public static void prepareParticipantUpdate(AutomationCompositionElement acElement, + List participantUpdates) { + if (participantUpdates.isEmpty()) { + participantUpdates.add(getAutomationCompositionElementList(acElement)); + return; + } + + var participantExists = false; + for (ParticipantUpdates participantUpdate : participantUpdates) { + if (participantUpdate.getParticipantId().equals(acElement.getParticipantId())) { + participantUpdate.setAutomationCompositionElementList(List.of(acElement)); + participantExists = true; + } + } + if (!participantExists) { + participantUpdates.add(getAutomationCompositionElementList(acElement)); + } + } + + private static ParticipantUpdates getAutomationCompositionElementList(AutomationCompositionElement acElement) { + var participantUpdate = new ParticipantUpdates(); + participantUpdate.setParticipantId(acElement.getParticipantId()); + participantUpdate.setAutomationCompositionElementList(List.of(acElement)); + return participantUpdate; + } + + /** + * Set the Policy information in the service template for the automation composition element. + * + * @param acElement automation composition element + * @param toscaServiceTemplate ToscaServiceTemplate + */ + public static void setServiceTemplatePolicyInfo(AutomationCompositionElement acElement, + ToscaServiceTemplate toscaServiceTemplate) { + // Pass respective PolicyTypes or Policies as part of toscaServiceTemplateFragment + if (toscaServiceTemplate.getPolicyTypes() == null + && toscaServiceTemplate.getToscaTopologyTemplate().getPolicies() == null) { + return; + } + ToscaServiceTemplate toscaServiceTemplateFragment = new ToscaServiceTemplate(); + toscaServiceTemplateFragment.setPolicyTypes(toscaServiceTemplate.getPolicyTypes()); + ToscaTopologyTemplate toscaTopologyTemplate = new ToscaTopologyTemplate(); + toscaTopologyTemplate.setPolicies(toscaServiceTemplate.getToscaTopologyTemplate().getPolicies()); + toscaServiceTemplateFragment.setToscaTopologyTemplate(toscaTopologyTemplate); + toscaServiceTemplateFragment.setDataTypes(toscaServiceTemplate.getDataTypes()); + acElement.setToscaServiceTemplateFragment(toscaServiceTemplateFragment); + } + + /** + * Prepare ParticipantDefinitionUpdate to set in the message. + * + * @param acParticipantType participant type + * @param entryKey key for the entry + * @param entryValue value relates to toscaNodeTemplate + * @param participantDefinitionUpdates list of participantDefinitionUpdates + * @param commonPropertiesMap common properties map + */ + public static void prepareParticipantDefinitionUpdate(ToscaConceptIdentifier acParticipantType, String entryKey, + ToscaNodeTemplate entryValue, List participantDefinitionUpdates, + Map commonPropertiesMap) { + + var acDefinition = new AutomationCompositionElementDefinition(); + acDefinition.setAcElementDefinitionId(new ToscaConceptIdentifier(entryKey, entryValue.getVersion())); + acDefinition.setAutomationCompositionElementToscaNodeTemplate(entryValue); + if (commonPropertiesMap != null) { + ToscaNodeType nodeType = commonPropertiesMap.get(entryValue.getType()); + if (nodeType != null) { + acDefinition.setCommonPropertiesMap(nodeType.getProperties()); + } + } + + List automationCompositionElementDefinitionList = new ArrayList<>(); + + if (participantDefinitionUpdates.isEmpty()) { + participantDefinitionUpdates.add( + getParticipantDefinition(acDefinition, acParticipantType, automationCompositionElementDefinitionList)); + } else { + var participantExists = false; + for (ParticipantDefinition participantDefinitionUpdate : participantDefinitionUpdates) { + if (participantDefinitionUpdate.getParticipantType().equals(acParticipantType)) { + participantDefinitionUpdate.getAutomationCompositionElementDefinitionList().add(acDefinition); + participantExists = true; + } + } + if (!participantExists) { + participantDefinitionUpdates.add(getParticipantDefinition(acDefinition, acParticipantType, + automationCompositionElementDefinitionList)); + } + } + } + + private static ParticipantDefinition getParticipantDefinition(AutomationCompositionElementDefinition acDefinition, + ToscaConceptIdentifier acParticipantType, + List automationCompositionElementDefinitionList) { + var participantDefinition = new ParticipantDefinition(); + participantDefinition.setParticipantType(acParticipantType); + automationCompositionElementDefinitionList.add(acDefinition); + participantDefinition.setAutomationCompositionElementDefinitionList(automationCompositionElementDefinitionList); + return participantDefinition; + } +} diff --git a/models/src/test/java/org/onap/policy/clamp/controlloop/models/controlloop/concepts/ClElementStatisticsTest.java b/models/src/test/java/org/onap/policy/clamp/controlloop/models/controlloop/concepts/ClElementStatisticsTest.java deleted file mode 100644 index 3bb0050c8..000000000 --- a/models/src/test/java/org/onap/policy/clamp/controlloop/models/controlloop/concepts/ClElementStatisticsTest.java +++ /dev/null @@ -1,67 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * Copyright (C) 2021 Nordix Foundation. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - * SPDX-License-Identifier: Apache-2.0 - * ============LICENSE_END========================================================= - */ - -package org.onap.policy.clamp.controlloop.models.controlloop.concepts; - -import static org.assertj.core.api.Assertions.assertThat; -import static org.assertj.core.api.Assertions.assertThatThrownBy; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertNotEquals; -import static org.junit.Assert.assertNotNull; - -import java.time.Instant; -import java.util.UUID; -import org.junit.jupiter.api.Test; -import org.onap.policy.models.tosca.authorative.concepts.ToscaConceptIdentifier; - -class ClElementStatisticsTest { - @Test - void testClElementStatisticsLombok() { - assertNotNull(new ClElementStatistics()); - ClElementStatistics cles0 = new ClElementStatistics(); - - assertThat(cles0.toString()).contains("ClElementStatistics("); - assertThat(cles0.hashCode()).isNotZero(); - assertEquals(true, cles0.equals(cles0)); - assertEquals(false, cles0.equals(null)); - - - ClElementStatistics cles1 = new ClElementStatistics(); - cles1.setParticipantId(new ToscaConceptIdentifier("defName", "0.0.1")); - cles1.setTimeStamp(Instant.now()); - - assertThat(cles1.toString()).contains("ClElementStatistics("); - assertEquals(false, cles1.hashCode() == 0); - assertEquals(false, cles1.equals(cles0)); - assertEquals(false, cles1.equals(null)); - - assertNotEquals(cles1, cles0); - - ClElementStatistics cles2 = new ClElementStatistics(); - cles2.setId(UUID.randomUUID()); - - // @formatter:off - assertThatThrownBy(() -> cles2.setParticipantId(null)).isInstanceOf(NullPointerException.class); - assertThatThrownBy(() -> cles2.setTimeStamp(null)).isInstanceOf(NullPointerException.class); - // @formatter:on - - assertNotEquals(cles2, cles0); - } -} diff --git a/models/src/test/java/org/onap/policy/clamp/controlloop/models/controlloop/concepts/ControlLoopConceptPojosTest.java b/models/src/test/java/org/onap/policy/clamp/controlloop/models/controlloop/concepts/ControlLoopConceptPojosTest.java deleted file mode 100644 index daade4d52..000000000 --- a/models/src/test/java/org/onap/policy/clamp/controlloop/models/controlloop/concepts/ControlLoopConceptPojosTest.java +++ /dev/null @@ -1,62 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * Copyright (C) 2021 Nordix Foundation. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - * SPDX-License-Identifier: Apache-2.0 - * ============LICENSE_END========================================================= - */ - -package org.onap.policy.clamp.controlloop.models.controlloop.concepts; - -import com.openpojo.reflection.PojoClass; -import com.openpojo.reflection.impl.PojoClassFactory; -import com.openpojo.validation.Validator; -import com.openpojo.validation.ValidatorBuilder; -import com.openpojo.validation.rule.impl.EqualsAndHashCodeMatchRule; -import com.openpojo.validation.rule.impl.GetterMustExistRule; -import com.openpojo.validation.rule.impl.NoPublicFieldsExceptStaticFinalRule; -import com.openpojo.validation.rule.impl.SetterMustExistRule; -import com.openpojo.validation.test.impl.GetterTester; -import com.openpojo.validation.test.impl.SetterTester; -import java.util.List; -import org.junit.jupiter.api.Test; -import org.onap.policy.common.utils.test.ToStringTester; - -/** - * Class to perform unit tests of all pojos. - */ -class ControlLoopConceptPojosTest { - - @Test - void testPojos() { - List pojoClasses = - PojoClassFactory.getPojoClasses(ControlLoopConceptPojosTest.class.getPackageName()); - - // @formatter:off - final Validator validator = ValidatorBuilder - .create() - .with(new SetterMustExistRule()) - .with(new GetterMustExistRule()) - .with(new EqualsAndHashCodeMatchRule()) - .with(new NoPublicFieldsExceptStaticFinalRule()) - .with(new SetterTester()) - .with(new GetterTester()) - .with(new ToStringTester()) - .build(); - - validator.validate(pojoClasses); - // @formatter:on - } -} diff --git a/models/src/test/java/org/onap/policy/clamp/controlloop/models/controlloop/concepts/ControlLoopElementTest.java b/models/src/test/java/org/onap/policy/clamp/controlloop/models/controlloop/concepts/ControlLoopElementTest.java deleted file mode 100644 index ed579febb..000000000 --- a/models/src/test/java/org/onap/policy/clamp/controlloop/models/controlloop/concepts/ControlLoopElementTest.java +++ /dev/null @@ -1,103 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * Copyright (C) 2021 Nordix Foundation. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - * SPDX-License-Identifier: Apache-2.0 - * ============LICENSE_END========================================================= - */ - -package org.onap.policy.clamp.controlloop.models.controlloop.concepts; - -import static org.assertj.core.api.Assertions.assertThat; -import static org.assertj.core.api.Assertions.assertThatThrownBy; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertNotEquals; -import static org.junit.Assert.assertNotNull; -import static org.junit.Assert.assertTrue; - -import java.util.UUID; -import org.junit.jupiter.api.Test; -import org.onap.policy.models.tosca.authorative.concepts.ToscaConceptIdentifier; - -class ControlLoopElementTest { - @Test - void testControlLoopElement() { - var cle0 = new ControlLoopElement(); - var cle1 = new ControlLoopElement(cle0); - assertEquals(cle0, cle1); - - cle1.setDefinition(new ToscaConceptIdentifier("defName", "0.0.1")); - cle1.setDescription("Description"); - cle1.setId(UUID.randomUUID()); - cle1.setOrderedState(ControlLoopOrderedState.UNINITIALISED); - cle1.setParticipantId(new ToscaConceptIdentifier("id", "1.2.3")); - cle1.setState(ControlLoopState.UNINITIALISED); - - var cle2 = new ControlLoopElement(cle1); - assertEquals(cle1, cle2); - } - - @Test - void testControlLoopState() { - var cle0 = new ControlLoopElement(); - - assertTrue( - cle0.getOrderedState() - .equalsControlLoopState(ControlLoopState.UNINITIALISED)); - - assertTrue( - cle0.getOrderedState().asState() - .equalsControlLoopOrderedState(ControlLoopOrderedState.UNINITIALISED)); - } - - @Test - void testControlLoopElementLombok() { - assertNotNull(new ControlLoopElement()); - var cle0 = new ControlLoopElement(); - - assertThat(cle0.toString()).contains("ControlLoopElement("); - assertThat(cle0.hashCode()).isNotZero(); - assertEquals(true, cle0.equals(cle0)); - assertEquals(false, cle0.equals(null)); - - var cle1 = new ControlLoopElement(); - - cle1.setDefinition(new ToscaConceptIdentifier("defName", "0.0.1")); - cle1.setDescription("Description"); - cle1.setId(UUID.randomUUID()); - cle1.setOrderedState(ControlLoopOrderedState.UNINITIALISED); - cle1.setParticipantId(new ToscaConceptIdentifier("id", "1.2.3")); - cle1.setState(ControlLoopState.UNINITIALISED); - - assertThat(cle1.toString()).contains("ControlLoopElement("); - assertEquals(false, cle1.hashCode() == 0); - assertEquals(false, cle1.equals(cle0)); - assertEquals(false, cle1.equals(null)); - - assertNotEquals(cle1, cle0); - - var cle2 = new ControlLoopElement(); - - // @formatter:off - assertThatThrownBy(() -> cle2.setDefinition(null)). isInstanceOf(NullPointerException.class); - assertThatThrownBy(() -> cle2.setId(null)). isInstanceOf(NullPointerException.class); - assertThatThrownBy(() -> cle2.setOrderedState(null)). isInstanceOf(NullPointerException.class); - assertThatThrownBy(() -> cle2.setParticipantId(null)).isInstanceOf(NullPointerException.class); - assertThatThrownBy(() -> cle2.setState(null)). isInstanceOf(NullPointerException.class); - // @formatter:on - - assertNotEquals(cle2, cle0); - } -} diff --git a/models/src/test/java/org/onap/policy/clamp/controlloop/models/controlloop/concepts/ControlLoopTest.java b/models/src/test/java/org/onap/policy/clamp/controlloop/models/controlloop/concepts/ControlLoopTest.java deleted file mode 100644 index d9c518b53..000000000 --- a/models/src/test/java/org/onap/policy/clamp/controlloop/models/controlloop/concepts/ControlLoopTest.java +++ /dev/null @@ -1,160 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * Copyright (C) 2021 Nordix Foundation. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - * SPDX-License-Identifier: Apache-2.0 - * ============LICENSE_END========================================================= - */ - -package org.onap.policy.clamp.controlloop.models.controlloop.concepts; - -import static org.assertj.core.api.Assertions.assertThat; -import static org.assertj.core.api.Assertions.assertThatThrownBy; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertNotEquals; -import static org.junit.Assert.assertNotNull; -import static org.junit.Assert.assertNull; - -import java.time.Instant; -import java.util.LinkedHashMap; -import java.util.List; -import java.util.UUID; -import org.junit.jupiter.api.Test; -import org.onap.policy.models.base.PfKey; -import org.onap.policy.models.tosca.authorative.concepts.ToscaConceptIdentifier; - -class ControlLoopTest { - @Test - void testControlLoop() { - var cl0 = new ControlLoop(); - cl0.setDefinition(new ToscaConceptIdentifier("dfName", "1.2.3")); - assertEquals("dfName", cl0.getType()); - assertEquals("1.2.3", cl0.getTypeVersion()); - - var cl1 = new ControlLoop(cl0); - assertEquals(cl0, cl1); - - assertEquals(0, cl0.compareTo(cl1)); - } - - @Test - void testControlLoopLombok() { - assertNotNull(new ControlLoop()); - var cl0 = new ControlLoop(); - cl0.setElements(new LinkedHashMap<>()); - - assertThat(cl0.toString()).contains("ControlLoop("); - assertThat(cl0.hashCode()).isNotZero(); - assertEquals(true, cl0.equals(cl0)); - assertEquals(false, cl0.equals(null)); - - var cl1 = new ControlLoop(); - - cl1.setDefinition(new ToscaConceptIdentifier("defName", "0.0.1")); - cl1.setDescription("Description"); - cl1.setElements(new LinkedHashMap<>()); - cl1.setName("Name"); - cl1.setOrderedState(ControlLoopOrderedState.UNINITIALISED); - cl1.setState(ControlLoopState.UNINITIALISED); - cl1.setVersion("0.0.1"); - - assertThat(cl1.toString()).contains("ControlLoop("); - assertEquals(false, cl1.hashCode() == 0); - assertEquals(false, cl1.equals(cl0)); - assertEquals(false, cl1.equals(null)); - - assertNotEquals(cl1, cl0); - - var cl2 = new ControlLoop(); - cl2.setElements(new LinkedHashMap<>()); - - // @formatter:off - assertThatThrownBy(() -> cl2.setDefinition(null)). isInstanceOf(NullPointerException.class); - assertThatThrownBy(() -> cl2.setOrderedState(null)).isInstanceOf(NullPointerException.class); - assertThatThrownBy(() -> cl2.setState(null)). isInstanceOf(NullPointerException.class); - // @formatter:on - - assertEquals(cl2, cl0); - - cl1.setCascadedOrderedState(ControlLoopOrderedState.PASSIVE); - assertEquals(ControlLoopOrderedState.PASSIVE, cl1.getOrderedState()); - - cl1.getElements().put(UUID.randomUUID(), new ControlLoopElement()); - cl1.setCascadedOrderedState(ControlLoopOrderedState.RUNNING); - assertEquals(ControlLoopOrderedState.RUNNING, cl1.getOrderedState()); - assertEquals(ControlLoopOrderedState.RUNNING, cl1.getElements().values().iterator().next().getOrderedState()); - - assertNull(cl0.getElements().get(UUID.randomUUID())); - assertNull(cl1.getElements().get(UUID.randomUUID())); - - assertEquals(PfKey.NULL_KEY_NAME, cl0.getDefinition().getName()); - - } - - @Test - void testControlLoopElementStatisticsList() { - var cl = new ControlLoop(); - List emptylist = cl.getControlLoopElementStatisticsList(cl); - assertEquals(List.of(), emptylist); - - var cl1 = getControlLoopTest(); - List list = cl1.getControlLoopElementStatisticsList(cl1); - assertNotNull(list); - assertEquals(2, list.size()); - assertEquals(ControlLoopState.UNINITIALISED, list.get(0).getControlLoopState()); - } - - private ControlLoop getControlLoopTest() { - var cl = new ControlLoop(); - cl.setDefinition(new ToscaConceptIdentifier("defName", "1.2.3")); - cl.setDescription("Description"); - cl.setElements(new LinkedHashMap<>()); - cl.setName("Name"); - cl.setOrderedState(ControlLoopOrderedState.UNINITIALISED); - cl.setState(ControlLoopState.UNINITIALISED); - cl.setVersion("0.0.1"); - - var uuid = UUID.randomUUID(); - var id = new ToscaConceptIdentifier( - "org.onap.policy.controlloop.PolicyControlLoopParticipant", "1.0.1"); - var clElement = getControlLoopElementTest(uuid, id); - - var uuid2 = UUID.randomUUID(); - var id2 = new ToscaConceptIdentifier( - "org.onap.policy.controlloop.PolicyControlLoopParticipantIntermediary", "0.0.1"); - var clElement2 = getControlLoopElementTest(uuid2, id2); - - cl.getElements().put(uuid, clElement); - cl.getElements().put(uuid2, clElement2); - return cl; - } - - private ControlLoopElement getControlLoopElementTest(UUID uuid, ToscaConceptIdentifier id) { - var clElement = new ControlLoopElement(); - clElement.setId(uuid); - clElement.setParticipantId(id); - clElement.setDefinition(id); - clElement.setOrderedState(ControlLoopOrderedState.UNINITIALISED); - - var clElementStatistics = new ClElementStatistics(); - clElementStatistics.setParticipantId(id); - clElementStatistics.setControlLoopState(ControlLoopState.UNINITIALISED); - clElementStatistics.setTimeStamp(Instant.now()); - - clElement.setClElementStatistics(clElementStatistics); - - return clElement; - } -} diff --git a/models/src/test/java/org/onap/policy/clamp/controlloop/models/controlloop/concepts/ParticipantStatisticsTest.java b/models/src/test/java/org/onap/policy/clamp/controlloop/models/controlloop/concepts/ParticipantStatisticsTest.java deleted file mode 100644 index f55f624bf..000000000 --- a/models/src/test/java/org/onap/policy/clamp/controlloop/models/controlloop/concepts/ParticipantStatisticsTest.java +++ /dev/null @@ -1,65 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * Copyright (C) 2021 Nordix Foundation. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - * SPDX-License-Identifier: Apache-2.0 - * ============LICENSE_END========================================================= - */ - -package org.onap.policy.clamp.controlloop.models.controlloop.concepts; - -import static org.assertj.core.api.Assertions.assertThat; -import static org.assertj.core.api.Assertions.assertThatThrownBy; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertNotEquals; -import static org.junit.Assert.assertNotNull; - -import java.time.Instant; -import org.junit.jupiter.api.Test; -import org.onap.policy.models.tosca.authorative.concepts.ToscaConceptIdentifier; - -class ParticipantStatisticsTest { - @Test - void testParticipantStatisticsLombok() { - assertNotNull(new ParticipantStatistics()); - ParticipantStatistics ps0 = new ParticipantStatistics(); - - assertThat(ps0.toString()).contains("ParticipantStatistics("); - assertThat(ps0.hashCode()).isNotZero(); - assertEquals(true, ps0.equals(ps0)); - assertEquals(false, ps0.equals(null)); - - - ParticipantStatistics ps1 = new ParticipantStatistics(); - ps1.setParticipantId(new ToscaConceptIdentifier("defName", "0.0.1")); - ps1.setTimeStamp(Instant.now()); - - assertThat(ps1.toString()).contains("ParticipantStatistics("); - assertEquals(false, ps1.hashCode() == 0); - assertEquals(false, ps1.equals(ps0)); - assertEquals(false, ps1.equals(null)); - - assertNotEquals(ps1, ps0); - - ParticipantStatistics ps2 = new ParticipantStatistics(); - - // @formatter:off - assertThatThrownBy(() -> ps2.setParticipantId(null)).isInstanceOf(NullPointerException.class); - assertThatThrownBy(() -> ps2.setTimeStamp(null)). isInstanceOf(NullPointerException.class); - // @formatter:on - - assertEquals(ps2, ps0); - } -} diff --git a/models/src/test/java/org/onap/policy/clamp/controlloop/models/controlloop/concepts/ParticipantTest.java b/models/src/test/java/org/onap/policy/clamp/controlloop/models/controlloop/concepts/ParticipantTest.java deleted file mode 100644 index 5c429b96c..000000000 --- a/models/src/test/java/org/onap/policy/clamp/controlloop/models/controlloop/concepts/ParticipantTest.java +++ /dev/null @@ -1,84 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * Copyright (C) 2021 Nordix Foundation. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - * SPDX-License-Identifier: Apache-2.0 - * ============LICENSE_END========================================================= - */ - -package org.onap.policy.clamp.controlloop.models.controlloop.concepts; - -import static org.assertj.core.api.Assertions.assertThat; -import static org.assertj.core.api.Assertions.assertThatThrownBy; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertNotEquals; -import static org.junit.Assert.assertNotNull; - -import org.junit.jupiter.api.Test; -import org.onap.policy.models.tosca.authorative.concepts.ToscaConceptIdentifier; - -class ParticipantTest { - @Test - void testParticipant() { - - Participant p0 = new Participant(); - p0.setDefinition(new ToscaConceptIdentifier("dfName", "1.2.3")); - assertEquals("dfName", p0.getType()); - assertEquals("1.2.3", p0.getTypeVersion()); - - Participant p1 = new Participant(p0); - assertEquals(p0, p1); - - assertEquals(0, p0.compareTo(p1)); - } - - @Test - void testParticipantLombok() { - assertNotNull(new Participant()); - Participant p0 = new Participant(); - - assertThat(p0.toString()).contains("Participant("); - assertThat(p0.hashCode()).isNotZero(); - assertEquals(true, p0.equals(p0)); - assertEquals(false, p0.equals(null)); - - - Participant p1 = new Participant(); - - p1.setDefinition(new ToscaConceptIdentifier("defName", "0.0.1")); - p1.setDescription("Description"); - p1.setHealthStatus(ParticipantHealthStatus.HEALTHY); - p1.setName("Name"); - p1.setParticipantState(ParticipantState.ACTIVE); - p1.setVersion("0.0.1"); - - assertThat(p1.toString()).contains("Participant("); - assertEquals(false, p1.hashCode() == 0); - assertEquals(false, p1.equals(p0)); - assertEquals(false, p1.equals(null)); - - assertNotEquals(p1, p0); - - Participant p2 = new Participant(); - - // @formatter:off - assertThatThrownBy(() -> p2.setDefinition(null)). isInstanceOf(NullPointerException.class); - assertThatThrownBy(() -> p2.setHealthStatus(null)). isInstanceOf(NullPointerException.class); - assertThatThrownBy(() -> p2.setParticipantState(null)).isInstanceOf(NullPointerException.class); - // @formatter:on - - assertEquals(p2, p0); - } -} diff --git a/models/src/test/java/org/onap/policy/clamp/controlloop/models/controlloop/concepts/ParticipantUtilsTest.java b/models/src/test/java/org/onap/policy/clamp/controlloop/models/controlloop/concepts/ParticipantUtilsTest.java deleted file mode 100644 index 3fb8b6d7f..000000000 --- a/models/src/test/java/org/onap/policy/clamp/controlloop/models/controlloop/concepts/ParticipantUtilsTest.java +++ /dev/null @@ -1,84 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * Copyright (C) 2021 Nordix Foundation. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - * SPDX-License-Identifier: Apache-2.0 - * ============LICENSE_END========================================================= - */ - -package org.onap.policy.clamp.controlloop.models.controlloop.concepts; - -import static org.assertj.core.api.Assertions.assertThat; - -import java.util.Map; -import org.junit.jupiter.api.Test; -import org.onap.policy.common.utils.coder.Coder; -import org.onap.policy.common.utils.coder.CoderException; -import org.onap.policy.common.utils.coder.StandardCoder; -import org.onap.policy.common.utils.coder.StandardYamlCoder; -import org.onap.policy.common.utils.resources.ResourceUtils; -import org.onap.policy.models.tosca.authorative.concepts.ToscaConceptIdentifier; -import org.onap.policy.models.tosca.authorative.concepts.ToscaNodeTemplate; -import org.onap.policy.models.tosca.authorative.concepts.ToscaServiceTemplate; - -class ParticipantUtilsTest { - - private static final Coder CODER = new StandardCoder(); - private static final String TOSCA_TEMPLATE_YAML = "examples/controlloop/PMSubscriptionHandling.yaml"; - private static final String CONTROL_LOOP_JSON = "src/test/resources/providers/TestControlLoops.json"; - private static final String CONTROL_LOOP_ELEMENT = "org.onap.policy.clamp.controlloop.ControlLoopElement"; - private static final String POLICY_CONTROL_LOOP_ELEMENT = - "org.onap.policy.clamp.controlloop.PolicyControlLoopElement"; - private static final String PARTICIPANT_CONTROL_LOOP_ELEMENT = "org.onap.policy.clamp.controlloop.Participant"; - private static final StandardYamlCoder YAML_TRANSLATOR = new StandardYamlCoder(); - - @Test - void testFindParticipantType() throws CoderException { - var identifier = new ToscaConceptIdentifier("Identifier", "1.0.1"); - var result = ParticipantUtils.findParticipantType(Map.of("participantType", CODER.encode(identifier))); - assertThat(result).isEqualTo(identifier); - } - - @Test - void testFindStartPhase() { - var identifier = 13; - var result = ParticipantUtils.findStartPhase(Map.of("startPhase", identifier)); - assertThat(result).isEqualTo(identifier); - } - - @Test - void testGetFirstStartPhase() throws CoderException { - var serviceTemplate = YAML_TRANSLATOR.decode(ResourceUtils.getResourceAsStream(TOSCA_TEMPLATE_YAML), - ToscaServiceTemplate.class); - var controlLoops = CODER.decode(ResourceUtils.getResourceAsString(CONTROL_LOOP_JSON), ControlLoops.class); - var result = ParticipantUtils.getFirstStartPhase(controlLoops.getControlLoopList().get(0), serviceTemplate); - assertThat(result).isZero(); - } - - @Test - void testCheckIfNodeTemplateIsControlLoopElement() throws CoderException { - var serviceTemplate = YAML_TRANSLATOR.decode(ResourceUtils.getResourceAsStream(TOSCA_TEMPLATE_YAML), - ToscaServiceTemplate.class); - var nodeTemplate = new ToscaNodeTemplate(); - nodeTemplate.setType(CONTROL_LOOP_ELEMENT); - assertThat(ParticipantUtils.checkIfNodeTemplateIsControlLoopElement(nodeTemplate, serviceTemplate)).isTrue(); - - nodeTemplate.setType(POLICY_CONTROL_LOOP_ELEMENT); - assertThat(ParticipantUtils.checkIfNodeTemplateIsControlLoopElement(nodeTemplate, serviceTemplate)).isTrue(); - - nodeTemplate.setType(PARTICIPANT_CONTROL_LOOP_ELEMENT); - assertThat(ParticipantUtils.checkIfNodeTemplateIsControlLoopElement(nodeTemplate, serviceTemplate)).isFalse(); - } -} diff --git a/models/src/test/java/org/onap/policy/clamp/controlloop/models/controlloop/persistence/concepts/DummyJpaClElementStatisticsChild.java b/models/src/test/java/org/onap/policy/clamp/controlloop/models/controlloop/persistence/concepts/DummyJpaClElementStatisticsChild.java deleted file mode 100644 index 94b0b13c7..000000000 --- a/models/src/test/java/org/onap/policy/clamp/controlloop/models/controlloop/persistence/concepts/DummyJpaClElementStatisticsChild.java +++ /dev/null @@ -1,28 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * Copyright (C) 2021 Nordix Foundation. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - * SPDX-License-Identifier: Apache-2.0 - * ============LICENSE_END========================================================= - */ - -package org.onap.policy.clamp.controlloop.models.controlloop.persistence.concepts; - -/** - * Test class for {@link JpaClElementStatistics} comparisons. - */ -class DummyJpaClElementStatisticsChild extends JpaClElementStatistics { - private static final long serialVersionUID = -5101743610779424064L; -} diff --git a/models/src/test/java/org/onap/policy/clamp/controlloop/models/controlloop/persistence/concepts/DummyJpaControlLoopChild.java b/models/src/test/java/org/onap/policy/clamp/controlloop/models/controlloop/persistence/concepts/DummyJpaControlLoopChild.java deleted file mode 100644 index 10150cf59..000000000 --- a/models/src/test/java/org/onap/policy/clamp/controlloop/models/controlloop/persistence/concepts/DummyJpaControlLoopChild.java +++ /dev/null @@ -1,28 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * Copyright (C) 2021 Nordix Foundation. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - * SPDX-License-Identifier: Apache-2.0 - * ============LICENSE_END========================================================= - */ - -package org.onap.policy.clamp.controlloop.models.controlloop.persistence.concepts; - -/** - * Test class for {@link JpaControlLoop} comparisons. - */ -class DummyJpaControlLoopChild extends JpaControlLoop { - private static final long serialVersionUID = -5101743610779424064L; -} diff --git a/models/src/test/java/org/onap/policy/clamp/controlloop/models/controlloop/persistence/concepts/DummyJpaControlLoopElementChild.java b/models/src/test/java/org/onap/policy/clamp/controlloop/models/controlloop/persistence/concepts/DummyJpaControlLoopElementChild.java deleted file mode 100644 index 4bacb9255..000000000 --- a/models/src/test/java/org/onap/policy/clamp/controlloop/models/controlloop/persistence/concepts/DummyJpaControlLoopElementChild.java +++ /dev/null @@ -1,28 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * Copyright (C) 2021 Nordix Foundation. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - * SPDX-License-Identifier: Apache-2.0 - * ============LICENSE_END========================================================= - */ - -package org.onap.policy.clamp.controlloop.models.controlloop.persistence.concepts; - -/** - * Test class for {@link JpaControlLoopElement} comparisons. - */ -class DummyJpaControlLoopElementChild extends JpaControlLoopElement { - private static final long serialVersionUID = -5101743610779424064L; -} diff --git a/models/src/test/java/org/onap/policy/clamp/controlloop/models/controlloop/persistence/concepts/DummyJpaParticipantChild.java b/models/src/test/java/org/onap/policy/clamp/controlloop/models/controlloop/persistence/concepts/DummyJpaParticipantChild.java deleted file mode 100644 index 68dcc319b..000000000 --- a/models/src/test/java/org/onap/policy/clamp/controlloop/models/controlloop/persistence/concepts/DummyJpaParticipantChild.java +++ /dev/null @@ -1,28 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * Copyright (C) 2021 Nordix Foundation. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - * SPDX-License-Identifier: Apache-2.0 - * ============LICENSE_END========================================================= - */ - -package org.onap.policy.clamp.controlloop.models.controlloop.persistence.concepts; - -/** - * Test class for {@link JpaParticipant} comparisons. - */ -class DummyJpaParticipantChild extends JpaParticipant { - private static final long serialVersionUID = -5101743610779424064L; -} diff --git a/models/src/test/java/org/onap/policy/clamp/controlloop/models/controlloop/persistence/concepts/DummyJpaParticipantStatisticsChild.java b/models/src/test/java/org/onap/policy/clamp/controlloop/models/controlloop/persistence/concepts/DummyJpaParticipantStatisticsChild.java deleted file mode 100644 index 2c1f04ea1..000000000 --- a/models/src/test/java/org/onap/policy/clamp/controlloop/models/controlloop/persistence/concepts/DummyJpaParticipantStatisticsChild.java +++ /dev/null @@ -1,28 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * Copyright (C) 2021 Nordix Foundation. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - * SPDX-License-Identifier: Apache-2.0 - * ============LICENSE_END========================================================= - */ - -package org.onap.policy.clamp.controlloop.models.controlloop.persistence.concepts; - -/** - * Test class for {@link JpaParticipantStatistics} comparisons. - */ -class DummyJpaParticipantStatisticsChild extends JpaParticipantStatistics { - private static final long serialVersionUID = -5101743610779424064L; -} diff --git a/models/src/test/java/org/onap/policy/clamp/controlloop/models/controlloop/persistence/concepts/JpaClElementStatisticsTest.java b/models/src/test/java/org/onap/policy/clamp/controlloop/models/controlloop/persistence/concepts/JpaClElementStatisticsTest.java deleted file mode 100644 index 0e6fb8383..000000000 --- a/models/src/test/java/org/onap/policy/clamp/controlloop/models/controlloop/persistence/concepts/JpaClElementStatisticsTest.java +++ /dev/null @@ -1,189 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * Copyright (C) 2021 Nordix Foundation. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - * SPDX-License-Identifier: Apache-2.0 - * ============LICENSE_END========================================================= - */ - -package org.onap.policy.clamp.controlloop.models.controlloop.persistence.concepts; - -import static org.assertj.core.api.Assertions.assertThat; -import static org.assertj.core.api.Assertions.assertThatThrownBy; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertNotEquals; -import static org.junit.Assert.assertNotNull; -import static org.junit.Assert.assertTrue; - -import java.time.Instant; -import java.util.UUID; -import org.junit.jupiter.api.Test; -import org.onap.policy.clamp.controlloop.models.controlloop.concepts.ClElementStatistics; -import org.onap.policy.clamp.controlloop.models.controlloop.concepts.ControlLoopState; -import org.onap.policy.clamp.controlloop.models.controlloop.concepts.Participant; -import org.onap.policy.models.base.PfConceptKey; -import org.onap.policy.models.base.PfReferenceTimestampKey; -import org.onap.policy.models.tosca.authorative.concepts.ToscaConceptIdentifier; - -/** - * Test the {@link JpaClElementStatistics} class. - */ -class JpaClElementStatisticsTest { - - private static final String NULL_KEY_ERROR = "key is marked .*ull but is null"; - - @Test - void testJpaClElementStatisticsConstructor() { - assertThatThrownBy(() -> { - new JpaClElementStatistics((JpaClElementStatistics) null); - }).hasMessageMatching("copyConcept is marked .*ull but is null"); - - assertThatThrownBy(() -> { - new JpaClElementStatistics((PfReferenceTimestampKey) null); - }).hasMessageMatching(NULL_KEY_ERROR); - - assertThatThrownBy(() -> { - new JpaClElementStatistics(null, null); - }).hasMessageMatching(NULL_KEY_ERROR); - - assertThatThrownBy(() -> { - new JpaClElementStatistics(null, new PfConceptKey()); - }).hasMessageMatching(NULL_KEY_ERROR); - - assertThatThrownBy(() -> { - new JpaClElementStatistics(new PfReferenceTimestampKey(), null); - }).hasMessageMatching("participantId is marked .*ull but is null"); - - assertNotNull(new JpaClElementStatistics()); - assertNotNull(new JpaClElementStatistics((new PfReferenceTimestampKey()))); - assertNotNull(new JpaClElementStatistics(new PfReferenceTimestampKey(), new PfConceptKey())); - } - - @Test - void testJpaClElementStatistics() { - JpaClElementStatistics testJpaClElementStatistics = createJpaClElementStatisticsInstance(); - - ClElementStatistics cles = createClElementStatisticsInstance(); - assertEquals(cles, testJpaClElementStatistics.toAuthorative()); - - assertThatThrownBy(() -> { - testJpaClElementStatistics.fromAuthorative(null); - }).hasMessageMatching("clElementStatistics is marked .*ull but is null"); - - assertThatThrownBy(() -> new JpaClElementStatistics((JpaClElementStatistics) null)) - .isInstanceOf(NullPointerException.class); - - JpaClElementStatistics testJpaClElementStatisticsFa = new JpaClElementStatistics(); - testJpaClElementStatisticsFa.setKey(null); - testJpaClElementStatisticsFa.fromAuthorative(cles); - assertEquals(testJpaClElementStatistics, testJpaClElementStatisticsFa); - testJpaClElementStatisticsFa.setKey(PfReferenceTimestampKey.getNullKey()); - testJpaClElementStatisticsFa.fromAuthorative(cles); - assertEquals(testJpaClElementStatistics, testJpaClElementStatisticsFa); - testJpaClElementStatisticsFa.setKey(new PfReferenceTimestampKey("elementName", "0.0.1", - "a95757ba-b34a-4049-a2a8-46773abcbe5e", Instant.ofEpochSecond(123456L))); - testJpaClElementStatisticsFa.fromAuthorative(cles); - assertEquals(testJpaClElementStatistics, testJpaClElementStatisticsFa); - - testJpaClElementStatisticsFa = new JpaClElementStatistics(cles); - assertEquals(testJpaClElementStatistics, testJpaClElementStatisticsFa); - - assertEquals(1, testJpaClElementStatistics.getKeys().size()); - - assertEquals("elementName", testJpaClElementStatistics.getKey().getReferenceKey().getParentKeyName()); - - testJpaClElementStatistics.clean(); - assertEquals("elementName", testJpaClElementStatistics.getKey().getReferenceKey().getParentKeyName()); - - JpaClElementStatistics testJpaClElementStatistics2 = new JpaClElementStatistics(testJpaClElementStatistics); - assertEquals(testJpaClElementStatistics, testJpaClElementStatistics2); - } - - @Test - void testJpaClElementStatisticsValidation() { - JpaClElementStatistics testJpaClElementStatistics = createJpaClElementStatisticsInstance(); - - assertThatThrownBy(() -> { - testJpaClElementStatistics.validate(null); - }).hasMessageMatching("fieldName is marked .*ull but is null"); - - assertTrue(testJpaClElementStatistics.validate("").isValid()); - } - - @Test - void testJpaClElementStatisticsCompareTo() { - JpaClElementStatistics testJpaClElementStatistics = createJpaClElementStatisticsInstance(); - - JpaClElementStatistics otherJpaClElementStatistics = new JpaClElementStatistics(testJpaClElementStatistics); - assertEquals(0, testJpaClElementStatistics.compareTo(otherJpaClElementStatistics)); - assertEquals(-1, testJpaClElementStatistics.compareTo(null)); - assertEquals(0, testJpaClElementStatistics.compareTo(testJpaClElementStatistics)); - assertNotEquals(0, testJpaClElementStatistics.compareTo(new DummyJpaClElementStatisticsChild())); - - testJpaClElementStatistics.setState(ControlLoopState.PASSIVE); - assertNotEquals(0, testJpaClElementStatistics.compareTo(otherJpaClElementStatistics)); - testJpaClElementStatistics.setState(ControlLoopState.UNINITIALISED); - assertEquals(0, testJpaClElementStatistics.compareTo(otherJpaClElementStatistics)); - - assertEquals(testJpaClElementStatistics, new JpaClElementStatistics(testJpaClElementStatistics)); - } - - @Test - void testJpaClElementStatisticsLombok() { - assertNotNull(new Participant()); - JpaClElementStatistics cles0 = new JpaClElementStatistics(); - - assertThat(cles0.toString()).contains("JpaClElementStatistics("); - assertThat(cles0.hashCode()).isNotZero(); - assertEquals(true, cles0.equals(cles0)); - assertEquals(false, cles0.equals(null)); - - - JpaClElementStatistics cles11 = new JpaClElementStatistics(); - - cles11.setState(ControlLoopState.UNINITIALISED); - - assertThat(cles11.toString()).contains("JpaClElementStatistics("); - assertEquals(false, cles11.hashCode() == 0); - assertEquals(false, cles11.equals(cles0)); - assertEquals(false, cles11.equals(null)); - - assertNotEquals(cles11, cles0); - - JpaClElementStatistics cles2 = new JpaClElementStatistics(); - assertEquals(cles2, cles0); - } - - private JpaClElementStatistics createJpaClElementStatisticsInstance() { - ClElementStatistics testCles = createClElementStatisticsInstance(); - JpaClElementStatistics testJpaClElementStatistics = new JpaClElementStatistics(); - testJpaClElementStatistics.setKey(null); - testJpaClElementStatistics.fromAuthorative(testCles); - testJpaClElementStatistics.setKey(PfReferenceTimestampKey.getNullKey()); - testJpaClElementStatistics.fromAuthorative(testCles); - - return testJpaClElementStatistics; - } - - private ClElementStatistics createClElementStatisticsInstance() { - ClElementStatistics clElementStatistics = new ClElementStatistics(); - clElementStatistics.setParticipantId(new ToscaConceptIdentifier("elementName", "0.0.1")); - clElementStatistics.setId(UUID.fromString("a95757ba-b34a-4049-a2a8-46773abcbe5e")); - clElementStatistics.setTimeStamp(Instant.ofEpochSecond(123456L)); - clElementStatistics.setControlLoopState(ControlLoopState.UNINITIALISED); - - return clElementStatistics; - } -} diff --git a/models/src/test/java/org/onap/policy/clamp/controlloop/models/controlloop/persistence/concepts/JpaControlLoopElementTest.java b/models/src/test/java/org/onap/policy/clamp/controlloop/models/controlloop/persistence/concepts/JpaControlLoopElementTest.java deleted file mode 100644 index 63c5ea3ab..000000000 --- a/models/src/test/java/org/onap/policy/clamp/controlloop/models/controlloop/persistence/concepts/JpaControlLoopElementTest.java +++ /dev/null @@ -1,300 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * Copyright (C) 2021 Nordix Foundation. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - * SPDX-License-Identifier: Apache-2.0 - * ============LICENSE_END========================================================= - */ - -package org.onap.policy.clamp.controlloop.models.controlloop.persistence.concepts; - -import static org.assertj.core.api.Assertions.assertThat; -import static org.assertj.core.api.Assertions.assertThatThrownBy; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertNotEquals; -import static org.junit.Assert.assertNotNull; -import static org.junit.Assert.assertNull; -import static org.junit.Assert.assertTrue; - -import java.io.File; -import java.util.UUID; -import org.junit.jupiter.api.Test; -import org.onap.policy.clamp.controlloop.models.controlloop.concepts.ControlLoopElement; -import org.onap.policy.clamp.controlloop.models.controlloop.concepts.ControlLoopOrderedState; -import org.onap.policy.clamp.controlloop.models.controlloop.concepts.ControlLoopState; -import org.onap.policy.clamp.controlloop.models.controlloop.concepts.Participant; -import org.onap.policy.common.utils.coder.CoderException; -import org.onap.policy.common.utils.coder.StandardCoder; -import org.onap.policy.models.base.PfConceptKey; -import org.onap.policy.models.base.PfKey; -import org.onap.policy.models.base.PfReferenceKey; -import org.onap.policy.models.tosca.authorative.concepts.ToscaConceptIdentifier; - -/** - * Test the {@link JpaControlLoopElement} class. - */ -class JpaControlLoopElementTest { - - private static final String NULL_KEY_ERROR = "key is marked .*ull but is null"; - - @Test - void testJpaControlLoopElementConstructor() { - assertThatThrownBy(() -> { - new JpaControlLoopElement((JpaControlLoopElement) null); - }).hasMessageMatching("copyConcept is marked .*ull but is null"); - - assertThatThrownBy(() -> { - new JpaControlLoopElement((PfReferenceKey) null); - }).hasMessageMatching(NULL_KEY_ERROR); - - assertThatThrownBy(() -> { - new JpaControlLoopElement(null, null, null, null); - }).hasMessageMatching(NULL_KEY_ERROR); - - assertThatThrownBy(() -> { - new JpaControlLoopElement(null, null, null, ControlLoopState.UNINITIALISED); - }).hasMessageMatching(NULL_KEY_ERROR); - - assertThatThrownBy(() -> { - new JpaControlLoopElement(null, null, new PfConceptKey("participant", "0.0.1"), null); - }).hasMessageMatching(NULL_KEY_ERROR); - - assertThatThrownBy(() -> { - new JpaControlLoopElement(null, null, new PfConceptKey("participant", "0.0.1"), - ControlLoopState.UNINITIALISED); - }).hasMessageMatching(NULL_KEY_ERROR); - - assertThatThrownBy(() -> { - new JpaControlLoopElement(null, new PfConceptKey(), null, null); - }).hasMessageMatching(NULL_KEY_ERROR); - - assertThatThrownBy(() -> { - new JpaControlLoopElement(null, new PfConceptKey(), null, ControlLoopState.UNINITIALISED); - }).hasMessageMatching(NULL_KEY_ERROR); - - assertThatThrownBy(() -> { - new JpaControlLoopElement(null, new PfConceptKey(), new PfConceptKey("participant", "0.0.1"), null); - }).hasMessageMatching(NULL_KEY_ERROR); - - assertThatThrownBy(() -> { - new JpaControlLoopElement(null, new PfConceptKey(), new PfConceptKey("participant", "0.0.1"), - ControlLoopState.UNINITIALISED); - }).hasMessageMatching(NULL_KEY_ERROR); - - assertThatThrownBy(() -> { - new JpaControlLoopElement(new PfReferenceKey(), null, null, null); - }).hasMessageMatching("definition is marked .*ull but is null"); - - assertThatThrownBy(() -> { - new JpaControlLoopElement(new PfReferenceKey(), null, null, ControlLoopState.UNINITIALISED); - }).hasMessageMatching("definition is marked .*ull but is null"); - - assertThatThrownBy(() -> { - new JpaControlLoopElement(new PfReferenceKey(), null, new PfConceptKey("participant", "0.0.1"), null); - }).hasMessageMatching("definition is marked .*ull but is null"); - - assertThatThrownBy(() -> { - new JpaControlLoopElement(new PfReferenceKey(), null, new PfConceptKey("participant", "0.0.1"), - ControlLoopState.UNINITIALISED); - }).hasMessageMatching("definition is marked .*ull but is null"); - - assertThatThrownBy(() -> { - new JpaControlLoopElement(new PfReferenceKey(), new PfConceptKey(), null, null); - }).hasMessageMatching("participantType is marked .*ull but is null"); - - assertThatThrownBy(() -> { - new JpaControlLoopElement(new PfReferenceKey(), new PfConceptKey(), null, ControlLoopState.UNINITIALISED); - }).hasMessageMatching("participantType is marked .*ull but is null"); - - assertThatThrownBy(() -> { - new JpaControlLoopElement(new PfReferenceKey(), new PfConceptKey(), - new PfConceptKey("participant", "0.0.1"), null); - }).hasMessageMatching("state is marked .*ull but is null"); - - assertNotNull(new JpaControlLoopElement()); - assertNotNull(new JpaControlLoopElement((new PfReferenceKey()))); - assertNotNull(new JpaControlLoopElement(new PfReferenceKey(), new PfConceptKey(), - new PfConceptKey("participant", "0.0.1"), ControlLoopState.UNINITIALISED)); - } - - @Test - void testJpaControlLoopElement() { - JpaControlLoopElement testJpaControlLoopElement = createJpaControlLoopElementInstance(); - - ControlLoopElement cle = createControlLoopElementInstance(); - assertEquals(cle, testJpaControlLoopElement.toAuthorative()); - - assertThatThrownBy(() -> { - testJpaControlLoopElement.fromAuthorative(null); - }).hasMessageMatching("element is marked .*ull but is null"); - - assertThatThrownBy(() -> new JpaControlLoopElement((JpaControlLoopElement) null)) - .isInstanceOf(NullPointerException.class); - - JpaControlLoopElement testJpaControlLoopElementFa = new JpaControlLoopElement(); - testJpaControlLoopElementFa.setKey(null); - testJpaControlLoopElementFa.fromAuthorative(cle); - assertEquals(testJpaControlLoopElement, testJpaControlLoopElementFa); - testJpaControlLoopElementFa.setKey(PfReferenceKey.getNullKey()); - testJpaControlLoopElementFa.fromAuthorative(cle); - assertEquals(testJpaControlLoopElement, testJpaControlLoopElementFa); - testJpaControlLoopElementFa.setKey(new PfReferenceKey(PfKey.NULL_KEY_NAME, PfKey.NULL_KEY_VERSION, - "a95757ba-b34a-4049-a2a8-46773abcbe5e")); - testJpaControlLoopElementFa.fromAuthorative(cle); - assertEquals(testJpaControlLoopElement, testJpaControlLoopElementFa); - - assertEquals("a95757ba-b34a-4049-a2a8-46773abcbe5e", testJpaControlLoopElement.getKey().getLocalName()); - assertEquals("a95757ba-b34a-4049-a2a8-46773abcbe5e", - new JpaControlLoopElement(createControlLoopElementInstance()).getKey().getLocalName()); - assertEquals("a95757ba-b34a-4049-a2a8-46773abcbe5e", - ((PfReferenceKey) new JpaControlLoopElement(createControlLoopElementInstance()).getKeys().get(0)) - .getLocalName()); - - testJpaControlLoopElement.clean(); - assertEquals("a95757ba-b34a-4049-a2a8-46773abcbe5e", testJpaControlLoopElement.getKey().getLocalName()); - - testJpaControlLoopElement.setDescription(" A Message "); - testJpaControlLoopElement.clean(); - assertEquals("A Message", testJpaControlLoopElement.getDescription()); - - JpaControlLoopElement testJpaControlLoopElement2 = new JpaControlLoopElement(testJpaControlLoopElement); - assertEquals(testJpaControlLoopElement, testJpaControlLoopElement2); - } - - @Test - void testJpaControlLoopElementOrderedState() throws CoderException { - ControlLoopElement testControlLoopElement = createControlLoopElementInstance(); - JpaControlLoopElement testJpaControlLoopElement = createJpaControlLoopElementInstance(); - - testJpaControlLoopElement.setOrderedState(null); - assertEquals(testControlLoopElement, testJpaControlLoopElement.toAuthorative()); - testJpaControlLoopElement.setOrderedState(ControlLoopOrderedState.UNINITIALISED); - - ControlLoopElement noOrderedStateCle = new StandardCoder().decode( - new File("src/test/resources/json/ControlLoopElementNoOrderedState.json"), ControlLoopElement.class); - - JpaControlLoopElement noOrderedStateJpaCle = new JpaControlLoopElement(noOrderedStateCle); - assertNull(noOrderedStateJpaCle.getOrderedState()); - noOrderedStateCle.setOrderedState(ControlLoopOrderedState.UNINITIALISED); - noOrderedStateJpaCle = new JpaControlLoopElement(noOrderedStateCle); - assertEquals(testJpaControlLoopElement, noOrderedStateJpaCle); - } - - @Test - void testJpaControlLoopElementValidation() { - JpaControlLoopElement testJpaControlLoopElement = createJpaControlLoopElementInstance(); - - assertThatThrownBy(() -> { - testJpaControlLoopElement.validate(null); - }).hasMessageMatching("fieldName is marked .*ull but is null"); - - assertTrue(testJpaControlLoopElement.validate("").isValid()); - } - - @Test - void testJpaControlLoopElementCompareTo() { - JpaControlLoopElement testJpaControlLoopElement = createJpaControlLoopElementInstance(); - - JpaControlLoopElement otherJpaControlLoopElement = new JpaControlLoopElement(testJpaControlLoopElement); - assertEquals(0, testJpaControlLoopElement.compareTo(otherJpaControlLoopElement)); - assertEquals(-1, testJpaControlLoopElement.compareTo(null)); - assertEquals(0, testJpaControlLoopElement.compareTo(testJpaControlLoopElement)); - assertNotEquals(0, testJpaControlLoopElement.compareTo(new DummyJpaControlLoopElementChild())); - - testJpaControlLoopElement - .setKey(new PfReferenceKey("BadValue", "0.0.1", "a95757ba-b34a-4049-a2a8-46773abcbe5e")); - assertNotEquals(0, testJpaControlLoopElement.compareTo(otherJpaControlLoopElement)); - testJpaControlLoopElement.setKey(new PfReferenceKey(PfKey.NULL_KEY_NAME, PfKey.NULL_KEY_VERSION, - "a95757ba-b34a-4049-a2a8-46773abcbe5e")); - assertEquals(0, testJpaControlLoopElement.compareTo(otherJpaControlLoopElement)); - - testJpaControlLoopElement.setDefinition(new PfConceptKey("BadValue", "0.0.1")); - assertNotEquals(0, testJpaControlLoopElement.compareTo(otherJpaControlLoopElement)); - testJpaControlLoopElement.setDefinition(new PfConceptKey("cleDef", "0.0.1")); - assertEquals(0, testJpaControlLoopElement.compareTo(otherJpaControlLoopElement)); - - testJpaControlLoopElement.setDescription("Description"); - assertNotEquals(0, testJpaControlLoopElement.compareTo(otherJpaControlLoopElement)); - testJpaControlLoopElement.setDescription(null); - assertEquals(0, testJpaControlLoopElement.compareTo(otherJpaControlLoopElement)); - - testJpaControlLoopElement.setOrderedState(ControlLoopOrderedState.PASSIVE); - assertNotEquals(0, testJpaControlLoopElement.compareTo(otherJpaControlLoopElement)); - testJpaControlLoopElement.setOrderedState(ControlLoopOrderedState.UNINITIALISED); - assertEquals(0, testJpaControlLoopElement.compareTo(otherJpaControlLoopElement)); - - testJpaControlLoopElement.setState(ControlLoopState.PASSIVE); - assertNotEquals(0, testJpaControlLoopElement.compareTo(otherJpaControlLoopElement)); - testJpaControlLoopElement.setState(ControlLoopState.UNINITIALISED); - assertEquals(0, testJpaControlLoopElement.compareTo(otherJpaControlLoopElement)); - - testJpaControlLoopElement.setParticipantType(new PfConceptKey("dummy", "0.0.1")); - assertNotEquals(0, testJpaControlLoopElement.compareTo(otherJpaControlLoopElement)); - testJpaControlLoopElement.setParticipantType(new PfConceptKey("participantType", "0.0.1")); - assertEquals(0, testJpaControlLoopElement.compareTo(otherJpaControlLoopElement)); - - assertEquals(testJpaControlLoopElement, new JpaControlLoopElement(testJpaControlLoopElement)); - } - - @Test - void testJpaControlLoopElementLombok() { - assertNotNull(new Participant()); - JpaControlLoopElement cle0 = new JpaControlLoopElement(); - - assertThat(cle0.toString()).contains("JpaControlLoopElement("); - assertThat(cle0.hashCode()).isNotZero(); - assertEquals(true, cle0.equals(cle0)); - assertEquals(false, cle0.equals(null)); - - - JpaControlLoopElement cle1 = new JpaControlLoopElement(); - - cle1.setDefinition(new PfConceptKey("defName", "0.0.1")); - cle1.setDescription("Description"); - cle1.setOrderedState(ControlLoopOrderedState.UNINITIALISED); - cle1.setState(ControlLoopState.UNINITIALISED); - cle1.setParticipantId(new PfConceptKey("participant", "0.0.1")); - - assertThat(cle1.toString()).contains("ControlLoopElement("); - assertEquals(false, cle1.hashCode() == 0); - assertEquals(false, cle1.equals(cle0)); - assertEquals(false, cle1.equals(null)); - - assertNotEquals(cle1, cle0); - - JpaControlLoopElement cle2 = new JpaControlLoopElement(); - assertEquals(cle2, cle0); - } - - private JpaControlLoopElement createJpaControlLoopElementInstance() { - ControlLoopElement testCle = createControlLoopElementInstance(); - JpaControlLoopElement testJpaControlLoopElement = new JpaControlLoopElement(); - testJpaControlLoopElement.setKey(null); - testJpaControlLoopElement.fromAuthorative(testCle); - testJpaControlLoopElement.setKey(PfReferenceKey.getNullKey()); - testJpaControlLoopElement.fromAuthorative(testCle); - - return testJpaControlLoopElement; - } - - private ControlLoopElement createControlLoopElementInstance() { - ControlLoopElement controlLoopElement = new ControlLoopElement(); - controlLoopElement.setId(UUID.fromString("a95757ba-b34a-4049-a2a8-46773abcbe5e")); - controlLoopElement.setDefinition(new ToscaConceptIdentifier("cleDef", "0.0.1")); - controlLoopElement.setParticipantType(new ToscaConceptIdentifier("participantType", "0.0.1")); - - return controlLoopElement; - } -} diff --git a/models/src/test/java/org/onap/policy/clamp/controlloop/models/controlloop/persistence/concepts/JpaControlLoopTest.java b/models/src/test/java/org/onap/policy/clamp/controlloop/models/controlloop/persistence/concepts/JpaControlLoopTest.java deleted file mode 100644 index d705c49b5..000000000 --- a/models/src/test/java/org/onap/policy/clamp/controlloop/models/controlloop/persistence/concepts/JpaControlLoopTest.java +++ /dev/null @@ -1,301 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * Copyright (C) 2021 Nordix Foundation. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - * SPDX-License-Identifier: Apache-2.0 - * ============LICENSE_END========================================================= - */ - -package org.onap.policy.clamp.controlloop.models.controlloop.persistence.concepts; - -import static org.assertj.core.api.Assertions.assertThat; -import static org.assertj.core.api.Assertions.assertThatCode; -import static org.assertj.core.api.Assertions.assertThatThrownBy; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertNotEquals; -import static org.junit.Assert.assertNotNull; -import static org.junit.Assert.assertNull; -import static org.junit.Assert.assertTrue; - -import java.io.File; -import java.util.LinkedHashMap; -import org.junit.jupiter.api.Test; -import org.onap.policy.clamp.controlloop.models.controlloop.concepts.ControlLoop; -import org.onap.policy.clamp.controlloop.models.controlloop.concepts.ControlLoopOrderedState; -import org.onap.policy.clamp.controlloop.models.controlloop.concepts.ControlLoopState; -import org.onap.policy.clamp.controlloop.models.controlloop.concepts.ControlLoops; -import org.onap.policy.common.utils.coder.CoderException; -import org.onap.policy.common.utils.coder.StandardCoder; -import org.onap.policy.models.base.PfConceptKey; -import org.onap.policy.models.tosca.authorative.concepts.ToscaConceptIdentifier; - -/** - * Test the {@link JpaControlLoopTest} class. - */ -class JpaControlLoopTest { - - private static final String NULL_KEY_ERROR = "key is marked .*ull but is null"; - - @Test - void testJpaControlLoopConstructor() { - assertThatThrownBy(() -> { - new JpaControlLoop((JpaControlLoop) null); - }).hasMessageMatching("copyConcept is marked .*ull but is null"); - - assertThatThrownBy(() -> { - new JpaControlLoop((PfConceptKey) null); - }).hasMessageMatching(NULL_KEY_ERROR); - - assertThatThrownBy(() -> { - new JpaControlLoop(null, null, null, null); - }).hasMessageMatching(NULL_KEY_ERROR); - - assertThatThrownBy(() -> { - new JpaControlLoop(null, null, null, new LinkedHashMap<>()); - }).hasMessageMatching(NULL_KEY_ERROR); - - assertThatThrownBy(() -> { - new JpaControlLoop(null, null, ControlLoopState.UNINITIALISED, null); - }).hasMessageMatching(NULL_KEY_ERROR); - - assertThatThrownBy(() -> { - new JpaControlLoop(null, null, ControlLoopState.UNINITIALISED, new LinkedHashMap<>()); - }).hasMessageMatching(NULL_KEY_ERROR); - - assertThatThrownBy(() -> { - new JpaControlLoop(null, new PfConceptKey(), null, null); - }).hasMessageMatching(NULL_KEY_ERROR); - - assertThatThrownBy(() -> { - new JpaControlLoop(null, new PfConceptKey(), null, new LinkedHashMap<>()); - }).hasMessageMatching(NULL_KEY_ERROR); - - assertThatThrownBy(() -> { - new JpaControlLoop(null, new PfConceptKey(), ControlLoopState.UNINITIALISED, null); - }).hasMessageMatching(NULL_KEY_ERROR); - - assertThatThrownBy(() -> { - new JpaControlLoop(null, new PfConceptKey(), ControlLoopState.UNINITIALISED, new LinkedHashMap<>()); - }).hasMessageMatching(NULL_KEY_ERROR); - - assertThatThrownBy(() -> { - new JpaControlLoop(new PfConceptKey(), null, null, null); - }).hasMessageMatching("definition is marked .*ull but is null"); - - assertThatThrownBy(() -> { - new JpaControlLoop(new PfConceptKey(), null, null, new LinkedHashMap<>()); - }).hasMessageMatching("definition is marked .*ull but is null"); - - assertThatThrownBy(() -> { - new JpaControlLoop(new PfConceptKey(), null, ControlLoopState.UNINITIALISED, null); - }).hasMessageMatching("definition is marked .*ull but is null"); - - assertThatThrownBy(() -> { - new JpaControlLoop(new PfConceptKey(), null, ControlLoopState.UNINITIALISED, new LinkedHashMap<>()); - }).hasMessageMatching("definition is marked .*ull but is null"); - - assertThatThrownBy(() -> { - new JpaControlLoop(new PfConceptKey(), new PfConceptKey(), null, null); - }).hasMessageMatching("state is marked .*ull but is null"); - - assertThatThrownBy(() -> { - new JpaControlLoop(new PfConceptKey(), new PfConceptKey(), null, new LinkedHashMap<>()); - }).hasMessageMatching("state is marked .*ull but is null"); - - assertThatThrownBy(() -> { - new JpaControlLoop(new PfConceptKey(), new PfConceptKey(), ControlLoopState.UNINITIALISED, null); - }).hasMessageMatching("elements is marked .*ull but is null"); - - assertNotNull(new JpaControlLoop()); - assertNotNull(new JpaControlLoop((new PfConceptKey()))); - assertNotNull(new JpaControlLoop(new PfConceptKey(), new PfConceptKey(), ControlLoopState.UNINITIALISED, - new LinkedHashMap<>())); - } - - @Test - void testJpaControlLoop() { - JpaControlLoop testJpaControlLoop = createJpaControlLoopInstance(); - - ControlLoop participant = createControlLoopInstance(); - assertEquals(participant, testJpaControlLoop.toAuthorative()); - - assertThatThrownBy(() -> { - testJpaControlLoop.fromAuthorative(null); - }).hasMessageMatching("controlLoop is marked .*ull but is null"); - - assertThatThrownBy(() -> new JpaControlLoop((JpaControlLoop) null)).isInstanceOf(NullPointerException.class); - - JpaControlLoop testJpaControlLoopFa = new JpaControlLoop(); - testJpaControlLoopFa.setKey(null); - testJpaControlLoopFa.fromAuthorative(participant); - assertEquals(testJpaControlLoop, testJpaControlLoopFa); - testJpaControlLoopFa.setKey(PfConceptKey.getNullKey()); - testJpaControlLoopFa.fromAuthorative(participant); - assertEquals(testJpaControlLoop, testJpaControlLoopFa); - testJpaControlLoopFa.setKey(new PfConceptKey("control-loop", "0.0.1")); - testJpaControlLoopFa.fromAuthorative(participant); - assertEquals(testJpaControlLoop, testJpaControlLoopFa); - - assertEquals("control-loop", testJpaControlLoop.getKey().getName()); - assertEquals("control-loop", new JpaControlLoop(createControlLoopInstance()).getKey().getName()); - assertEquals("control-loop", - ((PfConceptKey) new JpaControlLoop(createControlLoopInstance()).getKeys().get(0)).getName()); - - testJpaControlLoop.clean(); - assertEquals("control-loop", testJpaControlLoop.getKey().getName()); - - testJpaControlLoop.setDescription(" A Message "); - testJpaControlLoop.clean(); - assertEquals("A Message", testJpaControlLoop.getDescription()); - - JpaControlLoop testJpaControlLoop2 = new JpaControlLoop(testJpaControlLoop); - assertEquals(testJpaControlLoop, testJpaControlLoop2); - } - - @Test - void testJpaControlLoopElementOrderedState() throws CoderException { - ControlLoop testControlLoop = createControlLoopInstance(); - JpaControlLoop testJpaControlLoop = createJpaControlLoopInstance(); - - testJpaControlLoop.setOrderedState(null); - assertEquals(testControlLoop, testJpaControlLoop.toAuthorative()); - testJpaControlLoop.setOrderedState(ControlLoopOrderedState.UNINITIALISED); - - ControlLoop noOrderedStateCl = new StandardCoder() - .decode(new File("src/test/resources/json/ControlLoopNoOrderedState.json"), ControlLoop.class); - - JpaControlLoop noOrderedStateJpaCl = new JpaControlLoop(noOrderedStateCl); - assertNull(noOrderedStateJpaCl.getOrderedState()); - noOrderedStateCl.setOrderedState(ControlLoopOrderedState.UNINITIALISED); - noOrderedStateJpaCl = new JpaControlLoop(noOrderedStateCl); - assertEquals(testJpaControlLoop, noOrderedStateJpaCl); - - ControlLoops controlLoopsWithElements = new StandardCoder() - .decode(new File("src/test/resources/providers/TestControlLoops.json"), ControlLoops.class); - - JpaControlLoop jpaControlLoopWithElements = - new JpaControlLoop(controlLoopsWithElements.getControlLoopList().get(0)); - assertEquals(4, jpaControlLoopWithElements.getElements().size()); - assertEquals(18, jpaControlLoopWithElements.getKeys().size()); - assertThatCode(() -> jpaControlLoopWithElements.clean()).doesNotThrowAnyException(); - - assertEquals(controlLoopsWithElements.getControlLoopList().get(0), jpaControlLoopWithElements.toAuthorative()); - } - - @Test - void testJpaControlLoopValidation() { - JpaControlLoop testJpaControlLoop = createJpaControlLoopInstance(); - - assertThatThrownBy(() -> { - testJpaControlLoop.validate(null); - }).hasMessageMatching("fieldName is marked .*ull but is null"); - - assertTrue(testJpaControlLoop.validate("").isValid()); - } - - @Test - void testJpaControlLoopCompareTo() { - JpaControlLoop testJpaControlLoop = createJpaControlLoopInstance(); - - JpaControlLoop otherJpaControlLoop = new JpaControlLoop(testJpaControlLoop); - assertEquals(0, testJpaControlLoop.compareTo(otherJpaControlLoop)); - assertEquals(-1, testJpaControlLoop.compareTo(null)); - assertEquals(0, testJpaControlLoop.compareTo(testJpaControlLoop)); - assertNotEquals(0, testJpaControlLoop.compareTo(new DummyJpaControlLoopChild())); - - testJpaControlLoop.setKey(new PfConceptKey("BadValue", "0.0.1")); - assertNotEquals(0, testJpaControlLoop.compareTo(otherJpaControlLoop)); - testJpaControlLoop.setKey(new PfConceptKey("control-loop", "0.0.1")); - assertEquals(0, testJpaControlLoop.compareTo(otherJpaControlLoop)); - - testJpaControlLoop.setDefinition(new PfConceptKey("BadValue", "0.0.1")); - assertNotEquals(0, testJpaControlLoop.compareTo(otherJpaControlLoop)); - testJpaControlLoop.setDefinition(new PfConceptKey("controlLoopDefinitionName", "0.0.1")); - assertEquals(0, testJpaControlLoop.compareTo(otherJpaControlLoop)); - - testJpaControlLoop.setState(ControlLoopState.PASSIVE); - assertNotEquals(0, testJpaControlLoop.compareTo(otherJpaControlLoop)); - testJpaControlLoop.setState(ControlLoopState.UNINITIALISED); - assertEquals(0, testJpaControlLoop.compareTo(otherJpaControlLoop)); - - testJpaControlLoop.setOrderedState(ControlLoopOrderedState.PASSIVE); - assertNotEquals(0, testJpaControlLoop.compareTo(otherJpaControlLoop)); - testJpaControlLoop.setOrderedState(ControlLoopOrderedState.UNINITIALISED); - assertEquals(0, testJpaControlLoop.compareTo(otherJpaControlLoop)); - - testJpaControlLoop.setDescription("A description"); - assertNotEquals(0, testJpaControlLoop.compareTo(otherJpaControlLoop)); - testJpaControlLoop.setDescription(null); - assertEquals(0, testJpaControlLoop.compareTo(otherJpaControlLoop)); - - testJpaControlLoop.setPrimed(true); - assertNotEquals(0, testJpaControlLoop.compareTo(otherJpaControlLoop)); - testJpaControlLoop.setPrimed(false); - assertEquals(0, testJpaControlLoop.compareTo(otherJpaControlLoop)); - - assertEquals(testJpaControlLoop, new JpaControlLoop(testJpaControlLoop)); - } - - @Test - void testJpaControlLoopLombok() { - assertNotNull(new ControlLoop()); - JpaControlLoop cl0 = new JpaControlLoop(); - - assertThat(cl0.toString()).contains("JpaControlLoop("); - assertThat(cl0.hashCode()).isNotZero(); - assertEquals(true, cl0.equals(cl0)); - assertEquals(false, cl0.equals(null)); - - - JpaControlLoop cl1 = new JpaControlLoop(); - - cl1.setDefinition(new PfConceptKey("defName", "0.0.1")); - cl1.setDescription("Description"); - cl1.setElements(new LinkedHashMap<>()); - cl1.setKey(new PfConceptKey("participant", "0.0.1")); - cl1.setState(ControlLoopState.UNINITIALISED); - - assertThat(cl1.toString()).contains("ControlLoop("); - assertEquals(false, cl1.hashCode() == 0); - assertEquals(false, cl1.equals(cl0)); - assertEquals(false, cl1.equals(null)); - - assertNotEquals(cl1, cl0); - - JpaControlLoop cl2 = new JpaControlLoop(); - assertEquals(cl2, cl0); - } - - private JpaControlLoop createJpaControlLoopInstance() { - ControlLoop testControlLoop = createControlLoopInstance(); - JpaControlLoop testJpaControlLoop = new JpaControlLoop(); - testJpaControlLoop.setKey(null); - testJpaControlLoop.fromAuthorative(testControlLoop); - testJpaControlLoop.setKey(PfConceptKey.getNullKey()); - testJpaControlLoop.fromAuthorative(testControlLoop); - - return testJpaControlLoop; - } - - private ControlLoop createControlLoopInstance() { - ControlLoop testControlLoop = new ControlLoop(); - testControlLoop.setName("control-loop"); - testControlLoop.setVersion("0.0.1"); - testControlLoop.setDefinition(new ToscaConceptIdentifier("controlLoopDefinitionName", "0.0.1")); - testControlLoop.setElements(new LinkedHashMap<>()); - - return testControlLoop; - } -} diff --git a/models/src/test/java/org/onap/policy/clamp/controlloop/models/controlloop/persistence/concepts/JpaParticipantStatisticsTest.java b/models/src/test/java/org/onap/policy/clamp/controlloop/models/controlloop/persistence/concepts/JpaParticipantStatisticsTest.java deleted file mode 100644 index aff365515..000000000 --- a/models/src/test/java/org/onap/policy/clamp/controlloop/models/controlloop/persistence/concepts/JpaParticipantStatisticsTest.java +++ /dev/null @@ -1,193 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * Copyright (C) 2021 Nordix Foundation. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - * SPDX-License-Identifier: Apache-2.0 - * ============LICENSE_END========================================================= - */ - -package org.onap.policy.clamp.controlloop.models.controlloop.persistence.concepts; - -import static org.assertj.core.api.Assertions.assertThat; -import static org.assertj.core.api.Assertions.assertThatThrownBy; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertNotEquals; -import static org.junit.Assert.assertNotNull; -import static org.junit.Assert.assertTrue; - -import java.time.Instant; -import org.junit.jupiter.api.Test; -import org.onap.policy.clamp.controlloop.models.controlloop.concepts.Participant; -import org.onap.policy.clamp.controlloop.models.controlloop.concepts.ParticipantHealthStatus; -import org.onap.policy.clamp.controlloop.models.controlloop.concepts.ParticipantState; -import org.onap.policy.clamp.controlloop.models.controlloop.concepts.ParticipantStatistics; -import org.onap.policy.common.parameters.BeanValidationResult; -import org.onap.policy.models.base.PfConceptKey; -import org.onap.policy.models.base.PfTimestampKey; -import org.onap.policy.models.tosca.authorative.concepts.ToscaConceptIdentifier; - -/** - * Test the {@link JpaParticipantStatistics} class. - */ -class JpaParticipantStatisticsTest { - - private static final String NULL_KEY_ERROR = "key is marked .*ull but is null"; - - @Test - void testJpaParticipantStatisticsConstructor() { - assertThatThrownBy(() -> { - new JpaParticipantStatistics((JpaParticipantStatistics) null); - }).hasMessageMatching("copyConcept is marked .*ull but is null"); - - assertThatThrownBy(() -> { - new JpaParticipantStatistics((PfTimestampKey) null); - }).hasMessageMatching(NULL_KEY_ERROR); - - assertThatThrownBy(() -> { - new JpaParticipantStatistics(null, null); - }).hasMessageMatching(NULL_KEY_ERROR); - - assertThatThrownBy(() -> { - new JpaParticipantStatistics(null, new PfConceptKey()); - }).hasMessageMatching(NULL_KEY_ERROR); - - assertThatThrownBy(() -> { - new JpaParticipantStatistics(new PfTimestampKey(), null); - }).hasMessageMatching("participantId is marked .*ull but is null"); - - assertNotNull(new JpaParticipantStatistics()); - assertNotNull(new JpaParticipantStatistics((new PfTimestampKey()))); - assertNotNull(new JpaParticipantStatistics(new PfTimestampKey(), new PfConceptKey())); - } - - @Test - void testJpaParticipantStatistics() { - JpaParticipantStatistics testJpaParticipantStatistics = createJpaParticipantStatisticsInstance(); - - ParticipantStatistics cles = createParticipantStatisticsInstance(); - assertEquals(cles, testJpaParticipantStatistics.toAuthorative()); - - assertThatThrownBy(() -> { - testJpaParticipantStatistics.fromAuthorative(null); - }).hasMessageMatching("participantStatistics is marked .*ull but is null"); - - assertThatThrownBy(() -> new JpaParticipantStatistics((JpaParticipantStatistics) null)) - .isInstanceOf(NullPointerException.class); - - JpaParticipantStatistics testJpaParticipantStatisticsFa = new JpaParticipantStatistics(); - testJpaParticipantStatisticsFa.setKey(null); - testJpaParticipantStatisticsFa.fromAuthorative(cles); - assertEquals(testJpaParticipantStatistics, testJpaParticipantStatisticsFa); - testJpaParticipantStatisticsFa.setKey(PfTimestampKey.getNullKey()); - testJpaParticipantStatisticsFa.fromAuthorative(cles); - assertEquals(testJpaParticipantStatistics, testJpaParticipantStatisticsFa); - testJpaParticipantStatisticsFa - .setKey(new PfTimestampKey("participantName", "0.0.1", Instant.ofEpochMilli(123456L))); - testJpaParticipantStatisticsFa.fromAuthorative(cles); - assertEquals(testJpaParticipantStatistics, testJpaParticipantStatisticsFa); - - testJpaParticipantStatisticsFa = new JpaParticipantStatistics(cles); - assertEquals(testJpaParticipantStatistics, testJpaParticipantStatisticsFa); - - assertEquals(2, testJpaParticipantStatistics.getKeys().size()); - - assertEquals("participantName", testJpaParticipantStatistics.getKey().getName()); - - testJpaParticipantStatistics.clean(); - assertEquals("participantName", testJpaParticipantStatistics.getKey().getName()); - - JpaParticipantStatistics testJpaParticipantStatistics2 = - new JpaParticipantStatistics(testJpaParticipantStatistics); - assertEquals(testJpaParticipantStatistics, testJpaParticipantStatistics2); - } - - @Test - void testJpaParticipantStatisticsValidation() { - JpaParticipantStatistics testJpaParticipantStatistics = createJpaParticipantStatisticsInstance(); - - assertThatThrownBy(() -> { - testJpaParticipantStatistics.validate(null); - }).hasMessageMatching("fieldName is marked .*ull but is null"); - - BeanValidationResult validationResult = testJpaParticipantStatistics.validate(""); - assertTrue(validationResult.isValid()); - } - - @Test - void testJpaParticipantStatisticsConmpareTo() { - JpaParticipantStatistics testJpaParticipantStatistics = createJpaParticipantStatisticsInstance(); - - JpaParticipantStatistics otherJpaParticipantStatistics = - new JpaParticipantStatistics(testJpaParticipantStatistics); - assertEquals(0, testJpaParticipantStatistics.compareTo(otherJpaParticipantStatistics)); - assertEquals(-1, testJpaParticipantStatistics.compareTo(null)); - assertEquals(0, testJpaParticipantStatistics.compareTo(testJpaParticipantStatistics)); - assertNotEquals(0, testJpaParticipantStatistics.compareTo(new DummyJpaParticipantStatisticsChild())); - - testJpaParticipantStatistics.setState(ParticipantState.UNKNOWN); - assertNotEquals(0, testJpaParticipantStatistics.compareTo(otherJpaParticipantStatistics)); - testJpaParticipantStatistics.setState(ParticipantState.PASSIVE); - assertEquals(0, testJpaParticipantStatistics.compareTo(otherJpaParticipantStatistics)); - - assertEquals(testJpaParticipantStatistics, new JpaParticipantStatistics(testJpaParticipantStatistics)); - } - - @Test - void testJpaParticipantStatisticsLombok() { - assertNotNull(new Participant()); - JpaParticipantStatistics ps0 = new JpaParticipantStatistics(); - - assertThat(ps0.toString()).contains("JpaParticipantStatistics("); - assertThat(ps0.hashCode()).isNotZero(); - assertEquals(true, ps0.equals(ps0)); - assertEquals(false, ps0.equals(null)); - - - JpaParticipantStatistics ps1 = new JpaParticipantStatistics(); - - ps1.setState(ParticipantState.UNKNOWN); - - assertThat(ps1.toString()).contains("JpaParticipantStatistics("); - assertEquals(false, ps1.hashCode() == 0); - assertEquals(false, ps1.equals(ps0)); - assertEquals(false, ps1.equals(null)); - - assertNotEquals(ps1, ps0); - - JpaParticipantStatistics ps2 = new JpaParticipantStatistics(); - assertEquals(ps2, ps0); - } - - private JpaParticipantStatistics createJpaParticipantStatisticsInstance() { - ParticipantStatistics testCles = createParticipantStatisticsInstance(); - JpaParticipantStatistics testJpaParticipantStatistics = new JpaParticipantStatistics(); - testJpaParticipantStatistics.setKey(null); - testJpaParticipantStatistics.fromAuthorative(testCles); - testJpaParticipantStatistics.setKey(PfTimestampKey.getNullKey()); - testJpaParticipantStatistics.fromAuthorative(testCles); - - return testJpaParticipantStatistics; - } - - private ParticipantStatistics createParticipantStatisticsInstance() { - ParticipantStatistics participantStatistics = new ParticipantStatistics(); - participantStatistics.setParticipantId(new ToscaConceptIdentifier("participantName", "0.0.1")); - participantStatistics.setTimeStamp(Instant.ofEpochMilli(123456L)); - participantStatistics.setState(ParticipantState.PASSIVE); - participantStatistics.setHealthStatus(ParticipantHealthStatus.HEALTHY); - - return participantStatistics; - } -} diff --git a/models/src/test/java/org/onap/policy/clamp/controlloop/models/controlloop/persistence/concepts/JpaParticipantTest.java b/models/src/test/java/org/onap/policy/clamp/controlloop/models/controlloop/persistence/concepts/JpaParticipantTest.java deleted file mode 100644 index 087292354..000000000 --- a/models/src/test/java/org/onap/policy/clamp/controlloop/models/controlloop/persistence/concepts/JpaParticipantTest.java +++ /dev/null @@ -1,254 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * Copyright (C) 2021 Nordix Foundation. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - * SPDX-License-Identifier: Apache-2.0 - * ============LICENSE_END========================================================= - */ - -package org.onap.policy.clamp.controlloop.models.controlloop.persistence.concepts; - -import static org.assertj.core.api.Assertions.assertThat; -import static org.assertj.core.api.Assertions.assertThatThrownBy; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertNotEquals; -import static org.junit.Assert.assertNotNull; -import static org.junit.Assert.assertTrue; - -import org.junit.jupiter.api.Test; -import org.onap.policy.clamp.controlloop.models.controlloop.concepts.Participant; -import org.onap.policy.clamp.controlloop.models.controlloop.concepts.ParticipantHealthStatus; -import org.onap.policy.clamp.controlloop.models.controlloop.concepts.ParticipantState; -import org.onap.policy.models.base.PfConceptKey; -import org.onap.policy.models.tosca.authorative.concepts.ToscaConceptIdentifier; - -/** - * Test the {@link JpaParticiant} class. - */ -class JpaParticipantTest { - - private static final String NULL_KEY_ERROR = "key is marked .*ull but is null"; - - @Test - void testJpaParticipantConstructor() { - assertThatThrownBy(() -> { - new JpaParticipant((JpaParticipant) null); - }).hasMessageMatching("copyConcept is marked .*ull but is null"); - - assertThatThrownBy(() -> { - new JpaParticipant((PfConceptKey) null); - }).hasMessageMatching(NULL_KEY_ERROR); - - assertThatThrownBy(() -> { - new JpaParticipant(null, null, null, null); - }).hasMessageMatching(NULL_KEY_ERROR); - - assertThatThrownBy(() -> { - new JpaParticipant(null, null, null, ParticipantHealthStatus.HEALTHY); - }).hasMessageMatching(NULL_KEY_ERROR); - - assertThatThrownBy(() -> { - new JpaParticipant(null, null, ParticipantState.ACTIVE, null); - }).hasMessageMatching(NULL_KEY_ERROR); - - assertThatThrownBy(() -> { - new JpaParticipant(null, null, ParticipantState.ACTIVE, ParticipantHealthStatus.HEALTHY); - }).hasMessageMatching(NULL_KEY_ERROR); - - assertThatThrownBy(() -> { - new JpaParticipant(null, new PfConceptKey(), null, null); - }).hasMessageMatching(NULL_KEY_ERROR); - - assertThatThrownBy(() -> { - new JpaParticipant(null, new PfConceptKey(), null, ParticipantHealthStatus.HEALTHY); - }).hasMessageMatching(NULL_KEY_ERROR); - - assertThatThrownBy(() -> { - new JpaParticipant(null, new PfConceptKey(), ParticipantState.ACTIVE, null); - }).hasMessageMatching(NULL_KEY_ERROR); - - assertThatThrownBy(() -> { - new JpaParticipant(null, new PfConceptKey(), ParticipantState.ACTIVE, ParticipantHealthStatus.HEALTHY); - }).hasMessageMatching(NULL_KEY_ERROR); - - assertThatThrownBy(() -> { - new JpaParticipant(new PfConceptKey(), null, null, null); - }).hasMessageMatching("definition is marked .*ull but is null"); - - assertThatThrownBy(() -> { - new JpaParticipant(new PfConceptKey(), null, null, ParticipantHealthStatus.HEALTHY); - }).hasMessageMatching("definition is marked .*ull but is null"); - - assertThatThrownBy(() -> { - new JpaParticipant(new PfConceptKey(), null, ParticipantState.ACTIVE, null); - }).hasMessageMatching("definition is marked .*ull but is null"); - - assertThatThrownBy(() -> { - new JpaParticipant(new PfConceptKey(), null, ParticipantState.ACTIVE, ParticipantHealthStatus.HEALTHY); - }).hasMessageMatching("definition is marked .*ull but is null"); - - assertThatThrownBy(() -> { - new JpaParticipant(new PfConceptKey(), new PfConceptKey(), null, null); - }).hasMessageMatching("participantState is marked .*ull but is null"); - - assertThatThrownBy(() -> { - new JpaParticipant(new PfConceptKey(), new PfConceptKey(), null, ParticipantHealthStatus.HEALTHY); - }).hasMessageMatching("participantState is marked .*ull but is null"); - - assertThatThrownBy(() -> { - new JpaParticipant(new PfConceptKey(), new PfConceptKey(), ParticipantState.ACTIVE, null); - }).hasMessageMatching("healthStatus is marked .*ull but is null"); - - assertNotNull(new JpaParticipant()); - assertNotNull(new JpaParticipant((new PfConceptKey()))); - assertNotNull(new JpaParticipant(new PfConceptKey(), new PfConceptKey(), ParticipantState.ACTIVE, - ParticipantHealthStatus.HEALTHY)); - } - - @Test - void testJpaParticipant() { - JpaParticipant testJpaParticipant = createJpaParticipantInstance(); - - Participant participant = createParticipantInstance(); - assertEquals(participant, testJpaParticipant.toAuthorative()); - - assertThatThrownBy(() -> { - testJpaParticipant.fromAuthorative(null); - }).hasMessageMatching("participant is marked .*ull but is null"); - - assertThatThrownBy(() -> new JpaParticipant((JpaParticipant) null)).isInstanceOf(NullPointerException.class); - - JpaParticipant testJpaParticipantFa = new JpaParticipant(); - testJpaParticipantFa.setKey(null); - testJpaParticipantFa.fromAuthorative(participant); - assertEquals(testJpaParticipant, testJpaParticipantFa); - testJpaParticipantFa.setKey(PfConceptKey.getNullKey()); - testJpaParticipantFa.fromAuthorative(participant); - assertEquals(testJpaParticipant, testJpaParticipantFa); - testJpaParticipantFa.setKey(new PfConceptKey("participant", "0.0.1")); - testJpaParticipantFa.fromAuthorative(participant); - assertEquals(testJpaParticipant, testJpaParticipantFa); - - assertEquals("participant", testJpaParticipant.getKey().getName()); - assertEquals("participant", new JpaParticipant(createParticipantInstance()).getKey().getName()); - assertEquals("participant", - ((PfConceptKey) new JpaParticipant(createParticipantInstance()).getKeys().get(0)).getName()); - - testJpaParticipant.clean(); - assertEquals("participant", testJpaParticipant.getKey().getName()); - - testJpaParticipant.setDescription(" A Message "); - testJpaParticipant.clean(); - assertEquals("A Message", testJpaParticipant.getDescription()); - - JpaParticipant testJpaParticipant2 = new JpaParticipant(testJpaParticipant); - assertEquals(testJpaParticipant, testJpaParticipant2); - } - - @Test - void testJpaParticipantValidation() { - JpaParticipant testJpaParticipant = createJpaParticipantInstance(); - - assertThatThrownBy(() -> { - testJpaParticipant.validate(null); - }).hasMessageMatching("fieldName is marked .*ull but is null"); - - assertTrue(testJpaParticipant.validate("").isValid()); - } - - @Test - void testJpaParticipantCompareTo() { - JpaParticipant testJpaParticipant = createJpaParticipantInstance(); - - JpaParticipant otherJpaParticipant = new JpaParticipant(testJpaParticipant); - assertEquals(0, testJpaParticipant.compareTo(otherJpaParticipant)); - assertEquals(-1, testJpaParticipant.compareTo(null)); - assertEquals(0, testJpaParticipant.compareTo(testJpaParticipant)); - assertNotEquals(0, testJpaParticipant.compareTo(new DummyJpaParticipantChild())); - - testJpaParticipant.setKey(new PfConceptKey("BadValue", "0.0.1")); - assertNotEquals(0, testJpaParticipant.compareTo(otherJpaParticipant)); - testJpaParticipant.setKey(new PfConceptKey("participant", "0.0.1")); - assertEquals(0, testJpaParticipant.compareTo(otherJpaParticipant)); - - testJpaParticipant.setDefinition(new PfConceptKey("BadValue", "0.0.1")); - assertNotEquals(0, testJpaParticipant.compareTo(otherJpaParticipant)); - testJpaParticipant.setDefinition(new PfConceptKey("participantDefinitionName", "0.0.1")); - assertEquals(0, testJpaParticipant.compareTo(otherJpaParticipant)); - - testJpaParticipant.setParticipantState(ParticipantState.PASSIVE); - assertNotEquals(0, testJpaParticipant.compareTo(otherJpaParticipant)); - testJpaParticipant.setParticipantState(ParticipantState.UNKNOWN); - assertEquals(0, testJpaParticipant.compareTo(otherJpaParticipant)); - - testJpaParticipant.setHealthStatus(ParticipantHealthStatus.NOT_HEALTHY); - assertNotEquals(0, testJpaParticipant.compareTo(otherJpaParticipant)); - testJpaParticipant.setHealthStatus(ParticipantHealthStatus.UNKNOWN); - assertEquals(0, testJpaParticipant.compareTo(otherJpaParticipant)); - - assertEquals(testJpaParticipant, new JpaParticipant(testJpaParticipant)); - } - - @Test - void testJpaParticipantLombok() { - assertNotNull(new Participant()); - JpaParticipant p0 = new JpaParticipant(); - - assertThat(p0.toString()).contains("JpaParticipant("); - assertThat(p0.hashCode()).isNotZero(); - assertEquals(true, p0.equals(p0)); - assertEquals(false, p0.equals(null)); - - - JpaParticipant p1 = new JpaParticipant(); - - p1.setDefinition(new PfConceptKey("defName", "0.0.1")); - p1.setDescription("Description"); - p1.setHealthStatus(ParticipantHealthStatus.HEALTHY); - p1.setKey(new PfConceptKey("participant", "0.0.1")); - p1.setParticipantState(ParticipantState.ACTIVE); - - assertThat(p1.toString()).contains("Participant("); - assertEquals(false, p1.hashCode() == 0); - assertEquals(false, p1.equals(p0)); - assertEquals(false, p1.equals(null)); - - assertNotEquals(p1, p0); - - JpaParticipant p2 = new JpaParticipant(); - assertEquals(p2, p0); - } - - private JpaParticipant createJpaParticipantInstance() { - Participant testParticipant = createParticipantInstance(); - JpaParticipant testJpaParticipant = new JpaParticipant(); - testJpaParticipant.setKey(null); - testJpaParticipant.fromAuthorative(testParticipant); - testJpaParticipant.setKey(PfConceptKey.getNullKey()); - testJpaParticipant.fromAuthorative(testParticipant); - - return testJpaParticipant; - } - - private Participant createParticipantInstance() { - Participant testParticipant = new Participant(); - testParticipant.setName("participant"); - testParticipant.setVersion("0.0.1"); - testParticipant.setDefinition(new ToscaConceptIdentifier("participantDefinitionName", "0.0.1")); - testParticipant.setParticipantType(new ToscaConceptIdentifier("participantTypeName", "0.0.1")); - - return testParticipant; - } -} diff --git a/models/src/test/java/org/onap/policy/clamp/controlloop/models/controlloop/persistence/concepts/PojosTest.java b/models/src/test/java/org/onap/policy/clamp/controlloop/models/controlloop/persistence/concepts/PojosTest.java deleted file mode 100644 index c877f9696..000000000 --- a/models/src/test/java/org/onap/policy/clamp/controlloop/models/controlloop/persistence/concepts/PojosTest.java +++ /dev/null @@ -1,62 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * Copyright (C) 2021 Nordix Foundation. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - * SPDX-License-Identifier: Apache-2.0 - * ============LICENSE_END========================================================= - */ - -package org.onap.policy.clamp.controlloop.models.controlloop.persistence.concepts; - -import com.openpojo.reflection.PojoClass; -import com.openpojo.reflection.impl.PojoClassFactory; -import com.openpojo.validation.Validator; -import com.openpojo.validation.ValidatorBuilder; -import com.openpojo.validation.rule.impl.EqualsAndHashCodeMatchRule; -import com.openpojo.validation.rule.impl.GetterMustExistRule; -import com.openpojo.validation.rule.impl.NoPublicFieldsExceptStaticFinalRule; -import com.openpojo.validation.rule.impl.SetterMustExistRule; -import com.openpojo.validation.test.impl.GetterTester; -import com.openpojo.validation.test.impl.SetterTester; -import java.util.List; -import org.junit.jupiter.api.Test; -import org.onap.policy.common.utils.test.ToStringTester; - -/** - * Class to perform unit tests of all pojos. - */ -class PojosTest { - - @Test - void testPojos() { - List pojoClasses = - PojoClassFactory.getPojoClasses(PojosTest.class.getPackageName()); - - // @formatter:off - final Validator validator = ValidatorBuilder - .create() - .with(new SetterMustExistRule()) - .with(new GetterMustExistRule()) - .with(new EqualsAndHashCodeMatchRule()) - .with(new NoPublicFieldsExceptStaticFinalRule()) - .with(new SetterTester()) - .with(new GetterTester()) - .with(new ToStringTester()) - .build(); - - validator.validate(pojoClasses); - // @formatter:on - } -} diff --git a/models/src/test/java/org/onap/policy/clamp/controlloop/models/controlloop/persistence/provider/ClElementStatisticsProviderTest.java b/models/src/test/java/org/onap/policy/clamp/controlloop/models/controlloop/persistence/provider/ClElementStatisticsProviderTest.java deleted file mode 100644 index 82ce8d789..000000000 --- a/models/src/test/java/org/onap/policy/clamp/controlloop/models/controlloop/persistence/provider/ClElementStatisticsProviderTest.java +++ /dev/null @@ -1,116 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * Copyright (C) 2021 Nordix Foundation. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - * SPDX-License-Identifier: Apache-2.0 - * ============LICENSE_END========================================================= - */ - -package org.onap.policy.clamp.controlloop.models.controlloop.persistence.provider; - -import static org.assertj.core.api.Assertions.assertThat; -import static org.assertj.core.api.Assertions.assertThatThrownBy; -import static org.junit.Assert.assertEquals; -import static org.mockito.ArgumentMatchers.any; -import static org.mockito.ArgumentMatchers.anyList; -import static org.mockito.ArgumentMatchers.eq; -import static org.mockito.Mockito.mock; -import static org.mockito.Mockito.when; - -import java.time.Instant; -import java.util.List; -import org.junit.jupiter.api.BeforeEach; -import org.junit.jupiter.api.Test; -import org.onap.policy.clamp.controlloop.models.controlloop.concepts.ClElementStatistics; -import org.onap.policy.clamp.controlloop.models.controlloop.concepts.ClElementStatisticsList; -import org.onap.policy.clamp.controlloop.models.controlloop.persistence.concepts.JpaClElementStatistics; -import org.onap.policy.clamp.controlloop.models.controlloop.persistence.repository.ClElementStatisticsRepository; -import org.onap.policy.common.utils.coder.Coder; -import org.onap.policy.common.utils.coder.StandardCoder; -import org.onap.policy.common.utils.resources.ResourceUtils; -import org.onap.policy.models.tosca.authorative.concepts.ToscaConceptIdentifier; - -class ClElementStatisticsProviderTest { - private static final String LIST_IS_NULL = ".*. is marked .*ull but is null"; - private static final Coder CODER = new StandardCoder(); - private static final String CL_ELEMENT_STATS_JSON = "src/test/resources/providers/TestClElementStatistics.json"; - - private ClElementStatisticsProvider clElementStatisticsProvider; - private ClElementStatisticsList inputClElementStats; - private String originalJson = ResourceUtils.getResourceAsString(CL_ELEMENT_STATS_JSON); - - /** - * Set up test ClElement statistics provider. - * - * @throws Exception on errors - */ - @BeforeEach - void beforeSetupDao() throws Exception { - - inputClElementStats = CODER.decode(originalJson, ClElementStatisticsList.class); - var clElementStatisticsRepository = mock(ClElementStatisticsRepository.class); - - var jpaClElementStatisticsList = - ProviderUtils.getJpaAndValidateList(inputClElementStats.getClElementStatistics(), - JpaClElementStatistics::new, "control loop element statistics"); - - for (var clElementStat : jpaClElementStatisticsList) { - when(clElementStatisticsRepository.getById(eq(clElementStat.getKey()))).thenReturn(clElementStat); - when(clElementStatisticsRepository.findAllById(eq(List.of(clElementStat.getKey())))) - .thenReturn(List.of(clElementStat)); - } - - when(clElementStatisticsRepository.saveAll(anyList())).thenReturn(jpaClElementStatisticsList); - - when(clElementStatisticsRepository.getFiltered(eq(JpaClElementStatistics.class), any())) - .thenReturn(List.of(jpaClElementStatisticsList.get(0))); - - clElementStatisticsProvider = new ClElementStatisticsProvider(clElementStatisticsRepository); - } - - @Test - void testClElementStatisticsCreate() throws Exception { - assertThatThrownBy(() -> { - clElementStatisticsProvider.createClElementStatistics(null); - }).hasMessageMatching(LIST_IS_NULL); - - ClElementStatisticsList createdClElementStats = new ClElementStatisticsList(); - createdClElementStats.setClElementStatistics( - clElementStatisticsProvider.createClElementStatistics(inputClElementStats.getClElementStatistics())); - - assertEquals(inputClElementStats.toString().replaceAll("\\s+", ""), - createdClElementStats.toString().replaceAll("\\s+", "")); - } - - @Test - void testGetClElementStatistics() throws Exception { - - List getResponse; - - // Return empty list when no data present in db - getResponse = clElementStatisticsProvider.getClElementStatistics(null, null, null, null); - assertThat(getResponse).isEmpty(); - - clElementStatisticsProvider.createClElementStatistics(inputClElementStats.getClElementStatistics()); - ToscaConceptIdentifier identifier = inputClElementStats.getClElementStatistics().get(0).getParticipantId(); - Instant instant = inputClElementStats.getClElementStatistics().get(0).getTimeStamp(); - String id = inputClElementStats.getClElementStatistics().get(0).getId().toString(); - assertEquals(1, clElementStatisticsProvider - .getClElementStatistics(identifier.getName(), identifier.getVersion(), id, instant).size()); - - assertEquals(1, clElementStatisticsProvider - .getFilteredClElementStatistics("name2", "1.0.1", null, null, null, "DESC", 1).size()); - } -} diff --git a/models/src/test/java/org/onap/policy/clamp/controlloop/models/controlloop/persistence/provider/ControlLoopProviderTest.java b/models/src/test/java/org/onap/policy/clamp/controlloop/models/controlloop/persistence/provider/ControlLoopProviderTest.java deleted file mode 100644 index 4b8617b3d..000000000 --- a/models/src/test/java/org/onap/policy/clamp/controlloop/models/controlloop/persistence/provider/ControlLoopProviderTest.java +++ /dev/null @@ -1,290 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * Copyright (C) 2021 Nordix Foundation. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - * SPDX-License-Identifier: Apache-2.0 - * ============LICENSE_END========================================================= - */ - -package org.onap.policy.clamp.controlloop.models.controlloop.persistence.provider; - -import static org.assertj.core.api.Assertions.assertThat; -import static org.assertj.core.api.Assertions.assertThatThrownBy; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertNotNull; -import static org.mockito.ArgumentMatchers.any; -import static org.mockito.ArgumentMatchers.eq; -import static org.mockito.Mockito.mock; -import static org.mockito.Mockito.verify; -import static org.mockito.Mockito.when; - -import java.util.List; -import java.util.Optional; -import javax.persistence.EntityNotFoundException; -import org.junit.jupiter.api.BeforeEach; -import org.junit.jupiter.api.Test; -import org.onap.policy.clamp.controlloop.models.controlloop.concepts.ControlLoop; -import org.onap.policy.clamp.controlloop.models.controlloop.concepts.ControlLoops; -import org.onap.policy.clamp.controlloop.models.controlloop.persistence.concepts.JpaControlLoop; -import org.onap.policy.clamp.controlloop.models.controlloop.persistence.repository.ControlLoopRepository; -import org.onap.policy.clamp.controlloop.models.controlloop.persistence.repository.ToscaNodeTemplateRepository; -import org.onap.policy.clamp.controlloop.models.controlloop.persistence.repository.ToscaNodeTemplatesRepository; -import org.onap.policy.common.utils.coder.Coder; -import org.onap.policy.common.utils.coder.StandardCoder; -import org.onap.policy.common.utils.coder.YamlJsonTranslator; -import org.onap.policy.common.utils.resources.ResourceUtils; -import org.onap.policy.models.base.PfConceptKey; -import org.onap.policy.models.tosca.authorative.concepts.ToscaConceptIdentifier; -import org.onap.policy.models.tosca.authorative.concepts.ToscaNodeTemplate; -import org.onap.policy.models.tosca.authorative.concepts.ToscaServiceTemplate; -import org.onap.policy.models.tosca.authorative.concepts.ToscaTypedEntityFilter; -import org.onap.policy.models.tosca.simple.concepts.JpaToscaNodeTemplate; - -class ControlLoopProviderTest { - - private static final String LIST_IS_NULL = "controlLoops is marked .*ull but is null"; - private static final String OBJECT_IS_NULL = "controlLoop is marked non-null but is null"; - - private static final String ID_NAME = "PMSHInstance1"; - private static final String ID_VERSION = "1.0.1"; - private static final String ID_NAME_NOT_EXTST = "not_exist"; - private static final String ID_NAME_NOT_VALID = "not_valid"; - - private static final Coder CODER = new StandardCoder(); - private static final String CONTROL_LOOP_JSON = "src/test/resources/providers/TestControlLoops.json"; - private static final String TOSCA_TEMPLATE_YAML = "examples/controlloop/PMSubscriptionHandling.yaml"; - - private static final YamlJsonTranslator yamlTranslator = new YamlJsonTranslator(); - - private ControlLoops inputControlLoops; - private List inputControlLoopsJpa; - private String originalJson = ResourceUtils.getResourceAsString(CONTROL_LOOP_JSON); - - @BeforeEach - void beforeSetupDao() throws Exception { - inputControlLoops = CODER.decode(originalJson, ControlLoops.class); - inputControlLoopsJpa = ProviderUtils.getJpaAndValidateList(inputControlLoops.getControlLoopList(), - JpaControlLoop::new, "control loops"); - } - - @Test - void testControlLoopsSave() throws Exception { - var controlLoopRepository = mock(ControlLoopRepository.class); - var controlLoopProvider = new ControlLoopProvider(controlLoopRepository, - mock(ToscaNodeTemplateRepository.class), mock(ToscaNodeTemplatesRepository.class)); - - assertThatThrownBy(() -> { - controlLoopProvider.saveControlLoops(null); - }).hasMessageMatching(LIST_IS_NULL); - - when(controlLoopRepository.saveAll(inputControlLoopsJpa)).thenReturn(inputControlLoopsJpa); - - var createdControlLoops = new ControlLoops(); - createdControlLoops - .setControlLoopList(controlLoopProvider.saveControlLoops(inputControlLoops.getControlLoopList())); - - assertEquals(inputControlLoops, createdControlLoops); - - when(controlLoopRepository.saveAll(any())).thenThrow(IllegalArgumentException.class); - - assertThatThrownBy(() -> { - controlLoopProvider.saveControlLoops(inputControlLoops.getControlLoopList()); - }).hasMessageMatching("Error in save ControlLoops"); - } - - @Test - void testControlLoopSave() throws Exception { - var controlLoopRepository = mock(ControlLoopRepository.class); - var controlLoopProvider = new ControlLoopProvider(controlLoopRepository, - mock(ToscaNodeTemplateRepository.class), mock(ToscaNodeTemplatesRepository.class)); - - assertThatThrownBy(() -> { - controlLoopProvider.saveControlLoop(null); - }).hasMessageMatching(OBJECT_IS_NULL); - - when(controlLoopRepository.save(inputControlLoopsJpa.get(0))).thenReturn(inputControlLoopsJpa.get(0)); - - var createdControlLoop = controlLoopProvider.saveControlLoop(inputControlLoops.getControlLoopList().get(0)); - - assertEquals(inputControlLoops.getControlLoopList().get(0), createdControlLoop); - - when(controlLoopRepository.save(any())).thenThrow(IllegalArgumentException.class); - - assertThatThrownBy(() -> { - controlLoopProvider.saveControlLoop(inputControlLoops.getControlLoopList().get(0)); - }).hasMessageMatching("Error in save controlLoop"); - } - - @Test - void testGetControlLoops() throws Exception { - var controlLoopRepository = mock(ControlLoopRepository.class); - var controlLoopProvider = new ControlLoopProvider(controlLoopRepository, - mock(ToscaNodeTemplateRepository.class), mock(ToscaNodeTemplatesRepository.class)); - - // Return empty list when no data present in db - List getResponse = controlLoopProvider.getControlLoops(); - assertThat(getResponse).isEmpty(); - - controlLoopProvider.saveControlLoops(inputControlLoops.getControlLoopList()); - - var controlLoop0 = inputControlLoops.getControlLoopList().get(1); - var name = controlLoop0.getName(); - var version = controlLoop0.getVersion(); - var controlLoop1 = inputControlLoops.getControlLoopList().get(1); - - when(controlLoopRepository.getFiltered(eq(JpaControlLoop.class), any(), any())) - .thenReturn(List.of(new JpaControlLoop(controlLoop0), new JpaControlLoop(controlLoop1))); - when(controlLoopRepository.findById(controlLoop0.getKey().asIdentifier().asConceptKey())) - .thenReturn(Optional.of(new JpaControlLoop(controlLoop0))); - when(controlLoopRepository.getById(controlLoop0.getKey().asIdentifier().asConceptKey())) - .thenReturn(new JpaControlLoop(controlLoop0)); - when(controlLoopRepository.getFiltered(JpaControlLoop.class, name, version)) - .thenReturn(List.of(new JpaControlLoop(controlLoop0))); - when(controlLoopRepository.findById(controlLoop1.getKey().asIdentifier().asConceptKey())) - .thenReturn(Optional.of(new JpaControlLoop(controlLoop1))); - - assertEquals(1, controlLoopProvider.getControlLoops(name, version).size()); - - var cl = controlLoopProvider.findControlLoop(new ToscaConceptIdentifier(ID_NAME, ID_VERSION)).get(); - assertEquals(inputControlLoops.getControlLoopList().get(1), cl); - - cl = controlLoopProvider.getControlLoop(new ToscaConceptIdentifier(ID_NAME, ID_VERSION)); - assertEquals(inputControlLoops.getControlLoopList().get(1), cl); - - when(controlLoopRepository.getById(any())).thenThrow(EntityNotFoundException.class); - - assertThatThrownBy(() -> { - controlLoopProvider.getControlLoop(new ToscaConceptIdentifier(ID_NAME_NOT_EXTST, ID_VERSION)); - }).hasMessageMatching("ControlLoop not found"); - - cl = controlLoopProvider.findControlLoop(ID_NAME, ID_VERSION).get(); - assertEquals(inputControlLoops.getControlLoopList().get(1), cl); - - assertThat(controlLoopProvider.findControlLoop(new ToscaConceptIdentifier(ID_NAME_NOT_EXTST, ID_VERSION))) - .isEmpty(); - - when(controlLoopRepository.findById(any())).thenThrow(IllegalArgumentException.class); - - assertThatThrownBy(() -> { - controlLoopProvider.findControlLoop(ID_NAME_NOT_VALID, ID_VERSION); - }).hasMessageMatching("Not valid parameter"); - } - - @Test - void testDeleteControlLoop() throws Exception { - var controlLoopRepository = mock(ControlLoopRepository.class); - var controlLoopProvider = new ControlLoopProvider(controlLoopRepository, - mock(ToscaNodeTemplateRepository.class), mock(ToscaNodeTemplatesRepository.class)); - - assertThatThrownBy(() -> { - controlLoopProvider.deleteControlLoop(ID_NAME_NOT_EXTST, ID_VERSION); - }).hasMessageMatching(".*.failed, control loop does not exist"); - - var controlLoop = inputControlLoops.getControlLoopList().get(0); - var name = controlLoop.getName(); - var version = controlLoop.getVersion(); - - when(controlLoopRepository.findById(new PfConceptKey(name, version))) - .thenReturn(Optional.of(inputControlLoopsJpa.get(0))); - - ControlLoop deletedCl = controlLoopProvider.deleteControlLoop(name, version); - assertEquals(controlLoop, deletedCl); - } - - @Test - void testDeleteAllInstanceProperties() throws Exception { - var controlLoopProvider = new ControlLoopProvider(mock(ControlLoopRepository.class), - mock(ToscaNodeTemplateRepository.class), mock(ToscaNodeTemplatesRepository.class)); - var toscaServiceTemplate = testControlLoopRead(); - controlLoopProvider.deleteInstanceProperties(controlLoopProvider.saveInstanceProperties(toscaServiceTemplate), - controlLoopProvider.getAllNodeTemplates()); - assertThat(controlLoopProvider.getControlLoops()).isEmpty(); - } - - @Test - void testSaveAndDeleteInstanceProperties() throws Exception { - var toscaNodeTemplatesRepository = mock(ToscaNodeTemplatesRepository.class); - var toscaNodeTemplateRepository = mock(ToscaNodeTemplateRepository.class); - var controlLoopProvider = new ControlLoopProvider(mock(ControlLoopRepository.class), - toscaNodeTemplateRepository, toscaNodeTemplatesRepository); - var toscaServiceTest = testControlLoopRead(); - - controlLoopProvider.saveInstanceProperties(toscaServiceTest); - verify(toscaNodeTemplatesRepository).save(any()); - - var name = "org.onap.policy.controlloop.PolicyControlLoopParticipant"; - var version = "2.3.1"; - var elem = toscaServiceTest.getToscaTopologyTemplate().getNodeTemplates().get(name); - when(toscaNodeTemplateRepository.getFiltered(JpaToscaNodeTemplate.class, name, version)) - .thenReturn(List.of(new JpaToscaNodeTemplate(elem))); - - var filtered = controlLoopProvider.getNodeTemplates(name, version); - verify(toscaNodeTemplateRepository).getFiltered(JpaToscaNodeTemplate.class, name, version); - - controlLoopProvider.deleteInstanceProperties(controlLoopProvider.saveInstanceProperties(toscaServiceTest), - filtered); - - verify(toscaNodeTemplateRepository).delete(any()); - } - - @Test - void testGetNodeTemplates() throws Exception { - var toscaNodeTemplateRepository = mock(ToscaNodeTemplateRepository.class); - var controlLoopProvider = new ControlLoopProvider(mock(ControlLoopRepository.class), - toscaNodeTemplateRepository, mock(ToscaNodeTemplatesRepository.class)); - - var toscaNodeTemplate0 = new JpaToscaNodeTemplate(new PfConceptKey(ID_NAME, ID_VERSION)); - var toscaNodeTemplate1 = new JpaToscaNodeTemplate(new PfConceptKey("PMSHInstance2", ID_VERSION)); - - when(toscaNodeTemplateRepository.getFiltered(JpaToscaNodeTemplate.class, null, null)) - .thenReturn(List.of(toscaNodeTemplate0, toscaNodeTemplate1)); - when(toscaNodeTemplateRepository.findAll()).thenReturn(List.of(toscaNodeTemplate0, toscaNodeTemplate1)); - when(toscaNodeTemplateRepository.getFiltered(JpaToscaNodeTemplate.class, ID_NAME, ID_VERSION)) - .thenReturn(List.of(toscaNodeTemplate0)); - - // Getting all nodes - var listNodes = controlLoopProvider.getAllNodeTemplates(); - assertNotNull(listNodes); - assertThat(listNodes).hasSize(2); - - listNodes = controlLoopProvider.getNodeTemplates(ID_NAME, ID_VERSION); - assertNotNull(listNodes); - assertThat(listNodes).hasSize(1); - - listNodes = controlLoopProvider.getAllNodeTemplates(); - assertNotNull(listNodes); - assertThat(listNodes).hasSize(2); - - var nodeTemplateFilter = - ToscaTypedEntityFilter.builder().name(ID_NAME).version(ID_VERSION).build(); - - listNodes = controlLoopProvider.getFilteredNodeTemplates(nodeTemplateFilter); - assertNotNull(listNodes); - assertThat(listNodes).hasSize(1); - - assertThatThrownBy(() -> { - controlLoopProvider.getFilteredNodeTemplates(null); - }).hasMessageMatching("filter is marked non-null but is null"); - } - - private static ToscaServiceTemplate testControlLoopRead() { - return testControlLoopYamlSerialization(TOSCA_TEMPLATE_YAML); - } - - private static ToscaServiceTemplate testControlLoopYamlSerialization(String controlLoopFilePath) { - var controlLoopString = ResourceUtils.getResourceAsString(controlLoopFilePath); - return yamlTranslator.fromYaml(controlLoopString, ToscaServiceTemplate.class); - } -} diff --git a/models/src/test/java/org/onap/policy/clamp/controlloop/models/controlloop/persistence/provider/ParticipantProviderTest.java b/models/src/test/java/org/onap/policy/clamp/controlloop/models/controlloop/persistence/provider/ParticipantProviderTest.java deleted file mode 100644 index 9b48735f6..000000000 --- a/models/src/test/java/org/onap/policy/clamp/controlloop/models/controlloop/persistence/provider/ParticipantProviderTest.java +++ /dev/null @@ -1,149 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * Copyright (C) 2021 Nordix Foundation. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - * SPDX-License-Identifier: Apache-2.0 - * ============LICENSE_END========================================================= - */ - -package org.onap.policy.clamp.controlloop.models.controlloop.persistence.provider; - -import static org.assertj.core.api.Assertions.assertThat; -import static org.assertj.core.api.Assertions.assertThatThrownBy; -import static org.junit.Assert.assertEquals; -import static org.mockito.ArgumentMatchers.any; -import static org.mockito.ArgumentMatchers.eq; -import static org.mockito.Mockito.mock; -import static org.mockito.Mockito.when; - -import java.util.ArrayList; -import java.util.List; -import java.util.Optional; -import org.junit.jupiter.api.BeforeEach; -import org.junit.jupiter.api.Test; -import org.onap.policy.clamp.controlloop.models.controlloop.concepts.Participant; -import org.onap.policy.clamp.controlloop.models.controlloop.persistence.concepts.JpaParticipant; -import org.onap.policy.clamp.controlloop.models.controlloop.persistence.repository.ParticipantRepository; -import org.onap.policy.common.utils.coder.Coder; -import org.onap.policy.common.utils.coder.StandardCoder; -import org.onap.policy.common.utils.resources.ResourceUtils; -import org.onap.policy.models.base.PfConceptKey; -import org.onap.policy.models.tosca.authorative.concepts.ToscaTypedEntityFilter; - -class ParticipantProviderTest { - - private static final Coder CODER = new StandardCoder(); - private static final String PARTICIPANT_JSON = "src/test/resources/providers/TestParticipant.json"; - private static final String LIST_IS_NULL = ".*. is marked .*ull but is null"; - - private List inputParticipants = new ArrayList<>(); - private List jpaParticipantList; - private String originalJson = ResourceUtils.getResourceAsString(PARTICIPANT_JSON); - - @BeforeEach - void beforeSetupDao() throws Exception { - inputParticipants.add(CODER.decode(originalJson, Participant.class)); - jpaParticipantList = ProviderUtils.getJpaAndValidateList(inputParticipants, JpaParticipant::new, "participant"); - } - - @Test - void testParticipantSave() throws Exception { - var participantRepository = mock(ParticipantRepository.class); - for (var participant : jpaParticipantList) { - when(participantRepository.getById(new PfConceptKey(participant.getName(), participant.getVersion()))) - .thenReturn(participant); - } - var participantProvider = new ParticipantProvider(participantRepository); - - assertThatThrownBy(() -> { - participantProvider.saveParticipant(null); - }).hasMessageMatching(LIST_IS_NULL); - - when(participantRepository.save(any())).thenReturn(jpaParticipantList.get(0)); - - Participant savedParticipant = participantProvider.saveParticipant(inputParticipants.get(0)); - assertEquals(savedParticipant, inputParticipants.get(0)); - - when(participantRepository.save(any())).thenThrow(IllegalArgumentException.class); - - assertThatThrownBy(() -> { - participantProvider.saveParticipant(inputParticipants.get(0)); - }).hasMessageMatching("Error in save Participant"); - } - - @Test - void testGetControlLoops() throws Exception { - var participantRepository = mock(ParticipantRepository.class); - var participantProvider = new ParticipantProvider(participantRepository); - - // Return empty list when no data present in db - List getResponse = participantProvider.getParticipants(null, null); - assertThat(getResponse).isEmpty(); - - String name = inputParticipants.get(0).getName(); - String version = inputParticipants.get(0).getVersion(); - when(participantRepository.getFiltered(any(), eq(name), eq(version))) - .thenReturn(List.of(jpaParticipantList.get(0))); - assertEquals(1, participantProvider.getParticipants(name, version).size()); - - assertThat(participantProvider.getParticipants("invalid_name", "1.0.1")).isEmpty(); - - assertThat(participantProvider.findParticipant("invalid_name", "1.0.1")).isEmpty(); - - when(participantRepository.findAll()).thenReturn(jpaParticipantList); - assertThat(participantProvider.getParticipants()).hasSize(inputParticipants.size()); - - when(participantRepository.findById(any())).thenThrow(IllegalArgumentException.class); - - assertThatThrownBy(() -> { - participantProvider.findParticipant("notValid", "notValid"); - }).hasMessageMatching("Error in find Participant"); - - assertThatThrownBy(() -> { - participantProvider.getFilteredParticipants(null); - }).hasMessageMatching("filter is marked .*ull but is null"); - - when(participantRepository.getFiltered(eq(JpaParticipant.class), eq(null), eq(null))) - .thenReturn(jpaParticipantList); - - final ToscaTypedEntityFilter filter = ToscaTypedEntityFilter.builder() - .type("org.onap.domain.pmsh.PMSHControlLoopDefinition").build(); - assertEquals(1, participantProvider.getFilteredParticipants(filter).size()); - - } - - @Test - void testDeleteParticipant() throws Exception { - var participantRepository = mock(ParticipantRepository.class); - var participantProvider = new ParticipantProvider(participantRepository); - - assertThatThrownBy(() -> { - participantProvider.deleteParticipant("Invalid_name", "1.0.1"); - }).hasMessageMatching(".*.failed, participant does not exist"); - - String name = inputParticipants.get(0).getName(); - String version = inputParticipants.get(0).getVersion(); - - when(participantRepository.findById(any())).thenReturn(Optional.of(jpaParticipantList.get(0))); - - Participant deletedParticipant = participantProvider.deleteParticipant(name, version); - assertEquals(inputParticipants.get(0), deletedParticipant); - - when(participantRepository.findById(any())).thenThrow(IllegalArgumentException.class); - assertThatThrownBy(() -> { - participantProvider.deleteParticipant(name, version); - }).hasMessageMatching("Error in delete Participant"); - } -} diff --git a/models/src/test/java/org/onap/policy/clamp/controlloop/models/controlloop/persistence/provider/ParticipantStatisticsProviderTest.java b/models/src/test/java/org/onap/policy/clamp/controlloop/models/controlloop/persistence/provider/ParticipantStatisticsProviderTest.java deleted file mode 100644 index 16f4958a9..000000000 --- a/models/src/test/java/org/onap/policy/clamp/controlloop/models/controlloop/persistence/provider/ParticipantStatisticsProviderTest.java +++ /dev/null @@ -1,107 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * Copyright (C) 2021 Nordix Foundation. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - * SPDX-License-Identifier: Apache-2.0 - * ============LICENSE_END========================================================= - */ - -package org.onap.policy.clamp.controlloop.models.controlloop.persistence.provider; - -import static org.assertj.core.api.Assertions.assertThat; -import static org.assertj.core.api.Assertions.assertThatThrownBy; -import static org.junit.Assert.assertEquals; -import static org.mockito.ArgumentMatchers.any; -import static org.mockito.ArgumentMatchers.anyList; -import static org.mockito.ArgumentMatchers.eq; -import static org.mockito.Mockito.mock; -import static org.mockito.Mockito.when; - -import java.time.Instant; -import java.util.List; -import org.junit.jupiter.api.BeforeEach; -import org.junit.jupiter.api.Test; -import org.onap.policy.clamp.controlloop.models.controlloop.concepts.ParticipantStatistics; -import org.onap.policy.clamp.controlloop.models.controlloop.concepts.ParticipantStatisticsList; -import org.onap.policy.clamp.controlloop.models.controlloop.persistence.concepts.JpaParticipantStatistics; -import org.onap.policy.clamp.controlloop.models.controlloop.persistence.repository.ParticipantStatisticsRepository; -import org.onap.policy.common.utils.coder.Coder; -import org.onap.policy.common.utils.coder.StandardCoder; -import org.onap.policy.common.utils.resources.ResourceUtils; -import org.onap.policy.models.tosca.authorative.concepts.ToscaConceptIdentifier; - -class ParticipantStatisticsProviderTest { - - private static final String LIST_IS_NULL = ".*. is marked .*ull but is null"; - private static final Coder CODER = new StandardCoder(); - private static final String PARTICIPANT_STATS_JSON = "src/test/resources/providers/TestParticipantStatistics.json"; - - private ParticipantStatisticsProvider participantStatisticsProvider; - private ParticipantStatisticsList inputParticipantStatistics; - private String originalJson = ResourceUtils.getResourceAsString(PARTICIPANT_STATS_JSON); - - @BeforeEach - void beforeSetupDao() throws Exception { - var participantStatisticsRepository = mock(ParticipantStatisticsRepository.class); - participantStatisticsProvider = new ParticipantStatisticsProvider(participantStatisticsRepository); - inputParticipantStatistics = CODER.decode(originalJson, ParticipantStatisticsList.class); - - var jpaParticipantStatisticsList = - ProviderUtils.getJpaAndValidateList(inputParticipantStatistics.getStatisticsList(), - JpaParticipantStatistics::new, "Participant Statistics"); - - for (var participantStat : jpaParticipantStatisticsList) { - when(participantStatisticsRepository.getById(eq(participantStat.getKey()))).thenReturn(participantStat); - when(participantStatisticsRepository.findAllById(eq(List.of(participantStat.getKey())))) - .thenReturn(List.of(participantStat)); - } - - when(participantStatisticsRepository.getFiltered(eq(JpaParticipantStatistics.class), any())) - .thenReturn(List.of(jpaParticipantStatisticsList.get(0))); - - when(participantStatisticsRepository.saveAll(anyList())).thenReturn(jpaParticipantStatisticsList); - } - - @Test - void testParticipantStatisticsCreate() throws Exception { - assertThatThrownBy(() -> { - participantStatisticsProvider.createParticipantStatistics(null); - }).hasMessageMatching(LIST_IS_NULL); - - ParticipantStatisticsList createdStatsList = new ParticipantStatisticsList(); - createdStatsList.setStatisticsList(participantStatisticsProvider - .createParticipantStatistics(inputParticipantStatistics.getStatisticsList())); - - assertEquals(inputParticipantStatistics.toString().replaceAll("\\s+", ""), - createdStatsList.toString().replaceAll("\\s+", "")); - } - - @Test - void testGetControlLoops() throws Exception { - // Return empty list when no data present in db - List getResponse = - participantStatisticsProvider.getParticipantStatistics(null, null, null); - assertThat(getResponse).isEmpty(); - - participantStatisticsProvider.createParticipantStatistics(inputParticipantStatistics.getStatisticsList()); - ToscaConceptIdentifier identifier = inputParticipantStatistics.getStatisticsList().get(0).getParticipantId(); - Instant instant = inputParticipantStatistics.getStatisticsList().get(0).getTimeStamp(); - assertEquals(1, participantStatisticsProvider - .getParticipantStatistics(identifier.getName(), identifier.getVersion(), instant).size()); - - assertEquals(1, participantStatisticsProvider - .getFilteredParticipantStatistics("name2", "1.0.1", null, null, null, "DESC", 1).size()); - } -} diff --git a/models/src/test/java/org/onap/policy/clamp/controlloop/models/controlloop/persistence/provider/ServiceTemplateProviderTest.java b/models/src/test/java/org/onap/policy/clamp/controlloop/models/controlloop/persistence/provider/ServiceTemplateProviderTest.java deleted file mode 100644 index 523a4fb88..000000000 --- a/models/src/test/java/org/onap/policy/clamp/controlloop/models/controlloop/persistence/provider/ServiceTemplateProviderTest.java +++ /dev/null @@ -1,169 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * Copyright (C) 2021 Nordix Foundation. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - * SPDX-License-Identifier: Apache-2.0 - * ============LICENSE_END========================================================= - */ - -package org.onap.policy.clamp.controlloop.models.controlloop.persistence.provider; - -import static org.assertj.core.api.Assertions.assertThat; -import static org.assertj.core.api.Assertions.assertThatThrownBy; -import static org.junit.jupiter.api.Assertions.assertNotNull; -import static org.junit.jupiter.api.Assertions.fail; -import static org.mockito.ArgumentMatchers.any; -import static org.mockito.Mockito.mock; -import static org.mockito.Mockito.when; - -import java.util.List; -import java.util.Optional; -import org.junit.jupiter.api.BeforeAll; -import org.junit.jupiter.api.Test; -import org.onap.policy.clamp.controlloop.models.controlloop.persistence.repository.ToscaServiceTemplateRepository; -import org.onap.policy.common.utils.coder.CoderException; -import org.onap.policy.common.utils.coder.StandardYamlCoder; -import org.onap.policy.common.utils.resources.ResourceUtils; -import org.onap.policy.models.base.PfConceptKey; -import org.onap.policy.models.base.PfModelException; -import org.onap.policy.models.tosca.authorative.concepts.ToscaServiceTemplate; -import org.onap.policy.models.tosca.simple.concepts.JpaToscaServiceTemplate; - -class ServiceTemplateProviderTest { - - private static final String TOSCA_SERVICE_TEMPLATE_YAML = - "src/test/resources/providers/tosca-for-smoke-testing.yaml"; - - private static final StandardYamlCoder YAML_TRANSLATOR = new StandardYamlCoder(); - - private static ToscaServiceTemplate inputServiceTemplate; - - @BeforeAll - static void loadServiceTemplate() { - inputServiceTemplate = getToscaServiceTemplate(TOSCA_SERVICE_TEMPLATE_YAML); - } - - @Test - void testGetCommonOrInstancePropertiesFromNodeTypes() throws PfModelException { - var serviceTemplateRepository = mock(ToscaServiceTemplateRepository.class); - var serviceTemplateProvider = new ServiceTemplateProvider(serviceTemplateRepository); - - var result = serviceTemplateProvider.getCommonOrInstancePropertiesFromNodeTypes(true, inputServiceTemplate); - assertNotNull(result); - assertThat(result).hasSize(8); - } - - @Test - void testGetDerivedCommonOrInstanceNodeTemplates() throws PfModelException { - var serviceTemplateRepository = mock(ToscaServiceTemplateRepository.class); - var serviceTemplateProvider = new ServiceTemplateProvider(serviceTemplateRepository); - - var commonOrInstanceNodeTypeProps = - serviceTemplateProvider.getCommonOrInstancePropertiesFromNodeTypes(true, inputServiceTemplate); - - var result = serviceTemplateProvider.getDerivedCommonOrInstanceNodeTemplates( - inputServiceTemplate.getToscaTopologyTemplate().getNodeTemplates(), commonOrInstanceNodeTypeProps); - - assertNotNull(result); - assertThat(result).hasSize(8); - } - - @Test - void testCreateServiceTemplate() throws PfModelException { - var serviceTemplateRepository = mock(ToscaServiceTemplateRepository.class); - var serviceTemplateProvider = new ServiceTemplateProvider(serviceTemplateRepository); - - var jpaServiceTemplate = ProviderUtils.getJpaAndValidate(inputServiceTemplate, JpaToscaServiceTemplate::new, - "toscaServiceTemplate"); - when(serviceTemplateRepository.save(jpaServiceTemplate)).thenReturn(jpaServiceTemplate); - - var result = serviceTemplateProvider.createServiceTemplate(inputServiceTemplate); - - assertThat(result).isEqualTo(jpaServiceTemplate.toAuthorative()); - } - - @Test - void testDeleteServiceTemplate() throws PfModelException { - var jpaServiceTemplate = ProviderUtils.getJpaAndValidate(inputServiceTemplate, JpaToscaServiceTemplate::new, - "toscaServiceTemplate"); - var serviceTemplateRepository = mock(ToscaServiceTemplateRepository.class); - when(serviceTemplateRepository - .findById(new PfConceptKey(inputServiceTemplate.getName(), inputServiceTemplate.getVersion()))) - .thenReturn(Optional.of(jpaServiceTemplate)); - - var serviceTemplateProvider = new ServiceTemplateProvider(serviceTemplateRepository); - var result = serviceTemplateProvider.deleteServiceTemplate(inputServiceTemplate.getName(), - inputServiceTemplate.getVersion()); - - assertThat(result).isEqualTo(jpaServiceTemplate.toAuthorative()); - } - - @Test - void testGetServiceTemplateListEmpty() throws PfModelException { - var serviceTemplateRepository = mock(ToscaServiceTemplateRepository.class); - when(serviceTemplateRepository.findById(any())).thenReturn(Optional.empty()); - - var serviceTemplateProvider = new ServiceTemplateProvider(serviceTemplateRepository); - assertThatThrownBy(() -> serviceTemplateProvider.getToscaServiceTemplate("Name", "1.0.0")) - .hasMessage("Control Loop definitions not found"); - } - - @Test - void testGetServiceTemplateList() throws PfModelException { - var jpaServiceTemplate = ProviderUtils.getJpaAndValidate(inputServiceTemplate, JpaToscaServiceTemplate::new, - "toscaServiceTemplate"); - var serviceTemplateRepository = mock(ToscaServiceTemplateRepository.class); - when(serviceTemplateRepository - .findById(new PfConceptKey(inputServiceTemplate.getName(), inputServiceTemplate.getVersion()))) - .thenReturn(Optional.of(jpaServiceTemplate)); - - var serviceTemplateProvider = new ServiceTemplateProvider(serviceTemplateRepository); - var result = serviceTemplateProvider.getToscaServiceTemplate(inputServiceTemplate.getName(), - inputServiceTemplate.getVersion()); - - assertThat(result).isEqualTo(jpaServiceTemplate.toAuthorative()); - } - - @Test - void testGetServiceTemplate() throws PfModelException { - var jpaServiceTemplate = ProviderUtils.getJpaAndValidate(inputServiceTemplate, JpaToscaServiceTemplate::new, - "toscaServiceTemplate"); - var serviceTemplateRepository = mock(ToscaServiceTemplateRepository.class); - when(serviceTemplateRepository.getFiltered(JpaToscaServiceTemplate.class, inputServiceTemplate.getName(), - inputServiceTemplate.getVersion())).thenReturn(List.of(jpaServiceTemplate)); - - var serviceTemplateProvider = new ServiceTemplateProvider(serviceTemplateRepository); - var result = serviceTemplateProvider.getServiceTemplateList(inputServiceTemplate.getName(), - inputServiceTemplate.getVersion()); - - assertThat(result).hasSize(1); - assertThat(result.get(0)).isEqualTo(jpaServiceTemplate.toAuthorative()); - } - - /** - * Get ToscaServiceTemplate from resource. - * - * @param path path of the resource - */ - public static ToscaServiceTemplate getToscaServiceTemplate(String path) { - - try { - return YAML_TRANSLATOR.decode(ResourceUtils.getResourceAsStream(path), ToscaServiceTemplate.class); - } catch (CoderException e) { - fail("Cannot read or decode " + path); - return null; - } - } -} diff --git a/models/src/test/java/org/onap/policy/clamp/controlloop/models/controlloop/persistence/repository/FilterRepositoryImplTest.java b/models/src/test/java/org/onap/policy/clamp/controlloop/models/controlloop/persistence/repository/FilterRepositoryImplTest.java deleted file mode 100644 index 8b5357457..000000000 --- a/models/src/test/java/org/onap/policy/clamp/controlloop/models/controlloop/persistence/repository/FilterRepositoryImplTest.java +++ /dev/null @@ -1,106 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * Copyright (C) 2021 Nordix Foundation. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - * SPDX-License-Identifier: Apache-2.0 - * ============LICENSE_END========================================================= - */ - -package org.onap.policy.clamp.controlloop.models.controlloop.persistence.repository; - -import static org.assertj.core.api.Assertions.assertThat; - -import java.util.List; -import java.util.concurrent.atomic.AtomicInteger; -import org.junit.jupiter.api.BeforeEach; -import org.junit.jupiter.api.Test; -import org.onap.policy.clamp.controlloop.models.controlloop.concepts.ControlLoops; -import org.onap.policy.clamp.controlloop.models.controlloop.persistence.concepts.JpaControlLoop; -import org.onap.policy.clamp.controlloop.models.controlloop.persistence.provider.ProviderUtils; -import org.onap.policy.common.utils.coder.Coder; -import org.onap.policy.common.utils.coder.StandardCoder; -import org.onap.policy.common.utils.resources.ResourceUtils; -import org.onap.policy.models.dao.PfDao; -import org.onap.policy.models.dao.PfFilterParameters; -import org.onap.policy.models.provider.PolicyModelsProviderParameters; -import org.onap.policy.models.provider.impl.ModelsProvider; - -class FilterRepositoryImplTest { - private static final String CONTROL_LOOP_JSON = "src/test/resources/providers/TestControlLoops.json"; - private static final Coder CODER = new StandardCoder(); - private static final AtomicInteger dbNameCounter = new AtomicInteger(); - private static final String originalJson = ResourceUtils.getResourceAsString(CONTROL_LOOP_JSON); - private static List jpaControlLoops; - private PfDao pfDao; - - @BeforeEach - void beforeSetupDao() throws Exception { - var parameters = new PolicyModelsProviderParameters(); - parameters.setDatabaseDriver("org.h2.Driver"); - parameters.setName("PolicyProviderParameterGroup"); - parameters.setImplementation("org.onap.policy.models.provider.impl.DatabasePolicyModelsProviderImpl"); - parameters.setDatabaseUrl("jdbc:h2:mem:controlLoopProviderTestDb" + dbNameCounter.getAndDecrement()); - parameters.setDatabaseUser("policy"); - parameters.setDatabasePassword("P01icY"); - parameters.setPersistenceUnit("ToscaConceptTest"); - - pfDao = ModelsProvider.init(parameters); - var inputControlLoops = CODER.decode(originalJson, ControlLoops.class); - jpaControlLoops = ProviderUtils.getJpaAndValidateList(inputControlLoops.getControlLoopList(), - JpaControlLoop::new, "ControlLoops"); - - pfDao.createCollection(jpaControlLoops); - } - - @Test - void testGetPfDao() { - assertThat(new FilterRepositoryImpl().getPfDao()).isNotNull(); - } - - @Test - void testGetFilteredParams() { - var filterRepositoryImpl = new FilterRepositoryImpl() { - @Override - protected PfDao getPfDao() { - return pfDao; - } - }; - var result = filterRepositoryImpl.getFiltered(JpaControlLoop.class, null, null); - assertThat(result).hasSize(2); - - result = filterRepositoryImpl.getFiltered(JpaControlLoop.class, jpaControlLoops.get(0).getName(), null); - assertThat(result).hasSize(1); - } - - @Test - void testGetFiltered() { - var filterRepositoryImpl = new FilterRepositoryImpl() { - @Override - protected PfDao getPfDao() { - return pfDao; - } - }; - - // @formatter:off - PfFilterParameters filterParams = PfFilterParameters - .builder() - .name(jpaControlLoops.get(0).getName()) - .build(); - // @formatter:on - - var result = filterRepositoryImpl.getFiltered(JpaControlLoop.class, filterParams); - assertThat(result).hasSize(1); - } -} diff --git a/models/src/test/java/org/onap/policy/clamp/controlloop/models/messages/dmaap/notification/ControlLoopNotificationTest.java b/models/src/test/java/org/onap/policy/clamp/controlloop/models/messages/dmaap/notification/ControlLoopNotificationTest.java deleted file mode 100644 index bf2e2fa0a..000000000 --- a/models/src/test/java/org/onap/policy/clamp/controlloop/models/messages/dmaap/notification/ControlLoopNotificationTest.java +++ /dev/null @@ -1,83 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * Copyright (C) 2021 Nordix Foundation. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - * SPDX-License-Identifier: Apache-2.0 - * ============LICENSE_END========================================================= - */ - -package org.onap.policy.clamp.controlloop.models.messages.dmaap.notification; - -import static org.assertj.core.api.Assertions.assertThat; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertNotNull; - -import java.util.ArrayList; -import java.util.List; -import org.junit.jupiter.api.Test; - -class ControlLoopNotificationTest { - - @Test - void testControlLoopNotification() { - ControlLoopNotification cln0 = new ControlLoopNotification(); - - List addedList = new ArrayList<>(); - addedList.add(new ControlLoopStatus()); - - List deletedList = new ArrayList<>(); - deletedList.add(new ControlLoopStatus()); - - assertEquals(true, cln0.isEmpty()); - - cln0.setAdded(addedList); - assertEquals(false, cln0.isEmpty()); - cln0.setAdded(null); - assertEquals(true, cln0.isEmpty()); - - cln0.setDeleted(deletedList); - assertEquals(false, cln0.isEmpty()); - cln0.setDeleted(null); - assertEquals(true, cln0.isEmpty()); - - cln0.setAdded(addedList); - cln0.setDeleted(deletedList); - assertEquals(false, cln0.isEmpty()); - cln0.setAdded(null); - cln0.setDeleted(null); - assertEquals(true, cln0.isEmpty()); - } - - @Test - void testControlLoopNotificationLombok() { - assertNotNull(new ControlLoopNotification()); - assertNotNull(new ControlLoopNotification(new ArrayList<>(), new ArrayList<>())); - - ControlLoopNotification cln0 = new ControlLoopNotification(); - - assertThat(cln0.toString()).contains("ControlLoopNotification("); - assertEquals(false, cln0.hashCode() == 0); - assertEquals(true, cln0.equals(cln0)); - assertEquals(false, cln0.equals(null)); - - - ControlLoopNotification cln1 = new ControlLoopNotification(); - - assertThat(cln1.toString()).contains("ControlLoopNotification("); - assertEquals(false, cln1.hashCode() == 0); - assertEquals(true, cln1.equals(cln0)); - assertEquals(false, cln1.equals(null)); - } -} diff --git a/models/src/test/java/org/onap/policy/clamp/controlloop/models/messages/dmaap/notification/ControlLoopStatusTest.java b/models/src/test/java/org/onap/policy/clamp/controlloop/models/messages/dmaap/notification/ControlLoopStatusTest.java deleted file mode 100644 index cca5e8554..000000000 --- a/models/src/test/java/org/onap/policy/clamp/controlloop/models/messages/dmaap/notification/ControlLoopStatusTest.java +++ /dev/null @@ -1,48 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * Copyright (C) 2021 Nordix Foundation. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - * SPDX-License-Identifier: Apache-2.0 - * ============LICENSE_END========================================================= - */ - -package org.onap.policy.clamp.controlloop.models.messages.dmaap.notification; - -import static org.assertj.core.api.Assertions.assertThat; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertNotNull; - -import java.util.UUID; -import org.junit.jupiter.api.Test; -import org.onap.policy.models.tosca.authorative.concepts.ToscaConceptIdentifier; - -class ControlLoopStatusTest { - - @Test - void testControlLoopStatusLombok() { - assertNotNull(new ControlLoopStatus()); - assertNotNull(new ControlLoopStatus(UUID.randomUUID(), new ToscaConceptIdentifier())); - - ControlLoopStatus cln0 = new ControlLoopStatus(); - - assertThat(cln0.toString()).contains("ControlLoopStatus("); - assertEquals(false, cln0.hashCode() == 0); - assertEquals(true, cln0.equals(cln0)); - assertEquals(false, cln0.equals(null)); - - ControlLoopStatus cln1 = new ControlLoopStatus(); - assertEquals(true, cln1.equals(cln0)); - } -} diff --git a/models/src/test/java/org/onap/policy/clamp/controlloop/models/messages/dmaap/notification/NotificationPojosTest.java b/models/src/test/java/org/onap/policy/clamp/controlloop/models/messages/dmaap/notification/NotificationPojosTest.java deleted file mode 100644 index 1a89a1b3e..000000000 --- a/models/src/test/java/org/onap/policy/clamp/controlloop/models/messages/dmaap/notification/NotificationPojosTest.java +++ /dev/null @@ -1,58 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * Copyright (C) 2021 Nordix Foundation. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - * SPDX-License-Identifier: Apache-2.0 - * ============LICENSE_END========================================================= - */ - -package org.onap.policy.clamp.controlloop.models.messages.dmaap.notification; - -import com.openpojo.reflection.PojoClass; -import com.openpojo.reflection.impl.PojoClassFactory; -import com.openpojo.validation.Validator; -import com.openpojo.validation.ValidatorBuilder; -import com.openpojo.validation.rule.impl.GetterMustExistRule; -import com.openpojo.validation.rule.impl.SetterMustExistRule; -import com.openpojo.validation.test.impl.GetterTester; -import com.openpojo.validation.test.impl.SetterTester; -import java.util.List; -import org.junit.jupiter.api.Test; -import org.onap.policy.common.utils.test.ToStringTester; - -/** - * Class to perform unit tests of all pojos. - */ -class NotificationPojosTest { - - @Test - void testPojos() { - List pojoClasses = - PojoClassFactory.getPojoClasses(NotificationPojosTest.class.getPackageName()); - - // @formatter:off - final Validator validator = ValidatorBuilder - .create() - .with(new ToStringTester()) - .with(new SetterMustExistRule()) - .with(new GetterMustExistRule()) - .with(new SetterTester()) - .with(new GetterTester()) - .build(); - - validator.validate(pojoClasses); - // @formatter:on - } -} diff --git a/models/src/test/java/org/onap/policy/clamp/controlloop/models/messages/dmaap/participant/ControlLoopAckTest.java b/models/src/test/java/org/onap/policy/clamp/controlloop/models/messages/dmaap/participant/ControlLoopAckTest.java deleted file mode 100644 index f312c4863..000000000 --- a/models/src/test/java/org/onap/policy/clamp/controlloop/models/messages/dmaap/participant/ControlLoopAckTest.java +++ /dev/null @@ -1,68 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * Copyright (C) 2021 Nordix Foundation. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - * SPDX-License-Identifier: Apache-2.0 - * ============LICENSE_END========================================================= - */ - -package org.onap.policy.clamp.controlloop.models.messages.dmaap.participant; - -import static org.assertj.core.api.Assertions.assertThatThrownBy; -import static org.junit.Assert.assertEquals; -import static org.onap.policy.clamp.controlloop.models.messages.dmaap.participant.ParticipantMessageUtils.assertSerializable; -import static org.onap.policy.clamp.controlloop.models.messages.dmaap.participant.ParticipantMessageUtils.removeVariableFields; - -import java.util.Map; -import java.util.UUID; -import org.junit.jupiter.api.Test; -import org.onap.policy.clamp.controlloop.models.controlloop.concepts.ControlLoopElementAck; -import org.onap.policy.clamp.controlloop.models.controlloop.concepts.ControlLoopState; -import org.onap.policy.common.utils.coder.CoderException; -import org.onap.policy.models.tosca.authorative.concepts.ToscaConceptIdentifier; - -class ControlLoopAckTest { - - @Test - void testCopyConstructor() throws CoderException { - assertThatThrownBy(() -> new ControlLoopAck((ControlLoopAck) null)) - .isInstanceOf(NullPointerException.class); - - final var orig = new ControlLoopAck(ParticipantMessageType.CONTROL_LOOP_UPDATE); - - // verify with null values - assertEquals(removeVariableFields(orig.toString()), - removeVariableFields(new ControlLoopAck(orig).toString())); - - // verify with all values - var id = new ToscaConceptIdentifier("id", "1.2.3"); - orig.setControlLoopId(id); - orig.setParticipantId(id); - orig.setParticipantType(id); - var clElementResult = new ControlLoopElementAck(ControlLoopState.UNINITIALISED, - true, "ControlLoopElement result"); - final var controlLoopResultMap = Map.of(UUID.randomUUID(), clElementResult); - orig.setControlLoopResultMap(controlLoopResultMap); - - orig.setResponseTo(UUID.randomUUID()); - orig.setResult(true); - orig.setMessage("Successfully processed ControlLoopUpdate message"); - - assertEquals(removeVariableFields(orig.toString()), - removeVariableFields(new ControlLoopAck(orig).toString())); - - assertSerializable(orig, ControlLoopAck.class); - } -} diff --git a/models/src/test/java/org/onap/policy/clamp/controlloop/models/messages/dmaap/participant/ControlLoopStateChangeTest.java b/models/src/test/java/org/onap/policy/clamp/controlloop/models/messages/dmaap/participant/ControlLoopStateChangeTest.java deleted file mode 100644 index 1bf155e9a..000000000 --- a/models/src/test/java/org/onap/policy/clamp/controlloop/models/messages/dmaap/participant/ControlLoopStateChangeTest.java +++ /dev/null @@ -1,65 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * Copyright (C) 2021 Nordix Foundation. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - * SPDX-License-Identifier: Apache-2.0 - * ============LICENSE_END========================================================= - */ - -package org.onap.policy.clamp.controlloop.models.messages.dmaap.participant; - -import static org.assertj.core.api.Assertions.assertThatThrownBy; -import static org.junit.Assert.assertEquals; -import static org.onap.policy.clamp.controlloop.models.messages.dmaap.participant.ParticipantMessageUtils.assertSerializable; -import static org.onap.policy.clamp.controlloop.models.messages.dmaap.participant.ParticipantMessageUtils.removeVariableFields; - -import java.time.Instant; -import java.util.UUID; -import org.junit.jupiter.api.Test; -import org.onap.policy.clamp.controlloop.models.controlloop.concepts.ControlLoopOrderedState; -import org.onap.policy.clamp.controlloop.models.controlloop.concepts.ControlLoopState; -import org.onap.policy.common.utils.coder.CoderException; -import org.onap.policy.models.tosca.authorative.concepts.ToscaConceptIdentifier; - -/** - * Test the copy constructor and other methods. - */ -class ControlLoopStateChangeTest { - - @Test - void testCopyConstructor() throws CoderException { - assertThatThrownBy(() -> new ControlLoopStateChange(null)).isInstanceOf(NullPointerException.class); - - ControlLoopStateChange orig = new ControlLoopStateChange(); - - // verify with null values - assertEquals(removeVariableFields(orig.toString()), - removeVariableFields(new ControlLoopStateChange(orig).toString())); - - // verify with all values - ToscaConceptIdentifier id = new ToscaConceptIdentifier("id", "1.2.3"); - orig.setControlLoopId(id); - orig.setParticipantId(id); - orig.setMessageId(UUID.randomUUID()); - orig.setOrderedState(ControlLoopOrderedState.RUNNING); - orig.setCurrentState(ControlLoopState.PASSIVE); - orig.setTimestamp(Instant.ofEpochMilli(3000)); - - assertEquals(removeVariableFields(orig.toString()), - removeVariableFields(new ControlLoopStateChange(orig).toString())); - - assertSerializable(orig, ControlLoopStateChange.class); - } -} diff --git a/models/src/test/java/org/onap/policy/clamp/controlloop/models/messages/dmaap/participant/ControlLoopUpdateTest.java b/models/src/test/java/org/onap/policy/clamp/controlloop/models/messages/dmaap/participant/ControlLoopUpdateTest.java deleted file mode 100644 index ce56d582a..000000000 --- a/models/src/test/java/org/onap/policy/clamp/controlloop/models/messages/dmaap/participant/ControlLoopUpdateTest.java +++ /dev/null @@ -1,82 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * Copyright (C) 2021 Nordix Foundation. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - * SPDX-License-Identifier: Apache-2.0 - * ============LICENSE_END========================================================= - */ - -package org.onap.policy.clamp.controlloop.models.messages.dmaap.participant; - -import static org.assertj.core.api.Assertions.assertThatThrownBy; -import static org.junit.Assert.assertEquals; -import static org.onap.policy.clamp.controlloop.models.messages.dmaap.participant.ParticipantMessageUtils.assertSerializable; -import static org.onap.policy.clamp.controlloop.models.messages.dmaap.participant.ParticipantMessageUtils.removeVariableFields; - -import java.time.Instant; -import java.util.List; -import java.util.Map; -import java.util.UUID; -import org.junit.jupiter.api.Test; -import org.onap.policy.clamp.controlloop.models.controlloop.concepts.ControlLoopElement; -import org.onap.policy.clamp.controlloop.models.controlloop.concepts.ControlLoopOrderedState; -import org.onap.policy.clamp.controlloop.models.controlloop.concepts.ControlLoopState; -import org.onap.policy.clamp.controlloop.models.controlloop.concepts.ParticipantUpdates; -import org.onap.policy.common.utils.coder.CoderException; -import org.onap.policy.models.tosca.authorative.concepts.ToscaConceptIdentifier; -import org.onap.policy.models.tosca.authorative.concepts.ToscaProperty; - -/** - * Test the copy constructor. - */ -class ControlLoopUpdateTest { - @Test - void testCopyConstructor() throws CoderException { - assertThatThrownBy(() -> new ControlLoopUpdate(null)).isInstanceOf(NullPointerException.class); - - ControlLoopUpdate orig = new ControlLoopUpdate(); - // verify with all values - ToscaConceptIdentifier id = new ToscaConceptIdentifier("id", "1.2.3"); - orig.setControlLoopId(id); - orig.setParticipantId(null); - orig.setMessageId(UUID.randomUUID()); - orig.setTimestamp(Instant.ofEpochMilli(3000)); - - ControlLoopElement clElement = new ControlLoopElement(); - clElement.setId(UUID.randomUUID()); - clElement.setDefinition(id); - clElement.setDescription("Description"); - clElement.setOrderedState(ControlLoopOrderedState.PASSIVE); - clElement.setState(ControlLoopState.PASSIVE); - clElement.setParticipantId(id); - clElement.setParticipantType(id); - - ToscaProperty property = new ToscaProperty(); - property.setName("test"); - property.setType("testType"); - Map propertiesMap = Map.of("Prop1", property); - clElement.setPropertiesMap(propertiesMap); - - ParticipantUpdates participantUpdates = new ParticipantUpdates(); - participantUpdates.setParticipantId(id); - participantUpdates.setControlLoopElementList(List.of(clElement)); - orig.setParticipantUpdatesList(List.of(participantUpdates)); - - ControlLoopUpdate other = new ControlLoopUpdate(orig); - - assertEquals(removeVariableFields(orig.toString()), removeVariableFields(other.toString())); - assertSerializable(orig, ControlLoopUpdate.class); - } -} diff --git a/models/src/test/java/org/onap/policy/clamp/controlloop/models/messages/dmaap/participant/ParticipantAckMessageTest.java b/models/src/test/java/org/onap/policy/clamp/controlloop/models/messages/dmaap/participant/ParticipantAckMessageTest.java deleted file mode 100644 index df82ab071..000000000 --- a/models/src/test/java/org/onap/policy/clamp/controlloop/models/messages/dmaap/participant/ParticipantAckMessageTest.java +++ /dev/null @@ -1,105 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * Copyright (C) 2021 Nordix Foundation. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - * SPDX-License-Identifier: Apache-2.0 - * ============LICENSE_END========================================================= - */ - -package org.onap.policy.clamp.controlloop.models.messages.dmaap.participant; - -import static org.assertj.core.api.Assertions.assertThatThrownBy; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertFalse; -import static org.junit.Assert.assertTrue; -import static org.onap.policy.clamp.controlloop.models.messages.dmaap.participant.ParticipantMessageUtils.assertSerializable; - -import java.util.UUID; -import org.junit.jupiter.api.Test; -import org.onap.policy.common.utils.coder.CoderException; -import org.onap.policy.models.tosca.authorative.concepts.ToscaConceptIdentifier; - -class ParticipantAckMessageTest { - private ParticipantAckMessage message; - - private static final ToscaConceptIdentifier PTYPE_456 = new ToscaConceptIdentifier("PType", "4.5.6"); - private static final ToscaConceptIdentifier PTYPE_457 = new ToscaConceptIdentifier("PType", "4.5.7"); - private static final ToscaConceptIdentifier ID_123 = new ToscaConceptIdentifier("id", "1.2.3"); - private static final ToscaConceptIdentifier ID_124 = new ToscaConceptIdentifier("id", "1.2.4"); - - @Test - void testCopyConstructor() throws CoderException { - assertThatThrownBy(() -> new ParticipantAckMessage((ParticipantAckMessage) null)) - .isInstanceOf(NullPointerException.class); - - // verify with null values - message = new ParticipantAckMessage(ParticipantMessageType.PARTICIPANT_STATE_CHANGE); - ParticipantAckMessage newmsg = new ParticipantAckMessage(message); - newmsg.setResponseTo(message.getResponseTo()); - assertEquals(message.toString(), newmsg.toString()); - - // verify with all values - message = makeMessage(); - newmsg = new ParticipantAckMessage(message); - newmsg.setResponseTo(message.getResponseTo()); - assertEquals(message.toString(), newmsg.toString()); - - assertSerializable(message, ParticipantAckMessage.class); - } - - @Test - void testAppliesTo_NullParticipantId() { - message = makeMessage(); - - assertThatThrownBy(() -> message.appliesTo(null, null)).isInstanceOf(NullPointerException.class); - assertThatThrownBy(() -> message.appliesTo(PTYPE_456, null)).isInstanceOf(NullPointerException.class); - assertThatThrownBy(() -> message.appliesTo(null, ID_123)).isInstanceOf(NullPointerException.class); - } - - @Test - void testAppliesTo_ParticipantIdMatches() { - message = makeMessage(); - - // ParticipantId matches - assertTrue(message.appliesTo(PTYPE_456, ID_123)); - assertFalse(message.appliesTo(PTYPE_456, ID_124)); - assertFalse(message.appliesTo(PTYPE_457, ID_123)); - } - - @Test - void testAppliesTo_ParticipantIdNoMatch() { - message = makeMessage(); - - // ParticipantId does not match - ToscaConceptIdentifier id = new ToscaConceptIdentifier(); - id.setName("id1111"); - id.setVersion("3.2.1"); - assertFalse(message.appliesTo(id, id)); - message.setParticipantType(null); - assertTrue(message.appliesTo(id, id)); - } - - private ParticipantAckMessage makeMessage() { - ParticipantAckMessage msg = new ParticipantAckMessage(ParticipantMessageType.PARTICIPANT_DEREGISTER_ACK); - - msg.setParticipantType(PTYPE_456); - msg.setParticipantId(ID_123); - msg.setMessage("Successfull Ack"); - msg.setResult(true); - msg.setResponseTo(UUID.randomUUID()); - - return msg; - } -} diff --git a/models/src/test/java/org/onap/policy/clamp/controlloop/models/messages/dmaap/participant/ParticipantDeregisterAckTest.java b/models/src/test/java/org/onap/policy/clamp/controlloop/models/messages/dmaap/participant/ParticipantDeregisterAckTest.java deleted file mode 100644 index f1ae5f709..000000000 --- a/models/src/test/java/org/onap/policy/clamp/controlloop/models/messages/dmaap/participant/ParticipantDeregisterAckTest.java +++ /dev/null @@ -1,59 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * Copyright (C) 2021 Nordix Foundation. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - * SPDX-License-Identifier: Apache-2.0 - * ============LICENSE_END========================================================= - */ - -package org.onap.policy.clamp.controlloop.models.messages.dmaap.participant; - -import static org.assertj.core.api.Assertions.assertThatThrownBy; -import static org.junit.Assert.assertEquals; -import static org.onap.policy.clamp.controlloop.models.messages.dmaap.participant.ParticipantMessageUtils.assertSerializable; -import static org.onap.policy.clamp.controlloop.models.messages.dmaap.participant.ParticipantMessageUtils.removeVariableFields; - -import java.util.UUID; -import org.junit.jupiter.api.Test; -import org.onap.policy.common.utils.coder.CoderException; -import org.onap.policy.models.tosca.authorative.concepts.ToscaConceptIdentifier; - -class ParticipantDeregisterAckTest { - - @Test - void testCopyConstructor() throws CoderException { - assertThatThrownBy(() -> new ParticipantDeregisterAck(null)).isInstanceOf(NullPointerException.class); - - final ParticipantDeregisterAck orig = new ParticipantDeregisterAck(); - - // verify with null values - assertEquals(removeVariableFields(orig.toString()), - removeVariableFields(new ParticipantDeregisterAck(orig).toString())); - - // verify with all values - ToscaConceptIdentifier id = new ToscaConceptIdentifier(); - id.setName("id"); - id.setVersion("1.2.3"); - orig.setResponseTo(UUID.randomUUID()); - orig.setMessageType(ParticipantMessageType.PARTICIPANT_DEREGISTER_ACK); - orig.setResult(true); - orig.setMessage("Successfully processed message"); - - assertEquals(removeVariableFields(orig.toString()), - removeVariableFields(new ParticipantDeregisterAck(orig).toString())); - - assertSerializable(orig, ParticipantDeregisterAck.class); - } -} diff --git a/models/src/test/java/org/onap/policy/clamp/controlloop/models/messages/dmaap/participant/ParticipantDeregisterTest.java b/models/src/test/java/org/onap/policy/clamp/controlloop/models/messages/dmaap/participant/ParticipantDeregisterTest.java deleted file mode 100644 index 89546890a..000000000 --- a/models/src/test/java/org/onap/policy/clamp/controlloop/models/messages/dmaap/participant/ParticipantDeregisterTest.java +++ /dev/null @@ -1,61 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * Copyright (C) 2021 Nordix Foundation. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - * SPDX-License-Identifier: Apache-2.0 - * ============LICENSE_END========================================================= - */ - -package org.onap.policy.clamp.controlloop.models.messages.dmaap.participant; - -import static org.assertj.core.api.Assertions.assertThatThrownBy; -import static org.junit.Assert.assertEquals; -import static org.onap.policy.clamp.controlloop.models.messages.dmaap.participant.ParticipantMessageUtils.assertSerializable; -import static org.onap.policy.clamp.controlloop.models.messages.dmaap.participant.ParticipantMessageUtils.removeVariableFields; - -import java.time.Instant; -import java.util.UUID; -import org.junit.jupiter.api.Test; -import org.onap.policy.common.utils.coder.CoderException; -import org.onap.policy.models.tosca.authorative.concepts.ToscaConceptIdentifier; - -class ParticipantDeregisterTest { - - @Test - void testCopyConstructor() throws CoderException { - assertThatThrownBy(() -> new ParticipantDeregister(null)).isInstanceOf(NullPointerException.class); - - final ParticipantDeregister orig = new ParticipantDeregister(); - - // verify with null values - assertEquals(removeVariableFields(orig.toString()), - removeVariableFields(new ParticipantDeregister(orig).toString())); - - // verify with all values - ToscaConceptIdentifier id = new ToscaConceptIdentifier(); - id.setName("id"); - id.setVersion("1.2.3"); - orig.setControlLoopId(id); - orig.setParticipantId(id); - orig.setParticipantType(id); - orig.setMessageId(UUID.randomUUID()); - orig.setTimestamp(Instant.ofEpochMilli(3000)); - - assertEquals(removeVariableFields(orig.toString()), - removeVariableFields(new ParticipantDeregister(orig).toString())); - - assertSerializable(orig, ParticipantDeregister.class); - } -} diff --git a/models/src/test/java/org/onap/policy/clamp/controlloop/models/messages/dmaap/participant/ParticipantMessageTest.java b/models/src/test/java/org/onap/policy/clamp/controlloop/models/messages/dmaap/participant/ParticipantMessageTest.java deleted file mode 100644 index 58d3afebc..000000000 --- a/models/src/test/java/org/onap/policy/clamp/controlloop/models/messages/dmaap/participant/ParticipantMessageTest.java +++ /dev/null @@ -1,107 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * Copyright (C) 2021 Nordix Foundation. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - * SPDX-License-Identifier: Apache-2.0 - * ============LICENSE_END========================================================= - */ - -package org.onap.policy.clamp.controlloop.models.messages.dmaap.participant; - -import static org.assertj.core.api.Assertions.assertThatThrownBy; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertFalse; -import static org.junit.Assert.assertTrue; -import static org.onap.policy.clamp.controlloop.models.messages.dmaap.participant.ParticipantMessageUtils.assertSerializable; - -import java.time.Instant; -import java.util.UUID; -import org.junit.jupiter.api.Test; -import org.onap.policy.common.utils.coder.CoderException; -import org.onap.policy.models.tosca.authorative.concepts.ToscaConceptIdentifier; - -class ParticipantMessageTest { - private ParticipantMessage message; - - private static final ToscaConceptIdentifier PTYPE_456 = new ToscaConceptIdentifier("PType", "4.5.6"); - private static final ToscaConceptIdentifier PTYPE_457 = new ToscaConceptIdentifier("PType", "4.5.7"); - private static final ToscaConceptIdentifier ID_123 = new ToscaConceptIdentifier("id", "1.2.3"); - private static final ToscaConceptIdentifier ID_124 = new ToscaConceptIdentifier("id", "1.2.4"); - - @Test - void testCopyConstructor() throws CoderException { - assertThatThrownBy(() -> new ParticipantMessage((ParticipantMessage) null)) - .isInstanceOf(NullPointerException.class); - - // verify with null values - message = new ParticipantMessage(ParticipantMessageType.PARTICIPANT_STATE_CHANGE); - ParticipantMessage newmsg = new ParticipantMessage(message); - newmsg.setMessageId(message.getMessageId()); - newmsg.setTimestamp(message.getTimestamp()); - assertEquals(message.toString(), newmsg.toString()); - - // verify with all values - message = makeMessage(); - newmsg = new ParticipantMessage(message); - newmsg.setMessageId(message.getMessageId()); - newmsg.setTimestamp(message.getTimestamp()); - assertEquals(message.toString(), newmsg.toString()); - - assertSerializable(message, ParticipantMessage.class); - } - - @Test - void testAppliesTo_NullParticipantId() { - message = makeMessage(); - - assertThatThrownBy(() -> message.appliesTo(null, null)).isInstanceOf(NullPointerException.class); - assertThatThrownBy(() -> message.appliesTo(PTYPE_456, null)).isInstanceOf(NullPointerException.class); - assertThatThrownBy(() -> message.appliesTo(null, ID_123)).isInstanceOf(NullPointerException.class); - } - - @Test - void testAppliesTo_ParticipantIdMatches() { - message = makeMessage(); - - // ParticipantId matches - assertTrue(message.appliesTo(PTYPE_456, ID_123)); - assertFalse(message.appliesTo(PTYPE_456, ID_124)); - assertFalse(message.appliesTo(PTYPE_457, ID_123)); - } - - @Test - void testAppliesTo_ParticipantIdNoMatch() { - message = makeMessage(); - - // ParticipantId does not match - ToscaConceptIdentifier id = new ToscaConceptIdentifier(); - id.setName("id1111"); - id.setVersion("3.2.1"); - assertFalse(message.appliesTo(id, id)); - message.setParticipantType(null); - assertTrue(message.appliesTo(id, id)); - } - - private ParticipantMessage makeMessage() { - ParticipantMessage msg = new ParticipantMessage(ParticipantMessageType.PARTICIPANT_STATE_CHANGE); - - msg.setParticipantType(PTYPE_456); - msg.setParticipantId(ID_123); - msg.setMessageId(UUID.randomUUID()); - msg.setTimestamp(Instant.ofEpochMilli(3000)); - - return msg; - } -} diff --git a/models/src/test/java/org/onap/policy/clamp/controlloop/models/messages/dmaap/participant/ParticipantMessageUtils.java b/models/src/test/java/org/onap/policy/clamp/controlloop/models/messages/dmaap/participant/ParticipantMessageUtils.java deleted file mode 100644 index 78c278f98..000000000 --- a/models/src/test/java/org/onap/policy/clamp/controlloop/models/messages/dmaap/participant/ParticipantMessageUtils.java +++ /dev/null @@ -1,55 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * Copyright (C) 2021 Nordix Foundation. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - * SPDX-License-Identifier: Apache-2.0 - * ============LICENSE_END========================================================= - */ - -package org.onap.policy.clamp.controlloop.models.messages.dmaap.participant; - -import static org.junit.Assert.assertEquals; - -import org.onap.policy.common.utils.coder.CoderException; -import org.onap.policy.common.utils.coder.StandardCoder; - -/** - * Utility class for tests of ParticipantMessage subclasses. - */ -public class ParticipantMessageUtils { - - private ParticipantMessageUtils() { - - } - - public static String removeVariableFields(String text) { - return text.replaceAll("messageId=[^,]*", "messageId=xxx").replaceAll("timestamp=[^,]*", "timestamp=nnn"); - } - - /** - * Check if object is Serializable. - * - * @param object the Object - * @param clazz the class of the Object - * @throws CoderException if object is not Serializable - */ - public static void assertSerializable(Object object, Class clazz) throws CoderException { - var standardCoder = new StandardCoder(); - var json = standardCoder.encode(object); - var other = standardCoder.decode(json, clazz); - - assertEquals(removeVariableFields(object.toString()), removeVariableFields(other.toString())); - } -} diff --git a/models/src/test/java/org/onap/policy/clamp/controlloop/models/messages/dmaap/participant/ParticipantPojosTest.java b/models/src/test/java/org/onap/policy/clamp/controlloop/models/messages/dmaap/participant/ParticipantPojosTest.java deleted file mode 100644 index e67fbc143..000000000 --- a/models/src/test/java/org/onap/policy/clamp/controlloop/models/messages/dmaap/participant/ParticipantPojosTest.java +++ /dev/null @@ -1,65 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * Copyright (C) 2021 Nordix Foundation. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - * SPDX-License-Identifier: Apache-2.0 - * ============LICENSE_END========================================================= - */ - -package org.onap.policy.clamp.controlloop.models.messages.dmaap.participant; - -import com.openpojo.reflection.PojoClass; -import com.openpojo.reflection.impl.PojoClassFactory; -import com.openpojo.validation.Validator; -import com.openpojo.validation.ValidatorBuilder; -import com.openpojo.validation.rule.impl.GetterMustExistRule; -import com.openpojo.validation.rule.impl.SetterMustExistRule; -import com.openpojo.validation.test.impl.GetterTester; -import com.openpojo.validation.test.impl.SetterTester; -import java.util.List; -import org.junit.jupiter.api.Test; -import org.onap.policy.common.utils.test.ToStringTester; - -/** - * Class to perform unit tests of all pojos. - */ -class ParticipantPojosTest { - - @Test - void testPojos() { - List pojoClasses = - PojoClassFactory.getPojoClasses(ParticipantPojosTest.class.getPackageName()); - - pojoClasses.remove(PojoClassFactory.getPojoClass(ParticipantMessage.class)); - pojoClasses.remove(PojoClassFactory.getPojoClass(ParticipantMessageTest.class)); - pojoClasses.remove(PojoClassFactory.getPojoClass(ParticipantAckMessage.class)); - pojoClasses.remove(PojoClassFactory.getPojoClass(ParticipantAckMessageTest.class)); - pojoClasses.remove(PojoClassFactory.getPojoClass(ControlLoopAck.class)); - pojoClasses.remove(PojoClassFactory.getPojoClass(ControlLoopAckTest.class)); - - // @formatter:off - final Validator validator = ValidatorBuilder - .create() - .with(new ToStringTester()) - .with(new SetterMustExistRule()) - .with(new GetterMustExistRule()) - .with(new SetterTester()) - .with(new GetterTester()) - .build(); - - validator.validate(pojoClasses); - // @formatter:on - } -} diff --git a/models/src/test/java/org/onap/policy/clamp/controlloop/models/messages/dmaap/participant/ParticipantRegisterAckTest.java b/models/src/test/java/org/onap/policy/clamp/controlloop/models/messages/dmaap/participant/ParticipantRegisterAckTest.java deleted file mode 100644 index 886933aba..000000000 --- a/models/src/test/java/org/onap/policy/clamp/controlloop/models/messages/dmaap/participant/ParticipantRegisterAckTest.java +++ /dev/null @@ -1,59 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * Copyright (C) 2021 Nordix Foundation. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - * SPDX-License-Identifier: Apache-2.0 - * ============LICENSE_END========================================================= - */ - -package org.onap.policy.clamp.controlloop.models.messages.dmaap.participant; - -import static org.assertj.core.api.Assertions.assertThatThrownBy; -import static org.junit.Assert.assertEquals; -import static org.onap.policy.clamp.controlloop.models.messages.dmaap.participant.ParticipantMessageUtils.assertSerializable; -import static org.onap.policy.clamp.controlloop.models.messages.dmaap.participant.ParticipantMessageUtils.removeVariableFields; - -import java.util.UUID; -import org.junit.jupiter.api.Test; -import org.onap.policy.common.utils.coder.CoderException; -import org.onap.policy.models.tosca.authorative.concepts.ToscaConceptIdentifier; - -class ParticipantRegisterAckTest { - - @Test - void testCopyConstructor() throws CoderException { - assertThatThrownBy(() -> new ParticipantRegisterAck(null)).isInstanceOf(NullPointerException.class); - - final ParticipantRegisterAck orig = new ParticipantRegisterAck(); - - // verify with null values - assertEquals(removeVariableFields(orig.toString()), - removeVariableFields(new ParticipantRegisterAck(orig).toString())); - - // verify with all values - ToscaConceptIdentifier id = new ToscaConceptIdentifier(); - id.setName("id"); - id.setVersion("1.2.3"); - orig.setResponseTo(UUID.randomUUID()); - orig.setMessageType(ParticipantMessageType.PARTICIPANT_REGISTER_ACK); - orig.setResult(true); - orig.setMessage("Successfully processed message"); - - assertEquals(removeVariableFields(orig.toString()), - removeVariableFields(new ParticipantRegisterAck(orig).toString())); - - assertSerializable(orig, ParticipantRegisterAck.class); - } -} diff --git a/models/src/test/java/org/onap/policy/clamp/controlloop/models/messages/dmaap/participant/ParticipantRegisterTest.java b/models/src/test/java/org/onap/policy/clamp/controlloop/models/messages/dmaap/participant/ParticipantRegisterTest.java deleted file mode 100644 index e86d9e885..000000000 --- a/models/src/test/java/org/onap/policy/clamp/controlloop/models/messages/dmaap/participant/ParticipantRegisterTest.java +++ /dev/null @@ -1,61 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * Copyright (C) 2021 Nordix Foundation. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - * SPDX-License-Identifier: Apache-2.0 - * ============LICENSE_END========================================================= - */ - -package org.onap.policy.clamp.controlloop.models.messages.dmaap.participant; - -import static org.assertj.core.api.Assertions.assertThatThrownBy; -import static org.junit.Assert.assertEquals; -import static org.onap.policy.clamp.controlloop.models.messages.dmaap.participant.ParticipantMessageUtils.assertSerializable; -import static org.onap.policy.clamp.controlloop.models.messages.dmaap.participant.ParticipantMessageUtils.removeVariableFields; - -import java.time.Instant; -import java.util.UUID; -import org.junit.jupiter.api.Test; -import org.onap.policy.common.utils.coder.CoderException; -import org.onap.policy.models.tosca.authorative.concepts.ToscaConceptIdentifier; - -class ParticipantRegisterTest { - - @Test - void testCopyConstructor() throws CoderException { - assertThatThrownBy(() -> new ParticipantRegister(null)).isInstanceOf(NullPointerException.class); - - final ParticipantRegister orig = new ParticipantRegister(); - - // verify with null values - assertEquals(removeVariableFields(orig.toString()), - removeVariableFields(new ParticipantRegister(orig).toString())); - - // verify with all values - ToscaConceptIdentifier id = new ToscaConceptIdentifier(); - id.setName("id"); - id.setVersion("1.2.3"); - orig.setControlLoopId(id); - orig.setParticipantId(id); - orig.setParticipantType(id); - orig.setMessageId(UUID.randomUUID()); - orig.setTimestamp(Instant.ofEpochMilli(3000)); - - assertEquals(removeVariableFields(orig.toString()), - removeVariableFields(new ParticipantRegister(orig).toString())); - - assertSerializable(orig, ParticipantRegister.class); - } -} diff --git a/models/src/test/java/org/onap/policy/clamp/controlloop/models/messages/dmaap/participant/ParticipantStatusReqTest.java b/models/src/test/java/org/onap/policy/clamp/controlloop/models/messages/dmaap/participant/ParticipantStatusReqTest.java deleted file mode 100644 index 98c127107..000000000 --- a/models/src/test/java/org/onap/policy/clamp/controlloop/models/messages/dmaap/participant/ParticipantStatusReqTest.java +++ /dev/null @@ -1,56 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * Copyright (C) 2021 Nordix Foundation. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - * SPDX-License-Identifier: Apache-2.0 - * ============LICENSE_END========================================================= - */ - -package org.onap.policy.clamp.controlloop.models.messages.dmaap.participant; - -import static org.assertj.core.api.Assertions.assertThatThrownBy; -import static org.junit.Assert.assertEquals; -import static org.onap.policy.clamp.controlloop.models.messages.dmaap.participant.ParticipantMessageUtils.assertSerializable; -import static org.onap.policy.clamp.controlloop.models.messages.dmaap.participant.ParticipantMessageUtils.removeVariableFields; - -import java.time.Instant; -import java.util.UUID; -import org.junit.jupiter.api.Test; -import org.onap.policy.common.utils.coder.CoderException; -import org.onap.policy.models.tosca.authorative.concepts.ToscaConceptIdentifier; - -/** - * Test the copy constructor. - */ -class ParticipantStatusReqTest { - @Test - void testCopyConstructor() throws CoderException { - assertThatThrownBy(() -> new ParticipantStatusReq(null)).isInstanceOf(NullPointerException.class); - - ParticipantStatusReq orig = new ParticipantStatusReq(); - // verify with all values - ToscaConceptIdentifier id = new ToscaConceptIdentifier("id", "1.2.3"); - orig.setParticipantId(id); - orig.setControlLoopId(null); - orig.setParticipantType(null); - orig.setMessageId(UUID.randomUUID()); - orig.setTimestamp(Instant.ofEpochMilli(3000)); - - ParticipantStatusReq other = new ParticipantStatusReq(orig); - assertEquals(removeVariableFields(orig.toString()), removeVariableFields(other.toString())); - - assertSerializable(orig, ParticipantStatusReq.class); - } -} diff --git a/models/src/test/java/org/onap/policy/clamp/controlloop/models/messages/dmaap/participant/ParticipantStatusTest.java b/models/src/test/java/org/onap/policy/clamp/controlloop/models/messages/dmaap/participant/ParticipantStatusTest.java deleted file mode 100644 index b2bce05cc..000000000 --- a/models/src/test/java/org/onap/policy/clamp/controlloop/models/messages/dmaap/participant/ParticipantStatusTest.java +++ /dev/null @@ -1,129 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * Copyright (C) 2021 Nordix Foundation. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - * SPDX-License-Identifier: Apache-2.0 - * ============LICENSE_END========================================================= - */ - -package org.onap.policy.clamp.controlloop.models.messages.dmaap.participant; - -import static org.assertj.core.api.Assertions.assertThatThrownBy; -import static org.junit.Assert.assertEquals; -import static org.onap.policy.clamp.controlloop.models.messages.dmaap.participant.ParticipantMessageUtils.assertSerializable; -import static org.onap.policy.clamp.controlloop.models.messages.dmaap.participant.ParticipantMessageUtils.removeVariableFields; - -import java.time.Instant; -import java.util.List; -import java.util.Map; -import java.util.UUID; -import org.junit.jupiter.api.Test; -import org.onap.policy.clamp.controlloop.models.controlloop.concepts.ClElementStatistics; -import org.onap.policy.clamp.controlloop.models.controlloop.concepts.ClElementStatisticsList; -import org.onap.policy.clamp.controlloop.models.controlloop.concepts.ControlLoopElementDefinition; -import org.onap.policy.clamp.controlloop.models.controlloop.concepts.ControlLoopInfo; -import org.onap.policy.clamp.controlloop.models.controlloop.concepts.ControlLoopState; -import org.onap.policy.clamp.controlloop.models.controlloop.concepts.ControlLoopStatistics; -import org.onap.policy.clamp.controlloop.models.controlloop.concepts.ParticipantDefinition; -import org.onap.policy.clamp.controlloop.models.controlloop.concepts.ParticipantHealthStatus; -import org.onap.policy.clamp.controlloop.models.controlloop.concepts.ParticipantState; -import org.onap.policy.common.utils.coder.CoderException; -import org.onap.policy.models.tosca.authorative.concepts.ToscaConceptIdentifier; -import org.onap.policy.models.tosca.authorative.concepts.ToscaNodeTemplate; -import org.onap.policy.models.tosca.authorative.concepts.ToscaProperty; - -class ParticipantStatusTest { - - @Test - void testCopyConstructor() throws CoderException { - assertThatThrownBy(() -> new ParticipantStatus(null)).isInstanceOf(NullPointerException.class); - - final ParticipantStatus orig = new ParticipantStatus(); - - // verify with null values - assertEquals(removeVariableFields(orig.toString()), - removeVariableFields(new ParticipantStatus(orig).toString())); - - // verify with all values - ToscaConceptIdentifier id = new ToscaConceptIdentifier("id", "1.2.3"); - orig.setControlLoopId(id); - orig.setParticipantId(id); - ToscaConceptIdentifier type = new ToscaConceptIdentifier("type", "2.3.4"); - orig.setParticipantType(type); - orig.setMessageId(UUID.randomUUID()); - orig.setState(ParticipantState.ACTIVE); - orig.setHealthStatus(ParticipantHealthStatus.HEALTHY); - orig.setTimestamp(Instant.ofEpochMilli(3000)); - - ControlLoopInfo clInfo = getControlLoopInfo(id); - orig.setControlLoopInfoList(List.of(clInfo)); - - ParticipantDefinition participantDefinitionUpdate = new ParticipantDefinition(); - participantDefinitionUpdate.setParticipantId(id); - participantDefinitionUpdate.setParticipantType(type); - ControlLoopElementDefinition clDefinition = getClElementDefinition(id); - participantDefinitionUpdate.setControlLoopElementDefinitionList(List.of(clDefinition)); - orig.setParticipantDefinitionUpdates(List.of(participantDefinitionUpdate)); - - assertEquals(removeVariableFields(orig.toString()), - removeVariableFields(new ParticipantStatus(orig).toString())); - - assertSerializable(orig, ParticipantStatus.class); - } - - private ControlLoopInfo getControlLoopInfo(ToscaConceptIdentifier id) { - ControlLoopInfo clInfo = new ControlLoopInfo(); - clInfo.setState(ControlLoopState.PASSIVE2RUNNING); - clInfo.setControlLoopId(id); - - ControlLoopStatistics clStatistics = new ControlLoopStatistics(); - clStatistics.setControlLoopId(id); - clStatistics.setAverageExecutionTime(12345); - clStatistics.setEventCount(12345); - clStatistics.setLastEnterTime(12345); - clStatistics.setLastExecutionTime(12345); - clStatistics.setLastStart(12345); - clStatistics.setTimeStamp(Instant.ofEpochMilli(3000)); - clStatistics.setUpTime(12345); - ClElementStatisticsList clElementStatisticsList = new ClElementStatisticsList(); - ClElementStatistics clElementStatistics = new ClElementStatistics(); - clElementStatistics.setParticipantId(new ToscaConceptIdentifier("defName", "0.0.1")); - clElementStatistics.setTimeStamp(Instant.now()); - clElementStatisticsList.setClElementStatistics(List.of(clElementStatistics)); - clStatistics.setClElementStatisticsList(clElementStatisticsList); - - clInfo.setControlLoopStatistics(clStatistics); - return clInfo; - } - - private ControlLoopElementDefinition getClElementDefinition(ToscaConceptIdentifier id) { - ToscaNodeTemplate toscaNodeTemplate = new ToscaNodeTemplate(); - toscaNodeTemplate.setName("nodeTemplate"); - toscaNodeTemplate.setDerivedFrom("parentNodeTemplate"); - toscaNodeTemplate.setDescription("Description of nodeTemplate"); - toscaNodeTemplate.setVersion("1.2.3"); - - ControlLoopElementDefinition clDefinition = new ControlLoopElementDefinition(); - clDefinition.setClElementDefinitionId(id); - clDefinition.setControlLoopElementToscaNodeTemplate(toscaNodeTemplate); - - ToscaProperty property = new ToscaProperty(); - property.setName("test"); - property.setType("testType"); - Map commonPropertiesMap = Map.of("Prop1", property); - clDefinition.setCommonPropertiesMap(commonPropertiesMap); - return clDefinition; - } -} diff --git a/models/src/test/java/org/onap/policy/clamp/controlloop/models/messages/dmaap/participant/ParticipantUpdateAckTest.java b/models/src/test/java/org/onap/policy/clamp/controlloop/models/messages/dmaap/participant/ParticipantUpdateAckTest.java deleted file mode 100644 index d2a191018..000000000 --- a/models/src/test/java/org/onap/policy/clamp/controlloop/models/messages/dmaap/participant/ParticipantUpdateAckTest.java +++ /dev/null @@ -1,59 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * Copyright (C) 2021 Nordix Foundation. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - * SPDX-License-Identifier: Apache-2.0 - * ============LICENSE_END========================================================= - */ - -package org.onap.policy.clamp.controlloop.models.messages.dmaap.participant; - -import static org.assertj.core.api.Assertions.assertThatThrownBy; -import static org.junit.Assert.assertEquals; -import static org.onap.policy.clamp.controlloop.models.messages.dmaap.participant.ParticipantMessageUtils.assertSerializable; -import static org.onap.policy.clamp.controlloop.models.messages.dmaap.participant.ParticipantMessageUtils.removeVariableFields; - -import java.util.UUID; -import org.junit.jupiter.api.Test; -import org.onap.policy.common.utils.coder.CoderException; -import org.onap.policy.models.tosca.authorative.concepts.ToscaConceptIdentifier; - -class ParticipantUpdateAckTest { - - @Test - void testCopyConstructor() throws CoderException { - assertThatThrownBy(() -> new ParticipantUpdateAck(null)).isInstanceOf(NullPointerException.class); - - final ParticipantUpdateAck orig = new ParticipantUpdateAck(); - - // verify with null values - assertEquals(removeVariableFields(orig.toString()), - removeVariableFields(new ParticipantUpdateAck(orig).toString())); - - // verify with all values - ToscaConceptIdentifier id = new ToscaConceptIdentifier(); - id.setName("id"); - id.setVersion("1.2.3"); - orig.setResponseTo(UUID.randomUUID()); - orig.setMessageType(ParticipantMessageType.PARTICIPANT_UPDATE_ACK); - orig.setResult(true); - orig.setMessage("Successfully processed message"); - - assertEquals(removeVariableFields(orig.toString()), - removeVariableFields(new ParticipantUpdateAck(orig).toString())); - - assertSerializable(orig, ParticipantUpdateAck.class); - } -} diff --git a/models/src/test/java/org/onap/policy/clamp/controlloop/models/messages/dmaap/participant/ParticipantUpdateTest.java b/models/src/test/java/org/onap/policy/clamp/controlloop/models/messages/dmaap/participant/ParticipantUpdateTest.java deleted file mode 100644 index d7023d0c1..000000000 --- a/models/src/test/java/org/onap/policy/clamp/controlloop/models/messages/dmaap/participant/ParticipantUpdateTest.java +++ /dev/null @@ -1,101 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * Copyright (C) 2021 Nordix Foundation. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - * SPDX-License-Identifier: Apache-2.0 - * ============LICENSE_END========================================================= - */ - -package org.onap.policy.clamp.controlloop.models.messages.dmaap.participant; - -import static org.assertj.core.api.Assertions.assertThatThrownBy; -import static org.junit.Assert.assertEquals; -import static org.onap.policy.clamp.controlloop.models.messages.dmaap.participant.ParticipantMessageUtils.assertSerializable; -import static org.onap.policy.clamp.controlloop.models.messages.dmaap.participant.ParticipantMessageUtils.removeVariableFields; - -import java.time.Instant; -import java.util.List; -import java.util.Map; -import java.util.UUID; -import org.junit.jupiter.api.Test; -import org.onap.policy.clamp.controlloop.models.controlloop.concepts.ControlLoopElementDefinition; -import org.onap.policy.clamp.controlloop.models.controlloop.concepts.ParticipantDefinition; -import org.onap.policy.common.utils.coder.CoderException; -import org.onap.policy.models.tosca.authorative.concepts.ToscaConceptIdentifier; -import org.onap.policy.models.tosca.authorative.concepts.ToscaNodeTemplate; -import org.onap.policy.models.tosca.authorative.concepts.ToscaProperty; -import org.onap.policy.models.tosca.authorative.concepts.ToscaServiceTemplate; - -/** - * Test the copy constructor. - */ -class ParticipantUpdateTest { - @Test - void testCopyConstructor() throws CoderException { - assertThatThrownBy(() -> new ParticipantUpdate(null)).isInstanceOf(NullPointerException.class); - - ParticipantUpdate orig = new ParticipantUpdate(); - // verify with all values - ToscaConceptIdentifier id = new ToscaConceptIdentifier("id", "1.2.3"); - orig.setControlLoopId(id); - orig.setParticipantId(id); - orig.setParticipantType(id); - orig.setMessageId(UUID.randomUUID()); - orig.setTimestamp(Instant.ofEpochMilli(3000)); - - ToscaServiceTemplate toscaServiceTemplate = new ToscaServiceTemplate(); - toscaServiceTemplate.setName("serviceTemplate"); - toscaServiceTemplate.setDerivedFrom("parentServiceTemplate"); - toscaServiceTemplate.setDescription("Description of serviceTemplate"); - toscaServiceTemplate.setVersion("1.2.3"); - - ToscaNodeTemplate toscaNodeTemplate = new ToscaNodeTemplate(); - toscaNodeTemplate.setName("nodeTemplate"); - toscaNodeTemplate.setDerivedFrom("parentNodeTemplate"); - toscaNodeTemplate.setDescription("Description of nodeTemplate"); - toscaNodeTemplate.setVersion("1.2.3"); - - ParticipantDefinition participantDefinitionUpdate = new ParticipantDefinition(); - participantDefinitionUpdate.setParticipantType(id); - ControlLoopElementDefinition clDefinition = getClElementDefinition(id); - participantDefinitionUpdate.setControlLoopElementDefinitionList(List.of(clDefinition)); - orig.setParticipantDefinitionUpdates(List.of(participantDefinitionUpdate)); - - ParticipantUpdate other = new ParticipantUpdate(orig); - - assertEquals(removeVariableFields(orig.toString()), removeVariableFields(other.toString())); - - assertSerializable(orig, ParticipantUpdate.class); - } - - private ControlLoopElementDefinition getClElementDefinition(ToscaConceptIdentifier id) { - ToscaNodeTemplate toscaNodeTemplate = new ToscaNodeTemplate(); - toscaNodeTemplate.setName("nodeTemplate"); - toscaNodeTemplate.setDerivedFrom("parentNodeTemplate"); - toscaNodeTemplate.setDescription("Description of nodeTemplate"); - toscaNodeTemplate.setVersion("1.2.3"); - - ControlLoopElementDefinition clDefinition = new ControlLoopElementDefinition(); - clDefinition.setClElementDefinitionId(id); - clDefinition.setControlLoopElementToscaNodeTemplate(toscaNodeTemplate); - - ToscaProperty property = new ToscaProperty(); - property.setName("test"); - property.setType("testType"); - Map commonPropertiesMap = Map.of("Prop1", property); - clDefinition.setCommonPropertiesMap(commonPropertiesMap); - return clDefinition; - } -} diff --git a/models/src/test/java/org/onap/policy/clamp/controlloop/models/messages/rest/MessagesRestPojosTest.java b/models/src/test/java/org/onap/policy/clamp/controlloop/models/messages/rest/MessagesRestPojosTest.java deleted file mode 100644 index 435cce8ef..000000000 --- a/models/src/test/java/org/onap/policy/clamp/controlloop/models/messages/rest/MessagesRestPojosTest.java +++ /dev/null @@ -1,59 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * Copyright (C) 2021 Nordix Foundation. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - * SPDX-License-Identifier: Apache-2.0 - * ============LICENSE_END========================================================= - */ - -package org.onap.policy.clamp.controlloop.models.messages.rest; - -import com.openpojo.reflection.PojoClass; -import com.openpojo.reflection.impl.PojoClassFactory; -import com.openpojo.validation.Validator; -import com.openpojo.validation.ValidatorBuilder; -import com.openpojo.validation.rule.impl.GetterMustExistRule; -import com.openpojo.validation.rule.impl.SetterMustExistRule; -import com.openpojo.validation.test.impl.GetterTester; -import com.openpojo.validation.test.impl.SetterTester; -import java.util.List; -import org.junit.jupiter.api.Test; -import org.onap.policy.common.utils.test.ToStringTester; - -/** - * Class to perform unit tests of all pojos. - */ -class MessagesRestPojosTest { - - @Test - void testPojos() { - List pojoClasses = - PojoClassFactory.getPojoClassesRecursively(MessagesRestPojosTest.class.getPackageName(), null); - - - // @formatter:off - final Validator validator = ValidatorBuilder - .create() - .with(new ToStringTester()) - .with(new SetterMustExistRule()) - .with(new GetterMustExistRule()) - .with(new SetterTester()) - .with(new GetterTester()) - .build(); - - validator.validate(pojoClasses); - // @formatter:on - } -} diff --git a/models/src/test/java/org/onap/policy/clamp/controlloop/models/messages/rest/instantiation/InstantiationCommandTest.java b/models/src/test/java/org/onap/policy/clamp/controlloop/models/messages/rest/instantiation/InstantiationCommandTest.java deleted file mode 100644 index c9902753f..000000000 --- a/models/src/test/java/org/onap/policy/clamp/controlloop/models/messages/rest/instantiation/InstantiationCommandTest.java +++ /dev/null @@ -1,60 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * Copyright (C) 2021 Nordix Foundation. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - * SPDX-License-Identifier: Apache-2.0 - * ============LICENSE_END========================================================= - */ - -package org.onap.policy.clamp.controlloop.models.messages.rest.instantiation; - -import static org.assertj.core.api.Assertions.assertThat; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertNotEquals; -import static org.junit.Assert.assertNotNull; - -import java.util.ArrayList; -import org.junit.jupiter.api.Test; -import org.onap.policy.clamp.controlloop.models.controlloop.concepts.ControlLoopOrderedState; - -class InstantiationCommandTest { - @Test - void testInstantiationCommandLombok() { - assertNotNull(new InstantiationCommand()); - InstantiationCommand ic0 = new InstantiationCommand(); - - assertThat(ic0.toString()).contains("InstantiationCommand("); - assertEquals(false, ic0.hashCode() == 0); - assertEquals(true, ic0.equals(ic0)); - assertEquals(false, ic0.equals(null)); - - - InstantiationCommand ic1 = new InstantiationCommand(); - - ic1.setControlLoopIdentifierList(new ArrayList<>()); - ic1.setOrderedState(ControlLoopOrderedState.UNINITIALISED); - - assertThat(ic1.toString()).contains("InstantiationCommand("); - assertEquals(false, ic1.hashCode() == 0); - assertEquals(false, ic1.equals(ic0)); - assertEquals(false, ic1.equals(null)); - - assertNotEquals(ic1, ic0); - - InstantiationCommand ic2 = new InstantiationCommand(); - - assertEquals(ic2, ic0); - } -} diff --git a/models/src/test/java/org/onap/policy/clamp/controlloop/models/rest/RestUtilsTest.java b/models/src/test/java/org/onap/policy/clamp/controlloop/models/rest/RestUtilsTest.java deleted file mode 100644 index 4dedae200..000000000 --- a/models/src/test/java/org/onap/policy/clamp/controlloop/models/rest/RestUtilsTest.java +++ /dev/null @@ -1,54 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * Copyright (C) 2021 Nordix Foundation. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - * SPDX-License-Identifier: Apache-2.0 - * ============LICENSE_END========================================================= - */ - -package org.onap.policy.clamp.controlloop.models.rest; - -import static org.assertj.core.api.Assertions.assertThat; - -import javax.ws.rs.core.Response.Status; -import org.junit.jupiter.api.Test; -import org.onap.policy.models.errors.concepts.ErrorResponse; -import org.onap.policy.models.errors.concepts.ErrorResponseInfo; - -class RestUtilsTest { - - private static final String MESSAGE_ERROR = "Erorr"; - private static final Status STATUS_ERROR = Status.BAD_REQUEST; - - @Test - void testToSimpleResponse() { - var ex = new ErrorResponseInfo() { - - @Override - public ErrorResponse getErrorResponse() { - var er = new ErrorResponse(); - er.setErrorMessage(MESSAGE_ERROR); - er.setResponseCode(STATUS_ERROR); - return er; - } - }; - - var response = RestUtils.toSimpleResponse(ex); - - assertThat(response.getStatusCodeValue()).isEqualTo(STATUS_ERROR.getStatusCode()); - assertThat(response.getBody()).isNotNull(); - assertThat(response.getBody().getErrorDetails()).isEqualTo(MESSAGE_ERROR); - } -} diff --git a/models/src/test/java/org/onap/policy/clamp/models/acm/concepts/AcElementStatisticsTest.java b/models/src/test/java/org/onap/policy/clamp/models/acm/concepts/AcElementStatisticsTest.java new file mode 100644 index 000000000..ee79b27b7 --- /dev/null +++ b/models/src/test/java/org/onap/policy/clamp/models/acm/concepts/AcElementStatisticsTest.java @@ -0,0 +1,67 @@ +/*- + * ============LICENSE_START======================================================= + * Copyright (C) 2021 Nordix Foundation. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * SPDX-License-Identifier: Apache-2.0 + * ============LICENSE_END========================================================= + */ + +package org.onap.policy.clamp.models.acm.concepts; + +import static org.assertj.core.api.Assertions.assertThat; +import static org.assertj.core.api.Assertions.assertThatThrownBy; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNotEquals; +import static org.junit.Assert.assertNotNull; + +import java.time.Instant; +import java.util.UUID; +import org.junit.jupiter.api.Test; +import org.onap.policy.models.tosca.authorative.concepts.ToscaConceptIdentifier; + +class AcElementStatisticsTest { + @Test + void testAcElementStatisticsLombok() { + assertNotNull(new AcElementStatistics()); + AcElementStatistics aces0 = new AcElementStatistics(); + + assertThat(aces0.toString()).contains("AcElementStatistics("); + assertThat(aces0.hashCode()).isNotZero(); + assertEquals(true, aces0.equals(aces0)); + assertEquals(false, aces0.equals(null)); + + + AcElementStatistics aces1 = new AcElementStatistics(); + aces1.setParticipantId(new ToscaConceptIdentifier("defName", "0.0.1")); + aces1.setTimeStamp(Instant.now()); + + assertThat(aces1.toString()).contains("AcElementStatistics("); + assertEquals(false, aces1.hashCode() == 0); + assertEquals(false, aces1.equals(aces0)); + assertEquals(false, aces1.equals(null)); + + assertNotEquals(aces1, aces0); + + AcElementStatistics aces2 = new AcElementStatistics(); + aces2.setId(UUID.randomUUID()); + + // @formatter:off + assertThatThrownBy(() -> aces2.setParticipantId(null)).isInstanceOf(NullPointerException.class); + assertThatThrownBy(() -> aces2.setTimeStamp(null)).isInstanceOf(NullPointerException.class); + // @formatter:on + + assertNotEquals(aces2, aces0); + } +} diff --git a/models/src/test/java/org/onap/policy/clamp/models/acm/concepts/AutomationCompositionConceptPojosTest.java b/models/src/test/java/org/onap/policy/clamp/models/acm/concepts/AutomationCompositionConceptPojosTest.java new file mode 100644 index 000000000..1d45e5919 --- /dev/null +++ b/models/src/test/java/org/onap/policy/clamp/models/acm/concepts/AutomationCompositionConceptPojosTest.java @@ -0,0 +1,62 @@ +/*- + * ============LICENSE_START======================================================= + * Copyright (C) 2021 Nordix Foundation. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * SPDX-License-Identifier: Apache-2.0 + * ============LICENSE_END========================================================= + */ + +package org.onap.policy.clamp.models.acm.concepts; + +import com.openpojo.reflection.PojoClass; +import com.openpojo.reflection.impl.PojoClassFactory; +import com.openpojo.validation.Validator; +import com.openpojo.validation.ValidatorBuilder; +import com.openpojo.validation.rule.impl.EqualsAndHashCodeMatchRule; +import com.openpojo.validation.rule.impl.GetterMustExistRule; +import com.openpojo.validation.rule.impl.NoPublicFieldsExceptStaticFinalRule; +import com.openpojo.validation.rule.impl.SetterMustExistRule; +import com.openpojo.validation.test.impl.GetterTester; +import com.openpojo.validation.test.impl.SetterTester; +import java.util.List; +import org.junit.jupiter.api.Test; +import org.onap.policy.common.utils.test.ToStringTester; + +/** + * Class to perform unit tests of all pojos. + */ +class AutomationCompositionConceptPojosTest { + + @Test + void testPojos() { + List pojoClasses = + PojoClassFactory.getPojoClasses(AutomationCompositionConceptPojosTest.class.getPackageName()); + + // @formatter:off + final Validator validator = ValidatorBuilder + .create() + .with(new SetterMustExistRule()) + .with(new GetterMustExistRule()) + .with(new EqualsAndHashCodeMatchRule()) + .with(new NoPublicFieldsExceptStaticFinalRule()) + .with(new SetterTester()) + .with(new GetterTester()) + .with(new ToStringTester()) + .build(); + + validator.validate(pojoClasses); + // @formatter:on + } +} diff --git a/models/src/test/java/org/onap/policy/clamp/models/acm/concepts/AutomationCompositionElementTest.java b/models/src/test/java/org/onap/policy/clamp/models/acm/concepts/AutomationCompositionElementTest.java new file mode 100644 index 000000000..4e739db52 --- /dev/null +++ b/models/src/test/java/org/onap/policy/clamp/models/acm/concepts/AutomationCompositionElementTest.java @@ -0,0 +1,103 @@ +/*- + * ============LICENSE_START======================================================= + * Copyright (C) 2021 Nordix Foundation. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * SPDX-License-Identifier: Apache-2.0 + * ============LICENSE_END========================================================= + */ + +package org.onap.policy.clamp.models.acm.concepts; + +import static org.assertj.core.api.Assertions.assertThat; +import static org.assertj.core.api.Assertions.assertThatThrownBy; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNotEquals; +import static org.junit.Assert.assertNotNull; +import static org.junit.Assert.assertTrue; + +import java.util.UUID; +import org.junit.jupiter.api.Test; +import org.onap.policy.models.tosca.authorative.concepts.ToscaConceptIdentifier; + +class AutomationCompositionElementTest { + @Test + void testAutomationCompositionElement() { + var ace0 = new AutomationCompositionElement(); + var ace1 = new AutomationCompositionElement(ace0); + assertEquals(ace0, ace1); + + ace1.setDefinition(new ToscaConceptIdentifier("defName", "0.0.1")); + ace1.setDescription("Description"); + ace1.setId(UUID.randomUUID()); + ace1.setOrderedState(AutomationCompositionOrderedState.UNINITIALISED); + ace1.setParticipantId(new ToscaConceptIdentifier("id", "1.2.3")); + ace1.setState(AutomationCompositionState.UNINITIALISED); + + var ace2 = new AutomationCompositionElement(ace1); + assertEquals(ace1, ace2); + } + + @Test + void testAutomationCompositionState() { + var ace0 = new AutomationCompositionElement(); + + assertTrue( + ace0.getOrderedState() + .equalsAutomationCompositionState(AutomationCompositionState.UNINITIALISED)); + + assertTrue( + ace0.getOrderedState().asState() + .equalsAutomationCompositionOrderedState(AutomationCompositionOrderedState.UNINITIALISED)); + } + + @Test + void testAutomationCompositionElementLombok() { + assertNotNull(new AutomationCompositionElement()); + var ace0 = new AutomationCompositionElement(); + + assertThat(ace0.toString()).contains("AutomationCompositionElement("); + assertThat(ace0.hashCode()).isNotZero(); + assertEquals(true, ace0.equals(ace0)); + assertEquals(false, ace0.equals(null)); + + var ace1 = new AutomationCompositionElement(); + + ace1.setDefinition(new ToscaConceptIdentifier("defName", "0.0.1")); + ace1.setDescription("Description"); + ace1.setId(UUID.randomUUID()); + ace1.setOrderedState(AutomationCompositionOrderedState.UNINITIALISED); + ace1.setParticipantId(new ToscaConceptIdentifier("id", "1.2.3")); + ace1.setState(AutomationCompositionState.UNINITIALISED); + + assertThat(ace1.toString()).contains("AutomationCompositionElement("); + assertEquals(false, ace1.hashCode() == 0); + assertEquals(false, ace1.equals(ace0)); + assertEquals(false, ace1.equals(null)); + + assertNotEquals(ace1, ace0); + + var ace2 = new AutomationCompositionElement(); + + // @formatter:off + assertThatThrownBy(() -> ace2.setDefinition(null)). isInstanceOf(NullPointerException.class); + assertThatThrownBy(() -> ace2.setId(null)). isInstanceOf(NullPointerException.class); + assertThatThrownBy(() -> ace2.setOrderedState(null)). isInstanceOf(NullPointerException.class); + assertThatThrownBy(() -> ace2.setParticipantId(null)).isInstanceOf(NullPointerException.class); + assertThatThrownBy(() -> ace2.setState(null)). isInstanceOf(NullPointerException.class); + // @formatter:on + + assertNotEquals(ace2, ace0); + } +} diff --git a/models/src/test/java/org/onap/policy/clamp/models/acm/concepts/AutomationCompositionTest.java b/models/src/test/java/org/onap/policy/clamp/models/acm/concepts/AutomationCompositionTest.java new file mode 100644 index 000000000..ad8a1bbea --- /dev/null +++ b/models/src/test/java/org/onap/policy/clamp/models/acm/concepts/AutomationCompositionTest.java @@ -0,0 +1,160 @@ +/*- + * ============LICENSE_START======================================================= + * Copyright (C) 2021 Nordix Foundation. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * SPDX-License-Identifier: Apache-2.0 + * ============LICENSE_END========================================================= + */ + +package org.onap.policy.clamp.models.acm.concepts; + +import static org.assertj.core.api.Assertions.assertThat; +import static org.assertj.core.api.Assertions.assertThatThrownBy; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNotEquals; +import static org.junit.Assert.assertNotNull; +import static org.junit.Assert.assertNull; + +import java.time.Instant; +import java.util.LinkedHashMap; +import java.util.List; +import java.util.UUID; +import org.junit.jupiter.api.Test; +import org.onap.policy.models.base.PfKey; +import org.onap.policy.models.tosca.authorative.concepts.ToscaConceptIdentifier; + +class AutomationCompositionTest { + @Test + void testAutomationComposition() { + var ac0 = new AutomationComposition(); + ac0.setDefinition(new ToscaConceptIdentifier("dfName", "1.2.3")); + assertEquals("dfName", ac0.getType()); + assertEquals("1.2.3", ac0.getTypeVersion()); + + var ac1 = new AutomationComposition(ac0); + assertEquals(ac0, ac1); + + assertEquals(0, ac0.compareTo(ac1)); + } + + @Test + void testAutomationCompositionLombok() { + assertNotNull(new AutomationComposition()); + var ac0 = new AutomationComposition(); + ac0.setElements(new LinkedHashMap<>()); + + assertThat(ac0.toString()).contains("AutomationComposition("); + assertThat(ac0.hashCode()).isNotZero(); + assertEquals(true, ac0.equals(ac0)); + assertEquals(false, ac0.equals(null)); + + var ac1 = new AutomationComposition(); + + ac1.setDefinition(new ToscaConceptIdentifier("defName", "0.0.1")); + ac1.setDescription("Description"); + ac1.setElements(new LinkedHashMap<>()); + ac1.setName("Name"); + ac1.setOrderedState(AutomationCompositionOrderedState.UNINITIALISED); + ac1.setState(AutomationCompositionState.UNINITIALISED); + ac1.setVersion("0.0.1"); + + assertThat(ac1.toString()).contains("AutomationComposition("); + assertEquals(false, ac1.hashCode() == 0); + assertEquals(false, ac1.equals(ac0)); + assertEquals(false, ac1.equals(null)); + + assertNotEquals(ac1, ac0); + + var ac2 = new AutomationComposition(); + ac2.setElements(new LinkedHashMap<>()); + + // @formatter:off + assertThatThrownBy(() -> ac2.setDefinition(null)). isInstanceOf(NullPointerException.class); + assertThatThrownBy(() -> ac2.setOrderedState(null)).isInstanceOf(NullPointerException.class); + assertThatThrownBy(() -> ac2.setState(null)). isInstanceOf(NullPointerException.class); + // @formatter:on + + assertEquals(ac2, ac0); + + ac1.setCascadedOrderedState(AutomationCompositionOrderedState.PASSIVE); + assertEquals(AutomationCompositionOrderedState.PASSIVE, ac1.getOrderedState()); + + ac1.getElements().put(UUID.randomUUID(), new AutomationCompositionElement()); + ac1.setCascadedOrderedState(AutomationCompositionOrderedState.RUNNING); + assertEquals(AutomationCompositionOrderedState.RUNNING, ac1.getOrderedState()); + assertEquals(AutomationCompositionOrderedState.RUNNING, + ac1.getElements().values().iterator().next().getOrderedState()); + + assertNull(ac0.getElements().get(UUID.randomUUID())); + assertNull(ac1.getElements().get(UUID.randomUUID())); + + assertEquals(PfKey.NULL_KEY_NAME, ac0.getDefinition().getName()); + + } + + @Test + void testAutomationCompositionElementStatisticsList() { + var ac = new AutomationComposition(); + List emptylist = ac.getAutomationCompositionElementStatisticsList(ac); + assertEquals(List.of(), emptylist); + + var ac1 = getAutomationCompositionTest(); + List list = ac1.getAutomationCompositionElementStatisticsList(ac1); + assertNotNull(list); + assertEquals(2, list.size()); + assertEquals(AutomationCompositionState.UNINITIALISED, list.get(0).getState()); + } + + private AutomationComposition getAutomationCompositionTest() { + var ac = new AutomationComposition(); + ac.setDefinition(new ToscaConceptIdentifier("defName", "1.2.3")); + ac.setDescription("Description"); + ac.setElements(new LinkedHashMap<>()); + ac.setName("Name"); + ac.setOrderedState(AutomationCompositionOrderedState.UNINITIALISED); + ac.setState(AutomationCompositionState.UNINITIALISED); + ac.setVersion("0.0.1"); + + var uuid = UUID.randomUUID(); + var id = new ToscaConceptIdentifier("org.onap.policy.acm.PolicyAutomationCompositionParticipant", "1.0.1"); + var acElement = getAutomationCompositionElementTest(uuid, id); + + var uuid2 = UUID.randomUUID(); + var id2 = new ToscaConceptIdentifier("org.onap.policy.acm.PolicyAutomationCompositionParticipantIntermediary", + "0.0.1"); + var acElement2 = getAutomationCompositionElementTest(uuid2, id2); + + ac.getElements().put(uuid, acElement); + ac.getElements().put(uuid2, acElement2); + return ac; + } + + private AutomationCompositionElement getAutomationCompositionElementTest(UUID uuid, ToscaConceptIdentifier id) { + var acElement = new AutomationCompositionElement(); + acElement.setId(uuid); + acElement.setParticipantId(id); + acElement.setDefinition(id); + acElement.setOrderedState(AutomationCompositionOrderedState.UNINITIALISED); + + var acElementStatistics = new AcElementStatistics(); + acElementStatistics.setParticipantId(id); + acElementStatistics.setState(AutomationCompositionState.UNINITIALISED); + acElementStatistics.setTimeStamp(Instant.now()); + + acElement.setAcElementStatistics(acElementStatistics); + + return acElement; + } +} diff --git a/models/src/test/java/org/onap/policy/clamp/models/acm/concepts/ParticipantStatisticsTest.java b/models/src/test/java/org/onap/policy/clamp/models/acm/concepts/ParticipantStatisticsTest.java new file mode 100644 index 000000000..de9b884d3 --- /dev/null +++ b/models/src/test/java/org/onap/policy/clamp/models/acm/concepts/ParticipantStatisticsTest.java @@ -0,0 +1,65 @@ +/*- + * ============LICENSE_START======================================================= + * Copyright (C) 2021 Nordix Foundation. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * SPDX-License-Identifier: Apache-2.0 + * ============LICENSE_END========================================================= + */ + +package org.onap.policy.clamp.models.acm.concepts; + +import static org.assertj.core.api.Assertions.assertThat; +import static org.assertj.core.api.Assertions.assertThatThrownBy; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNotEquals; +import static org.junit.Assert.assertNotNull; + +import java.time.Instant; +import org.junit.jupiter.api.Test; +import org.onap.policy.models.tosca.authorative.concepts.ToscaConceptIdentifier; + +class ParticipantStatisticsTest { + @Test + void testParticipantStatisticsLombok() { + assertNotNull(new ParticipantStatistics()); + ParticipantStatistics ps0 = new ParticipantStatistics(); + + assertThat(ps0.toString()).contains("ParticipantStatistics("); + assertThat(ps0.hashCode()).isNotZero(); + assertEquals(true, ps0.equals(ps0)); + assertEquals(false, ps0.equals(null)); + + + ParticipantStatistics ps1 = new ParticipantStatistics(); + ps1.setParticipantId(new ToscaConceptIdentifier("defName", "0.0.1")); + ps1.setTimeStamp(Instant.now()); + + assertThat(ps1.toString()).contains("ParticipantStatistics("); + assertEquals(false, ps1.hashCode() == 0); + assertEquals(false, ps1.equals(ps0)); + assertEquals(false, ps1.equals(null)); + + assertNotEquals(ps1, ps0); + + ParticipantStatistics ps2 = new ParticipantStatistics(); + + // @formatter:off + assertThatThrownBy(() -> ps2.setParticipantId(null)).isInstanceOf(NullPointerException.class); + assertThatThrownBy(() -> ps2.setTimeStamp(null)). isInstanceOf(NullPointerException.class); + // @formatter:on + + assertEquals(ps2, ps0); + } +} diff --git a/models/src/test/java/org/onap/policy/clamp/models/acm/concepts/ParticipantTest.java b/models/src/test/java/org/onap/policy/clamp/models/acm/concepts/ParticipantTest.java new file mode 100644 index 000000000..164c7c1a0 --- /dev/null +++ b/models/src/test/java/org/onap/policy/clamp/models/acm/concepts/ParticipantTest.java @@ -0,0 +1,84 @@ +/*- + * ============LICENSE_START======================================================= + * Copyright (C) 2021 Nordix Foundation. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * SPDX-License-Identifier: Apache-2.0 + * ============LICENSE_END========================================================= + */ + +package org.onap.policy.clamp.models.acm.concepts; + +import static org.assertj.core.api.Assertions.assertThat; +import static org.assertj.core.api.Assertions.assertThatThrownBy; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNotEquals; +import static org.junit.Assert.assertNotNull; + +import org.junit.jupiter.api.Test; +import org.onap.policy.models.tosca.authorative.concepts.ToscaConceptIdentifier; + +class ParticipantTest { + @Test + void testParticipant() { + + Participant p0 = new Participant(); + p0.setDefinition(new ToscaConceptIdentifier("dfName", "1.2.3")); + assertEquals("dfName", p0.getType()); + assertEquals("1.2.3", p0.getTypeVersion()); + + Participant p1 = new Participant(p0); + assertEquals(p0, p1); + + assertEquals(0, p0.compareTo(p1)); + } + + @Test + void testParticipantLombok() { + assertNotNull(new Participant()); + Participant p0 = new Participant(); + + assertThat(p0.toString()).contains("Participant("); + assertThat(p0.hashCode()).isNotZero(); + assertEquals(true, p0.equals(p0)); + assertEquals(false, p0.equals(null)); + + + Participant p1 = new Participant(); + + p1.setDefinition(new ToscaConceptIdentifier("defName", "0.0.1")); + p1.setDescription("Description"); + p1.setHealthStatus(ParticipantHealthStatus.HEALTHY); + p1.setName("Name"); + p1.setParticipantState(ParticipantState.ACTIVE); + p1.setVersion("0.0.1"); + + assertThat(p1.toString()).contains("Participant("); + assertEquals(false, p1.hashCode() == 0); + assertEquals(false, p1.equals(p0)); + assertEquals(false, p1.equals(null)); + + assertNotEquals(p1, p0); + + Participant p2 = new Participant(); + + // @formatter:off + assertThatThrownBy(() -> p2.setDefinition(null)). isInstanceOf(NullPointerException.class); + assertThatThrownBy(() -> p2.setHealthStatus(null)). isInstanceOf(NullPointerException.class); + assertThatThrownBy(() -> p2.setParticipantState(null)).isInstanceOf(NullPointerException.class); + // @formatter:on + + assertEquals(p2, p0); + } +} diff --git a/models/src/test/java/org/onap/policy/clamp/models/acm/concepts/ParticipantUtilsTest.java b/models/src/test/java/org/onap/policy/clamp/models/acm/concepts/ParticipantUtilsTest.java new file mode 100644 index 000000000..5252221a8 --- /dev/null +++ b/models/src/test/java/org/onap/policy/clamp/models/acm/concepts/ParticipantUtilsTest.java @@ -0,0 +1,91 @@ +/*- + * ============LICENSE_START======================================================= + * Copyright (C) 2021 Nordix Foundation. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * SPDX-License-Identifier: Apache-2.0 + * ============LICENSE_END========================================================= + */ + +package org.onap.policy.clamp.models.acm.concepts; + +import static org.assertj.core.api.Assertions.assertThat; + +import java.util.Map; +import org.junit.jupiter.api.Test; +import org.onap.policy.common.utils.coder.Coder; +import org.onap.policy.common.utils.coder.CoderException; +import org.onap.policy.common.utils.coder.StandardCoder; +import org.onap.policy.common.utils.coder.StandardYamlCoder; +import org.onap.policy.common.utils.resources.ResourceUtils; +import org.onap.policy.models.tosca.authorative.concepts.ToscaConceptIdentifier; +import org.onap.policy.models.tosca.authorative.concepts.ToscaNodeTemplate; +import org.onap.policy.models.tosca.authorative.concepts.ToscaServiceTemplate; + +class ParticipantUtilsTest { + + private static final Coder CODER = new StandardCoder(); + private static final String TOSCA_TEMPLATE_YAML = "examples/acm/PMSubscriptionHandling.yaml"; + private static final String AUTOMATION_COMPOSITION_JSON = + "src/test/resources/providers/TestAutomationCompositions.json"; + private static final String AUTOMATION_COMPOSITION_ELEMENT = + "org.onap.policy.clamp.acm.AutomationCompositionElement"; + private static final String POLICY_AUTOMATION_COMPOSITION_ELEMENT = + "org.onap.policy.clamp.acm.PolicyAutomationCompositionElement"; + private static final String PARTICIPANT_AUTOMATION_COMPOSITION_ELEMENT = "org.onap.policy.clamp.acm.Participant"; + private static final StandardYamlCoder YAML_TRANSLATOR = new StandardYamlCoder(); + + @Test + void testFindParticipantType() throws CoderException { + var identifier = new ToscaConceptIdentifier("Identifier", "1.0.1"); + var result = ParticipantUtils.findParticipantType(Map.of("participantType", CODER.encode(identifier))); + assertThat(result).isEqualTo(identifier); + } + + @Test + void testFindStartPhase() { + var identifier = 13; + var result = ParticipantUtils.findStartPhase(Map.of("startPhase", identifier)); + assertThat(result).isEqualTo(identifier); + } + + @Test + void testGetFirstStartPhase() throws CoderException { + var serviceTemplate = + YAML_TRANSLATOR.decode(ResourceUtils.getResourceAsStream(TOSCA_TEMPLATE_YAML), ToscaServiceTemplate.class); + var automationCompositions = + CODER.decode(ResourceUtils.getResourceAsString(AUTOMATION_COMPOSITION_JSON), AutomationCompositions.class); + var result = ParticipantUtils.getFirstStartPhase(automationCompositions.getAutomationCompositionList().get(0), + serviceTemplate); + assertThat(result).isZero(); + } + + @Test + void testCheckIfNodeTemplateIsAutomationCompositionElement() throws CoderException { + var serviceTemplate = + YAML_TRANSLATOR.decode(ResourceUtils.getResourceAsStream(TOSCA_TEMPLATE_YAML), ToscaServiceTemplate.class); + var nodeTemplate = new ToscaNodeTemplate(); + nodeTemplate.setType(AUTOMATION_COMPOSITION_ELEMENT); + assertThat(ParticipantUtils.checkIfNodeTemplateIsAutomationCompositionElement(nodeTemplate, serviceTemplate)) + .isTrue(); + + nodeTemplate.setType(POLICY_AUTOMATION_COMPOSITION_ELEMENT); + assertThat(ParticipantUtils.checkIfNodeTemplateIsAutomationCompositionElement(nodeTemplate, serviceTemplate)) + .isTrue(); + + nodeTemplate.setType(PARTICIPANT_AUTOMATION_COMPOSITION_ELEMENT); + assertThat(ParticipantUtils.checkIfNodeTemplateIsAutomationCompositionElement(nodeTemplate, serviceTemplate)) + .isFalse(); + } +} diff --git a/models/src/test/java/org/onap/policy/clamp/models/acm/messages/dmaap/notification/AutomationCompositionNotificationTest.java b/models/src/test/java/org/onap/policy/clamp/models/acm/messages/dmaap/notification/AutomationCompositionNotificationTest.java new file mode 100644 index 000000000..49bb719ac --- /dev/null +++ b/models/src/test/java/org/onap/policy/clamp/models/acm/messages/dmaap/notification/AutomationCompositionNotificationTest.java @@ -0,0 +1,83 @@ +/*- + * ============LICENSE_START======================================================= + * Copyright (C) 2021 Nordix Foundation. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * SPDX-License-Identifier: Apache-2.0 + * ============LICENSE_END========================================================= + */ + +package org.onap.policy.clamp.models.acm.messages.dmaap.notification; + +import static org.assertj.core.api.Assertions.assertThat; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNotNull; + +import java.util.ArrayList; +import java.util.List; +import org.junit.jupiter.api.Test; + +class AutomationCompositionNotificationTest { + + @Test + void testAutomationCompositionNotification() { + AutomationCompositionNotification acn0 = new AutomationCompositionNotification(); + + List addedList = new ArrayList<>(); + addedList.add(new AutomationCompositionStatus()); + + List deletedList = new ArrayList<>(); + deletedList.add(new AutomationCompositionStatus()); + + assertEquals(true, acn0.isEmpty()); + + acn0.setAdded(addedList); + assertEquals(false, acn0.isEmpty()); + acn0.setAdded(null); + assertEquals(true, acn0.isEmpty()); + + acn0.setDeleted(deletedList); + assertEquals(false, acn0.isEmpty()); + acn0.setDeleted(null); + assertEquals(true, acn0.isEmpty()); + + acn0.setAdded(addedList); + acn0.setDeleted(deletedList); + assertEquals(false, acn0.isEmpty()); + acn0.setAdded(null); + acn0.setDeleted(null); + assertEquals(true, acn0.isEmpty()); + } + + @Test + void testAutomationCompositionNotificationLombok() { + assertNotNull(new AutomationCompositionNotification()); + assertNotNull(new AutomationCompositionNotification(new ArrayList<>(), new ArrayList<>())); + + AutomationCompositionNotification acn0 = new AutomationCompositionNotification(); + + assertThat(acn0.toString()).contains("AutomationCompositionNotification("); + assertEquals(false, acn0.hashCode() == 0); + assertEquals(true, acn0.equals(acn0)); + assertEquals(false, acn0.equals(null)); + + + AutomationCompositionNotification acn1 = new AutomationCompositionNotification(); + + assertThat(acn1.toString()).contains("AutomationCompositionNotification("); + assertEquals(false, acn1.hashCode() == 0); + assertEquals(true, acn1.equals(acn0)); + assertEquals(false, acn1.equals(null)); + } +} diff --git a/models/src/test/java/org/onap/policy/clamp/models/acm/messages/dmaap/notification/AutomationCompositionStatusTest.java b/models/src/test/java/org/onap/policy/clamp/models/acm/messages/dmaap/notification/AutomationCompositionStatusTest.java new file mode 100644 index 000000000..028566888 --- /dev/null +++ b/models/src/test/java/org/onap/policy/clamp/models/acm/messages/dmaap/notification/AutomationCompositionStatusTest.java @@ -0,0 +1,48 @@ +/*- + * ============LICENSE_START======================================================= + * Copyright (C) 2021 Nordix Foundation. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * SPDX-License-Identifier: Apache-2.0 + * ============LICENSE_END========================================================= + */ + +package org.onap.policy.clamp.models.acm.messages.dmaap.notification; + +import static org.assertj.core.api.Assertions.assertThat; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNotNull; + +import java.util.UUID; +import org.junit.jupiter.api.Test; +import org.onap.policy.models.tosca.authorative.concepts.ToscaConceptIdentifier; + +class AutomationCompositionStatusTest { + + @Test + void testAutomationCompositionStatusLombok() { + assertNotNull(new AutomationCompositionStatus()); + assertNotNull(new AutomationCompositionStatus(UUID.randomUUID(), new ToscaConceptIdentifier())); + + AutomationCompositionStatus acn0 = new AutomationCompositionStatus(); + + assertThat(acn0.toString()).contains("AutomationCompositionStatus("); + assertEquals(false, acn0.hashCode() == 0); + assertEquals(true, acn0.equals(acn0)); + assertEquals(false, acn0.equals(null)); + + AutomationCompositionStatus acn1 = new AutomationCompositionStatus(); + assertEquals(true, acn1.equals(acn0)); + } +} diff --git a/models/src/test/java/org/onap/policy/clamp/models/acm/messages/dmaap/notification/NotificationPojosTest.java b/models/src/test/java/org/onap/policy/clamp/models/acm/messages/dmaap/notification/NotificationPojosTest.java new file mode 100644 index 000000000..494252acc --- /dev/null +++ b/models/src/test/java/org/onap/policy/clamp/models/acm/messages/dmaap/notification/NotificationPojosTest.java @@ -0,0 +1,58 @@ +/*- + * ============LICENSE_START======================================================= + * Copyright (C) 2021 Nordix Foundation. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * SPDX-License-Identifier: Apache-2.0 + * ============LICENSE_END========================================================= + */ + +package org.onap.policy.clamp.models.acm.messages.dmaap.notification; + +import com.openpojo.reflection.PojoClass; +import com.openpojo.reflection.impl.PojoClassFactory; +import com.openpojo.validation.Validator; +import com.openpojo.validation.ValidatorBuilder; +import com.openpojo.validation.rule.impl.GetterMustExistRule; +import com.openpojo.validation.rule.impl.SetterMustExistRule; +import com.openpojo.validation.test.impl.GetterTester; +import com.openpojo.validation.test.impl.SetterTester; +import java.util.List; +import org.junit.jupiter.api.Test; +import org.onap.policy.common.utils.test.ToStringTester; + +/** + * Class to perform unit tests of all pojos. + */ +class NotificationPojosTest { + + @Test + void testPojos() { + List pojoClasses = + PojoClassFactory.getPojoClasses(NotificationPojosTest.class.getPackageName()); + + // @formatter:off + final Validator validator = ValidatorBuilder + .create() + .with(new ToStringTester()) + .with(new SetterMustExistRule()) + .with(new GetterMustExistRule()) + .with(new SetterTester()) + .with(new GetterTester()) + .build(); + + validator.validate(pojoClasses); + // @formatter:on + } +} diff --git a/models/src/test/java/org/onap/policy/clamp/models/acm/messages/dmaap/participant/AutomationCompositionAckTest.java b/models/src/test/java/org/onap/policy/clamp/models/acm/messages/dmaap/participant/AutomationCompositionAckTest.java new file mode 100644 index 000000000..383a55115 --- /dev/null +++ b/models/src/test/java/org/onap/policy/clamp/models/acm/messages/dmaap/participant/AutomationCompositionAckTest.java @@ -0,0 +1,68 @@ +/*- + * ============LICENSE_START======================================================= + * Copyright (C) 2021 Nordix Foundation. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * SPDX-License-Identifier: Apache-2.0 + * ============LICENSE_END========================================================= + */ + +package org.onap.policy.clamp.models.acm.messages.dmaap.participant; + +import static org.assertj.core.api.Assertions.assertThatThrownBy; +import static org.junit.Assert.assertEquals; +import static org.onap.policy.clamp.models.acm.messages.dmaap.participant.ParticipantMessageUtils.assertSerializable; +import static org.onap.policy.clamp.models.acm.messages.dmaap.participant.ParticipantMessageUtils.removeVariableFields; + +import java.util.Map; +import java.util.UUID; +import org.junit.jupiter.api.Test; +import org.onap.policy.clamp.models.acm.concepts.AutomationCompositionElementAck; +import org.onap.policy.clamp.models.acm.concepts.AutomationCompositionState; +import org.onap.policy.common.utils.coder.CoderException; +import org.onap.policy.models.tosca.authorative.concepts.ToscaConceptIdentifier; + +class AutomationCompositionAckTest { + + @Test + void testCopyConstructor() throws CoderException { + assertThatThrownBy(() -> new AutomationCompositionAck((AutomationCompositionAck) null)) + .isInstanceOf(NullPointerException.class); + + final var orig = new AutomationCompositionAck(ParticipantMessageType.AUTOMATION_COMPOSITION_UPDATE); + + // verify with null values + assertEquals(removeVariableFields(orig.toString()), + removeVariableFields(new AutomationCompositionAck(orig).toString())); + + // verify with all values + var id = new ToscaConceptIdentifier("id", "1.2.3"); + orig.setAutomationCompositionId(id); + orig.setParticipantId(id); + orig.setParticipantType(id); + var acElementResult = new AutomationCompositionElementAck(AutomationCompositionState.UNINITIALISED, + true, "AutomationCompositionElement result"); + final var automationCompositionResultMap = Map.of(UUID.randomUUID(), acElementResult); + orig.setAutomationCompositionResultMap(automationCompositionResultMap); + + orig.setResponseTo(UUID.randomUUID()); + orig.setResult(true); + orig.setMessage("Successfully processed AutomationCompositionUpdate message"); + + assertEquals(removeVariableFields(orig.toString()), + removeVariableFields(new AutomationCompositionAck(orig).toString())); + + assertSerializable(orig, AutomationCompositionAck.class); + } +} diff --git a/models/src/test/java/org/onap/policy/clamp/models/acm/messages/dmaap/participant/AutomationCompositionStateChangeTest.java b/models/src/test/java/org/onap/policy/clamp/models/acm/messages/dmaap/participant/AutomationCompositionStateChangeTest.java new file mode 100644 index 000000000..6c48afad2 --- /dev/null +++ b/models/src/test/java/org/onap/policy/clamp/models/acm/messages/dmaap/participant/AutomationCompositionStateChangeTest.java @@ -0,0 +1,65 @@ +/*- + * ============LICENSE_START======================================================= + * Copyright (C) 2021 Nordix Foundation. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * SPDX-License-Identifier: Apache-2.0 + * ============LICENSE_END========================================================= + */ + +package org.onap.policy.clamp.models.acm.messages.dmaap.participant; + +import static org.assertj.core.api.Assertions.assertThatThrownBy; +import static org.junit.Assert.assertEquals; +import static org.onap.policy.clamp.models.acm.messages.dmaap.participant.ParticipantMessageUtils.assertSerializable; +import static org.onap.policy.clamp.models.acm.messages.dmaap.participant.ParticipantMessageUtils.removeVariableFields; + +import java.time.Instant; +import java.util.UUID; +import org.junit.jupiter.api.Test; +import org.onap.policy.clamp.models.acm.concepts.AutomationCompositionOrderedState; +import org.onap.policy.clamp.models.acm.concepts.AutomationCompositionState; +import org.onap.policy.common.utils.coder.CoderException; +import org.onap.policy.models.tosca.authorative.concepts.ToscaConceptIdentifier; + +/** + * Test the copy constructor and other methods. + */ +class AutomationCompositionStateChangeTest { + + @Test + void testCopyConstructor() throws CoderException { + assertThatThrownBy(() -> new AutomationCompositionStateChange(null)).isInstanceOf(NullPointerException.class); + + AutomationCompositionStateChange orig = new AutomationCompositionStateChange(); + + // verify with null values + assertEquals(removeVariableFields(orig.toString()), + removeVariableFields(new AutomationCompositionStateChange(orig).toString())); + + // verify with all values + ToscaConceptIdentifier id = new ToscaConceptIdentifier("id", "1.2.3"); + orig.setAutomationCompositionId(id); + orig.setParticipantId(id); + orig.setMessageId(UUID.randomUUID()); + orig.setOrderedState(AutomationCompositionOrderedState.RUNNING); + orig.setCurrentState(AutomationCompositionState.PASSIVE); + orig.setTimestamp(Instant.ofEpochMilli(3000)); + + assertEquals(removeVariableFields(orig.toString()), + removeVariableFields(new AutomationCompositionStateChange(orig).toString())); + + assertSerializable(orig, AutomationCompositionStateChange.class); + } +} diff --git a/models/src/test/java/org/onap/policy/clamp/models/acm/messages/dmaap/participant/AutomationCompositionUpdateTest.java b/models/src/test/java/org/onap/policy/clamp/models/acm/messages/dmaap/participant/AutomationCompositionUpdateTest.java new file mode 100644 index 000000000..809256d40 --- /dev/null +++ b/models/src/test/java/org/onap/policy/clamp/models/acm/messages/dmaap/participant/AutomationCompositionUpdateTest.java @@ -0,0 +1,82 @@ +/*- + * ============LICENSE_START======================================================= + * Copyright (C) 2021 Nordix Foundation. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * SPDX-License-Identifier: Apache-2.0 + * ============LICENSE_END========================================================= + */ + +package org.onap.policy.clamp.models.acm.messages.dmaap.participant; + +import static org.assertj.core.api.Assertions.assertThatThrownBy; +import static org.junit.Assert.assertEquals; +import static org.onap.policy.clamp.models.acm.messages.dmaap.participant.ParticipantMessageUtils.assertSerializable; +import static org.onap.policy.clamp.models.acm.messages.dmaap.participant.ParticipantMessageUtils.removeVariableFields; + +import java.time.Instant; +import java.util.List; +import java.util.Map; +import java.util.UUID; +import org.junit.jupiter.api.Test; +import org.onap.policy.clamp.models.acm.concepts.AutomationCompositionElement; +import org.onap.policy.clamp.models.acm.concepts.AutomationCompositionOrderedState; +import org.onap.policy.clamp.models.acm.concepts.AutomationCompositionState; +import org.onap.policy.clamp.models.acm.concepts.ParticipantUpdates; +import org.onap.policy.common.utils.coder.CoderException; +import org.onap.policy.models.tosca.authorative.concepts.ToscaConceptIdentifier; +import org.onap.policy.models.tosca.authorative.concepts.ToscaProperty; + +/** + * Test the copy constructor. + */ +class AutomationCompositionUpdateTest { + @Test + void testCopyConstructor() throws CoderException { + assertThatThrownBy(() -> new AutomationCompositionUpdate(null)).isInstanceOf(NullPointerException.class); + + AutomationCompositionUpdate orig = new AutomationCompositionUpdate(); + // verify with all values + ToscaConceptIdentifier id = new ToscaConceptIdentifier("id", "1.2.3"); + orig.setAutomationCompositionId(id); + orig.setParticipantId(null); + orig.setMessageId(UUID.randomUUID()); + orig.setTimestamp(Instant.ofEpochMilli(3000)); + + AutomationCompositionElement acElement = new AutomationCompositionElement(); + acElement.setId(UUID.randomUUID()); + acElement.setDefinition(id); + acElement.setDescription("Description"); + acElement.setOrderedState(AutomationCompositionOrderedState.PASSIVE); + acElement.setState(AutomationCompositionState.PASSIVE); + acElement.setParticipantId(id); + acElement.setParticipantType(id); + + ToscaProperty property = new ToscaProperty(); + property.setName("test"); + property.setType("testType"); + Map propertiesMap = Map.of("Prop1", property); + acElement.setPropertiesMap(propertiesMap); + + ParticipantUpdates participantUpdates = new ParticipantUpdates(); + participantUpdates.setParticipantId(id); + participantUpdates.setAutomationCompositionElementList(List.of(acElement)); + orig.setParticipantUpdatesList(List.of(participantUpdates)); + + AutomationCompositionUpdate other = new AutomationCompositionUpdate(orig); + + assertEquals(removeVariableFields(orig.toString()), removeVariableFields(other.toString())); + assertSerializable(orig, AutomationCompositionUpdate.class); + } +} diff --git a/models/src/test/java/org/onap/policy/clamp/models/acm/messages/dmaap/participant/ParticipantAckMessageTest.java b/models/src/test/java/org/onap/policy/clamp/models/acm/messages/dmaap/participant/ParticipantAckMessageTest.java new file mode 100644 index 000000000..89a34e33d --- /dev/null +++ b/models/src/test/java/org/onap/policy/clamp/models/acm/messages/dmaap/participant/ParticipantAckMessageTest.java @@ -0,0 +1,105 @@ +/*- + * ============LICENSE_START======================================================= + * Copyright (C) 2021 Nordix Foundation. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * SPDX-License-Identifier: Apache-2.0 + * ============LICENSE_END========================================================= + */ + +package org.onap.policy.clamp.models.acm.messages.dmaap.participant; + +import static org.assertj.core.api.Assertions.assertThatThrownBy; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertTrue; +import static org.onap.policy.clamp.models.acm.messages.dmaap.participant.ParticipantMessageUtils.assertSerializable; + +import java.util.UUID; +import org.junit.jupiter.api.Test; +import org.onap.policy.common.utils.coder.CoderException; +import org.onap.policy.models.tosca.authorative.concepts.ToscaConceptIdentifier; + +class ParticipantAckMessageTest { + private ParticipantAckMessage message; + + private static final ToscaConceptIdentifier PTYPE_456 = new ToscaConceptIdentifier("PType", "4.5.6"); + private static final ToscaConceptIdentifier PTYPE_457 = new ToscaConceptIdentifier("PType", "4.5.7"); + private static final ToscaConceptIdentifier ID_123 = new ToscaConceptIdentifier("id", "1.2.3"); + private static final ToscaConceptIdentifier ID_124 = new ToscaConceptIdentifier("id", "1.2.4"); + + @Test + void testCopyConstructor() throws CoderException { + assertThatThrownBy(() -> new ParticipantAckMessage((ParticipantAckMessage) null)) + .isInstanceOf(NullPointerException.class); + + // verify with null values + message = new ParticipantAckMessage(ParticipantMessageType.PARTICIPANT_STATE_CHANGE); + ParticipantAckMessage newmsg = new ParticipantAckMessage(message); + newmsg.setResponseTo(message.getResponseTo()); + assertEquals(message.toString(), newmsg.toString()); + + // verify with all values + message = makeMessage(); + newmsg = new ParticipantAckMessage(message); + newmsg.setResponseTo(message.getResponseTo()); + assertEquals(message.toString(), newmsg.toString()); + + assertSerializable(message, ParticipantAckMessage.class); + } + + @Test + void testAppliesTo_NullParticipantId() { + message = makeMessage(); + + assertThatThrownBy(() -> message.appliesTo(null, null)).isInstanceOf(NullPointerException.class); + assertThatThrownBy(() -> message.appliesTo(PTYPE_456, null)).isInstanceOf(NullPointerException.class); + assertThatThrownBy(() -> message.appliesTo(null, ID_123)).isInstanceOf(NullPointerException.class); + } + + @Test + void testAppliesTo_ParticipantIdMatches() { + message = makeMessage(); + + // ParticipantId matches + assertTrue(message.appliesTo(PTYPE_456, ID_123)); + assertFalse(message.appliesTo(PTYPE_456, ID_124)); + assertFalse(message.appliesTo(PTYPE_457, ID_123)); + } + + @Test + void testAppliesTo_ParticipantIdNoMatch() { + message = makeMessage(); + + // ParticipantId does not match + ToscaConceptIdentifier id = new ToscaConceptIdentifier(); + id.setName("id1111"); + id.setVersion("3.2.1"); + assertFalse(message.appliesTo(id, id)); + message.setParticipantType(null); + assertTrue(message.appliesTo(id, id)); + } + + private ParticipantAckMessage makeMessage() { + ParticipantAckMessage msg = new ParticipantAckMessage(ParticipantMessageType.PARTICIPANT_DEREGISTER_ACK); + + msg.setParticipantType(PTYPE_456); + msg.setParticipantId(ID_123); + msg.setMessage("Successfull Ack"); + msg.setResult(true); + msg.setResponseTo(UUID.randomUUID()); + + return msg; + } +} diff --git a/models/src/test/java/org/onap/policy/clamp/models/acm/messages/dmaap/participant/ParticipantDeregisterAckTest.java b/models/src/test/java/org/onap/policy/clamp/models/acm/messages/dmaap/participant/ParticipantDeregisterAckTest.java new file mode 100644 index 000000000..59a6d826b --- /dev/null +++ b/models/src/test/java/org/onap/policy/clamp/models/acm/messages/dmaap/participant/ParticipantDeregisterAckTest.java @@ -0,0 +1,59 @@ +/*- + * ============LICENSE_START======================================================= + * Copyright (C) 2021 Nordix Foundation. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * SPDX-License-Identifier: Apache-2.0 + * ============LICENSE_END========================================================= + */ + +package org.onap.policy.clamp.models.acm.messages.dmaap.participant; + +import static org.assertj.core.api.Assertions.assertThatThrownBy; +import static org.junit.Assert.assertEquals; +import static org.onap.policy.clamp.models.acm.messages.dmaap.participant.ParticipantMessageUtils.assertSerializable; +import static org.onap.policy.clamp.models.acm.messages.dmaap.participant.ParticipantMessageUtils.removeVariableFields; + +import java.util.UUID; +import org.junit.jupiter.api.Test; +import org.onap.policy.common.utils.coder.CoderException; +import org.onap.policy.models.tosca.authorative.concepts.ToscaConceptIdentifier; + +class ParticipantDeregisterAckTest { + + @Test + void testCopyConstructor() throws CoderException { + assertThatThrownBy(() -> new ParticipantDeregisterAck(null)).isInstanceOf(NullPointerException.class); + + final ParticipantDeregisterAck orig = new ParticipantDeregisterAck(); + + // verify with null values + assertEquals(removeVariableFields(orig.toString()), + removeVariableFields(new ParticipantDeregisterAck(orig).toString())); + + // verify with all values + ToscaConceptIdentifier id = new ToscaConceptIdentifier(); + id.setName("id"); + id.setVersion("1.2.3"); + orig.setResponseTo(UUID.randomUUID()); + orig.setMessageType(ParticipantMessageType.PARTICIPANT_DEREGISTER_ACK); + orig.setResult(true); + orig.setMessage("Successfully processed message"); + + assertEquals(removeVariableFields(orig.toString()), + removeVariableFields(new ParticipantDeregisterAck(orig).toString())); + + assertSerializable(orig, ParticipantDeregisterAck.class); + } +} diff --git a/models/src/test/java/org/onap/policy/clamp/models/acm/messages/dmaap/participant/ParticipantDeregisterTest.java b/models/src/test/java/org/onap/policy/clamp/models/acm/messages/dmaap/participant/ParticipantDeregisterTest.java new file mode 100644 index 000000000..873257696 --- /dev/null +++ b/models/src/test/java/org/onap/policy/clamp/models/acm/messages/dmaap/participant/ParticipantDeregisterTest.java @@ -0,0 +1,61 @@ +/*- + * ============LICENSE_START======================================================= + * Copyright (C) 2021 Nordix Foundation. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * SPDX-License-Identifier: Apache-2.0 + * ============LICENSE_END========================================================= + */ + +package org.onap.policy.clamp.models.acm.messages.dmaap.participant; + +import static org.assertj.core.api.Assertions.assertThatThrownBy; +import static org.junit.Assert.assertEquals; +import static org.onap.policy.clamp.models.acm.messages.dmaap.participant.ParticipantMessageUtils.assertSerializable; +import static org.onap.policy.clamp.models.acm.messages.dmaap.participant.ParticipantMessageUtils.removeVariableFields; + +import java.time.Instant; +import java.util.UUID; +import org.junit.jupiter.api.Test; +import org.onap.policy.common.utils.coder.CoderException; +import org.onap.policy.models.tosca.authorative.concepts.ToscaConceptIdentifier; + +class ParticipantDeregisterTest { + + @Test + void testCopyConstructor() throws CoderException { + assertThatThrownBy(() -> new ParticipantDeregister(null)).isInstanceOf(NullPointerException.class); + + final ParticipantDeregister orig = new ParticipantDeregister(); + + // verify with null values + assertEquals(removeVariableFields(orig.toString()), + removeVariableFields(new ParticipantDeregister(orig).toString())); + + // verify with all values + ToscaConceptIdentifier id = new ToscaConceptIdentifier(); + id.setName("id"); + id.setVersion("1.2.3"); + orig.setAutomationCompositionId(id); + orig.setParticipantId(id); + orig.setParticipantType(id); + orig.setMessageId(UUID.randomUUID()); + orig.setTimestamp(Instant.ofEpochMilli(3000)); + + assertEquals(removeVariableFields(orig.toString()), + removeVariableFields(new ParticipantDeregister(orig).toString())); + + assertSerializable(orig, ParticipantDeregister.class); + } +} diff --git a/models/src/test/java/org/onap/policy/clamp/models/acm/messages/dmaap/participant/ParticipantMessageTest.java b/models/src/test/java/org/onap/policy/clamp/models/acm/messages/dmaap/participant/ParticipantMessageTest.java new file mode 100644 index 000000000..fa16d145d --- /dev/null +++ b/models/src/test/java/org/onap/policy/clamp/models/acm/messages/dmaap/participant/ParticipantMessageTest.java @@ -0,0 +1,107 @@ +/*- + * ============LICENSE_START======================================================= + * Copyright (C) 2021 Nordix Foundation. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * SPDX-License-Identifier: Apache-2.0 + * ============LICENSE_END========================================================= + */ + +package org.onap.policy.clamp.models.acm.messages.dmaap.participant; + +import static org.assertj.core.api.Assertions.assertThatThrownBy; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertTrue; +import static org.onap.policy.clamp.models.acm.messages.dmaap.participant.ParticipantMessageUtils.assertSerializable; + +import java.time.Instant; +import java.util.UUID; +import org.junit.jupiter.api.Test; +import org.onap.policy.common.utils.coder.CoderException; +import org.onap.policy.models.tosca.authorative.concepts.ToscaConceptIdentifier; + +class ParticipantMessageTest { + private ParticipantMessage message; + + private static final ToscaConceptIdentifier PTYPE_456 = new ToscaConceptIdentifier("PType", "4.5.6"); + private static final ToscaConceptIdentifier PTYPE_457 = new ToscaConceptIdentifier("PType", "4.5.7"); + private static final ToscaConceptIdentifier ID_123 = new ToscaConceptIdentifier("id", "1.2.3"); + private static final ToscaConceptIdentifier ID_124 = new ToscaConceptIdentifier("id", "1.2.4"); + + @Test + void testCopyConstructor() throws CoderException { + assertThatThrownBy(() -> new ParticipantMessage((ParticipantMessage) null)) + .isInstanceOf(NullPointerException.class); + + // verify with null values + message = new ParticipantMessage(ParticipantMessageType.PARTICIPANT_STATE_CHANGE); + ParticipantMessage newmsg = new ParticipantMessage(message); + newmsg.setMessageId(message.getMessageId()); + newmsg.setTimestamp(message.getTimestamp()); + assertEquals(message.toString(), newmsg.toString()); + + // verify with all values + message = makeMessage(); + newmsg = new ParticipantMessage(message); + newmsg.setMessageId(message.getMessageId()); + newmsg.setTimestamp(message.getTimestamp()); + assertEquals(message.toString(), newmsg.toString()); + + assertSerializable(message, ParticipantMessage.class); + } + + @Test + void testAppliesTo_NullParticipantId() { + message = makeMessage(); + + assertThatThrownBy(() -> message.appliesTo(null, null)).isInstanceOf(NullPointerException.class); + assertThatThrownBy(() -> message.appliesTo(PTYPE_456, null)).isInstanceOf(NullPointerException.class); + assertThatThrownBy(() -> message.appliesTo(null, ID_123)).isInstanceOf(NullPointerException.class); + } + + @Test + void testAppliesTo_ParticipantIdMatches() { + message = makeMessage(); + + // ParticipantId matches + assertTrue(message.appliesTo(PTYPE_456, ID_123)); + assertFalse(message.appliesTo(PTYPE_456, ID_124)); + assertFalse(message.appliesTo(PTYPE_457, ID_123)); + } + + @Test + void testAppliesTo_ParticipantIdNoMatch() { + message = makeMessage(); + + // ParticipantId does not match + ToscaConceptIdentifier id = new ToscaConceptIdentifier(); + id.setName("id1111"); + id.setVersion("3.2.1"); + assertFalse(message.appliesTo(id, id)); + message.setParticipantType(null); + assertTrue(message.appliesTo(id, id)); + } + + private ParticipantMessage makeMessage() { + ParticipantMessage msg = new ParticipantMessage(ParticipantMessageType.PARTICIPANT_STATE_CHANGE); + + msg.setParticipantType(PTYPE_456); + msg.setParticipantId(ID_123); + msg.setMessageId(UUID.randomUUID()); + msg.setTimestamp(Instant.ofEpochMilli(3000)); + + return msg; + } +} diff --git a/models/src/test/java/org/onap/policy/clamp/models/acm/messages/dmaap/participant/ParticipantMessageUtils.java b/models/src/test/java/org/onap/policy/clamp/models/acm/messages/dmaap/participant/ParticipantMessageUtils.java new file mode 100644 index 000000000..4ff4f3b35 --- /dev/null +++ b/models/src/test/java/org/onap/policy/clamp/models/acm/messages/dmaap/participant/ParticipantMessageUtils.java @@ -0,0 +1,55 @@ +/*- + * ============LICENSE_START======================================================= + * Copyright (C) 2021 Nordix Foundation. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * SPDX-License-Identifier: Apache-2.0 + * ============LICENSE_END========================================================= + */ + +package org.onap.policy.clamp.models.acm.messages.dmaap.participant; + +import static org.junit.Assert.assertEquals; + +import org.onap.policy.common.utils.coder.CoderException; +import org.onap.policy.common.utils.coder.StandardCoder; + +/** + * Utility class for tests of ParticipantMessage subclasses. + */ +public class ParticipantMessageUtils { + + private ParticipantMessageUtils() { + + } + + public static String removeVariableFields(String text) { + return text.replaceAll("messageId=[^,]*", "messageId=xxx").replaceAll("timestamp=[^,]*", "timestamp=nnn"); + } + + /** + * Check if object is Serializable. + * + * @param object the Object + * @param clazz the class of the Object + * @throws CoderException if object is not Serializable + */ + public static void assertSerializable(Object object, Class clazz) throws CoderException { + var standardCoder = new StandardCoder(); + var json = standardCoder.encode(object); + var other = standardCoder.decode(json, clazz); + + assertEquals(removeVariableFields(object.toString()), removeVariableFields(other.toString())); + } +} diff --git a/models/src/test/java/org/onap/policy/clamp/models/acm/messages/dmaap/participant/ParticipantPojosTest.java b/models/src/test/java/org/onap/policy/clamp/models/acm/messages/dmaap/participant/ParticipantPojosTest.java new file mode 100644 index 000000000..ce23a821f --- /dev/null +++ b/models/src/test/java/org/onap/policy/clamp/models/acm/messages/dmaap/participant/ParticipantPojosTest.java @@ -0,0 +1,65 @@ +/*- + * ============LICENSE_START======================================================= + * Copyright (C) 2021 Nordix Foundation. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * SPDX-License-Identifier: Apache-2.0 + * ============LICENSE_END========================================================= + */ + +package org.onap.policy.clamp.models.acm.messages.dmaap.participant; + +import com.openpojo.reflection.PojoClass; +import com.openpojo.reflection.impl.PojoClassFactory; +import com.openpojo.validation.Validator; +import com.openpojo.validation.ValidatorBuilder; +import com.openpojo.validation.rule.impl.GetterMustExistRule; +import com.openpojo.validation.rule.impl.SetterMustExistRule; +import com.openpojo.validation.test.impl.GetterTester; +import com.openpojo.validation.test.impl.SetterTester; +import java.util.List; +import org.junit.jupiter.api.Test; +import org.onap.policy.common.utils.test.ToStringTester; + +/** + * Class to perform unit tests of all pojos. + */ +class ParticipantPojosTest { + + @Test + void testPojos() { + List pojoClasses = + PojoClassFactory.getPojoClasses(ParticipantPojosTest.class.getPackageName()); + + pojoClasses.remove(PojoClassFactory.getPojoClass(ParticipantMessage.class)); + pojoClasses.remove(PojoClassFactory.getPojoClass(ParticipantMessageTest.class)); + pojoClasses.remove(PojoClassFactory.getPojoClass(ParticipantAckMessage.class)); + pojoClasses.remove(PojoClassFactory.getPojoClass(ParticipantAckMessageTest.class)); + pojoClasses.remove(PojoClassFactory.getPojoClass(AutomationCompositionAck.class)); + pojoClasses.remove(PojoClassFactory.getPojoClass(AutomationCompositionAckTest.class)); + + // @formatter:off + final Validator validator = ValidatorBuilder + .create() + .with(new ToStringTester()) + .with(new SetterMustExistRule()) + .with(new GetterMustExistRule()) + .with(new SetterTester()) + .with(new GetterTester()) + .build(); + + validator.validate(pojoClasses); + // @formatter:on + } +} diff --git a/models/src/test/java/org/onap/policy/clamp/models/acm/messages/dmaap/participant/ParticipantRegisterAckTest.java b/models/src/test/java/org/onap/policy/clamp/models/acm/messages/dmaap/participant/ParticipantRegisterAckTest.java new file mode 100644 index 000000000..10200d86f --- /dev/null +++ b/models/src/test/java/org/onap/policy/clamp/models/acm/messages/dmaap/participant/ParticipantRegisterAckTest.java @@ -0,0 +1,59 @@ +/*- + * ============LICENSE_START======================================================= + * Copyright (C) 2021 Nordix Foundation. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * SPDX-License-Identifier: Apache-2.0 + * ============LICENSE_END========================================================= + */ + +package org.onap.policy.clamp.models.acm.messages.dmaap.participant; + +import static org.assertj.core.api.Assertions.assertThatThrownBy; +import static org.junit.Assert.assertEquals; +import static org.onap.policy.clamp.models.acm.messages.dmaap.participant.ParticipantMessageUtils.assertSerializable; +import static org.onap.policy.clamp.models.acm.messages.dmaap.participant.ParticipantMessageUtils.removeVariableFields; + +import java.util.UUID; +import org.junit.jupiter.api.Test; +import org.onap.policy.common.utils.coder.CoderException; +import org.onap.policy.models.tosca.authorative.concepts.ToscaConceptIdentifier; + +class ParticipantRegisterAckTest { + + @Test + void testCopyConstructor() throws CoderException { + assertThatThrownBy(() -> new ParticipantRegisterAck(null)).isInstanceOf(NullPointerException.class); + + final ParticipantRegisterAck orig = new ParticipantRegisterAck(); + + // verify with null values + assertEquals(removeVariableFields(orig.toString()), + removeVariableFields(new ParticipantRegisterAck(orig).toString())); + + // verify with all values + ToscaConceptIdentifier id = new ToscaConceptIdentifier(); + id.setName("id"); + id.setVersion("1.2.3"); + orig.setResponseTo(UUID.randomUUID()); + orig.setMessageType(ParticipantMessageType.PARTICIPANT_REGISTER_ACK); + orig.setResult(true); + orig.setMessage("Successfully processed message"); + + assertEquals(removeVariableFields(orig.toString()), + removeVariableFields(new ParticipantRegisterAck(orig).toString())); + + assertSerializable(orig, ParticipantRegisterAck.class); + } +} diff --git a/models/src/test/java/org/onap/policy/clamp/models/acm/messages/dmaap/participant/ParticipantRegisterTest.java b/models/src/test/java/org/onap/policy/clamp/models/acm/messages/dmaap/participant/ParticipantRegisterTest.java new file mode 100644 index 000000000..d08acda47 --- /dev/null +++ b/models/src/test/java/org/onap/policy/clamp/models/acm/messages/dmaap/participant/ParticipantRegisterTest.java @@ -0,0 +1,61 @@ +/*- + * ============LICENSE_START======================================================= + * Copyright (C) 2021 Nordix Foundation. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * SPDX-License-Identifier: Apache-2.0 + * ============LICENSE_END========================================================= + */ + +package org.onap.policy.clamp.models.acm.messages.dmaap.participant; + +import static org.assertj.core.api.Assertions.assertThatThrownBy; +import static org.junit.Assert.assertEquals; +import static org.onap.policy.clamp.models.acm.messages.dmaap.participant.ParticipantMessageUtils.assertSerializable; +import static org.onap.policy.clamp.models.acm.messages.dmaap.participant.ParticipantMessageUtils.removeVariableFields; + +import java.time.Instant; +import java.util.UUID; +import org.junit.jupiter.api.Test; +import org.onap.policy.common.utils.coder.CoderException; +import org.onap.policy.models.tosca.authorative.concepts.ToscaConceptIdentifier; + +class ParticipantRegisterTest { + + @Test + void testCopyConstructor() throws CoderException { + assertThatThrownBy(() -> new ParticipantRegister(null)).isInstanceOf(NullPointerException.class); + + final ParticipantRegister orig = new ParticipantRegister(); + + // verify with null values + assertEquals(removeVariableFields(orig.toString()), + removeVariableFields(new ParticipantRegister(orig).toString())); + + // verify with all values + ToscaConceptIdentifier id = new ToscaConceptIdentifier(); + id.setName("id"); + id.setVersion("1.2.3"); + orig.setAutomationCompositionId(id); + orig.setParticipantId(id); + orig.setParticipantType(id); + orig.setMessageId(UUID.randomUUID()); + orig.setTimestamp(Instant.ofEpochMilli(3000)); + + assertEquals(removeVariableFields(orig.toString()), + removeVariableFields(new ParticipantRegister(orig).toString())); + + assertSerializable(orig, ParticipantRegister.class); + } +} diff --git a/models/src/test/java/org/onap/policy/clamp/models/acm/messages/dmaap/participant/ParticipantStatusReqTest.java b/models/src/test/java/org/onap/policy/clamp/models/acm/messages/dmaap/participant/ParticipantStatusReqTest.java new file mode 100644 index 000000000..92025a707 --- /dev/null +++ b/models/src/test/java/org/onap/policy/clamp/models/acm/messages/dmaap/participant/ParticipantStatusReqTest.java @@ -0,0 +1,56 @@ +/*- + * ============LICENSE_START======================================================= + * Copyright (C) 2021 Nordix Foundation. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * SPDX-License-Identifier: Apache-2.0 + * ============LICENSE_END========================================================= + */ + +package org.onap.policy.clamp.models.acm.messages.dmaap.participant; + +import static org.assertj.core.api.Assertions.assertThatThrownBy; +import static org.junit.Assert.assertEquals; +import static org.onap.policy.clamp.models.acm.messages.dmaap.participant.ParticipantMessageUtils.assertSerializable; +import static org.onap.policy.clamp.models.acm.messages.dmaap.participant.ParticipantMessageUtils.removeVariableFields; + +import java.time.Instant; +import java.util.UUID; +import org.junit.jupiter.api.Test; +import org.onap.policy.common.utils.coder.CoderException; +import org.onap.policy.models.tosca.authorative.concepts.ToscaConceptIdentifier; + +/** + * Test the copy constructor. + */ +class ParticipantStatusReqTest { + @Test + void testCopyConstructor() throws CoderException { + assertThatThrownBy(() -> new ParticipantStatusReq(null)).isInstanceOf(NullPointerException.class); + + ParticipantStatusReq orig = new ParticipantStatusReq(); + // verify with all values + ToscaConceptIdentifier id = new ToscaConceptIdentifier("id", "1.2.3"); + orig.setParticipantId(id); + orig.setAutomationCompositionId(null); + orig.setParticipantType(null); + orig.setMessageId(UUID.randomUUID()); + orig.setTimestamp(Instant.ofEpochMilli(3000)); + + ParticipantStatusReq other = new ParticipantStatusReq(orig); + assertEquals(removeVariableFields(orig.toString()), removeVariableFields(other.toString())); + + assertSerializable(orig, ParticipantStatusReq.class); + } +} diff --git a/models/src/test/java/org/onap/policy/clamp/models/acm/messages/dmaap/participant/ParticipantStatusTest.java b/models/src/test/java/org/onap/policy/clamp/models/acm/messages/dmaap/participant/ParticipantStatusTest.java new file mode 100644 index 000000000..a33c12f2e --- /dev/null +++ b/models/src/test/java/org/onap/policy/clamp/models/acm/messages/dmaap/participant/ParticipantStatusTest.java @@ -0,0 +1,129 @@ +/*- + * ============LICENSE_START======================================================= + * Copyright (C) 2021 Nordix Foundation. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * SPDX-License-Identifier: Apache-2.0 + * ============LICENSE_END========================================================= + */ + +package org.onap.policy.clamp.models.acm.messages.dmaap.participant; + +import static org.assertj.core.api.Assertions.assertThatThrownBy; +import static org.junit.Assert.assertEquals; +import static org.onap.policy.clamp.models.acm.messages.dmaap.participant.ParticipantMessageUtils.assertSerializable; +import static org.onap.policy.clamp.models.acm.messages.dmaap.participant.ParticipantMessageUtils.removeVariableFields; + +import java.time.Instant; +import java.util.List; +import java.util.Map; +import java.util.UUID; +import org.junit.jupiter.api.Test; +import org.onap.policy.clamp.models.acm.concepts.AcElementStatistics; +import org.onap.policy.clamp.models.acm.concepts.AcElementStatisticsList; +import org.onap.policy.clamp.models.acm.concepts.AutomationCompositionElementDefinition; +import org.onap.policy.clamp.models.acm.concepts.AutomationCompositionInfo; +import org.onap.policy.clamp.models.acm.concepts.AutomationCompositionState; +import org.onap.policy.clamp.models.acm.concepts.AutomationCompositionStatistics; +import org.onap.policy.clamp.models.acm.concepts.ParticipantDefinition; +import org.onap.policy.clamp.models.acm.concepts.ParticipantHealthStatus; +import org.onap.policy.clamp.models.acm.concepts.ParticipantState; +import org.onap.policy.common.utils.coder.CoderException; +import org.onap.policy.models.tosca.authorative.concepts.ToscaConceptIdentifier; +import org.onap.policy.models.tosca.authorative.concepts.ToscaNodeTemplate; +import org.onap.policy.models.tosca.authorative.concepts.ToscaProperty; + +class ParticipantStatusTest { + + @Test + void testCopyConstructor() throws CoderException { + assertThatThrownBy(() -> new ParticipantStatus(null)).isInstanceOf(NullPointerException.class); + + final ParticipantStatus orig = new ParticipantStatus(); + + // verify with null values + assertEquals(removeVariableFields(orig.toString()), + removeVariableFields(new ParticipantStatus(orig).toString())); + + // verify with all values + ToscaConceptIdentifier id = new ToscaConceptIdentifier("id", "1.2.3"); + orig.setAutomationCompositionId(id); + orig.setParticipantId(id); + ToscaConceptIdentifier type = new ToscaConceptIdentifier("type", "2.3.4"); + orig.setParticipantType(type); + orig.setMessageId(UUID.randomUUID()); + orig.setState(ParticipantState.ACTIVE); + orig.setHealthStatus(ParticipantHealthStatus.HEALTHY); + orig.setTimestamp(Instant.ofEpochMilli(3000)); + + AutomationCompositionInfo acInfo = getAutomationCompositionInfo(id); + orig.setAutomationCompositionInfoList(List.of(acInfo)); + + ParticipantDefinition participantDefinitionUpdate = new ParticipantDefinition(); + participantDefinitionUpdate.setParticipantId(id); + participantDefinitionUpdate.setParticipantType(type); + AutomationCompositionElementDefinition acDefinition = getAcElementDefinition(id); + participantDefinitionUpdate.setAutomationCompositionElementDefinitionList(List.of(acDefinition)); + orig.setParticipantDefinitionUpdates(List.of(participantDefinitionUpdate)); + + assertEquals(removeVariableFields(orig.toString()), + removeVariableFields(new ParticipantStatus(orig).toString())); + + assertSerializable(orig, ParticipantStatus.class); + } + + private AutomationCompositionInfo getAutomationCompositionInfo(ToscaConceptIdentifier id) { + AutomationCompositionInfo acInfo = new AutomationCompositionInfo(); + acInfo.setState(AutomationCompositionState.PASSIVE2RUNNING); + acInfo.setAutomationCompositionId(id); + + AutomationCompositionStatistics acStatistics = new AutomationCompositionStatistics(); + acStatistics.setAutomationCompositionId(id); + acStatistics.setAverageExecutionTime(12345); + acStatistics.setEventCount(12345); + acStatistics.setLastEnterTime(12345); + acStatistics.setLastExecutionTime(12345); + acStatistics.setLastStart(12345); + acStatistics.setTimeStamp(Instant.ofEpochMilli(3000)); + acStatistics.setUpTime(12345); + AcElementStatisticsList acElementStatisticsList = new AcElementStatisticsList(); + AcElementStatistics acElementStatistics = new AcElementStatistics(); + acElementStatistics.setParticipantId(new ToscaConceptIdentifier("defName", "0.0.1")); + acElementStatistics.setTimeStamp(Instant.now()); + acElementStatisticsList.setAcElementStatistics(List.of(acElementStatistics)); + acStatistics.setAcElementStatisticsList(acElementStatisticsList); + + acInfo.setAutomationCompositionStatistics(acStatistics); + return acInfo; + } + + private AutomationCompositionElementDefinition getAcElementDefinition(ToscaConceptIdentifier id) { + ToscaNodeTemplate toscaNodeTemplate = new ToscaNodeTemplate(); + toscaNodeTemplate.setName("nodeTemplate"); + toscaNodeTemplate.setDerivedFrom("parentNodeTemplate"); + toscaNodeTemplate.setDescription("Description of nodeTemplate"); + toscaNodeTemplate.setVersion("1.2.3"); + + AutomationCompositionElementDefinition acDefinition = new AutomationCompositionElementDefinition(); + acDefinition.setAcElementDefinitionId(id); + acDefinition.setAutomationCompositionElementToscaNodeTemplate(toscaNodeTemplate); + + ToscaProperty property = new ToscaProperty(); + property.setName("test"); + property.setType("testType"); + Map commonPropertiesMap = Map.of("Prop1", property); + acDefinition.setCommonPropertiesMap(commonPropertiesMap); + return acDefinition; + } +} diff --git a/models/src/test/java/org/onap/policy/clamp/models/acm/messages/dmaap/participant/ParticipantUpdateAckTest.java b/models/src/test/java/org/onap/policy/clamp/models/acm/messages/dmaap/participant/ParticipantUpdateAckTest.java new file mode 100644 index 000000000..9f011a383 --- /dev/null +++ b/models/src/test/java/org/onap/policy/clamp/models/acm/messages/dmaap/participant/ParticipantUpdateAckTest.java @@ -0,0 +1,59 @@ +/*- + * ============LICENSE_START======================================================= + * Copyright (C) 2021 Nordix Foundation. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * SPDX-License-Identifier: Apache-2.0 + * ============LICENSE_END========================================================= + */ + +package org.onap.policy.clamp.models.acm.messages.dmaap.participant; + +import static org.assertj.core.api.Assertions.assertThatThrownBy; +import static org.junit.Assert.assertEquals; +import static org.onap.policy.clamp.models.acm.messages.dmaap.participant.ParticipantMessageUtils.assertSerializable; +import static org.onap.policy.clamp.models.acm.messages.dmaap.participant.ParticipantMessageUtils.removeVariableFields; + +import java.util.UUID; +import org.junit.jupiter.api.Test; +import org.onap.policy.common.utils.coder.CoderException; +import org.onap.policy.models.tosca.authorative.concepts.ToscaConceptIdentifier; + +class ParticipantUpdateAckTest { + + @Test + void testCopyConstructor() throws CoderException { + assertThatThrownBy(() -> new ParticipantUpdateAck(null)).isInstanceOf(NullPointerException.class); + + final ParticipantUpdateAck orig = new ParticipantUpdateAck(); + + // verify with null values + assertEquals(removeVariableFields(orig.toString()), + removeVariableFields(new ParticipantUpdateAck(orig).toString())); + + // verify with all values + ToscaConceptIdentifier id = new ToscaConceptIdentifier(); + id.setName("id"); + id.setVersion("1.2.3"); + orig.setResponseTo(UUID.randomUUID()); + orig.setMessageType(ParticipantMessageType.PARTICIPANT_UPDATE_ACK); + orig.setResult(true); + orig.setMessage("Successfully processed message"); + + assertEquals(removeVariableFields(orig.toString()), + removeVariableFields(new ParticipantUpdateAck(orig).toString())); + + assertSerializable(orig, ParticipantUpdateAck.class); + } +} diff --git a/models/src/test/java/org/onap/policy/clamp/models/acm/messages/dmaap/participant/ParticipantUpdateTest.java b/models/src/test/java/org/onap/policy/clamp/models/acm/messages/dmaap/participant/ParticipantUpdateTest.java new file mode 100644 index 000000000..f8aaffe11 --- /dev/null +++ b/models/src/test/java/org/onap/policy/clamp/models/acm/messages/dmaap/participant/ParticipantUpdateTest.java @@ -0,0 +1,101 @@ +/*- + * ============LICENSE_START======================================================= + * Copyright (C) 2021 Nordix Foundation. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * SPDX-License-Identifier: Apache-2.0 + * ============LICENSE_END========================================================= + */ + +package org.onap.policy.clamp.models.acm.messages.dmaap.participant; + +import static org.assertj.core.api.Assertions.assertThatThrownBy; +import static org.junit.Assert.assertEquals; +import static org.onap.policy.clamp.models.acm.messages.dmaap.participant.ParticipantMessageUtils.assertSerializable; +import static org.onap.policy.clamp.models.acm.messages.dmaap.participant.ParticipantMessageUtils.removeVariableFields; + +import java.time.Instant; +import java.util.List; +import java.util.Map; +import java.util.UUID; +import org.junit.jupiter.api.Test; +import org.onap.policy.clamp.models.acm.concepts.AutomationCompositionElementDefinition; +import org.onap.policy.clamp.models.acm.concepts.ParticipantDefinition; +import org.onap.policy.common.utils.coder.CoderException; +import org.onap.policy.models.tosca.authorative.concepts.ToscaConceptIdentifier; +import org.onap.policy.models.tosca.authorative.concepts.ToscaNodeTemplate; +import org.onap.policy.models.tosca.authorative.concepts.ToscaProperty; +import org.onap.policy.models.tosca.authorative.concepts.ToscaServiceTemplate; + +/** + * Test the copy constructor. + */ +class ParticipantUpdateTest { + @Test + void testCopyConstructor() throws CoderException { + assertThatThrownBy(() -> new ParticipantUpdate(null)).isInstanceOf(NullPointerException.class); + + ParticipantUpdate orig = new ParticipantUpdate(); + // verify with all values + ToscaConceptIdentifier id = new ToscaConceptIdentifier("id", "1.2.3"); + orig.setAutomationCompositionId(id); + orig.setParticipantId(id); + orig.setParticipantType(id); + orig.setMessageId(UUID.randomUUID()); + orig.setTimestamp(Instant.ofEpochMilli(3000)); + + ToscaServiceTemplate toscaServiceTemplate = new ToscaServiceTemplate(); + toscaServiceTemplate.setName("serviceTemplate"); + toscaServiceTemplate.setDerivedFrom("parentServiceTemplate"); + toscaServiceTemplate.setDescription("Description of serviceTemplate"); + toscaServiceTemplate.setVersion("1.2.3"); + + ToscaNodeTemplate toscaNodeTemplate = new ToscaNodeTemplate(); + toscaNodeTemplate.setName("nodeTemplate"); + toscaNodeTemplate.setDerivedFrom("parentNodeTemplate"); + toscaNodeTemplate.setDescription("Description of nodeTemplate"); + toscaNodeTemplate.setVersion("1.2.3"); + + ParticipantDefinition participantDefinitionUpdate = new ParticipantDefinition(); + participantDefinitionUpdate.setParticipantType(id); + AutomationCompositionElementDefinition acDefinition = getAcElementDefinition(id); + participantDefinitionUpdate.setAutomationCompositionElementDefinitionList(List.of(acDefinition)); + orig.setParticipantDefinitionUpdates(List.of(participantDefinitionUpdate)); + + ParticipantUpdate other = new ParticipantUpdate(orig); + + assertEquals(removeVariableFields(orig.toString()), removeVariableFields(other.toString())); + + assertSerializable(orig, ParticipantUpdate.class); + } + + private AutomationCompositionElementDefinition getAcElementDefinition(ToscaConceptIdentifier id) { + ToscaNodeTemplate toscaNodeTemplate = new ToscaNodeTemplate(); + toscaNodeTemplate.setName("nodeTemplate"); + toscaNodeTemplate.setDerivedFrom("parentNodeTemplate"); + toscaNodeTemplate.setDescription("Description of nodeTemplate"); + toscaNodeTemplate.setVersion("1.2.3"); + + AutomationCompositionElementDefinition acDefinition = new AutomationCompositionElementDefinition(); + acDefinition.setAcElementDefinitionId(id); + acDefinition.setAutomationCompositionElementToscaNodeTemplate(toscaNodeTemplate); + + ToscaProperty property = new ToscaProperty(); + property.setName("test"); + property.setType("testType"); + Map commonPropertiesMap = Map.of("Prop1", property); + acDefinition.setCommonPropertiesMap(commonPropertiesMap); + return acDefinition; + } +} diff --git a/models/src/test/java/org/onap/policy/clamp/models/acm/messages/rest/MessagesRestPojosTest.java b/models/src/test/java/org/onap/policy/clamp/models/acm/messages/rest/MessagesRestPojosTest.java new file mode 100644 index 000000000..4503be783 --- /dev/null +++ b/models/src/test/java/org/onap/policy/clamp/models/acm/messages/rest/MessagesRestPojosTest.java @@ -0,0 +1,59 @@ +/*- + * ============LICENSE_START======================================================= + * Copyright (C) 2021 Nordix Foundation. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * SPDX-License-Identifier: Apache-2.0 + * ============LICENSE_END========================================================= + */ + +package org.onap.policy.clamp.models.acm.messages.rest; + +import com.openpojo.reflection.PojoClass; +import com.openpojo.reflection.impl.PojoClassFactory; +import com.openpojo.validation.Validator; +import com.openpojo.validation.ValidatorBuilder; +import com.openpojo.validation.rule.impl.GetterMustExistRule; +import com.openpojo.validation.rule.impl.SetterMustExistRule; +import com.openpojo.validation.test.impl.GetterTester; +import com.openpojo.validation.test.impl.SetterTester; +import java.util.List; +import org.junit.jupiter.api.Test; +import org.onap.policy.common.utils.test.ToStringTester; + +/** + * Class to perform unit tests of all pojos. + */ +class MessagesRestPojosTest { + + @Test + void testPojos() { + List pojoClasses = + PojoClassFactory.getPojoClassesRecursively(MessagesRestPojosTest.class.getPackageName(), null); + + + // @formatter:off + final Validator validator = ValidatorBuilder + .create() + .with(new ToStringTester()) + .with(new SetterMustExistRule()) + .with(new GetterMustExistRule()) + .with(new SetterTester()) + .with(new GetterTester()) + .build(); + + validator.validate(pojoClasses); + // @formatter:on + } +} diff --git a/models/src/test/java/org/onap/policy/clamp/models/acm/messages/rest/instantiation/InstantiationCommandTest.java b/models/src/test/java/org/onap/policy/clamp/models/acm/messages/rest/instantiation/InstantiationCommandTest.java new file mode 100644 index 000000000..348359743 --- /dev/null +++ b/models/src/test/java/org/onap/policy/clamp/models/acm/messages/rest/instantiation/InstantiationCommandTest.java @@ -0,0 +1,60 @@ +/*- + * ============LICENSE_START======================================================= + * Copyright (C) 2021 Nordix Foundation. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * SPDX-License-Identifier: Apache-2.0 + * ============LICENSE_END========================================================= + */ + +package org.onap.policy.clamp.models.acm.messages.rest.instantiation; + +import static org.assertj.core.api.Assertions.assertThat; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNotEquals; +import static org.junit.Assert.assertNotNull; + +import java.util.ArrayList; +import org.junit.jupiter.api.Test; +import org.onap.policy.clamp.models.acm.concepts.AutomationCompositionOrderedState; + +class InstantiationCommandTest { + @Test + void testInstantiationCommandLombok() { + assertNotNull(new InstantiationCommand()); + InstantiationCommand ic0 = new InstantiationCommand(); + + assertThat(ic0.toString()).contains("InstantiationCommand("); + assertEquals(false, ic0.hashCode() == 0); + assertEquals(true, ic0.equals(ic0)); + assertEquals(false, ic0.equals(null)); + + + InstantiationCommand ic1 = new InstantiationCommand(); + + ic1.setAutomationCompositionIdentifierList(new ArrayList<>()); + ic1.setOrderedState(AutomationCompositionOrderedState.UNINITIALISED); + + assertThat(ic1.toString()).contains("InstantiationCommand("); + assertEquals(false, ic1.hashCode() == 0); + assertEquals(false, ic1.equals(ic0)); + assertEquals(false, ic1.equals(null)); + + assertNotEquals(ic1, ic0); + + InstantiationCommand ic2 = new InstantiationCommand(); + + assertEquals(ic2, ic0); + } +} diff --git a/models/src/test/java/org/onap/policy/clamp/models/acm/persistence/concepts/DummyJpaAcElementStatisticsChild.java b/models/src/test/java/org/onap/policy/clamp/models/acm/persistence/concepts/DummyJpaAcElementStatisticsChild.java new file mode 100644 index 000000000..ebbaf1d42 --- /dev/null +++ b/models/src/test/java/org/onap/policy/clamp/models/acm/persistence/concepts/DummyJpaAcElementStatisticsChild.java @@ -0,0 +1,28 @@ +/*- + * ============LICENSE_START======================================================= + * Copyright (C) 2021 Nordix Foundation. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * SPDX-License-Identifier: Apache-2.0 + * ============LICENSE_END========================================================= + */ + +package org.onap.policy.clamp.models.acm.persistence.concepts; + +/** + * Test class for {@link JpaAcElementStatistics} comparisons. + */ +class DummyJpaAcElementStatisticsChild extends JpaAcElementStatistics { + private static final long serialVersionUID = -5101743610779424064L; +} diff --git a/models/src/test/java/org/onap/policy/clamp/models/acm/persistence/concepts/DummyJpaAutomationCompositionChild.java b/models/src/test/java/org/onap/policy/clamp/models/acm/persistence/concepts/DummyJpaAutomationCompositionChild.java new file mode 100644 index 000000000..c7f4351c7 --- /dev/null +++ b/models/src/test/java/org/onap/policy/clamp/models/acm/persistence/concepts/DummyJpaAutomationCompositionChild.java @@ -0,0 +1,28 @@ +/*- + * ============LICENSE_START======================================================= + * Copyright (C) 2021 Nordix Foundation. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * SPDX-License-Identifier: Apache-2.0 + * ============LICENSE_END========================================================= + */ + +package org.onap.policy.clamp.models.acm.persistence.concepts; + +/** + * Test class for {@link JpaAutomationComposition} comparisons. + */ +class DummyJpaAutomationCompositionChild extends JpaAutomationComposition { + private static final long serialVersionUID = -5101743610779424064L; +} diff --git a/models/src/test/java/org/onap/policy/clamp/models/acm/persistence/concepts/DummyJpaAutomationCompositionElementChild.java b/models/src/test/java/org/onap/policy/clamp/models/acm/persistence/concepts/DummyJpaAutomationCompositionElementChild.java new file mode 100644 index 000000000..86723d98f --- /dev/null +++ b/models/src/test/java/org/onap/policy/clamp/models/acm/persistence/concepts/DummyJpaAutomationCompositionElementChild.java @@ -0,0 +1,28 @@ +/*- + * ============LICENSE_START======================================================= + * Copyright (C) 2021 Nordix Foundation. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * SPDX-License-Identifier: Apache-2.0 + * ============LICENSE_END========================================================= + */ + +package org.onap.policy.clamp.models.acm.persistence.concepts; + +/** + * Test class for {@link JpaAutomationCompositionElement} comparisons. + */ +class DummyJpaAutomationCompositionElementChild extends JpaAutomationCompositionElement { + private static final long serialVersionUID = -5101743610779424064L; +} diff --git a/models/src/test/java/org/onap/policy/clamp/models/acm/persistence/concepts/DummyJpaParticipantChild.java b/models/src/test/java/org/onap/policy/clamp/models/acm/persistence/concepts/DummyJpaParticipantChild.java new file mode 100644 index 000000000..6b34cc44e --- /dev/null +++ b/models/src/test/java/org/onap/policy/clamp/models/acm/persistence/concepts/DummyJpaParticipantChild.java @@ -0,0 +1,28 @@ +/*- + * ============LICENSE_START======================================================= + * Copyright (C) 2021 Nordix Foundation. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * SPDX-License-Identifier: Apache-2.0 + * ============LICENSE_END========================================================= + */ + +package org.onap.policy.clamp.models.acm.persistence.concepts; + +/** + * Test class for {@link JpaParticipant} comparisons. + */ +class DummyJpaParticipantChild extends JpaParticipant { + private static final long serialVersionUID = -5101743610779424064L; +} diff --git a/models/src/test/java/org/onap/policy/clamp/models/acm/persistence/concepts/DummyJpaParticipantStatisticsChild.java b/models/src/test/java/org/onap/policy/clamp/models/acm/persistence/concepts/DummyJpaParticipantStatisticsChild.java new file mode 100644 index 000000000..95082cac7 --- /dev/null +++ b/models/src/test/java/org/onap/policy/clamp/models/acm/persistence/concepts/DummyJpaParticipantStatisticsChild.java @@ -0,0 +1,28 @@ +/*- + * ============LICENSE_START======================================================= + * Copyright (C) 2021 Nordix Foundation. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * SPDX-License-Identifier: Apache-2.0 + * ============LICENSE_END========================================================= + */ + +package org.onap.policy.clamp.models.acm.persistence.concepts; + +/** + * Test class for {@link JpaParticipantStatistics} comparisons. + */ +class DummyJpaParticipantStatisticsChild extends JpaParticipantStatistics { + private static final long serialVersionUID = -5101743610779424064L; +} diff --git a/models/src/test/java/org/onap/policy/clamp/models/acm/persistence/concepts/JpaAcElementStatisticsTest.java b/models/src/test/java/org/onap/policy/clamp/models/acm/persistence/concepts/JpaAcElementStatisticsTest.java new file mode 100644 index 000000000..4cf7b8af0 --- /dev/null +++ b/models/src/test/java/org/onap/policy/clamp/models/acm/persistence/concepts/JpaAcElementStatisticsTest.java @@ -0,0 +1,189 @@ +/*- + * ============LICENSE_START======================================================= + * Copyright (C) 2021 Nordix Foundation. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * SPDX-License-Identifier: Apache-2.0 + * ============LICENSE_END========================================================= + */ + +package org.onap.policy.clamp.models.acm.persistence.concepts; + +import static org.assertj.core.api.Assertions.assertThat; +import static org.assertj.core.api.Assertions.assertThatThrownBy; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNotEquals; +import static org.junit.Assert.assertNotNull; +import static org.junit.Assert.assertTrue; + +import java.time.Instant; +import java.util.UUID; +import org.junit.jupiter.api.Test; +import org.onap.policy.clamp.models.acm.concepts.AcElementStatistics; +import org.onap.policy.clamp.models.acm.concepts.AutomationCompositionState; +import org.onap.policy.clamp.models.acm.concepts.Participant; +import org.onap.policy.models.base.PfConceptKey; +import org.onap.policy.models.base.PfReferenceTimestampKey; +import org.onap.policy.models.tosca.authorative.concepts.ToscaConceptIdentifier; + +/** + * Test the {@link JpaAcElementStatistics} class. + */ +class JpaAcElementStatisticsTest { + + private static final String NULL_KEY_ERROR = "key is marked .*ull but is null"; + + @Test + void testJpaAcElementStatisticsConstructor() { + assertThatThrownBy(() -> { + new JpaAcElementStatistics((JpaAcElementStatistics) null); + }).hasMessageMatching("copyConcept is marked .*ull but is null"); + + assertThatThrownBy(() -> { + new JpaAcElementStatistics((PfReferenceTimestampKey) null); + }).hasMessageMatching(NULL_KEY_ERROR); + + assertThatThrownBy(() -> { + new JpaAcElementStatistics(null, null); + }).hasMessageMatching(NULL_KEY_ERROR); + + assertThatThrownBy(() -> { + new JpaAcElementStatistics(null, new PfConceptKey()); + }).hasMessageMatching(NULL_KEY_ERROR); + + assertThatThrownBy(() -> { + new JpaAcElementStatistics(new PfReferenceTimestampKey(), null); + }).hasMessageMatching("participantId is marked .*ull but is null"); + + assertNotNull(new JpaAcElementStatistics()); + assertNotNull(new JpaAcElementStatistics((new PfReferenceTimestampKey()))); + assertNotNull(new JpaAcElementStatistics(new PfReferenceTimestampKey(), new PfConceptKey())); + } + + @Test + void testJpaAcElementStatistics() { + JpaAcElementStatistics testJpaAcElementStatistics = createJpaAcElementStatisticsInstance(); + + AcElementStatistics aces = createAcElementStatisticsInstance(); + assertEquals(aces, testJpaAcElementStatistics.toAuthorative()); + + assertThatThrownBy(() -> { + testJpaAcElementStatistics.fromAuthorative(null); + }).hasMessageMatching("acElementStatistics is marked .*ull but is null"); + + assertThatThrownBy(() -> new JpaAcElementStatistics((JpaAcElementStatistics) null)) + .isInstanceOf(NullPointerException.class); + + JpaAcElementStatistics testJpaAcElementStatisticsFa = new JpaAcElementStatistics(); + testJpaAcElementStatisticsFa.setKey(null); + testJpaAcElementStatisticsFa.fromAuthorative(aces); + assertEquals(testJpaAcElementStatistics, testJpaAcElementStatisticsFa); + testJpaAcElementStatisticsFa.setKey(PfReferenceTimestampKey.getNullKey()); + testJpaAcElementStatisticsFa.fromAuthorative(aces); + assertEquals(testJpaAcElementStatistics, testJpaAcElementStatisticsFa); + testJpaAcElementStatisticsFa.setKey(new PfReferenceTimestampKey("elementName", "0.0.1", + "a95757ba-b34a-4049-a2a8-46773abcbe5e", Instant.ofEpochSecond(123456L))); + testJpaAcElementStatisticsFa.fromAuthorative(aces); + assertEquals(testJpaAcElementStatistics, testJpaAcElementStatisticsFa); + + testJpaAcElementStatisticsFa = new JpaAcElementStatistics(aces); + assertEquals(testJpaAcElementStatistics, testJpaAcElementStatisticsFa); + + assertEquals(1, testJpaAcElementStatistics.getKeys().size()); + + assertEquals("elementName", testJpaAcElementStatistics.getKey().getReferenceKey().getParentKeyName()); + + testJpaAcElementStatistics.clean(); + assertEquals("elementName", testJpaAcElementStatistics.getKey().getReferenceKey().getParentKeyName()); + + JpaAcElementStatistics testJpaAcElementStatistics2 = new JpaAcElementStatistics(testJpaAcElementStatistics); + assertEquals(testJpaAcElementStatistics, testJpaAcElementStatistics2); + } + + @Test + void testJpaAcElementStatisticsValidation() { + JpaAcElementStatistics testJpaAcElementStatistics = createJpaAcElementStatisticsInstance(); + + assertThatThrownBy(() -> { + testJpaAcElementStatistics.validate(null); + }).hasMessageMatching("fieldName is marked .*ull but is null"); + + assertTrue(testJpaAcElementStatistics.validate("").isValid()); + } + + @Test + void testJpaAcElementStatisticsCompareTo() { + JpaAcElementStatistics testJpaAcElementStatistics = createJpaAcElementStatisticsInstance(); + + JpaAcElementStatistics otherJpaAcElementStatistics = new JpaAcElementStatistics(testJpaAcElementStatistics); + assertEquals(0, testJpaAcElementStatistics.compareTo(otherJpaAcElementStatistics)); + assertEquals(-1, testJpaAcElementStatistics.compareTo(null)); + assertEquals(0, testJpaAcElementStatistics.compareTo(testJpaAcElementStatistics)); + assertNotEquals(0, testJpaAcElementStatistics.compareTo(new DummyJpaAcElementStatisticsChild())); + + testJpaAcElementStatistics.setState(AutomationCompositionState.PASSIVE); + assertNotEquals(0, testJpaAcElementStatistics.compareTo(otherJpaAcElementStatistics)); + testJpaAcElementStatistics.setState(AutomationCompositionState.UNINITIALISED); + assertEquals(0, testJpaAcElementStatistics.compareTo(otherJpaAcElementStatistics)); + + assertEquals(testJpaAcElementStatistics, new JpaAcElementStatistics(testJpaAcElementStatistics)); + } + + @Test + void testJpaAcElementStatisticsLombok() { + assertNotNull(new Participant()); + JpaAcElementStatistics aces0 = new JpaAcElementStatistics(); + + assertThat(aces0.toString()).contains("JpaAcElementStatistics("); + assertThat(aces0.hashCode()).isNotZero(); + assertEquals(true, aces0.equals(aces0)); + assertEquals(false, aces0.equals(null)); + + + JpaAcElementStatistics aces11 = new JpaAcElementStatistics(); + + aces11.setState(AutomationCompositionState.UNINITIALISED); + + assertThat(aces11.toString()).contains("JpaAcElementStatistics("); + assertEquals(false, aces11.hashCode() == 0); + assertEquals(false, aces11.equals(aces0)); + assertEquals(false, aces11.equals(null)); + + assertNotEquals(aces11, aces0); + + JpaAcElementStatistics aces2 = new JpaAcElementStatistics(); + assertEquals(aces2, aces0); + } + + private JpaAcElementStatistics createJpaAcElementStatisticsInstance() { + AcElementStatistics testAces = createAcElementStatisticsInstance(); + JpaAcElementStatistics testJpaAcElementStatistics = new JpaAcElementStatistics(); + testJpaAcElementStatistics.setKey(null); + testJpaAcElementStatistics.fromAuthorative(testAces); + testJpaAcElementStatistics.setKey(PfReferenceTimestampKey.getNullKey()); + testJpaAcElementStatistics.fromAuthorative(testAces); + + return testJpaAcElementStatistics; + } + + private AcElementStatistics createAcElementStatisticsInstance() { + AcElementStatistics acElementStatistics = new AcElementStatistics(); + acElementStatistics.setParticipantId(new ToscaConceptIdentifier("elementName", "0.0.1")); + acElementStatistics.setId(UUID.fromString("a95757ba-b34a-4049-a2a8-46773abcbe5e")); + acElementStatistics.setTimeStamp(Instant.ofEpochSecond(123456L)); + acElementStatistics.setState(AutomationCompositionState.UNINITIALISED); + + return acElementStatistics; + } +} diff --git a/models/src/test/java/org/onap/policy/clamp/models/acm/persistence/concepts/JpaAutomationCompositionElementTest.java b/models/src/test/java/org/onap/policy/clamp/models/acm/persistence/concepts/JpaAutomationCompositionElementTest.java new file mode 100644 index 000000000..f4257bdd2 --- /dev/null +++ b/models/src/test/java/org/onap/policy/clamp/models/acm/persistence/concepts/JpaAutomationCompositionElementTest.java @@ -0,0 +1,315 @@ +/*- + * ============LICENSE_START======================================================= + * Copyright (C) 2021 Nordix Foundation. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * SPDX-License-Identifier: Apache-2.0 + * ============LICENSE_END========================================================= + */ + +package org.onap.policy.clamp.models.acm.persistence.concepts; + +import static org.assertj.core.api.Assertions.assertThat; +import static org.assertj.core.api.Assertions.assertThatThrownBy; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNotEquals; +import static org.junit.Assert.assertNotNull; +import static org.junit.Assert.assertNull; +import static org.junit.Assert.assertTrue; + +import java.io.File; +import java.util.UUID; +import org.junit.jupiter.api.Test; +import org.onap.policy.clamp.models.acm.concepts.AutomationCompositionElement; +import org.onap.policy.clamp.models.acm.concepts.AutomationCompositionOrderedState; +import org.onap.policy.clamp.models.acm.concepts.AutomationCompositionState; +import org.onap.policy.clamp.models.acm.concepts.Participant; +import org.onap.policy.common.utils.coder.CoderException; +import org.onap.policy.common.utils.coder.StandardCoder; +import org.onap.policy.models.base.PfConceptKey; +import org.onap.policy.models.base.PfKey; +import org.onap.policy.models.base.PfReferenceKey; +import org.onap.policy.models.tosca.authorative.concepts.ToscaConceptIdentifier; + +/** + * Test the {@link JpaAutomationCompositionElement} class. + */ +class JpaAutomationCompositionElementTest { + + private static final String NULL_KEY_ERROR = "key is marked .*ull but is null"; + + @Test + void testJpaAutomationCompositionElementConstructor() { + assertThatThrownBy(() -> { + new JpaAutomationCompositionElement((JpaAutomationCompositionElement) null); + }).hasMessageMatching("copyConcept is marked .*ull but is null"); + + assertThatThrownBy(() -> { + new JpaAutomationCompositionElement((PfReferenceKey) null); + }).hasMessageMatching(NULL_KEY_ERROR); + + assertThatThrownBy(() -> { + new JpaAutomationCompositionElement(null, null, null, null); + }).hasMessageMatching(NULL_KEY_ERROR); + + assertThatThrownBy(() -> { + new JpaAutomationCompositionElement(null, null, null, AutomationCompositionState.UNINITIALISED); + }).hasMessageMatching(NULL_KEY_ERROR); + + assertThatThrownBy(() -> { + new JpaAutomationCompositionElement(null, null, new PfConceptKey("participant", "0.0.1"), null); + }).hasMessageMatching(NULL_KEY_ERROR); + + assertThatThrownBy(() -> { + new JpaAutomationCompositionElement(null, null, new PfConceptKey("participant", "0.0.1"), + AutomationCompositionState.UNINITIALISED); + }).hasMessageMatching(NULL_KEY_ERROR); + + assertThatThrownBy(() -> { + new JpaAutomationCompositionElement(null, new PfConceptKey(), null, null); + }).hasMessageMatching(NULL_KEY_ERROR); + + assertThatThrownBy(() -> { + new JpaAutomationCompositionElement(null, new PfConceptKey(), null, + AutomationCompositionState.UNINITIALISED); + }).hasMessageMatching(NULL_KEY_ERROR); + + assertThatThrownBy(() -> { + new JpaAutomationCompositionElement(null, new PfConceptKey(), new PfConceptKey("participant", "0.0.1"), + null); + }).hasMessageMatching(NULL_KEY_ERROR); + + assertThatThrownBy(() -> { + new JpaAutomationCompositionElement(null, new PfConceptKey(), new PfConceptKey("participant", "0.0.1"), + AutomationCompositionState.UNINITIALISED); + }).hasMessageMatching(NULL_KEY_ERROR); + + assertThatThrownBy(() -> { + new JpaAutomationCompositionElement(new PfReferenceKey(), null, null, null); + }).hasMessageMatching("definition is marked .*ull but is null"); + + assertThatThrownBy(() -> { + new JpaAutomationCompositionElement(new PfReferenceKey(), null, null, + AutomationCompositionState.UNINITIALISED); + }).hasMessageMatching("definition is marked .*ull but is null"); + + assertThatThrownBy(() -> { + new JpaAutomationCompositionElement(new PfReferenceKey(), null, new PfConceptKey("participant", "0.0.1"), + null); + }).hasMessageMatching("definition is marked .*ull but is null"); + + assertThatThrownBy(() -> { + new JpaAutomationCompositionElement(new PfReferenceKey(), null, new PfConceptKey("participant", "0.0.1"), + AutomationCompositionState.UNINITIALISED); + }).hasMessageMatching("definition is marked .*ull but is null"); + + assertThatThrownBy(() -> { + new JpaAutomationCompositionElement(new PfReferenceKey(), new PfConceptKey(), null, null); + }).hasMessageMatching("participantType is marked .*ull but is null"); + + assertThatThrownBy(() -> { + new JpaAutomationCompositionElement(new PfReferenceKey(), new PfConceptKey(), null, + AutomationCompositionState.UNINITIALISED); + }).hasMessageMatching("participantType is marked .*ull but is null"); + + assertThatThrownBy(() -> { + new JpaAutomationCompositionElement(new PfReferenceKey(), new PfConceptKey(), + new PfConceptKey("participant", "0.0.1"), null); + }).hasMessageMatching("state is marked .*ull but is null"); + + assertNotNull(new JpaAutomationCompositionElement()); + assertNotNull(new JpaAutomationCompositionElement((new PfReferenceKey()))); + assertNotNull(new JpaAutomationCompositionElement(new PfReferenceKey(), new PfConceptKey(), + new PfConceptKey("participant", "0.0.1"), AutomationCompositionState.UNINITIALISED)); + } + + @Test + void testJpaAutomationCompositionElement() { + JpaAutomationCompositionElement testJpaAutomationCompositionElement = + createJpaAutomationCompositionElementInstance(); + + AutomationCompositionElement ace = createAutomationCompositionElementInstance(); + assertEquals(ace, testJpaAutomationCompositionElement.toAuthorative()); + + assertThatThrownBy(() -> { + testJpaAutomationCompositionElement.fromAuthorative(null); + }).hasMessageMatching("element is marked .*ull but is null"); + + assertThatThrownBy(() -> new JpaAutomationCompositionElement((JpaAutomationCompositionElement) null)) + .isInstanceOf(NullPointerException.class); + + JpaAutomationCompositionElement testJpaAutomationCompositionElementFa = new JpaAutomationCompositionElement(); + testJpaAutomationCompositionElementFa.setKey(null); + testJpaAutomationCompositionElementFa.fromAuthorative(ace); + assertEquals(testJpaAutomationCompositionElement, testJpaAutomationCompositionElementFa); + testJpaAutomationCompositionElementFa.setKey(PfReferenceKey.getNullKey()); + testJpaAutomationCompositionElementFa.fromAuthorative(ace); + assertEquals(testJpaAutomationCompositionElement, testJpaAutomationCompositionElementFa); + testJpaAutomationCompositionElementFa.setKey( + new PfReferenceKey(PfKey.NULL_KEY_NAME, PfKey.NULL_KEY_VERSION, "a95757ba-b34a-4049-a2a8-46773abcbe5e")); + testJpaAutomationCompositionElementFa.fromAuthorative(ace); + assertEquals(testJpaAutomationCompositionElement, testJpaAutomationCompositionElementFa); + + assertEquals("a95757ba-b34a-4049-a2a8-46773abcbe5e", + testJpaAutomationCompositionElement.getKey().getLocalName()); + assertEquals("a95757ba-b34a-4049-a2a8-46773abcbe5e", + new JpaAutomationCompositionElement(createAutomationCompositionElementInstance()).getKey().getLocalName()); + assertEquals("a95757ba-b34a-4049-a2a8-46773abcbe5e", + ((PfReferenceKey) new JpaAutomationCompositionElement(createAutomationCompositionElementInstance()) + .getKeys().get(0)).getLocalName()); + + testJpaAutomationCompositionElement.clean(); + assertEquals("a95757ba-b34a-4049-a2a8-46773abcbe5e", + testJpaAutomationCompositionElement.getKey().getLocalName()); + + testJpaAutomationCompositionElement.setDescription(" A Message "); + testJpaAutomationCompositionElement.clean(); + assertEquals("A Message", testJpaAutomationCompositionElement.getDescription()); + + JpaAutomationCompositionElement testJpaAutomationCompositionElement2 = + new JpaAutomationCompositionElement(testJpaAutomationCompositionElement); + assertEquals(testJpaAutomationCompositionElement, testJpaAutomationCompositionElement2); + } + + @Test + void testJpaAutomationCompositionElementOrderedState() throws CoderException { + AutomationCompositionElement testAutomationCompositionElement = createAutomationCompositionElementInstance(); + JpaAutomationCompositionElement testJpaAutomationCompositionElement = + createJpaAutomationCompositionElementInstance(); + + testJpaAutomationCompositionElement.setOrderedState(null); + assertEquals(testAutomationCompositionElement, testJpaAutomationCompositionElement.toAuthorative()); + testJpaAutomationCompositionElement.setOrderedState(AutomationCompositionOrderedState.UNINITIALISED); + + AutomationCompositionElement noOrderedStateAce = new StandardCoder().decode( + new File("src/test/resources/json/AutomationCompositionElementNoOrderedState.json"), + AutomationCompositionElement.class); + + JpaAutomationCompositionElement noOrderedStateJpaAce = new JpaAutomationCompositionElement(noOrderedStateAce); + assertNull(noOrderedStateJpaAce.getOrderedState()); + noOrderedStateAce.setOrderedState(AutomationCompositionOrderedState.UNINITIALISED); + noOrderedStateJpaAce = new JpaAutomationCompositionElement(noOrderedStateAce); + assertEquals(testJpaAutomationCompositionElement, noOrderedStateJpaAce); + } + + @Test + void testJpaAutomationCompositionElementValidation() { + JpaAutomationCompositionElement testJpaAutomationCompositionElement = + createJpaAutomationCompositionElementInstance(); + + assertThatThrownBy(() -> { + testJpaAutomationCompositionElement.validate(null); + }).hasMessageMatching("fieldName is marked .*ull but is null"); + + assertTrue(testJpaAutomationCompositionElement.validate("").isValid()); + } + + @Test + void testJpaAutomationCompositionElementCompareTo() { + JpaAutomationCompositionElement testJpaAutomationCompositionElement = + createJpaAutomationCompositionElementInstance(); + + JpaAutomationCompositionElement otherJpaAutomationCompositionElement = + new JpaAutomationCompositionElement(testJpaAutomationCompositionElement); + assertEquals(0, testJpaAutomationCompositionElement.compareTo(otherJpaAutomationCompositionElement)); + assertEquals(-1, testJpaAutomationCompositionElement.compareTo(null)); + assertEquals(0, testJpaAutomationCompositionElement.compareTo(testJpaAutomationCompositionElement)); + assertNotEquals(0, + testJpaAutomationCompositionElement.compareTo(new DummyJpaAutomationCompositionElementChild())); + + testJpaAutomationCompositionElement + .setKey(new PfReferenceKey("BadValue", "0.0.1", "a95757ba-b34a-4049-a2a8-46773abcbe5e")); + assertNotEquals(0, testJpaAutomationCompositionElement.compareTo(otherJpaAutomationCompositionElement)); + testJpaAutomationCompositionElement.setKey( + new PfReferenceKey(PfKey.NULL_KEY_NAME, PfKey.NULL_KEY_VERSION, "a95757ba-b34a-4049-a2a8-46773abcbe5e")); + assertEquals(0, testJpaAutomationCompositionElement.compareTo(otherJpaAutomationCompositionElement)); + + testJpaAutomationCompositionElement.setDefinition(new PfConceptKey("BadValue", "0.0.1")); + assertNotEquals(0, testJpaAutomationCompositionElement.compareTo(otherJpaAutomationCompositionElement)); + testJpaAutomationCompositionElement.setDefinition(new PfConceptKey("aceDef", "0.0.1")); + assertEquals(0, testJpaAutomationCompositionElement.compareTo(otherJpaAutomationCompositionElement)); + + testJpaAutomationCompositionElement.setDescription("Description"); + assertNotEquals(0, testJpaAutomationCompositionElement.compareTo(otherJpaAutomationCompositionElement)); + testJpaAutomationCompositionElement.setDescription(null); + assertEquals(0, testJpaAutomationCompositionElement.compareTo(otherJpaAutomationCompositionElement)); + + testJpaAutomationCompositionElement.setOrderedState(AutomationCompositionOrderedState.PASSIVE); + assertNotEquals(0, testJpaAutomationCompositionElement.compareTo(otherJpaAutomationCompositionElement)); + testJpaAutomationCompositionElement.setOrderedState(AutomationCompositionOrderedState.UNINITIALISED); + assertEquals(0, testJpaAutomationCompositionElement.compareTo(otherJpaAutomationCompositionElement)); + + testJpaAutomationCompositionElement.setState(AutomationCompositionState.PASSIVE); + assertNotEquals(0, testJpaAutomationCompositionElement.compareTo(otherJpaAutomationCompositionElement)); + testJpaAutomationCompositionElement.setState(AutomationCompositionState.UNINITIALISED); + assertEquals(0, testJpaAutomationCompositionElement.compareTo(otherJpaAutomationCompositionElement)); + + testJpaAutomationCompositionElement.setParticipantType(new PfConceptKey("dummy", "0.0.1")); + assertNotEquals(0, testJpaAutomationCompositionElement.compareTo(otherJpaAutomationCompositionElement)); + testJpaAutomationCompositionElement.setParticipantType(new PfConceptKey("participantType", "0.0.1")); + assertEquals(0, testJpaAutomationCompositionElement.compareTo(otherJpaAutomationCompositionElement)); + + assertEquals(testJpaAutomationCompositionElement, + new JpaAutomationCompositionElement(testJpaAutomationCompositionElement)); + } + + @Test + void testJpaAutomationCompositionElementLombok() { + assertNotNull(new Participant()); + JpaAutomationCompositionElement ace0 = new JpaAutomationCompositionElement(); + + assertThat(ace0.toString()).contains("JpaAutomationCompositionElement("); + assertThat(ace0.hashCode()).isNotZero(); + assertEquals(true, ace0.equals(ace0)); + assertEquals(false, ace0.equals(null)); + + JpaAutomationCompositionElement ace1 = new JpaAutomationCompositionElement(); + + ace1.setDefinition(new PfConceptKey("defName", "0.0.1")); + ace1.setDescription("Description"); + ace1.setOrderedState(AutomationCompositionOrderedState.UNINITIALISED); + ace1.setState(AutomationCompositionState.UNINITIALISED); + ace1.setParticipantId(new PfConceptKey("participant", "0.0.1")); + + assertThat(ace1.toString()).contains("AutomationCompositionElement("); + assertEquals(false, ace1.hashCode() == 0); + assertEquals(false, ace1.equals(ace0)); + assertEquals(false, ace1.equals(null)); + + assertNotEquals(ace1, ace0); + + JpaAutomationCompositionElement ace2 = new JpaAutomationCompositionElement(); + assertEquals(ace2, ace0); + } + + private JpaAutomationCompositionElement createJpaAutomationCompositionElementInstance() { + AutomationCompositionElement testAce = createAutomationCompositionElementInstance(); + JpaAutomationCompositionElement testJpaAutomationCompositionElement = new JpaAutomationCompositionElement(); + testJpaAutomationCompositionElement.setKey(null); + testJpaAutomationCompositionElement.fromAuthorative(testAce); + testJpaAutomationCompositionElement.setKey(PfReferenceKey.getNullKey()); + testJpaAutomationCompositionElement.fromAuthorative(testAce); + + return testJpaAutomationCompositionElement; + } + + private AutomationCompositionElement createAutomationCompositionElementInstance() { + AutomationCompositionElement automationCompositionElement = new AutomationCompositionElement(); + automationCompositionElement.setId(UUID.fromString("a95757ba-b34a-4049-a2a8-46773abcbe5e")); + automationCompositionElement.setDefinition(new ToscaConceptIdentifier("aceDef", "0.0.1")); + automationCompositionElement.setParticipantType(new ToscaConceptIdentifier("participantType", "0.0.1")); + + return automationCompositionElement; + } +} diff --git a/models/src/test/java/org/onap/policy/clamp/models/acm/persistence/concepts/JpaAutomationCompositionTest.java b/models/src/test/java/org/onap/policy/clamp/models/acm/persistence/concepts/JpaAutomationCompositionTest.java new file mode 100644 index 000000000..a016d1202 --- /dev/null +++ b/models/src/test/java/org/onap/policy/clamp/models/acm/persistence/concepts/JpaAutomationCompositionTest.java @@ -0,0 +1,310 @@ +/*- + * ============LICENSE_START======================================================= + * Copyright (C) 2021 Nordix Foundation. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * SPDX-License-Identifier: Apache-2.0 + * ============LICENSE_END========================================================= + */ + +package org.onap.policy.clamp.models.acm.persistence.concepts; + +import static org.assertj.core.api.Assertions.assertThat; +import static org.assertj.core.api.Assertions.assertThatCode; +import static org.assertj.core.api.Assertions.assertThatThrownBy; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNotEquals; +import static org.junit.Assert.assertNotNull; +import static org.junit.Assert.assertNull; +import static org.junit.Assert.assertTrue; + +import java.io.File; +import java.util.LinkedHashMap; +import org.junit.jupiter.api.Test; +import org.onap.policy.clamp.models.acm.concepts.AutomationComposition; +import org.onap.policy.clamp.models.acm.concepts.AutomationCompositionOrderedState; +import org.onap.policy.clamp.models.acm.concepts.AutomationCompositionState; +import org.onap.policy.clamp.models.acm.concepts.AutomationCompositions; +import org.onap.policy.common.utils.coder.CoderException; +import org.onap.policy.common.utils.coder.StandardCoder; +import org.onap.policy.models.base.PfConceptKey; +import org.onap.policy.models.tosca.authorative.concepts.ToscaConceptIdentifier; + +/** + * Test the {@link JpaAutomationCompositionTest} class. + */ +class JpaAutomationCompositionTest { + + private static final String NULL_KEY_ERROR = "key is marked .*ull but is null"; + + @Test + void testJpaAutomationCompositionConstructor() { + assertThatThrownBy(() -> { + new JpaAutomationComposition((JpaAutomationComposition) null); + }).hasMessageMatching("copyConcept is marked .*ull but is null"); + + assertThatThrownBy(() -> { + new JpaAutomationComposition((PfConceptKey) null); + }).hasMessageMatching(NULL_KEY_ERROR); + + assertThatThrownBy(() -> { + new JpaAutomationComposition(null, null, null, null); + }).hasMessageMatching(NULL_KEY_ERROR); + + assertThatThrownBy(() -> { + new JpaAutomationComposition(null, null, null, new LinkedHashMap<>()); + }).hasMessageMatching(NULL_KEY_ERROR); + + assertThatThrownBy(() -> { + new JpaAutomationComposition(null, null, AutomationCompositionState.UNINITIALISED, null); + }).hasMessageMatching(NULL_KEY_ERROR); + + assertThatThrownBy(() -> { + new JpaAutomationComposition(null, null, AutomationCompositionState.UNINITIALISED, new LinkedHashMap<>()); + }).hasMessageMatching(NULL_KEY_ERROR); + + assertThatThrownBy(() -> { + new JpaAutomationComposition(null, new PfConceptKey(), null, null); + }).hasMessageMatching(NULL_KEY_ERROR); + + assertThatThrownBy(() -> { + new JpaAutomationComposition(null, new PfConceptKey(), null, new LinkedHashMap<>()); + }).hasMessageMatching(NULL_KEY_ERROR); + + assertThatThrownBy(() -> { + new JpaAutomationComposition(null, new PfConceptKey(), AutomationCompositionState.UNINITIALISED, null); + }).hasMessageMatching(NULL_KEY_ERROR); + + assertThatThrownBy(() -> { + new JpaAutomationComposition(null, new PfConceptKey(), AutomationCompositionState.UNINITIALISED, + new LinkedHashMap<>()); + }).hasMessageMatching(NULL_KEY_ERROR); + + assertThatThrownBy(() -> { + new JpaAutomationComposition(new PfConceptKey(), null, null, null); + }).hasMessageMatching("definition is marked .*ull but is null"); + + assertThatThrownBy(() -> { + new JpaAutomationComposition(new PfConceptKey(), null, null, new LinkedHashMap<>()); + }).hasMessageMatching("definition is marked .*ull but is null"); + + assertThatThrownBy(() -> { + new JpaAutomationComposition(new PfConceptKey(), null, AutomationCompositionState.UNINITIALISED, null); + }).hasMessageMatching("definition is marked .*ull but is null"); + + assertThatThrownBy(() -> { + new JpaAutomationComposition(new PfConceptKey(), null, AutomationCompositionState.UNINITIALISED, + new LinkedHashMap<>()); + }).hasMessageMatching("definition is marked .*ull but is null"); + + assertThatThrownBy(() -> { + new JpaAutomationComposition(new PfConceptKey(), new PfConceptKey(), null, null); + }).hasMessageMatching("state is marked .*ull but is null"); + + assertThatThrownBy(() -> { + new JpaAutomationComposition(new PfConceptKey(), new PfConceptKey(), null, new LinkedHashMap<>()); + }).hasMessageMatching("state is marked .*ull but is null"); + + assertThatThrownBy(() -> { + new JpaAutomationComposition(new PfConceptKey(), new PfConceptKey(), + AutomationCompositionState.UNINITIALISED, null); + }).hasMessageMatching("elements is marked .*ull but is null"); + + assertNotNull(new JpaAutomationComposition()); + assertNotNull(new JpaAutomationComposition((new PfConceptKey()))); + assertNotNull(new JpaAutomationComposition(new PfConceptKey(), new PfConceptKey(), + AutomationCompositionState.UNINITIALISED, new LinkedHashMap<>())); + } + + @Test + void testJpaAutomationComposition() { + JpaAutomationComposition testJpaAutomationComposition = createJpaAutomationCompositionInstance(); + + AutomationComposition participant = createAutomationCompositionInstance(); + assertEquals(participant, testJpaAutomationComposition.toAuthorative()); + + assertThatThrownBy(() -> { + testJpaAutomationComposition.fromAuthorative(null); + }).hasMessageMatching("automationComposition is marked .*ull but is null"); + + assertThatThrownBy(() -> new JpaAutomationComposition((JpaAutomationComposition) null)) + .isInstanceOf(NullPointerException.class); + + JpaAutomationComposition testJpaAutomationCompositionFa = new JpaAutomationComposition(); + testJpaAutomationCompositionFa.setKey(null); + testJpaAutomationCompositionFa.fromAuthorative(participant); + assertEquals(testJpaAutomationComposition, testJpaAutomationCompositionFa); + testJpaAutomationCompositionFa.setKey(PfConceptKey.getNullKey()); + testJpaAutomationCompositionFa.fromAuthorative(participant); + assertEquals(testJpaAutomationComposition, testJpaAutomationCompositionFa); + testJpaAutomationCompositionFa.setKey(new PfConceptKey("automation-composition", "0.0.1")); + testJpaAutomationCompositionFa.fromAuthorative(participant); + assertEquals(testJpaAutomationComposition, testJpaAutomationCompositionFa); + + assertEquals("automation-composition", testJpaAutomationComposition.getKey().getName()); + assertEquals("automation-composition", + new JpaAutomationComposition(createAutomationCompositionInstance()).getKey().getName()); + assertEquals("automation-composition", + ((PfConceptKey) new JpaAutomationComposition(createAutomationCompositionInstance()).getKeys().get(0)) + .getName()); + + testJpaAutomationComposition.clean(); + assertEquals("automation-composition", testJpaAutomationComposition.getKey().getName()); + + testJpaAutomationComposition.setDescription(" A Message "); + testJpaAutomationComposition.clean(); + assertEquals("A Message", testJpaAutomationComposition.getDescription()); + + JpaAutomationComposition testJpaAutomationComposition2 = + new JpaAutomationComposition(testJpaAutomationComposition); + assertEquals(testJpaAutomationComposition, testJpaAutomationComposition2); + } + + @Test + void testJpaAutomationCompositionElementOrderedState() throws CoderException { + AutomationComposition testAutomationComposition = createAutomationCompositionInstance(); + JpaAutomationComposition testJpaAutomationComposition = createJpaAutomationCompositionInstance(); + + testJpaAutomationComposition.setOrderedState(null); + assertEquals(testAutomationComposition, testJpaAutomationComposition.toAuthorative()); + testJpaAutomationComposition.setOrderedState(AutomationCompositionOrderedState.UNINITIALISED); + + AutomationComposition noOrderedStateAc = new StandardCoder().decode( + new File("src/test/resources/json/AutomationCompositionNoOrderedState.json"), AutomationComposition.class); + + JpaAutomationComposition noOrderedStateJpaAc = new JpaAutomationComposition(noOrderedStateAc); + assertNull(noOrderedStateJpaAc.getOrderedState()); + noOrderedStateAc.setOrderedState(AutomationCompositionOrderedState.UNINITIALISED); + noOrderedStateJpaAc = new JpaAutomationComposition(noOrderedStateAc); + assertEquals(testJpaAutomationComposition, noOrderedStateJpaAc); + + AutomationCompositions automationCompositionsWithElements = new StandardCoder().decode( + new File("src/test/resources/providers/TestAutomationCompositions.json"), AutomationCompositions.class); + + JpaAutomationComposition jpaAutomationCompositionWithElements = + new JpaAutomationComposition(automationCompositionsWithElements.getAutomationCompositionList().get(0)); + assertEquals(4, jpaAutomationCompositionWithElements.getElements().size()); + assertEquals(18, jpaAutomationCompositionWithElements.getKeys().size()); + assertThatCode(() -> jpaAutomationCompositionWithElements.clean()).doesNotThrowAnyException(); + + assertEquals(automationCompositionsWithElements.getAutomationCompositionList().get(0), + jpaAutomationCompositionWithElements.toAuthorative()); + } + + @Test + void testJpaAutomationCompositionValidation() { + JpaAutomationComposition testJpaAutomationComposition = createJpaAutomationCompositionInstance(); + + assertThatThrownBy(() -> { + testJpaAutomationComposition.validate(null); + }).hasMessageMatching("fieldName is marked .*ull but is null"); + + assertTrue(testJpaAutomationComposition.validate("").isValid()); + } + + @Test + void testJpaAutomationCompositionCompareTo() { + JpaAutomationComposition testJpaAutomationComposition = createJpaAutomationCompositionInstance(); + + JpaAutomationComposition otherJpaAutomationComposition = + new JpaAutomationComposition(testJpaAutomationComposition); + assertEquals(0, testJpaAutomationComposition.compareTo(otherJpaAutomationComposition)); + assertEquals(-1, testJpaAutomationComposition.compareTo(null)); + assertEquals(0, testJpaAutomationComposition.compareTo(testJpaAutomationComposition)); + assertNotEquals(0, testJpaAutomationComposition.compareTo(new DummyJpaAutomationCompositionChild())); + + testJpaAutomationComposition.setKey(new PfConceptKey("BadValue", "0.0.1")); + assertNotEquals(0, testJpaAutomationComposition.compareTo(otherJpaAutomationComposition)); + testJpaAutomationComposition.setKey(new PfConceptKey("automation-composition", "0.0.1")); + assertEquals(0, testJpaAutomationComposition.compareTo(otherJpaAutomationComposition)); + + testJpaAutomationComposition.setDefinition(new PfConceptKey("BadValue", "0.0.1")); + assertNotEquals(0, testJpaAutomationComposition.compareTo(otherJpaAutomationComposition)); + testJpaAutomationComposition.setDefinition(new PfConceptKey("automationCompositionDefinitionName", "0.0.1")); + assertEquals(0, testJpaAutomationComposition.compareTo(otherJpaAutomationComposition)); + + testJpaAutomationComposition.setState(AutomationCompositionState.PASSIVE); + assertNotEquals(0, testJpaAutomationComposition.compareTo(otherJpaAutomationComposition)); + testJpaAutomationComposition.setState(AutomationCompositionState.UNINITIALISED); + assertEquals(0, testJpaAutomationComposition.compareTo(otherJpaAutomationComposition)); + + testJpaAutomationComposition.setOrderedState(AutomationCompositionOrderedState.PASSIVE); + assertNotEquals(0, testJpaAutomationComposition.compareTo(otherJpaAutomationComposition)); + testJpaAutomationComposition.setOrderedState(AutomationCompositionOrderedState.UNINITIALISED); + assertEquals(0, testJpaAutomationComposition.compareTo(otherJpaAutomationComposition)); + + testJpaAutomationComposition.setDescription("A description"); + assertNotEquals(0, testJpaAutomationComposition.compareTo(otherJpaAutomationComposition)); + testJpaAutomationComposition.setDescription(null); + assertEquals(0, testJpaAutomationComposition.compareTo(otherJpaAutomationComposition)); + + testJpaAutomationComposition.setPrimed(true); + assertNotEquals(0, testJpaAutomationComposition.compareTo(otherJpaAutomationComposition)); + testJpaAutomationComposition.setPrimed(false); + assertEquals(0, testJpaAutomationComposition.compareTo(otherJpaAutomationComposition)); + + assertEquals(testJpaAutomationComposition, new JpaAutomationComposition(testJpaAutomationComposition)); + } + + @Test + void testJpaAutomationCompositionLombok() { + assertNotNull(new AutomationComposition()); + JpaAutomationComposition ac0 = new JpaAutomationComposition(); + + assertThat(ac0.toString()).contains("JpaAutomationComposition("); + assertThat(ac0.hashCode()).isNotZero(); + assertEquals(true, ac0.equals(ac0)); + assertEquals(false, ac0.equals(null)); + + JpaAutomationComposition ac1 = new JpaAutomationComposition(); + + ac1.setDefinition(new PfConceptKey("defName", "0.0.1")); + ac1.setDescription("Description"); + ac1.setElements(new LinkedHashMap<>()); + ac1.setKey(new PfConceptKey("participant", "0.0.1")); + ac1.setState(AutomationCompositionState.UNINITIALISED); + + assertThat(ac1.toString()).contains("AutomationComposition("); + assertEquals(false, ac1.hashCode() == 0); + assertEquals(false, ac1.equals(ac0)); + assertEquals(false, ac1.equals(null)); + + assertNotEquals(ac1, ac0); + + JpaAutomationComposition ac2 = new JpaAutomationComposition(); + assertEquals(ac2, ac0); + } + + private JpaAutomationComposition createJpaAutomationCompositionInstance() { + AutomationComposition testAutomationComposition = createAutomationCompositionInstance(); + JpaAutomationComposition testJpaAutomationComposition = new JpaAutomationComposition(); + testJpaAutomationComposition.setKey(null); + testJpaAutomationComposition.fromAuthorative(testAutomationComposition); + testJpaAutomationComposition.setKey(PfConceptKey.getNullKey()); + testJpaAutomationComposition.fromAuthorative(testAutomationComposition); + + return testJpaAutomationComposition; + } + + private AutomationComposition createAutomationCompositionInstance() { + AutomationComposition testAutomationComposition = new AutomationComposition(); + testAutomationComposition.setName("automation-composition"); + testAutomationComposition.setVersion("0.0.1"); + testAutomationComposition + .setDefinition(new ToscaConceptIdentifier("automationCompositionDefinitionName", "0.0.1")); + testAutomationComposition.setElements(new LinkedHashMap<>()); + + return testAutomationComposition; + } +} diff --git a/models/src/test/java/org/onap/policy/clamp/models/acm/persistence/concepts/JpaParticipantStatisticsTest.java b/models/src/test/java/org/onap/policy/clamp/models/acm/persistence/concepts/JpaParticipantStatisticsTest.java new file mode 100644 index 000000000..284d13374 --- /dev/null +++ b/models/src/test/java/org/onap/policy/clamp/models/acm/persistence/concepts/JpaParticipantStatisticsTest.java @@ -0,0 +1,193 @@ +/*- + * ============LICENSE_START======================================================= + * Copyright (C) 2021 Nordix Foundation. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * SPDX-License-Identifier: Apache-2.0 + * ============LICENSE_END========================================================= + */ + +package org.onap.policy.clamp.models.acm.persistence.concepts; + +import static org.assertj.core.api.Assertions.assertThat; +import static org.assertj.core.api.Assertions.assertThatThrownBy; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNotEquals; +import static org.junit.Assert.assertNotNull; +import static org.junit.Assert.assertTrue; + +import java.time.Instant; +import org.junit.jupiter.api.Test; +import org.onap.policy.clamp.models.acm.concepts.Participant; +import org.onap.policy.clamp.models.acm.concepts.ParticipantHealthStatus; +import org.onap.policy.clamp.models.acm.concepts.ParticipantState; +import org.onap.policy.clamp.models.acm.concepts.ParticipantStatistics; +import org.onap.policy.common.parameters.BeanValidationResult; +import org.onap.policy.models.base.PfConceptKey; +import org.onap.policy.models.base.PfTimestampKey; +import org.onap.policy.models.tosca.authorative.concepts.ToscaConceptIdentifier; + +/** + * Test the {@link JpaParticipantStatistics} class. + */ +class JpaParticipantStatisticsTest { + + private static final String NULL_KEY_ERROR = "key is marked .*ull but is null"; + + @Test + void testJpaParticipantStatisticsConstructor() { + assertThatThrownBy(() -> { + new JpaParticipantStatistics((JpaParticipantStatistics) null); + }).hasMessageMatching("copyConcept is marked .*ull but is null"); + + assertThatThrownBy(() -> { + new JpaParticipantStatistics((PfTimestampKey) null); + }).hasMessageMatching(NULL_KEY_ERROR); + + assertThatThrownBy(() -> { + new JpaParticipantStatistics(null, null); + }).hasMessageMatching(NULL_KEY_ERROR); + + assertThatThrownBy(() -> { + new JpaParticipantStatistics(null, new PfConceptKey()); + }).hasMessageMatching(NULL_KEY_ERROR); + + assertThatThrownBy(() -> { + new JpaParticipantStatistics(new PfTimestampKey(), null); + }).hasMessageMatching("participantId is marked .*ull but is null"); + + assertNotNull(new JpaParticipantStatistics()); + assertNotNull(new JpaParticipantStatistics((new PfTimestampKey()))); + assertNotNull(new JpaParticipantStatistics(new PfTimestampKey(), new PfConceptKey())); + } + + @Test + void testJpaParticipantStatistics() { + JpaParticipantStatistics testJpaParticipantStatistics = createJpaParticipantStatisticsInstance(); + + ParticipantStatistics aces = createParticipantStatisticsInstance(); + assertEquals(aces, testJpaParticipantStatistics.toAuthorative()); + + assertThatThrownBy(() -> { + testJpaParticipantStatistics.fromAuthorative(null); + }).hasMessageMatching("participantStatistics is marked .*ull but is null"); + + assertThatThrownBy(() -> new JpaParticipantStatistics((JpaParticipantStatistics) null)) + .isInstanceOf(NullPointerException.class); + + JpaParticipantStatistics testJpaParticipantStatisticsFa = new JpaParticipantStatistics(); + testJpaParticipantStatisticsFa.setKey(null); + testJpaParticipantStatisticsFa.fromAuthorative(aces); + assertEquals(testJpaParticipantStatistics, testJpaParticipantStatisticsFa); + testJpaParticipantStatisticsFa.setKey(PfTimestampKey.getNullKey()); + testJpaParticipantStatisticsFa.fromAuthorative(aces); + assertEquals(testJpaParticipantStatistics, testJpaParticipantStatisticsFa); + testJpaParticipantStatisticsFa + .setKey(new PfTimestampKey("participantName", "0.0.1", Instant.ofEpochMilli(123456L))); + testJpaParticipantStatisticsFa.fromAuthorative(aces); + assertEquals(testJpaParticipantStatistics, testJpaParticipantStatisticsFa); + + testJpaParticipantStatisticsFa = new JpaParticipantStatistics(aces); + assertEquals(testJpaParticipantStatistics, testJpaParticipantStatisticsFa); + + assertEquals(2, testJpaParticipantStatistics.getKeys().size()); + + assertEquals("participantName", testJpaParticipantStatistics.getKey().getName()); + + testJpaParticipantStatistics.clean(); + assertEquals("participantName", testJpaParticipantStatistics.getKey().getName()); + + JpaParticipantStatistics testJpaParticipantStatistics2 = + new JpaParticipantStatistics(testJpaParticipantStatistics); + assertEquals(testJpaParticipantStatistics, testJpaParticipantStatistics2); + } + + @Test + void testJpaParticipantStatisticsValidation() { + JpaParticipantStatistics testJpaParticipantStatistics = createJpaParticipantStatisticsInstance(); + + assertThatThrownBy(() -> { + testJpaParticipantStatistics.validate(null); + }).hasMessageMatching("fieldName is marked .*ull but is null"); + + BeanValidationResult validationResult = testJpaParticipantStatistics.validate(""); + assertTrue(validationResult.isValid()); + } + + @Test + void testJpaParticipantStatisticsConmpareTo() { + JpaParticipantStatistics testJpaParticipantStatistics = createJpaParticipantStatisticsInstance(); + + JpaParticipantStatistics otherJpaParticipantStatistics = + new JpaParticipantStatistics(testJpaParticipantStatistics); + assertEquals(0, testJpaParticipantStatistics.compareTo(otherJpaParticipantStatistics)); + assertEquals(-1, testJpaParticipantStatistics.compareTo(null)); + assertEquals(0, testJpaParticipantStatistics.compareTo(testJpaParticipantStatistics)); + assertNotEquals(0, testJpaParticipantStatistics.compareTo(new DummyJpaParticipantStatisticsChild())); + + testJpaParticipantStatistics.setState(ParticipantState.UNKNOWN); + assertNotEquals(0, testJpaParticipantStatistics.compareTo(otherJpaParticipantStatistics)); + testJpaParticipantStatistics.setState(ParticipantState.PASSIVE); + assertEquals(0, testJpaParticipantStatistics.compareTo(otherJpaParticipantStatistics)); + + assertEquals(testJpaParticipantStatistics, new JpaParticipantStatistics(testJpaParticipantStatistics)); + } + + @Test + void testJpaParticipantStatisticsLombok() { + assertNotNull(new Participant()); + JpaParticipantStatistics ps0 = new JpaParticipantStatistics(); + + assertThat(ps0.toString()).contains("JpaParticipantStatistics("); + assertThat(ps0.hashCode()).isNotZero(); + assertEquals(true, ps0.equals(ps0)); + assertEquals(false, ps0.equals(null)); + + + JpaParticipantStatistics ps1 = new JpaParticipantStatistics(); + + ps1.setState(ParticipantState.UNKNOWN); + + assertThat(ps1.toString()).contains("JpaParticipantStatistics("); + assertEquals(false, ps1.hashCode() == 0); + assertEquals(false, ps1.equals(ps0)); + assertEquals(false, ps1.equals(null)); + + assertNotEquals(ps1, ps0); + + JpaParticipantStatistics ps2 = new JpaParticipantStatistics(); + assertEquals(ps2, ps0); + } + + private JpaParticipantStatistics createJpaParticipantStatisticsInstance() { + ParticipantStatistics testAces = createParticipantStatisticsInstance(); + JpaParticipantStatistics testJpaParticipantStatistics = new JpaParticipantStatistics(); + testJpaParticipantStatistics.setKey(null); + testJpaParticipantStatistics.fromAuthorative(testAces); + testJpaParticipantStatistics.setKey(PfTimestampKey.getNullKey()); + testJpaParticipantStatistics.fromAuthorative(testAces); + + return testJpaParticipantStatistics; + } + + private ParticipantStatistics createParticipantStatisticsInstance() { + ParticipantStatistics participantStatistics = new ParticipantStatistics(); + participantStatistics.setParticipantId(new ToscaConceptIdentifier("participantName", "0.0.1")); + participantStatistics.setTimeStamp(Instant.ofEpochMilli(123456L)); + participantStatistics.setState(ParticipantState.PASSIVE); + participantStatistics.setHealthStatus(ParticipantHealthStatus.HEALTHY); + + return participantStatistics; + } +} diff --git a/models/src/test/java/org/onap/policy/clamp/models/acm/persistence/concepts/JpaParticipantTest.java b/models/src/test/java/org/onap/policy/clamp/models/acm/persistence/concepts/JpaParticipantTest.java new file mode 100644 index 000000000..776aafa2e --- /dev/null +++ b/models/src/test/java/org/onap/policy/clamp/models/acm/persistence/concepts/JpaParticipantTest.java @@ -0,0 +1,254 @@ +/*- + * ============LICENSE_START======================================================= + * Copyright (C) 2021 Nordix Foundation. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * SPDX-License-Identifier: Apache-2.0 + * ============LICENSE_END========================================================= + */ + +package org.onap.policy.clamp.models.acm.persistence.concepts; + +import static org.assertj.core.api.Assertions.assertThat; +import static org.assertj.core.api.Assertions.assertThatThrownBy; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNotEquals; +import static org.junit.Assert.assertNotNull; +import static org.junit.Assert.assertTrue; + +import org.junit.jupiter.api.Test; +import org.onap.policy.clamp.models.acm.concepts.Participant; +import org.onap.policy.clamp.models.acm.concepts.ParticipantHealthStatus; +import org.onap.policy.clamp.models.acm.concepts.ParticipantState; +import org.onap.policy.models.base.PfConceptKey; +import org.onap.policy.models.tosca.authorative.concepts.ToscaConceptIdentifier; + +/** + * Test the {@link JpaParticiant} class. + */ +class JpaParticipantTest { + + private static final String NULL_KEY_ERROR = "key is marked .*ull but is null"; + + @Test + void testJpaParticipantConstructor() { + assertThatThrownBy(() -> { + new JpaParticipant((JpaParticipant) null); + }).hasMessageMatching("copyConcept is marked .*ull but is null"); + + assertThatThrownBy(() -> { + new JpaParticipant((PfConceptKey) null); + }).hasMessageMatching(NULL_KEY_ERROR); + + assertThatThrownBy(() -> { + new JpaParticipant(null, null, null, null); + }).hasMessageMatching(NULL_KEY_ERROR); + + assertThatThrownBy(() -> { + new JpaParticipant(null, null, null, ParticipantHealthStatus.HEALTHY); + }).hasMessageMatching(NULL_KEY_ERROR); + + assertThatThrownBy(() -> { + new JpaParticipant(null, null, ParticipantState.ACTIVE, null); + }).hasMessageMatching(NULL_KEY_ERROR); + + assertThatThrownBy(() -> { + new JpaParticipant(null, null, ParticipantState.ACTIVE, ParticipantHealthStatus.HEALTHY); + }).hasMessageMatching(NULL_KEY_ERROR); + + assertThatThrownBy(() -> { + new JpaParticipant(null, new PfConceptKey(), null, null); + }).hasMessageMatching(NULL_KEY_ERROR); + + assertThatThrownBy(() -> { + new JpaParticipant(null, new PfConceptKey(), null, ParticipantHealthStatus.HEALTHY); + }).hasMessageMatching(NULL_KEY_ERROR); + + assertThatThrownBy(() -> { + new JpaParticipant(null, new PfConceptKey(), ParticipantState.ACTIVE, null); + }).hasMessageMatching(NULL_KEY_ERROR); + + assertThatThrownBy(() -> { + new JpaParticipant(null, new PfConceptKey(), ParticipantState.ACTIVE, ParticipantHealthStatus.HEALTHY); + }).hasMessageMatching(NULL_KEY_ERROR); + + assertThatThrownBy(() -> { + new JpaParticipant(new PfConceptKey(), null, null, null); + }).hasMessageMatching("definition is marked .*ull but is null"); + + assertThatThrownBy(() -> { + new JpaParticipant(new PfConceptKey(), null, null, ParticipantHealthStatus.HEALTHY); + }).hasMessageMatching("definition is marked .*ull but is null"); + + assertThatThrownBy(() -> { + new JpaParticipant(new PfConceptKey(), null, ParticipantState.ACTIVE, null); + }).hasMessageMatching("definition is marked .*ull but is null"); + + assertThatThrownBy(() -> { + new JpaParticipant(new PfConceptKey(), null, ParticipantState.ACTIVE, ParticipantHealthStatus.HEALTHY); + }).hasMessageMatching("definition is marked .*ull but is null"); + + assertThatThrownBy(() -> { + new JpaParticipant(new PfConceptKey(), new PfConceptKey(), null, null); + }).hasMessageMatching("participantState is marked .*ull but is null"); + + assertThatThrownBy(() -> { + new JpaParticipant(new PfConceptKey(), new PfConceptKey(), null, ParticipantHealthStatus.HEALTHY); + }).hasMessageMatching("participantState is marked .*ull but is null"); + + assertThatThrownBy(() -> { + new JpaParticipant(new PfConceptKey(), new PfConceptKey(), ParticipantState.ACTIVE, null); + }).hasMessageMatching("healthStatus is marked .*ull but is null"); + + assertNotNull(new JpaParticipant()); + assertNotNull(new JpaParticipant((new PfConceptKey()))); + assertNotNull(new JpaParticipant(new PfConceptKey(), new PfConceptKey(), ParticipantState.ACTIVE, + ParticipantHealthStatus.HEALTHY)); + } + + @Test + void testJpaParticipant() { + JpaParticipant testJpaParticipant = createJpaParticipantInstance(); + + Participant participant = createParticipantInstance(); + assertEquals(participant, testJpaParticipant.toAuthorative()); + + assertThatThrownBy(() -> { + testJpaParticipant.fromAuthorative(null); + }).hasMessageMatching("participant is marked .*ull but is null"); + + assertThatThrownBy(() -> new JpaParticipant((JpaParticipant) null)).isInstanceOf(NullPointerException.class); + + JpaParticipant testJpaParticipantFa = new JpaParticipant(); + testJpaParticipantFa.setKey(null); + testJpaParticipantFa.fromAuthorative(participant); + assertEquals(testJpaParticipant, testJpaParticipantFa); + testJpaParticipantFa.setKey(PfConceptKey.getNullKey()); + testJpaParticipantFa.fromAuthorative(participant); + assertEquals(testJpaParticipant, testJpaParticipantFa); + testJpaParticipantFa.setKey(new PfConceptKey("participant", "0.0.1")); + testJpaParticipantFa.fromAuthorative(participant); + assertEquals(testJpaParticipant, testJpaParticipantFa); + + assertEquals("participant", testJpaParticipant.getKey().getName()); + assertEquals("participant", new JpaParticipant(createParticipantInstance()).getKey().getName()); + assertEquals("participant", + ((PfConceptKey) new JpaParticipant(createParticipantInstance()).getKeys().get(0)).getName()); + + testJpaParticipant.clean(); + assertEquals("participant", testJpaParticipant.getKey().getName()); + + testJpaParticipant.setDescription(" A Message "); + testJpaParticipant.clean(); + assertEquals("A Message", testJpaParticipant.getDescription()); + + JpaParticipant testJpaParticipant2 = new JpaParticipant(testJpaParticipant); + assertEquals(testJpaParticipant, testJpaParticipant2); + } + + @Test + void testJpaParticipantValidation() { + JpaParticipant testJpaParticipant = createJpaParticipantInstance(); + + assertThatThrownBy(() -> { + testJpaParticipant.validate(null); + }).hasMessageMatching("fieldName is marked .*ull but is null"); + + assertTrue(testJpaParticipant.validate("").isValid()); + } + + @Test + void testJpaParticipantCompareTo() { + JpaParticipant testJpaParticipant = createJpaParticipantInstance(); + + JpaParticipant otherJpaParticipant = new JpaParticipant(testJpaParticipant); + assertEquals(0, testJpaParticipant.compareTo(otherJpaParticipant)); + assertEquals(-1, testJpaParticipant.compareTo(null)); + assertEquals(0, testJpaParticipant.compareTo(testJpaParticipant)); + assertNotEquals(0, testJpaParticipant.compareTo(new DummyJpaParticipantChild())); + + testJpaParticipant.setKey(new PfConceptKey("BadValue", "0.0.1")); + assertNotEquals(0, testJpaParticipant.compareTo(otherJpaParticipant)); + testJpaParticipant.setKey(new PfConceptKey("participant", "0.0.1")); + assertEquals(0, testJpaParticipant.compareTo(otherJpaParticipant)); + + testJpaParticipant.setDefinition(new PfConceptKey("BadValue", "0.0.1")); + assertNotEquals(0, testJpaParticipant.compareTo(otherJpaParticipant)); + testJpaParticipant.setDefinition(new PfConceptKey("participantDefinitionName", "0.0.1")); + assertEquals(0, testJpaParticipant.compareTo(otherJpaParticipant)); + + testJpaParticipant.setParticipantState(ParticipantState.PASSIVE); + assertNotEquals(0, testJpaParticipant.compareTo(otherJpaParticipant)); + testJpaParticipant.setParticipantState(ParticipantState.UNKNOWN); + assertEquals(0, testJpaParticipant.compareTo(otherJpaParticipant)); + + testJpaParticipant.setHealthStatus(ParticipantHealthStatus.NOT_HEALTHY); + assertNotEquals(0, testJpaParticipant.compareTo(otherJpaParticipant)); + testJpaParticipant.setHealthStatus(ParticipantHealthStatus.UNKNOWN); + assertEquals(0, testJpaParticipant.compareTo(otherJpaParticipant)); + + assertEquals(testJpaParticipant, new JpaParticipant(testJpaParticipant)); + } + + @Test + void testJpaParticipantLombok() { + assertNotNull(new Participant()); + JpaParticipant p0 = new JpaParticipant(); + + assertThat(p0.toString()).contains("JpaParticipant("); + assertThat(p0.hashCode()).isNotZero(); + assertEquals(true, p0.equals(p0)); + assertEquals(false, p0.equals(null)); + + + JpaParticipant p1 = new JpaParticipant(); + + p1.setDefinition(new PfConceptKey("defName", "0.0.1")); + p1.setDescription("Description"); + p1.setHealthStatus(ParticipantHealthStatus.HEALTHY); + p1.setKey(new PfConceptKey("participant", "0.0.1")); + p1.setParticipantState(ParticipantState.ACTIVE); + + assertThat(p1.toString()).contains("Participant("); + assertEquals(false, p1.hashCode() == 0); + assertEquals(false, p1.equals(p0)); + assertEquals(false, p1.equals(null)); + + assertNotEquals(p1, p0); + + JpaParticipant p2 = new JpaParticipant(); + assertEquals(p2, p0); + } + + private JpaParticipant createJpaParticipantInstance() { + Participant testParticipant = createParticipantInstance(); + JpaParticipant testJpaParticipant = new JpaParticipant(); + testJpaParticipant.setKey(null); + testJpaParticipant.fromAuthorative(testParticipant); + testJpaParticipant.setKey(PfConceptKey.getNullKey()); + testJpaParticipant.fromAuthorative(testParticipant); + + return testJpaParticipant; + } + + private Participant createParticipantInstance() { + Participant testParticipant = new Participant(); + testParticipant.setName("participant"); + testParticipant.setVersion("0.0.1"); + testParticipant.setDefinition(new ToscaConceptIdentifier("participantDefinitionName", "0.0.1")); + testParticipant.setParticipantType(new ToscaConceptIdentifier("participantTypeName", "0.0.1")); + + return testParticipant; + } +} diff --git a/models/src/test/java/org/onap/policy/clamp/models/acm/persistence/concepts/PojosTest.java b/models/src/test/java/org/onap/policy/clamp/models/acm/persistence/concepts/PojosTest.java new file mode 100644 index 000000000..1f40fae5f --- /dev/null +++ b/models/src/test/java/org/onap/policy/clamp/models/acm/persistence/concepts/PojosTest.java @@ -0,0 +1,62 @@ +/*- + * ============LICENSE_START======================================================= + * Copyright (C) 2021 Nordix Foundation. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * SPDX-License-Identifier: Apache-2.0 + * ============LICENSE_END========================================================= + */ + +package org.onap.policy.clamp.models.acm.persistence.concepts; + +import com.openpojo.reflection.PojoClass; +import com.openpojo.reflection.impl.PojoClassFactory; +import com.openpojo.validation.Validator; +import com.openpojo.validation.ValidatorBuilder; +import com.openpojo.validation.rule.impl.EqualsAndHashCodeMatchRule; +import com.openpojo.validation.rule.impl.GetterMustExistRule; +import com.openpojo.validation.rule.impl.NoPublicFieldsExceptStaticFinalRule; +import com.openpojo.validation.rule.impl.SetterMustExistRule; +import com.openpojo.validation.test.impl.GetterTester; +import com.openpojo.validation.test.impl.SetterTester; +import java.util.List; +import org.junit.jupiter.api.Test; +import org.onap.policy.common.utils.test.ToStringTester; + +/** + * Class to perform unit tests of all pojos. + */ +class PojosTest { + + @Test + void testPojos() { + List pojoClasses = + PojoClassFactory.getPojoClasses(PojosTest.class.getPackageName()); + + // @formatter:off + final Validator validator = ValidatorBuilder + .create() + .with(new SetterMustExistRule()) + .with(new GetterMustExistRule()) + .with(new EqualsAndHashCodeMatchRule()) + .with(new NoPublicFieldsExceptStaticFinalRule()) + .with(new SetterTester()) + .with(new GetterTester()) + .with(new ToStringTester()) + .build(); + + validator.validate(pojoClasses); + // @formatter:on + } +} diff --git a/models/src/test/java/org/onap/policy/clamp/models/acm/persistence/provider/AcElementStatisticsProviderTest.java b/models/src/test/java/org/onap/policy/clamp/models/acm/persistence/provider/AcElementStatisticsProviderTest.java new file mode 100644 index 000000000..15d1d845d --- /dev/null +++ b/models/src/test/java/org/onap/policy/clamp/models/acm/persistence/provider/AcElementStatisticsProviderTest.java @@ -0,0 +1,116 @@ +/*- + * ============LICENSE_START======================================================= + * Copyright (C) 2021 Nordix Foundation. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * SPDX-License-Identifier: Apache-2.0 + * ============LICENSE_END========================================================= + */ + +package org.onap.policy.clamp.models.acm.persistence.provider; + +import static org.assertj.core.api.Assertions.assertThat; +import static org.assertj.core.api.Assertions.assertThatThrownBy; +import static org.junit.Assert.assertEquals; +import static org.mockito.ArgumentMatchers.any; +import static org.mockito.ArgumentMatchers.anyList; +import static org.mockito.ArgumentMatchers.eq; +import static org.mockito.Mockito.mock; +import static org.mockito.Mockito.when; + +import java.time.Instant; +import java.util.List; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; +import org.onap.policy.clamp.models.acm.concepts.AcElementStatistics; +import org.onap.policy.clamp.models.acm.concepts.AcElementStatisticsList; +import org.onap.policy.clamp.models.acm.persistence.concepts.JpaAcElementStatistics; +import org.onap.policy.clamp.models.acm.persistence.repository.AcElementStatisticsRepository; +import org.onap.policy.common.utils.coder.Coder; +import org.onap.policy.common.utils.coder.StandardCoder; +import org.onap.policy.common.utils.resources.ResourceUtils; +import org.onap.policy.models.tosca.authorative.concepts.ToscaConceptIdentifier; + +class AcElementStatisticsProviderTest { + private static final String LIST_IS_NULL = ".*. is marked .*ull but is null"; + private static final Coder CODER = new StandardCoder(); + private static final String AC_ELEMENT_STATS_JSON = "src/test/resources/providers/TestAcElementStatistics.json"; + + private AcElementStatisticsProvider acElementStatisticsProvider; + private AcElementStatisticsList inputAcElementStats; + private String originalJson = ResourceUtils.getResourceAsString(AC_ELEMENT_STATS_JSON); + + /** + * Set up test AcElement statistics provider. + * + * @throws Exception on errors + */ + @BeforeEach + void beforeSetupDao() throws Exception { + + inputAcElementStats = CODER.decode(originalJson, AcElementStatisticsList.class); + var acElementStatisticsRepository = mock(AcElementStatisticsRepository.class); + + var jpaAcElementStatisticsList = + ProviderUtils.getJpaAndValidateList(inputAcElementStats.getAcElementStatistics(), + JpaAcElementStatistics::new, "automation composition element statistics"); + + for (var acElementStat : jpaAcElementStatisticsList) { + when(acElementStatisticsRepository.getById(eq(acElementStat.getKey()))).thenReturn(acElementStat); + when(acElementStatisticsRepository.findAllById(eq(List.of(acElementStat.getKey())))) + .thenReturn(List.of(acElementStat)); + } + + when(acElementStatisticsRepository.saveAll(anyList())).thenReturn(jpaAcElementStatisticsList); + + when(acElementStatisticsRepository.getFiltered(eq(JpaAcElementStatistics.class), any())) + .thenReturn(List.of(jpaAcElementStatisticsList.get(0))); + + acElementStatisticsProvider = new AcElementStatisticsProvider(acElementStatisticsRepository); + } + + @Test + void testAcElementStatisticsCreate() throws Exception { + assertThatThrownBy(() -> { + acElementStatisticsProvider.createAcElementStatistics(null); + }).hasMessageMatching(LIST_IS_NULL); + + AcElementStatisticsList createdAcElementStats = new AcElementStatisticsList(); + createdAcElementStats.setAcElementStatistics( + acElementStatisticsProvider.createAcElementStatistics(inputAcElementStats.getAcElementStatistics())); + + assertEquals(inputAcElementStats.toString().replaceAll("\\s+", ""), + createdAcElementStats.toString().replaceAll("\\s+", "")); + } + + @Test + void testGetAcElementStatistics() throws Exception { + + List getResponse; + + // Return empty list when no data present in db + getResponse = acElementStatisticsProvider.getAcElementStatistics(null, null, null, null); + assertThat(getResponse).isEmpty(); + + acElementStatisticsProvider.createAcElementStatistics(inputAcElementStats.getAcElementStatistics()); + ToscaConceptIdentifier identifier = inputAcElementStats.getAcElementStatistics().get(0).getParticipantId(); + Instant instant = inputAcElementStats.getAcElementStatistics().get(0).getTimeStamp(); + String id = inputAcElementStats.getAcElementStatistics().get(0).getId().toString(); + assertEquals(1, acElementStatisticsProvider + .getAcElementStatistics(identifier.getName(), identifier.getVersion(), id, instant).size()); + + assertEquals(1, acElementStatisticsProvider + .getFilteredAcElementStatistics("name2", "1.0.1", null, null, null, "DESC", 1).size()); + } +} diff --git a/models/src/test/java/org/onap/policy/clamp/models/acm/persistence/provider/AutomationCompositionProviderTest.java b/models/src/test/java/org/onap/policy/clamp/models/acm/persistence/provider/AutomationCompositionProviderTest.java new file mode 100644 index 000000000..0a367eed8 --- /dev/null +++ b/models/src/test/java/org/onap/policy/clamp/models/acm/persistence/provider/AutomationCompositionProviderTest.java @@ -0,0 +1,305 @@ +/*- + * ============LICENSE_START======================================================= + * Copyright (C) 2021 Nordix Foundation. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * SPDX-License-Identifier: Apache-2.0 + * ============LICENSE_END========================================================= + */ + +package org.onap.policy.clamp.models.acm.persistence.provider; + +import static org.assertj.core.api.Assertions.assertThat; +import static org.assertj.core.api.Assertions.assertThatThrownBy; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNotNull; +import static org.mockito.ArgumentMatchers.any; +import static org.mockito.ArgumentMatchers.eq; +import static org.mockito.Mockito.mock; +import static org.mockito.Mockito.verify; +import static org.mockito.Mockito.when; + +import java.util.List; +import java.util.Optional; +import javax.persistence.EntityNotFoundException; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; +import org.onap.policy.clamp.models.acm.concepts.AutomationComposition; +import org.onap.policy.clamp.models.acm.concepts.AutomationCompositions; +import org.onap.policy.clamp.models.acm.persistence.concepts.JpaAutomationComposition; +import org.onap.policy.clamp.models.acm.persistence.repository.AutomationCompositionRepository; +import org.onap.policy.clamp.models.acm.persistence.repository.ToscaNodeTemplateRepository; +import org.onap.policy.clamp.models.acm.persistence.repository.ToscaNodeTemplatesRepository; +import org.onap.policy.common.utils.coder.Coder; +import org.onap.policy.common.utils.coder.StandardCoder; +import org.onap.policy.common.utils.coder.YamlJsonTranslator; +import org.onap.policy.common.utils.resources.ResourceUtils; +import org.onap.policy.models.base.PfConceptKey; +import org.onap.policy.models.tosca.authorative.concepts.ToscaConceptIdentifier; +import org.onap.policy.models.tosca.authorative.concepts.ToscaNodeTemplate; +import org.onap.policy.models.tosca.authorative.concepts.ToscaServiceTemplate; +import org.onap.policy.models.tosca.authorative.concepts.ToscaTypedEntityFilter; +import org.onap.policy.models.tosca.simple.concepts.JpaToscaNodeTemplate; + +class AutomationCompositionProviderTest { + + private static final String LIST_IS_NULL = "automationCompositions is marked .*ull but is null"; + private static final String OBJECT_IS_NULL = "automationComposition is marked non-null but is null"; + + private static final String ID_NAME = "PMSHInstance1"; + private static final String ID_VERSION = "1.0.1"; + private static final String ID_NAME_NOT_EXTST = "not_exist"; + private static final String ID_NAME_NOT_VALID = "not_valid"; + + private static final Coder CODER = new StandardCoder(); + private static final String AUTOMATION_COMPOSITION_JSON = + "src/test/resources/providers/TestAutomationCompositions.json"; + private static final String TOSCA_TEMPLATE_YAML = "examples/acm/PMSubscriptionHandling.yaml"; + + private static final YamlJsonTranslator yamlTranslator = new YamlJsonTranslator(); + + private AutomationCompositions inputAutomationCompositions; + private List inputAutomationCompositionsJpa; + private String originalJson = ResourceUtils.getResourceAsString(AUTOMATION_COMPOSITION_JSON); + + @BeforeEach + void beforeSetupDao() throws Exception { + inputAutomationCompositions = CODER.decode(originalJson, AutomationCompositions.class); + inputAutomationCompositionsJpa = + ProviderUtils.getJpaAndValidateList(inputAutomationCompositions.getAutomationCompositionList(), + JpaAutomationComposition::new, "automation compositions"); + } + + @Test + void testAutomationCompositionsSave() throws Exception { + var automationCompositionRepository = mock(AutomationCompositionRepository.class); + var automationCompositionProvider = new AutomationCompositionProvider(automationCompositionRepository, + mock(ToscaNodeTemplateRepository.class), mock(ToscaNodeTemplatesRepository.class)); + + assertThatThrownBy(() -> { + automationCompositionProvider.saveAutomationCompositions(null); + }).hasMessageMatching(LIST_IS_NULL); + + when(automationCompositionRepository.saveAll(inputAutomationCompositionsJpa)) + .thenReturn(inputAutomationCompositionsJpa); + + var createdAutomationCompositions = new AutomationCompositions(); + createdAutomationCompositions.setAutomationCompositionList(automationCompositionProvider + .saveAutomationCompositions(inputAutomationCompositions.getAutomationCompositionList())); + + assertEquals(inputAutomationCompositions, createdAutomationCompositions); + + when(automationCompositionRepository.saveAll(any())).thenThrow(IllegalArgumentException.class); + + assertThatThrownBy(() -> { + automationCompositionProvider + .saveAutomationCompositions(inputAutomationCompositions.getAutomationCompositionList()); + }).hasMessageMatching("Error in save AutomationCompositions"); + } + + @Test + void testAutomationCompositionSave() throws Exception { + var automationCompositionRepository = mock(AutomationCompositionRepository.class); + var automationCompositionProvider = new AutomationCompositionProvider(automationCompositionRepository, + mock(ToscaNodeTemplateRepository.class), mock(ToscaNodeTemplatesRepository.class)); + + assertThatThrownBy(() -> { + automationCompositionProvider.saveAutomationComposition(null); + }).hasMessageMatching(OBJECT_IS_NULL); + + when(automationCompositionRepository.save(inputAutomationCompositionsJpa.get(0))) + .thenReturn(inputAutomationCompositionsJpa.get(0)); + + var createdAutomationComposition = automationCompositionProvider + .saveAutomationComposition(inputAutomationCompositions.getAutomationCompositionList().get(0)); + + assertEquals(inputAutomationCompositions.getAutomationCompositionList().get(0), createdAutomationComposition); + + when(automationCompositionRepository.save(any())).thenThrow(IllegalArgumentException.class); + + assertThatThrownBy(() -> { + automationCompositionProvider + .saveAutomationComposition(inputAutomationCompositions.getAutomationCompositionList().get(0)); + }).hasMessageMatching("Error in save automationComposition"); + } + + @Test + void testGetAutomationCompositions() throws Exception { + var automationCompositionRepository = mock(AutomationCompositionRepository.class); + var automationCompositionProvider = new AutomationCompositionProvider(automationCompositionRepository, + mock(ToscaNodeTemplateRepository.class), mock(ToscaNodeTemplatesRepository.class)); + + // Return empty list when no data present in db + List getResponse = automationCompositionProvider.getAutomationCompositions(); + assertThat(getResponse).isEmpty(); + + automationCompositionProvider + .saveAutomationCompositions(inputAutomationCompositions.getAutomationCompositionList()); + + var automationComposition0 = inputAutomationCompositions.getAutomationCompositionList().get(1); + var name = automationComposition0.getName(); + var version = automationComposition0.getVersion(); + var automationComposition1 = inputAutomationCompositions.getAutomationCompositionList().get(1); + + when(automationCompositionRepository.getFiltered(eq(JpaAutomationComposition.class), any(), any())) + .thenReturn(List.of(new JpaAutomationComposition(automationComposition0), + new JpaAutomationComposition(automationComposition1))); + when(automationCompositionRepository.findById(automationComposition0.getKey().asIdentifier().asConceptKey())) + .thenReturn(Optional.of(new JpaAutomationComposition(automationComposition0))); + when(automationCompositionRepository.getById(automationComposition0.getKey().asIdentifier().asConceptKey())) + .thenReturn(new JpaAutomationComposition(automationComposition0)); + when(automationCompositionRepository.getFiltered(JpaAutomationComposition.class, name, version)) + .thenReturn(List.of(new JpaAutomationComposition(automationComposition0))); + when(automationCompositionRepository.findById(automationComposition1.getKey().asIdentifier().asConceptKey())) + .thenReturn(Optional.of(new JpaAutomationComposition(automationComposition1))); + + assertEquals(1, automationCompositionProvider.getAutomationCompositions(name, version).size()); + + var ac = automationCompositionProvider + .findAutomationComposition(new ToscaConceptIdentifier(ID_NAME, ID_VERSION)).get(); + assertEquals(inputAutomationCompositions.getAutomationCompositionList().get(1), ac); + + ac = automationCompositionProvider.getAutomationComposition(new ToscaConceptIdentifier(ID_NAME, ID_VERSION)); + assertEquals(inputAutomationCompositions.getAutomationCompositionList().get(1), ac); + + when(automationCompositionRepository.getById(any())).thenThrow(EntityNotFoundException.class); + + assertThatThrownBy(() -> { + automationCompositionProvider + .getAutomationComposition(new ToscaConceptIdentifier(ID_NAME_NOT_EXTST, ID_VERSION)); + }).hasMessageMatching("AutomationComposition not found"); + + ac = automationCompositionProvider.findAutomationComposition(ID_NAME, ID_VERSION).get(); + assertEquals(inputAutomationCompositions.getAutomationCompositionList().get(1), ac); + + assertThat(automationCompositionProvider + .findAutomationComposition(new ToscaConceptIdentifier(ID_NAME_NOT_EXTST, ID_VERSION))).isEmpty(); + + when(automationCompositionRepository.findById(any())).thenThrow(IllegalArgumentException.class); + + assertThatThrownBy(() -> { + automationCompositionProvider.findAutomationComposition(ID_NAME_NOT_VALID, ID_VERSION); + }).hasMessageMatching("Not valid parameter"); + } + + @Test + void testDeleteAutomationComposition() throws Exception { + var automationCompositionRepository = mock(AutomationCompositionRepository.class); + var automationCompositionProvider = new AutomationCompositionProvider(automationCompositionRepository, + mock(ToscaNodeTemplateRepository.class), mock(ToscaNodeTemplatesRepository.class)); + + assertThatThrownBy(() -> { + automationCompositionProvider.deleteAutomationComposition(ID_NAME_NOT_EXTST, ID_VERSION); + }).hasMessageMatching(".*.failed, automation composition does not exist"); + + var automationComposition = inputAutomationCompositions.getAutomationCompositionList().get(0); + var name = automationComposition.getName(); + var version = automationComposition.getVersion(); + + when(automationCompositionRepository.findById(new PfConceptKey(name, version))) + .thenReturn(Optional.of(inputAutomationCompositionsJpa.get(0))); + + AutomationComposition deletedAc = automationCompositionProvider.deleteAutomationComposition(name, version); + assertEquals(automationComposition, deletedAc); + } + + @Test + void testDeleteAllInstanceProperties() throws Exception { + var automationCompositionProvider = + new AutomationCompositionProvider(mock(AutomationCompositionRepository.class), + mock(ToscaNodeTemplateRepository.class), mock(ToscaNodeTemplatesRepository.class)); + var toscaServiceTemplate = testAutomationCompositionRead(); + automationCompositionProvider.deleteInstanceProperties( + automationCompositionProvider.saveInstanceProperties(toscaServiceTemplate), + automationCompositionProvider.getAllNodeTemplates()); + assertThat(automationCompositionProvider.getAutomationCompositions()).isEmpty(); + } + + @Test + void testSaveAndDeleteInstanceProperties() throws Exception { + var toscaNodeTemplatesRepository = mock(ToscaNodeTemplatesRepository.class); + var toscaNodeTemplateRepository = mock(ToscaNodeTemplateRepository.class); + var automationCompositionProvider = new AutomationCompositionProvider( + mock(AutomationCompositionRepository.class), toscaNodeTemplateRepository, toscaNodeTemplatesRepository); + var toscaServiceTest = testAutomationCompositionRead(); + + automationCompositionProvider.saveInstanceProperties(toscaServiceTest); + verify(toscaNodeTemplatesRepository).save(any()); + + var name = "org.onap.policy.acm.PolicyAutomationCompositionParticipant"; + var version = "2.3.1"; + var elem = toscaServiceTest.getToscaTopologyTemplate().getNodeTemplates().get(name); + when(toscaNodeTemplateRepository.getFiltered(JpaToscaNodeTemplate.class, name, version)) + .thenReturn(List.of(new JpaToscaNodeTemplate(elem))); + + var filtered = automationCompositionProvider.getNodeTemplates(name, version); + verify(toscaNodeTemplateRepository).getFiltered(JpaToscaNodeTemplate.class, name, version); + + automationCompositionProvider + .deleteInstanceProperties(automationCompositionProvider.saveInstanceProperties(toscaServiceTest), filtered); + + verify(toscaNodeTemplateRepository).delete(any()); + } + + @Test + void testGetNodeTemplates() throws Exception { + var toscaNodeTemplateRepository = mock(ToscaNodeTemplateRepository.class); + var automationCompositionProvider = + new AutomationCompositionProvider(mock(AutomationCompositionRepository.class), toscaNodeTemplateRepository, + mock(ToscaNodeTemplatesRepository.class)); + + var toscaNodeTemplate0 = new JpaToscaNodeTemplate(new PfConceptKey(ID_NAME, ID_VERSION)); + var toscaNodeTemplate1 = new JpaToscaNodeTemplate(new PfConceptKey("PMSHInstance2", ID_VERSION)); + + when(toscaNodeTemplateRepository.getFiltered(JpaToscaNodeTemplate.class, null, null)) + .thenReturn(List.of(toscaNodeTemplate0, toscaNodeTemplate1)); + when(toscaNodeTemplateRepository.findAll()).thenReturn(List.of(toscaNodeTemplate0, toscaNodeTemplate1)); + when(toscaNodeTemplateRepository.getFiltered(JpaToscaNodeTemplate.class, ID_NAME, ID_VERSION)) + .thenReturn(List.of(toscaNodeTemplate0)); + + // Getting all nodes + var listNodes = automationCompositionProvider.getAllNodeTemplates(); + assertNotNull(listNodes); + assertThat(listNodes).hasSize(2); + + listNodes = automationCompositionProvider.getNodeTemplates(ID_NAME, ID_VERSION); + assertNotNull(listNodes); + assertThat(listNodes).hasSize(1); + + listNodes = automationCompositionProvider.getAllNodeTemplates(); + assertNotNull(listNodes); + assertThat(listNodes).hasSize(2); + + var nodeTemplateFilter = + ToscaTypedEntityFilter.builder().name(ID_NAME).version(ID_VERSION).build(); + + listNodes = automationCompositionProvider.getFilteredNodeTemplates(nodeTemplateFilter); + assertNotNull(listNodes); + assertThat(listNodes).hasSize(1); + + assertThatThrownBy(() -> { + automationCompositionProvider.getFilteredNodeTemplates(null); + }).hasMessageMatching("filter is marked non-null but is null"); + } + + private static ToscaServiceTemplate testAutomationCompositionRead() { + return testAutomationCompositionYamlSerialization(TOSCA_TEMPLATE_YAML); + } + + private static ToscaServiceTemplate testAutomationCompositionYamlSerialization( + String automationCompositionFilePath) { + var automationCompositionString = ResourceUtils.getResourceAsString(automationCompositionFilePath); + return yamlTranslator.fromYaml(automationCompositionString, ToscaServiceTemplate.class); + } +} diff --git a/models/src/test/java/org/onap/policy/clamp/models/acm/persistence/provider/ParticipantProviderTest.java b/models/src/test/java/org/onap/policy/clamp/models/acm/persistence/provider/ParticipantProviderTest.java new file mode 100644 index 000000000..f537e2cd7 --- /dev/null +++ b/models/src/test/java/org/onap/policy/clamp/models/acm/persistence/provider/ParticipantProviderTest.java @@ -0,0 +1,149 @@ +/*- + * ============LICENSE_START======================================================= + * Copyright (C) 2021 Nordix Foundation. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * SPDX-License-Identifier: Apache-2.0 + * ============LICENSE_END========================================================= + */ + +package org.onap.policy.clamp.models.acm.persistence.provider; + +import static org.assertj.core.api.Assertions.assertThat; +import static org.assertj.core.api.Assertions.assertThatThrownBy; +import static org.junit.Assert.assertEquals; +import static org.mockito.ArgumentMatchers.any; +import static org.mockito.ArgumentMatchers.eq; +import static org.mockito.Mockito.mock; +import static org.mockito.Mockito.when; + +import java.util.ArrayList; +import java.util.List; +import java.util.Optional; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; +import org.onap.policy.clamp.models.acm.concepts.Participant; +import org.onap.policy.clamp.models.acm.persistence.concepts.JpaParticipant; +import org.onap.policy.clamp.models.acm.persistence.repository.ParticipantRepository; +import org.onap.policy.common.utils.coder.Coder; +import org.onap.policy.common.utils.coder.StandardCoder; +import org.onap.policy.common.utils.resources.ResourceUtils; +import org.onap.policy.models.base.PfConceptKey; +import org.onap.policy.models.tosca.authorative.concepts.ToscaTypedEntityFilter; + +class ParticipantProviderTest { + + private static final Coder CODER = new StandardCoder(); + private static final String PARTICIPANT_JSON = "src/test/resources/providers/TestParticipant.json"; + private static final String LIST_IS_NULL = ".*. is marked .*ull but is null"; + + private List inputParticipants = new ArrayList<>(); + private List jpaParticipantList; + private String originalJson = ResourceUtils.getResourceAsString(PARTICIPANT_JSON); + + @BeforeEach + void beforeSetupDao() throws Exception { + inputParticipants.add(CODER.decode(originalJson, Participant.class)); + jpaParticipantList = ProviderUtils.getJpaAndValidateList(inputParticipants, JpaParticipant::new, "participant"); + } + + @Test + void testParticipantSave() throws Exception { + var participantRepository = mock(ParticipantRepository.class); + for (var participant : jpaParticipantList) { + when(participantRepository.getById(new PfConceptKey(participant.getName(), participant.getVersion()))) + .thenReturn(participant); + } + var participantProvider = new ParticipantProvider(participantRepository); + + assertThatThrownBy(() -> { + participantProvider.saveParticipant(null); + }).hasMessageMatching(LIST_IS_NULL); + + when(participantRepository.save(any())).thenReturn(jpaParticipantList.get(0)); + + Participant savedParticipant = participantProvider.saveParticipant(inputParticipants.get(0)); + assertEquals(savedParticipant, inputParticipants.get(0)); + + when(participantRepository.save(any())).thenThrow(IllegalArgumentException.class); + + assertThatThrownBy(() -> { + participantProvider.saveParticipant(inputParticipants.get(0)); + }).hasMessageMatching("Error in save Participant"); + } + + @Test + void testGetAutomationCompositions() throws Exception { + var participantRepository = mock(ParticipantRepository.class); + var participantProvider = new ParticipantProvider(participantRepository); + + // Return empty list when no data present in db + List getResponse = participantProvider.getParticipants(null, null); + assertThat(getResponse).isEmpty(); + + String name = inputParticipants.get(0).getName(); + String version = inputParticipants.get(0).getVersion(); + when(participantRepository.getFiltered(any(), eq(name), eq(version))) + .thenReturn(List.of(jpaParticipantList.get(0))); + assertEquals(1, participantProvider.getParticipants(name, version).size()); + + assertThat(participantProvider.getParticipants("invalid_name", "1.0.1")).isEmpty(); + + assertThat(participantProvider.findParticipant("invalid_name", "1.0.1")).isEmpty(); + + when(participantRepository.findAll()).thenReturn(jpaParticipantList); + assertThat(participantProvider.getParticipants()).hasSize(inputParticipants.size()); + + when(participantRepository.findById(any())).thenThrow(IllegalArgumentException.class); + + assertThatThrownBy(() -> { + participantProvider.findParticipant("notValid", "notValid"); + }).hasMessageMatching("Error in find Participant"); + + assertThatThrownBy(() -> { + participantProvider.getFilteredParticipants(null); + }).hasMessageMatching("filter is marked .*ull but is null"); + + when(participantRepository.getFiltered(eq(JpaParticipant.class), eq(null), eq(null))) + .thenReturn(jpaParticipantList); + + final ToscaTypedEntityFilter filter = ToscaTypedEntityFilter.builder() + .type("org.onap.domain.pmsh.PMSHAutomationCompositionDefinition").build(); + assertEquals(1, participantProvider.getFilteredParticipants(filter).size()); + + } + + @Test + void testDeleteParticipant() throws Exception { + var participantRepository = mock(ParticipantRepository.class); + var participantProvider = new ParticipantProvider(participantRepository); + + assertThatThrownBy(() -> { + participantProvider.deleteParticipant("Invalid_name", "1.0.1"); + }).hasMessageMatching(".*.failed, participant does not exist"); + + String name = inputParticipants.get(0).getName(); + String version = inputParticipants.get(0).getVersion(); + + when(participantRepository.findById(any())).thenReturn(Optional.of(jpaParticipantList.get(0))); + + Participant deletedParticipant = participantProvider.deleteParticipant(name, version); + assertEquals(inputParticipants.get(0), deletedParticipant); + + when(participantRepository.findById(any())).thenThrow(IllegalArgumentException.class); + assertThatThrownBy(() -> { + participantProvider.deleteParticipant(name, version); + }).hasMessageMatching("Error in delete Participant"); + } +} diff --git a/models/src/test/java/org/onap/policy/clamp/models/acm/persistence/provider/ParticipantStatisticsProviderTest.java b/models/src/test/java/org/onap/policy/clamp/models/acm/persistence/provider/ParticipantStatisticsProviderTest.java new file mode 100644 index 000000000..3c6b1eb83 --- /dev/null +++ b/models/src/test/java/org/onap/policy/clamp/models/acm/persistence/provider/ParticipantStatisticsProviderTest.java @@ -0,0 +1,107 @@ +/*- + * ============LICENSE_START======================================================= + * Copyright (C) 2021 Nordix Foundation. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * SPDX-License-Identifier: Apache-2.0 + * ============LICENSE_END========================================================= + */ + +package org.onap.policy.clamp.models.acm.persistence.provider; + +import static org.assertj.core.api.Assertions.assertThat; +import static org.assertj.core.api.Assertions.assertThatThrownBy; +import static org.junit.Assert.assertEquals; +import static org.mockito.ArgumentMatchers.any; +import static org.mockito.ArgumentMatchers.anyList; +import static org.mockito.ArgumentMatchers.eq; +import static org.mockito.Mockito.mock; +import static org.mockito.Mockito.when; + +import java.time.Instant; +import java.util.List; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; +import org.onap.policy.clamp.models.acm.concepts.ParticipantStatistics; +import org.onap.policy.clamp.models.acm.concepts.ParticipantStatisticsList; +import org.onap.policy.clamp.models.acm.persistence.concepts.JpaParticipantStatistics; +import org.onap.policy.clamp.models.acm.persistence.repository.ParticipantStatisticsRepository; +import org.onap.policy.common.utils.coder.Coder; +import org.onap.policy.common.utils.coder.StandardCoder; +import org.onap.policy.common.utils.resources.ResourceUtils; +import org.onap.policy.models.tosca.authorative.concepts.ToscaConceptIdentifier; + +class ParticipantStatisticsProviderTest { + + private static final String LIST_IS_NULL = ".*. is marked .*ull but is null"; + private static final Coder CODER = new StandardCoder(); + private static final String PARTICIPANT_STATS_JSON = "src/test/resources/providers/TestParticipantStatistics.json"; + + private ParticipantStatisticsProvider participantStatisticsProvider; + private ParticipantStatisticsList inputParticipantStatistics; + private String originalJson = ResourceUtils.getResourceAsString(PARTICIPANT_STATS_JSON); + + @BeforeEach + void beforeSetupDao() throws Exception { + var participantStatisticsRepository = mock(ParticipantStatisticsRepository.class); + participantStatisticsProvider = new ParticipantStatisticsProvider(participantStatisticsRepository); + inputParticipantStatistics = CODER.decode(originalJson, ParticipantStatisticsList.class); + + var jpaParticipantStatisticsList = + ProviderUtils.getJpaAndValidateList(inputParticipantStatistics.getStatisticsList(), + JpaParticipantStatistics::new, "Participant Statistics"); + + for (var participantStat : jpaParticipantStatisticsList) { + when(participantStatisticsRepository.getById(eq(participantStat.getKey()))).thenReturn(participantStat); + when(participantStatisticsRepository.findAllById(eq(List.of(participantStat.getKey())))) + .thenReturn(List.of(participantStat)); + } + + when(participantStatisticsRepository.getFiltered(eq(JpaParticipantStatistics.class), any())) + .thenReturn(List.of(jpaParticipantStatisticsList.get(0))); + + when(participantStatisticsRepository.saveAll(anyList())).thenReturn(jpaParticipantStatisticsList); + } + + @Test + void testParticipantStatisticsCreate() throws Exception { + assertThatThrownBy(() -> { + participantStatisticsProvider.createParticipantStatistics(null); + }).hasMessageMatching(LIST_IS_NULL); + + ParticipantStatisticsList createdStatsList = new ParticipantStatisticsList(); + createdStatsList.setStatisticsList(participantStatisticsProvider + .createParticipantStatistics(inputParticipantStatistics.getStatisticsList())); + + assertEquals(inputParticipantStatistics.toString().replaceAll("\\s+", ""), + createdStatsList.toString().replaceAll("\\s+", "")); + } + + @Test + void testGetAutomationCompositions() throws Exception { + // Return empty list when no data present in db + List getResponse = + participantStatisticsProvider.getParticipantStatistics(null, null, null); + assertThat(getResponse).isEmpty(); + + participantStatisticsProvider.createParticipantStatistics(inputParticipantStatistics.getStatisticsList()); + ToscaConceptIdentifier identifier = inputParticipantStatistics.getStatisticsList().get(0).getParticipantId(); + Instant instant = inputParticipantStatistics.getStatisticsList().get(0).getTimeStamp(); + assertEquals(1, participantStatisticsProvider + .getParticipantStatistics(identifier.getName(), identifier.getVersion(), instant).size()); + + assertEquals(1, participantStatisticsProvider + .getFilteredParticipantStatistics("name2", "1.0.1", null, null, null, "DESC", 1).size()); + } +} diff --git a/models/src/test/java/org/onap/policy/clamp/models/acm/persistence/provider/ServiceTemplateProviderTest.java b/models/src/test/java/org/onap/policy/clamp/models/acm/persistence/provider/ServiceTemplateProviderTest.java new file mode 100644 index 000000000..4d998717e --- /dev/null +++ b/models/src/test/java/org/onap/policy/clamp/models/acm/persistence/provider/ServiceTemplateProviderTest.java @@ -0,0 +1,169 @@ +/*- + * ============LICENSE_START======================================================= + * Copyright (C) 2021 Nordix Foundation. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * SPDX-License-Identifier: Apache-2.0 + * ============LICENSE_END========================================================= + */ + +package org.onap.policy.clamp.models.acm.persistence.provider; + +import static org.assertj.core.api.Assertions.assertThat; +import static org.assertj.core.api.Assertions.assertThatThrownBy; +import static org.junit.jupiter.api.Assertions.assertNotNull; +import static org.junit.jupiter.api.Assertions.fail; +import static org.mockito.ArgumentMatchers.any; +import static org.mockito.Mockito.mock; +import static org.mockito.Mockito.when; + +import java.util.List; +import java.util.Optional; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.Test; +import org.onap.policy.clamp.models.acm.persistence.repository.ToscaServiceTemplateRepository; +import org.onap.policy.common.utils.coder.CoderException; +import org.onap.policy.common.utils.coder.StandardYamlCoder; +import org.onap.policy.common.utils.resources.ResourceUtils; +import org.onap.policy.models.base.PfConceptKey; +import org.onap.policy.models.base.PfModelException; +import org.onap.policy.models.tosca.authorative.concepts.ToscaServiceTemplate; +import org.onap.policy.models.tosca.simple.concepts.JpaToscaServiceTemplate; + +class ServiceTemplateProviderTest { + + private static final String TOSCA_SERVICE_TEMPLATE_YAML = + "src/test/resources/providers/tosca-for-smoke-testing.yaml"; + + private static final StandardYamlCoder YAML_TRANSLATOR = new StandardYamlCoder(); + + private static ToscaServiceTemplate inputServiceTemplate; + + @BeforeAll + static void loadServiceTemplate() { + inputServiceTemplate = getToscaServiceTemplate(TOSCA_SERVICE_TEMPLATE_YAML); + } + + @Test + void testGetCommonOrInstancePropertiesFromNodeTypes() throws PfModelException { + var serviceTemplateRepository = mock(ToscaServiceTemplateRepository.class); + var serviceTemplateProvider = new ServiceTemplateProvider(serviceTemplateRepository); + + var result = serviceTemplateProvider.getCommonOrInstancePropertiesFromNodeTypes(true, inputServiceTemplate); + assertNotNull(result); + assertThat(result).hasSize(8); + } + + @Test + void testGetDerivedCommonOrInstanceNodeTemplates() throws PfModelException { + var serviceTemplateRepository = mock(ToscaServiceTemplateRepository.class); + var serviceTemplateProvider = new ServiceTemplateProvider(serviceTemplateRepository); + + var commonOrInstanceNodeTypeProps = + serviceTemplateProvider.getCommonOrInstancePropertiesFromNodeTypes(true, inputServiceTemplate); + + var result = serviceTemplateProvider.getDerivedCommonOrInstanceNodeTemplates( + inputServiceTemplate.getToscaTopologyTemplate().getNodeTemplates(), commonOrInstanceNodeTypeProps); + + assertNotNull(result); + assertThat(result).hasSize(8); + } + + @Test + void testCreateServiceTemplate() throws PfModelException { + var serviceTemplateRepository = mock(ToscaServiceTemplateRepository.class); + var serviceTemplateProvider = new ServiceTemplateProvider(serviceTemplateRepository); + + var jpaServiceTemplate = ProviderUtils.getJpaAndValidate(inputServiceTemplate, JpaToscaServiceTemplate::new, + "toscaServiceTemplate"); + when(serviceTemplateRepository.save(jpaServiceTemplate)).thenReturn(jpaServiceTemplate); + + var result = serviceTemplateProvider.createServiceTemplate(inputServiceTemplate); + + assertThat(result).isEqualTo(jpaServiceTemplate.toAuthorative()); + } + + @Test + void testDeleteServiceTemplate() throws PfModelException { + var jpaServiceTemplate = ProviderUtils.getJpaAndValidate(inputServiceTemplate, JpaToscaServiceTemplate::new, + "toscaServiceTemplate"); + var serviceTemplateRepository = mock(ToscaServiceTemplateRepository.class); + when(serviceTemplateRepository + .findById(new PfConceptKey(inputServiceTemplate.getName(), inputServiceTemplate.getVersion()))) + .thenReturn(Optional.of(jpaServiceTemplate)); + + var serviceTemplateProvider = new ServiceTemplateProvider(serviceTemplateRepository); + var result = serviceTemplateProvider.deleteServiceTemplate(inputServiceTemplate.getName(), + inputServiceTemplate.getVersion()); + + assertThat(result).isEqualTo(jpaServiceTemplate.toAuthorative()); + } + + @Test + void testGetServiceTemplateListEmpty() throws PfModelException { + var serviceTemplateRepository = mock(ToscaServiceTemplateRepository.class); + when(serviceTemplateRepository.findById(any())).thenReturn(Optional.empty()); + + var serviceTemplateProvider = new ServiceTemplateProvider(serviceTemplateRepository); + assertThatThrownBy(() -> serviceTemplateProvider.getToscaServiceTemplate("Name", "1.0.0")) + .hasMessage("Automation composition definitions not found"); + } + + @Test + void testGetServiceTemplateList() throws PfModelException { + var jpaServiceTemplate = ProviderUtils.getJpaAndValidate(inputServiceTemplate, JpaToscaServiceTemplate::new, + "toscaServiceTemplate"); + var serviceTemplateRepository = mock(ToscaServiceTemplateRepository.class); + when(serviceTemplateRepository + .findById(new PfConceptKey(inputServiceTemplate.getName(), inputServiceTemplate.getVersion()))) + .thenReturn(Optional.of(jpaServiceTemplate)); + + var serviceTemplateProvider = new ServiceTemplateProvider(serviceTemplateRepository); + var result = serviceTemplateProvider.getToscaServiceTemplate(inputServiceTemplate.getName(), + inputServiceTemplate.getVersion()); + + assertThat(result).isEqualTo(jpaServiceTemplate.toAuthorative()); + } + + @Test + void testGetServiceTemplate() throws PfModelException { + var jpaServiceTemplate = ProviderUtils.getJpaAndValidate(inputServiceTemplate, JpaToscaServiceTemplate::new, + "toscaServiceTemplate"); + var serviceTemplateRepository = mock(ToscaServiceTemplateRepository.class); + when(serviceTemplateRepository.getFiltered(JpaToscaServiceTemplate.class, inputServiceTemplate.getName(), + inputServiceTemplate.getVersion())).thenReturn(List.of(jpaServiceTemplate)); + + var serviceTemplateProvider = new ServiceTemplateProvider(serviceTemplateRepository); + var result = serviceTemplateProvider.getServiceTemplateList(inputServiceTemplate.getName(), + inputServiceTemplate.getVersion()); + + assertThat(result).hasSize(1); + assertThat(result.get(0)).isEqualTo(jpaServiceTemplate.toAuthorative()); + } + + /** + * Get ToscaServiceTemplate from resource. + * + * @param path path of the resource + */ + public static ToscaServiceTemplate getToscaServiceTemplate(String path) { + + try { + return YAML_TRANSLATOR.decode(ResourceUtils.getResourceAsStream(path), ToscaServiceTemplate.class); + } catch (CoderException e) { + fail("Cannot read or decode " + path); + return null; + } + } +} diff --git a/models/src/test/java/org/onap/policy/clamp/models/acm/persistence/repository/FilterRepositoryImplTest.java b/models/src/test/java/org/onap/policy/clamp/models/acm/persistence/repository/FilterRepositoryImplTest.java new file mode 100644 index 000000000..7210a6afd --- /dev/null +++ b/models/src/test/java/org/onap/policy/clamp/models/acm/persistence/repository/FilterRepositoryImplTest.java @@ -0,0 +1,109 @@ +/*- + * ============LICENSE_START======================================================= + * Copyright (C) 2021 Nordix Foundation. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * SPDX-License-Identifier: Apache-2.0 + * ============LICENSE_END========================================================= + */ + +package org.onap.policy.clamp.models.acm.persistence.repository; + +import static org.assertj.core.api.Assertions.assertThat; + +import java.util.List; +import java.util.concurrent.atomic.AtomicInteger; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; +import org.onap.policy.clamp.models.acm.concepts.AutomationCompositions; +import org.onap.policy.clamp.models.acm.persistence.concepts.JpaAutomationComposition; +import org.onap.policy.clamp.models.acm.persistence.provider.ProviderUtils; +import org.onap.policy.common.utils.coder.Coder; +import org.onap.policy.common.utils.coder.StandardCoder; +import org.onap.policy.common.utils.resources.ResourceUtils; +import org.onap.policy.models.dao.PfDao; +import org.onap.policy.models.dao.PfFilterParameters; +import org.onap.policy.models.provider.PolicyModelsProviderParameters; +import org.onap.policy.models.provider.impl.ModelsProvider; + +class FilterRepositoryImplTest { + private static final String AUTOMATION_COMPOSITION_JSON = + "src/test/resources/providers/TestAutomationCompositions.json"; + private static final Coder CODER = new StandardCoder(); + private static final AtomicInteger dbNameCounter = new AtomicInteger(); + private static final String originalJson = ResourceUtils.getResourceAsString(AUTOMATION_COMPOSITION_JSON); + private static List jpaAutomationCompositions; + private PfDao pfDao; + + @BeforeEach + void beforeSetupDao() throws Exception { + var parameters = new PolicyModelsProviderParameters(); + parameters.setDatabaseDriver("org.h2.Driver"); + parameters.setName("PolicyProviderParameterGroup"); + parameters.setImplementation("org.onap.policy.models.provider.impl.DatabasePolicyModelsProviderImpl"); + parameters.setDatabaseUrl("jdbc:h2:mem:automationCompositionProviderTestDb" + dbNameCounter.getAndDecrement()); + parameters.setDatabaseUser("policy"); + parameters.setDatabasePassword("P01icY"); + parameters.setPersistenceUnit("ToscaConceptTest"); + + pfDao = ModelsProvider.init(parameters); + var inputAutomationCompositions = CODER.decode(originalJson, AutomationCompositions.class); + jpaAutomationCompositions = + ProviderUtils.getJpaAndValidateList(inputAutomationCompositions.getAutomationCompositionList(), + JpaAutomationComposition::new, "AutomationCompositions"); + + pfDao.createCollection(jpaAutomationCompositions); + } + + @Test + void testGetPfDao() { + assertThat(new FilterRepositoryImpl().getPfDao()).isNotNull(); + } + + @Test + void testGetFilteredParams() { + var filterRepositoryImpl = new FilterRepositoryImpl() { + @Override + protected PfDao getPfDao() { + return pfDao; + } + }; + var result = filterRepositoryImpl.getFiltered(JpaAutomationComposition.class, null, null); + assertThat(result).hasSize(2); + + result = filterRepositoryImpl.getFiltered(JpaAutomationComposition.class, + jpaAutomationCompositions.get(0).getName(), null); + assertThat(result).hasSize(1); + } + + @Test + void testGetFiltered() { + var filterRepositoryImpl = new FilterRepositoryImpl() { + @Override + protected PfDao getPfDao() { + return pfDao; + } + }; + + // @formatter:off + PfFilterParameters filterParams = PfFilterParameters + .builder() + .name(jpaAutomationCompositions.get(0).getName()) + .build(); + // @formatter:on + + var result = filterRepositoryImpl.getFiltered(JpaAutomationComposition.class, filterParams); + assertThat(result).hasSize(1); + } +} diff --git a/models/src/test/java/org/onap/policy/clamp/models/acm/rest/RestUtilsTest.java b/models/src/test/java/org/onap/policy/clamp/models/acm/rest/RestUtilsTest.java new file mode 100644 index 000000000..a62f78ba2 --- /dev/null +++ b/models/src/test/java/org/onap/policy/clamp/models/acm/rest/RestUtilsTest.java @@ -0,0 +1,54 @@ +/*- + * ============LICENSE_START======================================================= + * Copyright (C) 2021 Nordix Foundation. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * SPDX-License-Identifier: Apache-2.0 + * ============LICENSE_END========================================================= + */ + +package org.onap.policy.clamp.models.acm.rest; + +import static org.assertj.core.api.Assertions.assertThat; + +import javax.ws.rs.core.Response.Status; +import org.junit.jupiter.api.Test; +import org.onap.policy.models.errors.concepts.ErrorResponse; +import org.onap.policy.models.errors.concepts.ErrorResponseInfo; + +class RestUtilsTest { + + private static final String MESSAGE_ERROR = "Erorr"; + private static final Status STATUS_ERROR = Status.BAD_REQUEST; + + @Test + void testToSimpleResponse() { + var ex = new ErrorResponseInfo() { + + @Override + public ErrorResponse getErrorResponse() { + var er = new ErrorResponse(); + er.setErrorMessage(MESSAGE_ERROR); + er.setResponseCode(STATUS_ERROR); + return er; + } + }; + + var response = RestUtils.toSimpleResponse(ex); + + assertThat(response.getStatusCodeValue()).isEqualTo(STATUS_ERROR.getStatusCode()); + assertThat(response.getBody()).isNotNull(); + assertThat(response.getBody().getErrorDetails()).isEqualTo(MESSAGE_ERROR); + } +} diff --git a/models/src/test/java/org/onap/policy/clamp/models/acm/utils/AcmUtilsTest.java b/models/src/test/java/org/onap/policy/clamp/models/acm/utils/AcmUtilsTest.java new file mode 100644 index 000000000..a5434240a --- /dev/null +++ b/models/src/test/java/org/onap/policy/clamp/models/acm/utils/AcmUtilsTest.java @@ -0,0 +1,149 @@ +/*- + * ============LICENSE_START======================================================= + * Copyright (C) 2021 Nordix Foundation. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * SPDX-License-Identifier: Apache-2.0 + * ============LICENSE_END========================================================= + */ + +package org.onap.policy.clamp.models.acm.utils; + +import static org.assertj.core.api.Assertions.assertThat; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNotEquals; + +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import org.junit.jupiter.api.Test; +import org.onap.policy.clamp.models.acm.concepts.AutomationCompositionElement; +import org.onap.policy.clamp.models.acm.concepts.ParticipantDefinition; +import org.onap.policy.clamp.models.acm.concepts.ParticipantUpdates; +import org.onap.policy.clamp.models.acm.concepts.ParticipantUtils; +import org.onap.policy.models.tosca.authorative.concepts.ToscaConceptIdentifier; +import org.onap.policy.models.tosca.authorative.concepts.ToscaDataType; +import org.onap.policy.models.tosca.authorative.concepts.ToscaNodeTemplate; +import org.onap.policy.models.tosca.authorative.concepts.ToscaPolicy; +import org.onap.policy.models.tosca.authorative.concepts.ToscaPolicyType; +import org.onap.policy.models.tosca.authorative.concepts.ToscaServiceTemplate; +import org.onap.policy.models.tosca.authorative.concepts.ToscaTopologyTemplate; + +class AcmUtilsTest { + + private ToscaConceptIdentifier id = new ToscaConceptIdentifier("id", "1.0.0"); + private ToscaConceptIdentifier idNode = + new ToscaConceptIdentifier("org.onap.dcae.acm.DCAEMicroserviceAutomationCompositionParticipant", "0.0.0"); + + @Test + void testCommonUtilsParticipantUpdate() { + var acElement = new AutomationCompositionElement(); + List participantUpdates = new ArrayList<>(); + assertThat(participantUpdates).isEmpty(); + + AcmUtils.prepareParticipantUpdate(acElement, participantUpdates); + assertThat(participantUpdates).isNotEmpty(); + assertEquals(acElement, participantUpdates.get(0).getAutomationCompositionElementList().get(0)); + + AcmUtils.prepareParticipantUpdate(acElement, participantUpdates); + assertNotEquals(id, participantUpdates.get(0).getParticipantId()); + + acElement.setParticipantId(id); + acElement.setParticipantType(id); + AcmUtils.prepareParticipantUpdate(acElement, participantUpdates); + assertEquals(id, participantUpdates.get(1).getParticipantId()); + } + + @Test + void testCommonUtilsServiceTemplate() { + var acElement = new AutomationCompositionElement(); + var toscaServiceTemplate = getDummyToscaServiceTemplate(); + AcmUtils.setServiceTemplatePolicyInfo(acElement, toscaServiceTemplate); + assertEquals(getDummyToscaDataTypeMap(), acElement.getToscaServiceTemplateFragment().getDataTypes()); + } + + @Test + void testCommonUtilsDefinitionUpdate() { + var toscaServiceTemplate = getDummyToscaServiceTemplate(); + List participantDefinitionUpdates = new ArrayList<>(); + assertThat(participantDefinitionUpdates).isEmpty(); + + checkParticipantDefinitionUpdate(toscaServiceTemplate, participantDefinitionUpdates); + assertThat(participantDefinitionUpdates).isNotEmpty(); + assertEquals(id, participantDefinitionUpdates.get(0).getParticipantType()); + + checkParticipantDefinitionUpdate(toscaServiceTemplate, participantDefinitionUpdates); + assertEquals(idNode, participantDefinitionUpdates.get(0).getAutomationCompositionElementDefinitionList().get(0) + .getAcElementDefinitionId()); + } + + private ToscaServiceTemplate getDummyToscaServiceTemplate() { + var toscaServiceTemplate = new ToscaServiceTemplate(); + var policyTypes = getDummyPolicyTypesMap(); + toscaServiceTemplate.setPolicyTypes(policyTypes); + + var dataTypes = getDummyToscaDataTypeMap(); + dataTypes.put("onap.datatypes.ToscaConceptIdentifier", new ToscaDataType()); + toscaServiceTemplate.setDataTypes(dataTypes); + + var toscaTopologyTemplate = new ToscaTopologyTemplate(); + Map policy = new HashMap<>(); + toscaTopologyTemplate.setPolicies(List.of(policy)); + var nodeTemplates = getDummyNodeTemplates(); + toscaTopologyTemplate.setNodeTemplates(nodeTemplates); + + toscaServiceTemplate.setToscaTopologyTemplate(toscaTopologyTemplate); + toscaServiceTemplate.setDerivedFrom("tosca.nodetypes.Root"); + toscaServiceTemplate.setDescription("description"); + toscaServiceTemplate.setMetadata(null); + toscaServiceTemplate.setName("name"); + toscaServiceTemplate.setToscaDefinitionsVersion("1.0.0"); + toscaServiceTemplate.setVersion("1.0.1"); + return toscaServiceTemplate; + } + + private Map getDummyPolicyTypesMap() { + Map policyTypes = new HashMap<>(); + policyTypes.put("onap.policies.Match", new ToscaPolicyType()); + return policyTypes; + } + + private Map getDummyToscaDataTypeMap() { + Map dataTypes = new HashMap<>(); + dataTypes.put("onap.datatypes.ToscaConceptIdentifier", new ToscaDataType()); + return dataTypes; + } + + private Map getDummyNodeTemplates() { + Map nodeTemplates = new HashMap<>(); + var nodeTemplate = new ToscaNodeTemplate(); + nodeTemplate.setType("org.onap.policy.clamp.acm.AutomationCompositionElement"); + nodeTemplates.put("org.onap.dcae.acm.DCAEMicroserviceAutomationCompositionParticipant", nodeTemplate); + return nodeTemplates; + } + + private void checkParticipantDefinitionUpdate(ToscaServiceTemplate toscaServiceTemplate, + List participantDefinitionUpdates) { + + for (Map.Entry toscaInputEntry : toscaServiceTemplate.getToscaTopologyTemplate() + .getNodeTemplates().entrySet()) { + if (ParticipantUtils.checkIfNodeTemplateIsAutomationCompositionElement(toscaInputEntry.getValue(), + toscaServiceTemplate)) { + AcmUtils.prepareParticipantDefinitionUpdate(id, toscaInputEntry.getKey(), toscaInputEntry.getValue(), + participantDefinitionUpdates, null); + } + } + } +} diff --git a/models/src/test/resources/META-INF/persistence.xml b/models/src/test/resources/META-INF/persistence.xml index 54495a2fe..9bd136229 100644 --- a/models/src/test/resources/META-INF/persistence.xml +++ b/models/src/test/resources/META-INF/persistence.xml @@ -52,11 +52,11 @@ org.onap.policy.models.tosca.simple.concepts.JpaToscaServiceTemplate org.onap.policy.models.tosca.simple.concepts.JpaToscaTopologyTemplate org.onap.policy.models.tosca.simple.concepts.JpaToscaTrigger - org.onap.policy.clamp.controlloop.models.controlloop.persistence.concepts.JpaControlLoop - org.onap.policy.clamp.controlloop.models.controlloop.persistence.concepts.JpaControlLoopElement - org.onap.policy.clamp.controlloop.models.controlloop.persistence.concepts.JpaParticipant - org.onap.policy.clamp.controlloop.models.controlloop.persistence.concepts.JpaParticipantStatistics - org.onap.policy.clamp.controlloop.models.controlloop.persistence.concepts.JpaClElementStatistics + org.onap.policy.clamp.models.acm.persistence.concepts.JpaAutomationComposition + org.onap.policy.clamp.models.acm.persistence.concepts.JpaAutomationCompositionElement + org.onap.policy.clamp.models.acm.persistence.concepts.JpaParticipant + org.onap.policy.clamp.models.acm.persistence.concepts.JpaParticipantStatistics + org.onap.policy.clamp.models.acm.persistence.concepts.JpaClElementStatistics diff --git a/models/src/test/resources/examples/acm/PMSubscriptionHandling.yaml b/models/src/test/resources/examples/acm/PMSubscriptionHandling.yaml new file mode 100644 index 000000000..c8796ac49 --- /dev/null +++ b/models/src/test/resources/examples/acm/PMSubscriptionHandling.yaml @@ -0,0 +1,3325 @@ +# ============LICENSE_START======================================================= +# Copyright (C) 2021 Nordix Foundation. +# ================================================================================ +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# SPDX-License-Identifier: Apache-2.0 +# ============LICENSE_END========================================================= +tosca_definitions_version: tosca_simple_yaml_1_3 +data_types: + onap.datatypes.ToscaConceptIdentifier: + derived_from: tosca.datatypes.Root + properties: + name: + type: string + required: true + version: + type: string + required: true + org.onap.datatypes.policy.clamp.acm.DCAEMicroserviceAutomationCompositionElementConsulInfo: + name: org.onap.datatypes.policy.clamp.acm.DCAEMicroserviceAutomationCompositionElementConsulInfo + version: 0.0.0 + derived_from: tosca.datatypes.Root + properties: + consulUrl: + name: consulUrl + type: string + typeVersion: 0.0.0 + description: Consul url for this entry + required: true + consul_body: + name: consulBody + type: string + typeVersion: 0.0.0 + description: Body of Consul entry + required: true + onap.datatypes.monitoring.managedObjectDNsBasic: + constraints: [] + properties: + DN: + name: DN + type: string + typeVersion: 0.0.0 + description: Managed object distinguished name + required: true + constraints: [] + metadata: {} + name: onap.datatypes.monitoring.managedObjectDNsBasic + version: 0.0.0 + derived_from: tosca.datatypes.Root + metadata: {} + onap.datatypes.monitoring.managedObjectDNsBasics: + constraints: [] + properties: + managedObjectDNsBasic: + name: managedObjectDNsBasic + type: map + typeVersion: 0.0.0 + description: Managed object distinguished name object + required: true + constraints: [] + entry_schema: + type: onap.datatypes.monitoring.managedObjectDNsBasic + typeVersion: 0.0.0 + constraints: [] + metadata: {} + name: onap.datatypes.monitoring.managedObjectDNsBasics + version: 0.0.0 + derived_from: tosca.datatypes.Root + metadata: {} + onap.datatypes.monitoring.measurementGroup: + constraints: [] + properties: + measurementTypes: + name: measurementTypes + type: list + typeVersion: 0.0.0 + description: List of measurement types + required: true + constraints: [] + entry_schema: + type: onap.datatypes.monitoring.measurementTypes + typeVersion: 0.0.0 + constraints: [] + metadata: {} + managedObjectDNsBasic: + name: managedObjectDNsBasic + type: list + typeVersion: 0.0.0 + description: List of managed object distinguished names + required: true + constraints: [] + entry_schema: + type: onap.datatypes.monitoring.managedObjectDNsBasics + typeVersion: 0.0.0 + constraints: [] + metadata: {} + name: onap.datatypes.monitoring.measurementGroup + version: 0.0.0 + derived_from: tosca.datatypes.Root + metadata: {} + onap.datatypes.monitoring.measurementGroups: + constraints: [] + properties: + measurementGroup: + name: measurementGroup + type: map + typeVersion: 0.0.0 + description: Measurement Group + required: true + constraints: [] + entry_schema: + type: onap.datatypes.monitoring.measurementGroup + typeVersion: 0.0.0 + constraints: [] + metadata: {} + name: onap.datatypes.monitoring.measurementGroups + version: 0.0.0 + derived_from: tosca.datatypes.Root + metadata: {} + onap.datatypes.monitoring.measurementType: + constraints: [] + properties: + measurementType: + name: measurementType + type: string + typeVersion: 0.0.0 + description: Measurement type + required: true + constraints: [] + metadata: {} + name: onap.datatypes.monitoring.measurementType + version: 0.0.0 + derived_from: tosca.datatypes.Root + metadata: {} + onap.datatypes.monitoring.measurementTypes: + constraints: [] + properties: + measurementType: + name: measurementType + type: map + typeVersion: 0.0.0 + description: Measurement type object + required: true + constraints: [] + entry_schema: + type: onap.datatypes.monitoring.measurementType + typeVersion: 0.0.0 + constraints: [] + metadata: {} + name: onap.datatypes.monitoring.measurementTypes + version: 0.0.0 + derived_from: tosca.datatypes.Root + metadata: {} + onap.datatypes.monitoring.nfFilter: + constraints: [] + properties: + modelNames: + name: modelNames + type: list + typeVersion: 0.0.0 + description: List of model names + required: true + constraints: [] + entry_schema: + type: string + typeVersion: 0.0.0 + constraints: [] + metadata: {} + modelInvariantIDs: + name: modelInvariantIDs + type: list + typeVersion: 0.0.0 + description: List of model invariant IDs + required: true + constraints: [] + entry_schema: + type: string + typeVersion: 0.0.0 + constraints: [] + metadata: {} + modelVersionIDs: + name: modelVersionIDs + type: list + typeVersion: 0.0.0 + description: List of model version IDs + required: true + constraints: [] + entry_schema: + type: string + typeVersion: 0.0.0 + constraints: [] + metadata: {} + nfNames: + name: nfNames + type: list + typeVersion: 0.0.0 + description: List of network functions + required: true + constraints: [] + entry_schema: + type: string + typeVersion: 0.0.0 + constraints: [] + metadata: {} + name: onap.datatypes.monitoring.nfFilter + version: 0.0.0 + derived_from: tosca.datatypes.Root + metadata: {} + onap.datatypes.monitoring.subscription: + constraints: [] + properties: + measurementGroups: + name: measurementGroups + type: list + typeVersion: 0.0.0 + description: Measurement Groups + required: true + constraints: [] + entry_schema: + type: onap.datatypes.monitoring.measurementGroups + typeVersion: 0.0.0 + constraints: [] + metadata: {} + fileBasedGP: + name: fileBasedGP + type: integer + typeVersion: 0.0.0 + description: File based granularity period + required: true + constraints: [] + metadata: {} + fileLocation: + name: fileLocation + type: string + typeVersion: 0.0.0 + description: ROP file location + required: true + constraints: [] + metadata: {} + subscriptionName: + name: subscriptionName + type: string + typeVersion: 0.0.0 + description: Name of the subscription + required: true + constraints: [] + metadata: {} + administrativeState: + name: administrativeState + type: string + typeVersion: 0.0.0 + description: State of the subscription + required: true + constraints: + - valid_values: + - LOCKED + - UNLOCKED + metadata: {} + nfFilter: + name: nfFilter + type: map + typeVersion: 0.0.0 + description: Network function filter + required: true + constraints: [] + entry_schema: + type: onap.datatypes.monitoring.nfFilter + typeVersion: 0.0.0 + constraints: [] + metadata: {} + name: onap.datatypes.monitoring.subscription + version: 0.0.0 + derived_from: tosca.datatypes.Root + metadata: {} +policy_types: + onap.policies.Monitoring: + derived_from: tosca.policies.Root + description: a base policy type for all policies that govern monitoring provisioning + version: 1.0.0 + name: onap.policies.Monitoring + onap.policies.monitoring.dcae-pm-subscription-handler: + properties: + pmsh_policy: + name: pmsh_policy + type: onap.datatypes.monitoring.subscription + typeVersion: 0.0.0 + description: PMSH Policy JSON + required: false + constraints: [] + metadata: {} + name: onap.policies.monitoring.dcae-pm-subscription-handler + version: 1.0.0 + derived_from: onap.policies.Monitoring + metadata: {} +node_types: + org.onap.policy.clamp.acm.Participant: + version: 1.0.1 + derived_from: tosca.nodetypes.Root + properties: + provider: + type: string + required: false + org.onap.policy.clamp.acm.AutomationCompositionElement: + version: 1.0.1 + derived_from: tosca.nodetypes.Root + properties: + provider: + type: string + required: false + participantType: + type: onap.datatypes.ToscaConceptIdentifier + required: true + startPhase: + type: integer + required: false + constraints: + - greater-or-equal: 0 + metadata: + common: true + description: A value indicating the start phase in which this automation composition element will be started, + the first start phase is zero. Automation composition elements are started in their start_phase + order and stopped in reverse start phase order. Automation composition elements with the same start + phase are started and stopped simultaneously + org.onap.policy.clamp.acm.AutomationComposition: + version: 1.0.1 + derived_from: tosca.nodetypes.Root + properties: + provider: + type: string + required: false + elements: + type: list + required: true + entry_schema: + type: onap.datatypes.ToscaConceptIdentifier + org.onap.policy.clamp.acm.DCAEMicroserviceAutomationCompositionElement: + version: 1.0.1 + derived_from: org.onap.policy.clamp.acm.AutomationCompositionElement + properties: + dcae_blueprint_id: + type: onap.datatypes.ToscaConceptIdentifier + required: false + dcae_blueprint: + type: onap.dcae.cloudify_blueprint + required: false + consul_info: + type: list + required: false + entry_schema: + type: org.onap.datatypes.policy.clamp.acm.DCAEMicroserviceAutomationCompositionElementConsulInfo + org.onap.policy.clamp.acm.PolicyAutomationCompositionElement: + version: 1.0.1 + derived_from: org.onap.policy.clamp.acm.AutomationCompositionElement + properties: + policy_type_id: + type: onap.datatypes.ToscaConceptIdentifier + required: true + policy_id: + type: onap.datatypes.ToscaConceptIdentifier + required: false + org.onap.policy.clamp.acm.CDSAutomationCompositionElement: + version: 1.0.1 + derived_from: org.onap.policy.clamp.acm.AutomationCompositionElement + properties: + cds_blueprint_id: + type: onap.datatypes.ToscaConceptIdentifier + required: true +topology_template: + inputs: + pmsh_monitoring_policy: + type: onap.datatypes.ToscaConceptIdentifier + description: The ID of the PMSH monitoring policy to use + default: + name: MICROSERVICE_vLoadBalancerMS_v1_0_dcae-pm-subscription-handler_1_0_0test + version: 1.0.0 + pmsh_operational_policy: + type: onap.datatypes.ToscaConceptIdentifier + description: The ID of the PMSH operational policy to use + default: + name: operational.apex.pmcontrol + version: 1.0.0 + node_templates: + org.onap.dcae.acm.DCAEMicroserviceAutomationCompositionParticipant: + version: 2.3.4 + type: org.onap.policy.clamp.acm.Participant + type_version: 1.0.1 + description: Participant for DCAE microservices + properties: + provider: ONAP + org.onap.policy.acm.PolicyAutomationCompositionParticipant: + version: 2.3.1 + type: org.onap.policy.clamp.acm.Participant + type_version: 1.0.1 + description: Participant for DCAE microservices + properties: + provider: ONAP + org.onap.ccsdk.cds.acm.CdsAutomationCompositionParticipant: + version: 2.2.1 + type: org.onap.policy.clamp.acm.Participant + type_version: 1.0.1 + description: Participant for DCAE microservices + properties: + provider: ONAP + org.onap.domain.pmsh.PMSH_DCAEMicroservice: + version: 1.2.3 + type: org.onap.policy.clamp.acm.DCAEMicroserviceAutomationCompositionElement + type_version: 1.0.0 + description: Automation composition element for the DCAE microservice for Performance Management Subscription Handling + properties: + provider: Ericsson + participantType: + name: org.onap.dcae.acm.DCAEMicroserviceAutomationCompositionParticipant + version: 2.3.4 + dcae_blueprint: + tosca_definitions_version: cloudify_dsl_1_3 + imports: + - https://www.getcloudify.org/spec/cloudify/4.5.5/types.yaml + - plugin:k8splugin?version=3.7.0 + - plugin:pgaas?version=1.3.0 + - plugin:clamppolicyplugin?version=1.1.0 + inputs: + tag_version: + type: string + description: Docker image to be used + default: nexus3.onap.org:10001/onap/org.onap.dcaegen2.services.pmsh:1.1.2 + replicas: + type: integer + description: Number of instances + default: 1 + operational_policy_name: + type: string + default: operational.apex.pmcontrol + control_loop_name: + type: string + default: pmsh-control-loop + pmsh_publish_topic_name: + type: string + default: unauthenticated.DCAE_CL_OUTPUT + policy_feedback_topic_name: + type: string + default: unauthenticated.PMSH_CL_INPUT + aai_notification_topic_name: + type: string + default: AAI-EVENT + publisher_client_role: + type: string + description: Client role to request secure access to topic + default: org.onap.dcae.pmPublisher + subscriber_client_role: + type: string + description: Client role to request secure access to topic + default: org.onap.dcae.pmSubscriber + dcae_location: + type: string + description: DCAE location for the subscriber, used to set up routing + default: san-francisco + cpu_limit: + type: string + default: 1000m + cpu_request: + type: string + default: 1000m + memory_limit: + type: string + default: 1024Mi + memory_request: + type: string + default: 1024Mi + pgaas_cluster_name: + type: string + default: dcae-pg-primary.onap + enable_tls: + type: boolean + default: true + protocol: + type: string + description: PMSH protocol. If enable_tls is false, set to http + default: https + policy_model_id: + type: string + default: onap.policies.monitoring.dcae-pm-subscription-handler + policy_id: + type: string + default: MICROSERVICE_vLoadBalancerMS_v1_0_dcae-pm-subscription-handler_1_0_0test + node_templates: + pgaasvm: + type: dcae.nodes.pgaas.database + properties: + writerfqdn: + get_input: pgaas_cluster_name + name: pmsh + pmsh: + type: dcae.nodes.ContainerizedServiceComponentUsingDmaap + interfaces: + cloudify.interfaces.lifecycle: + create: + inputs: + ports: + - '8443:0' + envs: + PMSH_PG_URL: + get_attribute: + - pgaasvm + - admin + - host + PMSH_PG_PASSWORD: + get_attribute: + - pgaasvm + - admin + - password + PMSH_PG_USERNAME: + get_attribute: + - pgaasvm + - admin + - user + PMSH_DB_NAME: + get_attribute: + - pgaasvm + - admin + - database + relationships: + - target: pmsh-policy + type: cloudify.relationships.depends_on + properties: + service_component_type: dcae-pmsh + service_component_name_override: dcae-pmsh + application_config: + enable_tls: + get_input: enable_tls + aaf_identity: dcae@dcae.onap.org + aaf_password: demo123456! + operational_policy_name: + get_input: operational_policy_name + control_loop_name: + get_input: control_loop_name + cert_path: /opt/app/pmsh/etc/certs/cert.pem + key_path: /opt/app/pmsh/etc/certs/key.pem + ca_cert_path: /opt/app/pmsh/etc/certs/cacert.pem + streams_publishes: + policy_pm_publisher: + type: message_router + dmaap_info: + topic_url: + concat: + - http://message-router:3904/events/ + - get_input: pmsh_publish_topic_name + streams_subscribes: + policy_pm_subscriber: + type: message_router + dmaap_info: + topic_url: + concat: + - http://message-router:3904/events/ + - get_input: policy_feedback_topic_name + aai_subscriber: + type: message_router + dmaap_info: + topic_url: + concat: + - http://message-router:3904/events/ + - get_input: aai_notification_topic_name + resource_config: + limits: + cpu: + get_input: cpu_limit + memory: + get_input: memory_limit + requests: + cpu: + get_input: cpu_request + memory: + get_input: memory_request + docker_config: + healthcheck: + endpoint: /healthcheck + interval: 15s + timeout: 1s + type: + get_input: protocol + image: + get_input: tag_version + replicas: + get_input: replicas + log_info: + log_directory: /var/log/ONAP/dcaegen2/services/pmsh + tls_info: + cert_directory: /opt/app/pmsh/etc/certs + use_tls: + get_input: enable_tls + pmsh-policy: + type: clamp.nodes.policy + properties: + policy_model_id: + get_input: policy_model_id + policy_id: + get_input: policy_id + consul_info: + - consulUrl: http://consul:31321/v1/kv/dcae-pmsh:policy + consulBody: + subscription: + subscriptionName: subscriptiona + administrativeState: UNLOCKED + fileBasedGP: 15 + fileLocation: /pm/pm.xml + nfFilter: + nfNames: + - ^pnf1.* + modelInvariantIDs: + - 5845y423-g654-6fju-po78-8n53154532k6 + - 7129e420-d396-4efb-af02-6b83499b12f8 + modelVersionIDs: + - e80a6ae3-cafd-4d24-850d-e14c084a5ca9 + measurementGroups: + - measurementGroup: + measurementTypes: + - measurementType: countera + - measurementType: counterb + managedObjectDNsBasic: + - DN: dna + - DN: dnb + - measurementGroup: + measurementTypes: + - measurementType: counterc + - measurementType: counterd + managedObjectDNsBasic: + - DN: dnc + - DN: dnd + org.onap.domain.pmsh.PMSH_MonitoringPolicyAutomationCompositionElement: + version: 1.2.3 + type: org.onap.policy.clamp.acm.PolicyAutomationCompositionElement + type_version: 1.0.0 + description: Automation composition element for the monitoring policy for Performance Management Subscription Handling + properties: + provider: Ericsson + participantType: + name: org.onap.policy.acm.PolicyAutomationCompositionParticipant + version: 2.3.1 + policy_type_id: + name: onap.policies.monitoring.pm-subscription-handler + version: 1.0.0 + policy_id: + get_input: pmsh_monitoring_policy + org.onap.domain.pmsh.PMSH_OperationalPolicyAutomationCompositionElement: + version: 1.2.3 + type: org.onap.policy.clamp.acm.PolicyAutomationCompositionElement + type_version: 1.0.0 + description: Automation composition element for the operational policy for Performance Management Subscription Handling + properties: + provider: Ericsson + participantType: + name: org.onap.policy.acm.PolicyAutomationCompositionParticipant + version: 2.2.1 + policy_type_id: + name: onap.policies.operational.pm-subscription-handler + version: 1.0.0 + policy_id: + get_input: pmsh_operational_policy + org.onap.domain.pmsh.PMSH_CDS_AutomationCompositionElement: + version: 1.2.3 + type: org.onap.policy.clamp.acm.CDSAutomationCompositionElement + type_version: 1.0.0 + description: Automation composition element for CDS for Performance Management Subscription Handling + properties: + provider: Ericsson + participantType: + name: org.onap.ccsdk.cds.acm.CdsAutomationCompositionParticipant + version: 3.2.1 + cds_blueprint_id: + name: org.onap.ccsdk.cds.PMSHCdsBlueprint + version: 1.0.0 + org.onap.domain.pmsh.PMSHAutomationCompositionDefinition: + version: 1.2.3 + type: org.onap.policy.clamp.acm.AutomationComposition + type_version: 1.0.0 + description: Automation composition for Performance Management Subscription Handling + properties: + provider: Ericsson + elements: + - name: org.onap.domain.pmsh.PMSH_DCAEMicroservice + version: 1.2.3 + - name: org.onap.domain.pmsh.PMSH_MonitoringPolicyAutomationCompositionElement + version: 1.2.3 + - name: org.onap.domain.pmsh.PMSH_OperationalPolicyAutomationCompositionElement + version: 1.2.3 + - name: org.onap.domain.pmsh.PMSH_CDS_AutomationCompositionElement + version: 1.2.3 + policies: + - MICROSERVICE_vLoadBalancerMS_v1_0_dcae-pm-subscription-handler_1_0_0test: + type: onap.policies.monitoring.dcae-pm-subscription-handler + type_version: 1.0.0 + name: MICROSERVICE_vLoadBalancerMS_v1_0_dcae-pm-subscription-handler_1_0_0test + version: 1.0.0 + metadata: + policy-id: MICROSERVICE_vLoadBalancerMS_v1_0_dcae-pm-subscription-handler_1_0_0test + policy-version: 1.0.0 + properties: + pmsh_policy: + fileBasedGP: 15 + fileLocation: /pm/pm.xml + subscriptionName: subscriptiona + administrativeState: UNLOCKED + nfFilter: + onap.datatypes.monitoring.nfFilter: + modelVersionIDs: + - e80a6ae3-cafd-4d24-850d-e14c084a5ca9 + modelInvariantIDs: + - 5845y423-g654-6fju-po78-8n53154532k6 + - 7129e420-d396-4efb-af02-6b83499b12f8 + modelNames: [] + nfNames: + - '"^pnf1.*"' + measurementGroups: + - measurementGroup: + onap.datatypes.monitoring.measurementGroup: + measurementTypes: + - measurementType: + onap.datatypes.monitoring.measurementType: + measurementType: countera + - measurementType: + onap.datatypes.monitoring.measurementType: + measurementType: counterb + managedObjectDNsBasic: + - managedObjectDNsBasic: + onap.datatypes.monitoring.managedObjectDNsBasic: + DN: dna + - managedObjectDNsBasic: + onap.datatypes.monitoring.managedObjectDNsBasic: + DN: dnb + - measurementGroup: + onap.datatypes.monitoring.measurementGroup: + measurementTypes: + - measurementType: + onap.datatypes.monitoring.measurementType: + measurementType: counterc + - measurementType: + onap.datatypes.monitoring.measurementType: + measurementType: counterd + managedObjectDNsBasic: + - managedObjectDNsBasic: + onap.datatypes.monitoring.managedObjectDNsBasic: + DN: dnc + - managedObjectDNsBasic: + onap.datatypes.monitoring.managedObjectDNsBasic: + DN: dnd + - operational.apex.pmcontrol: + type: onap.policies.acm.operational.common.Apex + type_version: 1.0.0 + version: 1.0.0 + metadata: + policy-id: operational.apex.pmcontrol + policy-version: 1 + properties: + engineServiceParameters: + name: MyApexEngine + version: 0.0.1 + id: 45 + instanceCount: 2 + deploymentPort: 12561 + policy_type_impl: + apexPolicyModel: + key: + name: PMControlPolicy + version: 0.0.1 + keyInformation: + key: + name: PMControlPolicy_KeyInfo + version: 0.0.1 + keyInfoMap: + entry: + - key: + name: CDSActionIdentifiersType + version: 0.0.1 + value: + key: + name: CDSActionIdentifiersType + version: 0.0.1 + UUID: 6e5fa19b-14df-37e3-a4ae-8c537e861a82 + description: Generated description for concept referred to by key "CDSActionIdentifiersType:0.0.1" + - key: + name: CDSCreateResponseEvent + version: 0.0.1 + value: + key: + name: CDSCreateResponseEvent + version: 0.0.1 + UUID: 14b29e38-ac75-3273-aa4e-8583c0aa7dad + description: Generated description for concept referred to by key "CDSCreateResponseEvent:0.0.1" + - key: + name: CDSCreateResponsePayloadType + version: 0.0.1 + value: + key: + name: CDSCreateResponsePayloadType + version: 0.0.1 + UUID: 04573f8f-e772-30a5-b1d9-d7318d4a1e13 + description: Generated description for concept referred to by key "CDSCreateResponsePayloadType:0.0.1" + - key: + name: CDSCreateResponsePolicy + version: 0.0.1 + value: + key: + name: CDSCreateResponsePolicy + version: 0.0.1 + UUID: e126c965-fc09-3bfe-8f55-70f380a4a49c + description: Generated description for concept referred to by key "CDSCreateResponsePolicy:0.0.1" + - key: + name: CDSCreateResponseTask + version: 0.0.1 + value: + key: + name: CDSCreateResponseTask + version: 0.0.1 + UUID: 6165ee82-afd2-3aab-a517-f00b3f2461d2 + description: Generated description for concept referred to by key "CDSCreateResponseTask:0.0.1" + - key: + name: CDSCreateSubscriptionPayloadType + version: 0.0.1 + value: + key: + name: CDSCreateSubscriptionPayloadType + version: 0.0.1 + UUID: 8350ac5e-c157-38b9-9614-a0f93a830e60 + description: Generated description for concept referred to by key "CDSCreateSubscriptionPayloadType:0.0.1" + - key: + name: CDSCreateSubscriptionRequestEvent + version: 0.0.1 + value: + key: + name: CDSCreateSubscriptionRequestEvent + version: 0.0.1 + UUID: cfa325ba-226b-3a31-9183-ec43e2b6e9a2 + description: Generated description for concept referred to by key "CDSCreateSubscriptionRequestEvent:0.0.1" + - key: + name: CDSDeleteResponseEvent + version: 0.0.1 + value: + key: + name: CDSDeleteResponseEvent + version: 0.0.1 + UUID: 8be9c0fa-7437-3841-aff2-b3cec6ae3bd8 + description: Generated description for concept referred to by key "CDSDeleteResponseEvent:0.0.1" + - key: + name: CDSDeleteResponsePayloadType + version: 0.0.1 + value: + key: + name: CDSDeleteResponsePayloadType + version: 0.0.1 + UUID: 3fbfe0c9-152e-34d3-a504-09cd13c058d0 + description: Generated description for concept referred to by key "CDSDeleteResponsePayloadType:0.0.1" + - key: + name: CDSDeleteResponsePolicy + version: 0.0.1 + value: + key: + name: CDSDeleteResponsePolicy + version: 0.0.1 + UUID: a780251c-edd5-3132-b865-04313246b43c + description: Generated description for concept referred to by key "CDSDeleteResponsePolicy:0.0.1" + - key: + name: CDSDeleteResponseTask + version: 0.0.1 + value: + key: + name: CDSDeleteResponseTask + version: 0.0.1 + UUID: afce4555-3aa3-3521-a7d8-ee8cdf0d3efc + description: Generated description for concept referred to by key "CDSDeleteResponseTask:0.0.1" + - key: + name: CDSDeleteSubscriptionPayloadType + version: 0.0.1 + value: + key: + name: CDSDeleteSubscriptionPayloadType + version: 0.0.1 + UUID: 12658406-9147-3c9d-a38c-5ad5e30b092b + description: Generated description for concept referred to by key "CDSDeleteSubscriptionPayloadType:0.0.1" + - key: + name: CDSDeleteSubscriptionRequestEvent + version: 0.0.1 + value: + key: + name: CDSDeleteSubscriptionRequestEvent + version: 0.0.1 + UUID: 24380c95-9289-36e6-8cbf-0edefa15ccd9 + description: Generated description for concept referred to by key "CDSDeleteSubscriptionRequestEvent:0.0.1" + - key: + name: CDSRequestCommonHeaderType + version: 0.0.1 + value: + key: + name: CDSRequestCommonHeaderType + version: 0.0.1 + UUID: 35590ac0-062c-39f1-8786-b4ff716e30b1 + description: Generated description for concept referred to by key "CDSRequestCommonHeaderType:0.0.1" + - key: + name: CDSResponseCommonHeaderType + version: 0.0.1 + value: + key: + name: CDSResponseCommonHeaderType + version: 0.0.1 + UUID: dd7e1805-885a-350b-aaf9-ed541321ae3c + description: Generated description for concept referred to by key "CDSResponseCommonHeaderType:0.0.1" + - key: + name: CDSResponseStatusEvent + version: 0.0.1 + value: + key: + name: CDSResponseStatusEvent + version: 0.0.1 + UUID: 7986e21b-32f7-302e-9554-31f21b673493 + description: Generated description for concept referred to by key "CDSResponseStatusEvent:0.0.1" + - key: + name: CDSResponseStatusType + version: 0.0.1 + value: + key: + name: CDSResponseStatusType + version: 0.0.1 + UUID: 92b8a2cf-344e-3ce1-8cc0-2b7d3cb695fa + description: Generated description for concept referred to by key "CDSResponseStatusType:0.0.1" + - key: + name: CreateSubscriptionPayloadEvent + version: 0.0.1 + value: + key: + name: CreateSubscriptionPayloadEvent + version: 0.0.1 + UUID: 92162397-1a8e-3a3f-a469-d2af7700af4a + description: Generated description for concept referred to by key "CreateSubscriptionPayloadEvent:0.0.1" + - key: + name: CreateSubscriptionPayloadTask + version: 0.0.1 + value: + key: + name: CreateSubscriptionPayloadTask + version: 0.0.1 + UUID: bc0c69f0-52ed-38ea-b468-ae4a6fd1730d + description: Generated description for concept referred to by key "CreateSubscriptionPayloadTask:0.0.1" + - key: + name: CreateSubscriptionRequestTask + version: 0.0.1 + value: + key: + name: CreateSubscriptionRequestTask + version: 0.0.1 + UUID: 89cb75e9-f06c-30d3-b4ff-698d45f63869 + description: Generated description for concept referred to by key "CreateSubscriptionRequestTask:0.0.1" + - key: + name: DeleteSubscriptionPayloadEvent + version: 0.0.1 + value: + key: + name: DeleteSubscriptionPayloadEvent + version: 0.0.1 + UUID: 994fa441-04ab-33bb-832d-1cd12ab5d074 + description: Generated description for concept referred to by key "DeleteSubscriptionPayloadEvent:0.0.1" + - key: + name: DeleteSubscriptionPayloadTask + version: 0.0.1 + value: + key: + name: DeleteSubscriptionPayloadTask + version: 0.0.1 + UUID: 0f519117-5fea-3e4b-941f-8f778100465f + description: Generated description for concept referred to by key "DeleteSubscriptionPayloadTask:0.0.1" + - key: + name: DeleteSubscriptionRequestTask + version: 0.0.1 + value: + key: + name: DeleteSubscriptionRequestTask + version: 0.0.1 + UUID: acb772fe-d442-39e3-98f9-b1080caf4150 + description: Generated description for concept referred to by key "DeleteSubscriptionRequestTask:0.0.1" + - key: + name: MRResponseEvent + version: 0.0.1 + value: + key: + name: MRResponseEvent + version: 0.0.1 + UUID: 13c747a3-6bae-3bcf-9c80-b152e01dc194 + description: Generated description for concept referred to by key "MRResponseEvent:0.0.1" + - key: + name: PMControlPolicy + version: 0.0.1 + value: + key: + name: PMControlPolicy + version: 0.0.1 + UUID: acf1e55c-7bc5-3bd5-975a-0ca54afcd8a4 + description: Generated description for concept referred to by key "PMControlPolicy:0.0.1" + - key: + name: PMControlPolicy_Albums + version: 0.0.1 + value: + key: + name: PMControlPolicy_Albums + version: 0.0.1 + UUID: b38ad204-c2c8-32f4-9b5a-dda0aeb0145b + description: Generated description for concept referred to by key "PMControlPolicy_Albums:0.0.1" + - key: + name: PMControlPolicy_Events + version: 0.0.1 + value: + key: + name: PMControlPolicy_Events + version: 0.0.1 + UUID: be3871a0-c42a-3113-a066-82d192840eca + description: Generated description for concept referred to by key "PMControlPolicy_Events:0.0.1" + - key: + name: PMControlPolicy_KeyInfo + version: 0.0.1 + value: + key: + name: PMControlPolicy_KeyInfo + version: 0.0.1 + UUID: ced37634-28a4-3178-b7f6-2980794927b0 + description: Generated description for concept referred to by key "PMControlPolicy_KeyInfo:0.0.1" + - key: + name: PMControlPolicy_Policies + version: 0.0.1 + value: + key: + name: PMControlPolicy_Policies + version: 0.0.1 + UUID: be3d180d-ef9c-3a75-8e9c-84271a038bed + description: Generated description for concept referred to by key "PMControlPolicy_Policies:0.0.1" + - key: + name: PMControlPolicy_Schemas + version: 0.0.1 + value: + key: + name: PMControlPolicy_Schemas + version: 0.0.1 + UUID: e61973f1-189c-39e5-82f6-0d3afe298a20 + description: Generated description for concept referred to by key "PMControlPolicy_Schemas:0.0.1" + - key: + name: PMControlPolicy_Tasks + version: 0.0.1 + value: + key: + name: PMControlPolicy_Tasks + version: 0.0.1 + UUID: 5658adb3-2962-30a3-a241-fae75bb8eb4a + description: Generated description for concept referred to by key "PMControlPolicy_Tasks:0.0.1" + - key: + name: PMSubscriptionAlbum + version: 0.0.1 + value: + key: + name: PMSubscriptionAlbum + version: 0.0.1 + UUID: c2bd6f0d-6854-317a-9be2-97c08338428c + description: Generated description for concept referred to by key "PMSubscriptionAlbum:0.0.1" + - key: + name: PMSubscriptionOutputEvent + version: 0.0.1 + value: + key: + name: PMSubscriptionOutputEvent + version: 0.0.1 + UUID: 992b7819-9f69-3aa0-bb0f-6e45ea15ce05 + description: Generated description for concept referred to by key "PMSubscriptionOutputEvent:0.0.1" + - key: + name: PMSubscriptionType + version: 0.0.1 + value: + key: + name: PMSubscriptionType + version: 0.0.1 + UUID: 73c1c397-4fc3-357f-93b6-a8ad707fbaae + description: Generated description for concept referred to by key "PMSubscriptionType:0.0.1" + - key: + name: ReceiveEventPolicy + version: 0.0.1 + value: + key: + name: ReceiveEventPolicy + version: 0.0.1 + UUID: 568b7345-9de1-36d3-b6a3-9b857e6809a1 + description: Generated description for concept referred to by key "ReceiveEventPolicy:0.0.1" + - key: + name: ReceiveSubscriptionTask + version: 0.0.1 + value: + key: + name: ReceiveSubscriptionTask + version: 0.0.1 + UUID: f596afc8-100c-35eb-92c8-352355ea457d + description: Generated description for concept referred to by key "ReceiveSubscriptionTask:0.0.1" + - key: + name: SimpleIntType + version: 0.0.1 + value: + key: + name: SimpleIntType + version: 0.0.1 + UUID: 153791fd-ae0a-36a7-88a5-309a7936415d + description: Generated description for concept referred to by key "SimpleIntType:0.0.1" + - key: + name: SimpleStringType + version: 0.0.1 + value: + key: + name: SimpleStringType + version: 0.0.1 + UUID: 8a4957cf-9493-3a76-8c22-a208e23259af + description: Generated description for concept referred to by key "SimpleStringType:0.0.1" + - key: + name: SubscriptionStatusType + version: 0.0.1 + value: + key: + name: SubscriptionStatusType + version: 0.0.1 + UUID: 597643b1-9db1-31ce-85d0-e1c63c43b30b + description: Generated description for concept referred to by key "SubscriptionStatusType:0.0.1" + - key: + name: SubscriptionType + version: 0.0.1 + value: + key: + name: SubscriptionType + version: 0.0.1 + UUID: 184547bb-7d64-3cb2-a273-d7185102c5ce + description: Generated description for concept referred to by key "SubscriptionType:0.0.1" + - key: + name: UUIDType + version: 0.0.1 + value: + key: + name: UUIDType + version: 0.0.1 + UUID: 6a8cc68e-dfc8-3403-9c6d-071c886b319c + description: Generated description for concept referred to by key "UUIDType:0.0.1" + - key: + name: pmsh-operational-policy + version: 0.0.1 + value: + key: + name: pmsh-operational-policy + version: 0.0.1 + UUID: fdf2c9ff-6422-3ea6-b6b6-49b12116265d + description: Generated description for concept referred to by key "pmsh-operational-policy:0.0.1" + policies: + key: + name: PMControlPolicy_Policies + version: 0.0.1 + policyMap: + entry: + - key: + name: CDSCreateResponsePolicy + version: 0.0.1 + value: + policyKey: + name: CDSCreateResponsePolicy + version: 0.0.1 + template: Freestyle + state: + entry: + - key: CDSCreateResponseState + value: + stateKey: + parentKeyName: CDSCreateResponsePolicy + parentKeyVersion: 0.0.1 + parentLocalName: 'NULL' + localName: CDSCreateResponseState + trigger: + name: CDSCreateResponseEvent + version: 0.0.1 + stateOutputs: + entry: + - key: ResponseOutput + value: + key: + parentKeyName: CDSCreateResponsePolicy + parentKeyVersion: 0.0.1 + parentLocalName: CDSCreateResponseState + localName: ResponseOutput + outgoingEvent: + name: CDSResponseStatusEvent + version: 0.0.1 + nextState: + parentKeyName: 'NULL' + parentKeyVersion: 0.0.0 + parentLocalName: 'NULL' + localName: 'NULL' + contextAlbumReference: [] + taskSelectionLogic: + key: 'NULL' + logicFlavour: UNDEFINED + logic: '' + stateFinalizerLogicMap: + entry: [] + defaultTask: + name: CDSCreateResponseTask + version: 0.0.1 + taskReferences: + entry: + - key: + name: CDSCreateResponseTask + version: 0.0.1 + value: + key: + parentKeyName: CDSCreateResponsePolicy + parentKeyVersion: 0.0.1 + parentLocalName: CDSCreateResponseState + localName: CDSCreateResponsePolicy + outputType: DIRECT + output: + parentKeyName: CDSCreateResponsePolicy + parentKeyVersion: 0.0.1 + parentLocalName: CDSCreateResponseState + localName: ResponseOutput + firstState: CDSCreateResponseState + - key: + name: CDSDeleteResponsePolicy + version: 0.0.1 + value: + policyKey: + name: CDSDeleteResponsePolicy + version: 0.0.1 + template: Freestyle + state: + entry: + - key: CDSDeleteResponseState + value: + stateKey: + parentKeyName: CDSDeleteResponsePolicy + parentKeyVersion: 0.0.1 + parentLocalName: 'NULL' + localName: CDSDeleteResponseState + trigger: + name: CDSDeleteResponseEvent + version: 0.0.1 + stateOutputs: + entry: + - key: ResponseOutput + value: + key: + parentKeyName: CDSDeleteResponsePolicy + parentKeyVersion: 0.0.1 + parentLocalName: CDSDeleteResponseState + localName: ResponseOutput + outgoingEvent: + name: CDSResponseStatusEvent + version: 0.0.1 + nextState: + parentKeyName: 'NULL' + parentKeyVersion: 0.0.0 + parentLocalName: 'NULL' + localName: 'NULL' + contextAlbumReference: [] + taskSelectionLogic: + key: 'NULL' + logicFlavour: UNDEFINED + logic: '' + stateFinalizerLogicMap: + entry: [] + defaultTask: + name: CDSDeleteResponseTask + version: 0.0.1 + taskReferences: + entry: + - key: + name: CDSDeleteResponseTask + version: 0.0.1 + value: + key: + parentKeyName: CDSDeleteResponsePolicy + parentKeyVersion: 0.0.1 + parentLocalName: CDSDeleteResponseState + localName: CDSDeleteResponsePolicy + outputType: DIRECT + output: + parentKeyName: CDSDeleteResponsePolicy + parentKeyVersion: 0.0.1 + parentLocalName: CDSDeleteResponseState + localName: ResponseOutput + firstState: CDSDeleteResponseState + - key: + name: ReceiveEventPolicy + version: 0.0.1 + value: + policyKey: + name: ReceiveEventPolicy + version: 0.0.1 + template: Freestyle + state: + entry: + - key: CreateOrDeleteState + value: + stateKey: + parentKeyName: ReceiveEventPolicy + parentKeyVersion: 0.0.1 + parentLocalName: 'NULL' + localName: CreateOrDeleteState + trigger: + name: PMSubscriptionOutputEvent + version: 0.0.1 + stateOutputs: + entry: + - key: CreateSubscriptionPayload + value: + key: + parentKeyName: ReceiveEventPolicy + parentKeyVersion: 0.0.1 + parentLocalName: CreateOrDeleteState + localName: CreateSubscriptionPayload + outgoingEvent: + name: CreateSubscriptionPayloadEvent + version: 0.0.1 + nextState: + parentKeyName: ReceiveEventPolicy + parentKeyVersion: 0.0.1 + parentLocalName: 'NULL' + localName: CreateSubscription + - key: DeleteSubscriptionPayload + value: + key: + parentKeyName: ReceiveEventPolicy + parentKeyVersion: 0.0.1 + parentLocalName: CreateOrDeleteState + localName: DeleteSubscriptionPayload + outgoingEvent: + name: DeleteSubscriptionPayloadEvent + version: 0.0.1 + nextState: + parentKeyName: ReceiveEventPolicy + parentKeyVersion: 0.0.1 + parentLocalName: 'NULL' + localName: DeleteSubscription + contextAlbumReference: + - name: PMSubscriptionAlbum + version: 0.0.1 + taskSelectionLogic: + key: TaskSelectionLogic + logicFlavour: JAVASCRIPT + logic: |- + /* + * ============LICENSE_START======================================================= + * Copyright (C) 2020 Nordix. 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); + + var pmSubscriptionInfo = executor.getContextAlbum("PMSubscriptionAlbum").get(executor.inFields.get("albumID").toString()) + var changeType = pmSubscriptionInfo.get("changeType").toString() + + executor.logger.info("Change Type is " + changeType) + + if ("CREATE".equals(changeType)) { + executor.logger.info("Choosing to create a subscription") + executor.subject.getTaskKey("CreateSubscriptionPayloadTask").copyTo(executor.selectedTask); + } + else if ("DELETE".equals(changeType)) { + executor.logger.info("Choosing to delete a subscription") + executor.subject.getTaskKey("DeleteSubscriptionPayloadTask").copyTo(executor.selectedTask); + } + + //var returnValue = executor.isTrue; + true; + stateFinalizerLogicMap: + entry: [] + defaultTask: + name: CreateSubscriptionPayloadTask + version: 0.0.1 + taskReferences: + entry: + - key: + name: CreateSubscriptionPayloadTask + version: 0.0.1 + value: + key: + parentKeyName: ReceiveEventPolicy + parentKeyVersion: 0.0.1 + parentLocalName: CreateOrDeleteState + localName: ReceiveEventPolicy + outputType: DIRECT + output: + parentKeyName: ReceiveEventPolicy + parentKeyVersion: 0.0.1 + parentLocalName: CreateOrDeleteState + localName: CreateSubscriptionPayload + - key: + name: DeleteSubscriptionPayloadTask + version: 0.0.1 + value: + key: + parentKeyName: ReceiveEventPolicy + parentKeyVersion: 0.0.1 + parentLocalName: CreateOrDeleteState + localName: ReceiveEventPolicy + outputType: DIRECT + output: + parentKeyName: ReceiveEventPolicy + parentKeyVersion: 0.0.1 + parentLocalName: CreateOrDeleteState + localName: DeleteSubscriptionPayload + - key: CreateSubscription + value: + stateKey: + parentKeyName: ReceiveEventPolicy + parentKeyVersion: 0.0.1 + parentLocalName: 'NULL' + localName: CreateSubscription + trigger: + name: CreateSubscriptionPayloadEvent + version: 0.0.1 + stateOutputs: + entry: + - key: IssueCreateSubscriptionRequestOutput + value: + key: + parentKeyName: ReceiveEventPolicy + parentKeyVersion: 0.0.1 + parentLocalName: CreateSubscription + localName: IssueCreateSubscriptionRequestOutput + outgoingEvent: + name: CDSCreateSubscriptionRequestEvent + version: 0.0.1 + nextState: + parentKeyName: 'NULL' + parentKeyVersion: 0.0.0 + parentLocalName: 'NULL' + localName: 'NULL' + contextAlbumReference: + - name: PMSubscriptionAlbum + version: 0.0.1 + taskSelectionLogic: + key: 'NULL' + logicFlavour: UNDEFINED + logic: '' + stateFinalizerLogicMap: + entry: [] + defaultTask: + name: CreateSubscriptionRequestTask + version: 0.0.1 + taskReferences: + entry: + - key: + name: CreateSubscriptionRequestTask + version: 0.0.1 + value: + key: + parentKeyName: ReceiveEventPolicy + parentKeyVersion: 0.0.1 + parentLocalName: CreateSubscription + localName: ReceiveEventPolicy + outputType: DIRECT + output: + parentKeyName: ReceiveEventPolicy + parentKeyVersion: 0.0.1 + parentLocalName: CreateSubscription + localName: IssueCreateSubscriptionRequestOutput + - key: DeleteSubscription + value: + stateKey: + parentKeyName: ReceiveEventPolicy + parentKeyVersion: 0.0.1 + parentLocalName: 'NULL' + localName: DeleteSubscription + trigger: + name: DeleteSubscriptionPayloadEvent + version: 0.0.1 + stateOutputs: + entry: + - key: IssueDeleteSubscriptionRequestOutput + value: + key: + parentKeyName: ReceiveEventPolicy + parentKeyVersion: 0.0.1 + parentLocalName: DeleteSubscription + localName: IssueDeleteSubscriptionRequestOutput + outgoingEvent: + name: CDSDeleteSubscriptionRequestEvent + version: 0.0.1 + nextState: + parentKeyName: 'NULL' + parentKeyVersion: 0.0.0 + parentLocalName: 'NULL' + localName: 'NULL' + contextAlbumReference: + - name: PMSubscriptionAlbum + version: 0.0.1 + taskSelectionLogic: + key: 'NULL' + logicFlavour: UNDEFINED + logic: '' + stateFinalizerLogicMap: + entry: [] + defaultTask: + name: DeleteSubscriptionRequestTask + version: 0.0.1 + taskReferences: + entry: + - key: + name: DeleteSubscriptionRequestTask + version: 0.0.1 + value: + key: + parentKeyName: ReceiveEventPolicy + parentKeyVersion: 0.0.1 + parentLocalName: DeleteSubscription + localName: ReceiveEventPolicy + outputType: DIRECT + output: + parentKeyName: ReceiveEventPolicy + parentKeyVersion: 0.0.1 + parentLocalName: DeleteSubscription + localName: IssueDeleteSubscriptionRequestOutput + - key: ReceiveSubscriptionState + value: + stateKey: + parentKeyName: ReceiveEventPolicy + parentKeyVersion: 0.0.1 + parentLocalName: 'NULL' + localName: ReceiveSubscriptionState + trigger: + name: pmsh-operational-policy + version: 0.0.1 + stateOutputs: + entry: + - key: ReceivePMSubscriptionOutput + value: + key: + parentKeyName: ReceiveEventPolicy + parentKeyVersion: 0.0.1 + parentLocalName: ReceiveSubscriptionState + localName: ReceivePMSubscriptionOutput + outgoingEvent: + name: PMSubscriptionOutputEvent + version: 0.0.1 + nextState: + parentKeyName: ReceiveEventPolicy + parentKeyVersion: 0.0.1 + parentLocalName: 'NULL' + localName: CreateOrDeleteState + contextAlbumReference: + - name: PMSubscriptionAlbum + version: 0.0.1 + taskSelectionLogic: + key: 'NULL' + logicFlavour: UNDEFINED + logic: '' + stateFinalizerLogicMap: + entry: [] + defaultTask: + name: ReceiveSubscriptionTask + version: 0.0.1 + taskReferences: + entry: + - key: + name: ReceiveSubscriptionTask + version: 0.0.1 + value: + key: + parentKeyName: ReceiveEventPolicy + parentKeyVersion: 0.0.1 + parentLocalName: ReceiveSubscriptionState + localName: ReceiveEventPolicy + outputType: DIRECT + output: + parentKeyName: ReceiveEventPolicy + parentKeyVersion: 0.0.1 + parentLocalName: ReceiveSubscriptionState + localName: ReceivePMSubscriptionOutput + firstState: ReceiveSubscriptionState + tasks: + key: + name: PMControlPolicy_Tasks + version: 0.0.1 + taskMap: + entry: + - key: + name: CDSCreateResponseTask + version: 0.0.1 + value: + key: + name: CDSCreateResponseTask + version: 0.0.1 + inputFields: + entry: + - key: actionIdentifiers + value: + key: actionIdentifiers + fieldSchemaKey: + name: CDSActionIdentifiersType + version: 0.0.1 + optional: false + - key: commonHeader + value: + key: commonHeader + fieldSchemaKey: + name: CDSResponseCommonHeaderType + version: 0.0.1 + optional: false + - key: payload + value: + key: payload + fieldSchemaKey: + name: CDSCreateResponsePayloadType + version: 0.0.1 + optional: false + - key: status + value: + key: status + fieldSchemaKey: + name: CDSResponseStatusType + version: 0.0.1 + optional: false + outputFields: + entry: + - key: status + value: + key: status + fieldSchemaKey: + name: SubscriptionStatusType + version: 0.0.1 + optional: false + taskParameters: + entry: [] + contextAlbumReference: + - name: PMSubscriptionAlbum + version: 0.0.1 + taskLogic: + key: TaskLogic + logicFlavour: JAVASCRIPT + logic: |- + /* + * ============LICENSE_START======================================================= + * Copyright (C) 2020 Nordix. 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); + + var commonHeader = executor.inFields.get("commonHeader") + var response = executor.inFields.get("payload") + var albumID = commonHeader.get("requestId") + + var pmSubscriptionInfo = executor.getContextAlbum("PMSubscriptionAlbum").get(albumID.toString()); + var responseStatus = executor.subject.getOutFieldSchemaHelper("status").createNewInstance(); + + responseStatus.put("subscriptionName", pmSubscriptionInfo.get("subscription").get("subscriptionName")) + responseStatus.put("nfName", pmSubscriptionInfo.get("nfName")) + responseStatus.put("changeType", pmSubscriptionInfo.get("changeType")) + + var status = response.get(pmSubscriptionInfo.get("changeType").toLowerCase() + "_DasH_subscription_DasH_response").get("odl_DasH_response").get("status") + + executor.logger.info("RESPONSE STATUS = " + status) + + if(status == "success") { + responseStatus.put("message", "success") + } else { + responseStatus.put("message", "failed") + } + + executor.outFields.put("status", responseStatus) + + //var returnValue = executor.isTrue; + true; + - key: + name: CDSDeleteResponseTask + version: 0.0.1 + value: + key: + name: CDSDeleteResponseTask + version: 0.0.1 + inputFields: + entry: + - key: actionIdentifiers + value: + key: actionIdentifiers + fieldSchemaKey: + name: CDSActionIdentifiersType + version: 0.0.1 + optional: false + - key: commonHeader + value: + key: commonHeader + fieldSchemaKey: + name: CDSResponseCommonHeaderType + version: 0.0.1 + optional: false + - key: payload + value: + key: payload + fieldSchemaKey: + name: CDSDeleteResponsePayloadType + version: 0.0.1 + optional: false + - key: status + value: + key: status + fieldSchemaKey: + name: CDSResponseStatusType + version: 0.0.1 + optional: false + outputFields: + entry: + - key: status + value: + key: status + fieldSchemaKey: + name: SubscriptionStatusType + version: 0.0.1 + optional: false + taskParameters: + entry: [] + contextAlbumReference: + - name: PMSubscriptionAlbum + version: 0.0.1 + taskLogic: + key: TaskLogic + logicFlavour: JAVASCRIPT + logic: |- + /* + * ============LICENSE_START======================================================= + * Copyright (C) 2020 Nordix. 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); + + var commonHeader = executor.inFields.get("commonHeader") + var response = executor.inFields.get("payload") + var albumID = commonHeader.get("requestId") + + var pmSubscriptionInfo = executor.getContextAlbum("PMSubscriptionAlbum").get(albumID.toString()); + var responseStatus = executor.subject.getOutFieldSchemaHelper("status").createNewInstance(); + + responseStatus.put("subscriptionName", pmSubscriptionInfo.get("subscription").get("subscriptionName")) + responseStatus.put("nfName", pmSubscriptionInfo.get("nfName")) + responseStatus.put("changeType", pmSubscriptionInfo.get("changeType")) + + var status = response.get(pmSubscriptionInfo.get("changeType").toLowerCase() + "_DasH_subscription_DasH_response").get("odl_DasH_response").get("status") + + executor.logger.info("RESPONSE STATUS = " + status) + + if(status == "success") { + responseStatus.put("message", "success") + } else { + responseStatus.put("message", "failed") + } + + executor.outFields.put("status", responseStatus) + + //var returnValue = executor.isTrue; + true; + - key: + name: CreateSubscriptionPayloadTask + version: 0.0.1 + value: + key: + name: CreateSubscriptionPayloadTask + version: 0.0.1 + inputFields: + entry: + - key: albumID + value: + key: albumID + fieldSchemaKey: + name: UUIDType + version: 0.0.1 + optional: false + outputFields: + entry: + - key: albumID + value: + key: albumID + fieldSchemaKey: + name: UUIDType + version: 0.0.1 + optional: false + - key: payload + value: + key: payload + fieldSchemaKey: + name: CDSCreateSubscriptionPayloadType + version: 0.0.1 + optional: false + taskParameters: + entry: [] + contextAlbumReference: + - name: PMSubscriptionAlbum + version: 0.0.1 + taskLogic: + key: TaskLogic + logicFlavour: JAVASCRIPT + logic: |- + /* + * ============LICENSE_START======================================================= + * Copyright (C) 2020 Nordix. 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); + + var pmSubscriptionInfo = executor.getContextAlbum("PMSubscriptionAlbum").get(executor.inFields.get("albumID").toString()) + + var changeType = pmSubscriptionInfo.get("changeType").toLowerCase() + + var payloadProperties = executor.subject.getOutFieldSchemaHelper("payload").createNewSubInstance(changeType + "_DasH_subscription_DasH_properties_record"); + + payloadProperties.put("nfName", pmSubscriptionInfo.get("nfName")) + payloadProperties.put("subscriptionName", pmSubscriptionInfo.get("subscription").get("subscriptionName")) + payloadProperties.put("administrativeState", pmSubscriptionInfo.get("subscription").get("administrativeState")) + payloadProperties.put("fileBasedGP", pmSubscriptionInfo.get("subscription").get("fileBasedGP").toString()) + payloadProperties.put("fileLocation", pmSubscriptionInfo.get("subscription").get("fileLocation")) + payloadProperties.put("measurementGroups", pmSubscriptionInfo.get("subscription").get("measurementGroups")) + + var payloadEntry = executor.subject.getOutFieldSchemaHelper("payload").createNewSubInstance("CDSRequestPayloadEntry"); + payloadEntry.put(changeType + "_DasH_subscription_DasH_properties", payloadProperties) + + var payload = executor.subject.getOutFieldSchemaHelper("payload").createNewInstance(); + payload.put(changeType + "_DasH_subscription_DasH_request", payloadEntry); + + executor.outFields.put("albumID", executor.inFields.get("albumID")) + executor.outFields.put("payload", payload); + + //var returnValue = executor.isTrue; + true; + - key: + name: CreateSubscriptionRequestTask + version: 0.0.1 + value: + key: + name: CreateSubscriptionRequestTask + version: 0.0.1 + inputFields: + entry: + - key: albumID + value: + key: albumID + fieldSchemaKey: + name: UUIDType + version: 0.0.1 + optional: false + - key: payload + value: + key: payload + fieldSchemaKey: + name: CDSCreateSubscriptionPayloadType + version: 0.0.1 + optional: false + outputFields: + entry: + - key: actionIdentifiers + value: + key: actionIdentifiers + fieldSchemaKey: + name: CDSActionIdentifiersType + version: 0.0.1 + optional: false + - key: commonHeader + value: + key: commonHeader + fieldSchemaKey: + name: CDSRequestCommonHeaderType + version: 0.0.1 + optional: false + - key: payload + value: + key: payload + fieldSchemaKey: + name: CDSCreateSubscriptionPayloadType + version: 0.0.1 + optional: false + taskParameters: + entry: [] + contextAlbumReference: + - name: PMSubscriptionAlbum + version: 0.0.1 + taskLogic: + key: TaskLogic + logicFlavour: JAVASCRIPT + logic: |- + /* + * ============LICENSE_START======================================================= + * Copyright (C) 2020 Nordix. 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); + + var pmSubscriptionInfo = executor.getContextAlbum("PMSubscriptionAlbum").get(executor.inFields.get("albumID").toString()) + + var changeType = pmSubscriptionInfo.get("changeType").toLowerCase() + var blueprintName = pmSubscriptionInfo.get("blueprintName").toLowerCase() + var blueprintVersion = pmSubscriptionInfo.get("blueprintVersion").toLowerCase() + var payload = executor.inFields.get("payload") + var actionName = changeType + "-subscription" + + var commonHeader = executor.subject.getOutFieldSchemaHelper("commonHeader").createNewInstance(); + commonHeader.put("originatorId", "sdnc"); + commonHeader.put("requestId", executor.inFields.get("albumID").toString()); + commonHeader.put("subRequestId", "sub-123456-1000"); + + var actionIdentifiers = executor.subject.getOutFieldSchemaHelper("actionIdentifiers").createNewInstance(); + actionIdentifiers.put("actionName", actionName); + actionIdentifiers.put("blueprintName", blueprintName); + actionIdentifiers.put("blueprintVersion", blueprintVersion); + actionIdentifiers.put("mode", "sync"); + + executor.outFields.put("commonHeader", commonHeader); + executor.outFields.put("actionIdentifiers", actionIdentifiers); + executor.outFields.put("payload", payload); + + //var returnValue = executor.isTrue; + true; + - key: + name: DeleteSubscriptionPayloadTask + version: 0.0.1 + value: + key: + name: DeleteSubscriptionPayloadTask + version: 0.0.1 + inputFields: + entry: + - key: albumID + value: + key: albumID + fieldSchemaKey: + name: UUIDType + version: 0.0.1 + optional: false + outputFields: + entry: + - key: albumID + value: + key: albumID + fieldSchemaKey: + name: UUIDType + version: 0.0.1 + optional: false + - key: payload + value: + key: payload + fieldSchemaKey: + name: CDSDeleteSubscriptionPayloadType + version: 0.0.1 + optional: false + taskParameters: + entry: [] + contextAlbumReference: + - name: PMSubscriptionAlbum + version: 0.0.1 + taskLogic: + key: TaskLogic + logicFlavour: JAVASCRIPT + logic: |- + /* + * ============LICENSE_START======================================================= + * Copyright (C) 2020 Nordix. 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); + + var pmSubscriptionInfo = executor.getContextAlbum("PMSubscriptionAlbum").get(executor.inFields.get("albumID").toString()) + + var changeType = pmSubscriptionInfo.get("changeType").toLowerCase() + + var payloadProperties = executor.subject.getOutFieldSchemaHelper("payload").createNewSubInstance(changeType + "_DasH_subscription_DasH_properties_record"); + + payloadProperties.put("nfName", pmSubscriptionInfo.get("nfName")) + payloadProperties.put("subscriptionName", pmSubscriptionInfo.get("subscription").get("subscriptionName")) + payloadProperties.put("administrativeState", pmSubscriptionInfo.get("subscription").get("administrativeState")) + payloadProperties.put("fileBasedGP", pmSubscriptionInfo.get("subscription").get("fileBasedGP").toString()) + payloadProperties.put("fileLocation", pmSubscriptionInfo.get("subscription").get("fileLocation")) + payloadProperties.put("measurementGroups", pmSubscriptionInfo.get("subscription").get("measurementGroups")) + + var payloadEntry = executor.subject.getOutFieldSchemaHelper("payload").createNewSubInstance("CDSRequestPayloadEntry"); + payloadEntry.put(changeType + "_DasH_subscription_DasH_properties", payloadProperties) + + var payload = executor.subject.getOutFieldSchemaHelper("payload").createNewInstance(); + payload.put(changeType + "_DasH_subscription_DasH_request", payloadEntry); + + executor.outFields.put("albumID", executor.inFields.get("albumID")) + executor.outFields.put("payload", payload); + + //var returnValue = executor.isTrue; + true; + - key: + name: DeleteSubscriptionRequestTask + version: 0.0.1 + value: + key: + name: DeleteSubscriptionRequestTask + version: 0.0.1 + inputFields: + entry: + - key: albumID + value: + key: albumID + fieldSchemaKey: + name: UUIDType + version: 0.0.1 + optional: false + - key: payload + value: + key: payload + fieldSchemaKey: + name: CDSDeleteSubscriptionPayloadType + version: 0.0.1 + optional: false + outputFields: + entry: + - key: actionIdentifiers + value: + key: actionIdentifiers + fieldSchemaKey: + name: CDSActionIdentifiersType + version: 0.0.1 + optional: false + - key: commonHeader + value: + key: commonHeader + fieldSchemaKey: + name: CDSRequestCommonHeaderType + version: 0.0.1 + optional: false + - key: payload + value: + key: payload + fieldSchemaKey: + name: CDSDeleteSubscriptionPayloadType + version: 0.0.1 + optional: false + taskParameters: + entry: [] + contextAlbumReference: + - name: PMSubscriptionAlbum + version: 0.0.1 + taskLogic: + key: TaskLogic + logicFlavour: JAVASCRIPT + logic: |- + /* + * ============LICENSE_START======================================================= + * Copyright (C) 2020 Nordix. 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); + + var pmSubscriptionInfo = executor.getContextAlbum("PMSubscriptionAlbum").get(executor.inFields.get("albumID").toString()) + + var changeType = pmSubscriptionInfo.get("changeType").toLowerCase() + var blueprintName = pmSubscriptionInfo.get("blueprintName").toLowerCase() + var blueprintVersion = pmSubscriptionInfo.get("blueprintVersion").toLowerCase() + var payload = executor.inFields.get("payload") + var actionName = changeType + "-subscription" + + var commonHeader = executor.subject.getOutFieldSchemaHelper("commonHeader").createNewInstance(); + commonHeader.put("originatorId", "sdnc"); + commonHeader.put("requestId", executor.inFields.get("albumID").toString()); + commonHeader.put("subRequestId", "sub-123456-1000"); + + var actionIdentifiers = executor.subject.getOutFieldSchemaHelper("actionIdentifiers").createNewInstance(); + actionIdentifiers.put("actionName", actionName); + actionIdentifiers.put("blueprintName", blueprintName); + actionIdentifiers.put("blueprintVersion", blueprintVersion); + actionIdentifiers.put("mode", "sync"); + + executor.outFields.put("commonHeader", commonHeader); + executor.outFields.put("actionIdentifiers", actionIdentifiers); + executor.outFields.put("payload", payload); + + //var returnValue = executor.isTrue; + true; + - key: + name: ReceiveSubscriptionTask + version: 0.0.1 + value: + key: + name: ReceiveSubscriptionTask + version: 0.0.1 + inputFields: + entry: + - key: blueprintName + value: + key: blueprintName + fieldSchemaKey: + name: SimpleStringType + version: 0.0.1 + optional: false + - key: blueprintVersion + value: + key: blueprintVersion + fieldSchemaKey: + name: SimpleStringType + version: 0.0.1 + optional: false + - key: changeType + value: + key: changeType + fieldSchemaKey: + name: SimpleStringType + version: 0.0.1 + optional: false + - key: closedLoopControlName + value: + key: closedLoopControlName + fieldSchemaKey: + name: SimpleStringType + version: 0.0.1 + optional: false + - key: nfName + value: + key: nfName + fieldSchemaKey: + name: SimpleStringType + version: 0.0.1 + optional: false + - key: policyName + value: + key: policyName + fieldSchemaKey: + name: SimpleStringType + version: 0.0.1 + optional: false + - key: subscription + value: + key: subscription + fieldSchemaKey: + name: SubscriptionType + version: 0.0.1 + optional: false + outputFields: + entry: + - key: albumID + value: + key: albumID + fieldSchemaKey: + name: UUIDType + version: 0.0.1 + optional: false + taskParameters: + entry: [] + contextAlbumReference: + - name: PMSubscriptionAlbum + version: 0.0.1 + taskLogic: + key: TaskLogic + logicFlavour: JAVASCRIPT + logic: |- + /* + * ============LICENSE_START======================================================= + * Copyright (C) 2020 Nordix. 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========================================================= + */ + var uuidType = java.util.UUID; + + executor.logger.info(executor.subject.id); + + //albumID will be used to fetch info from our album later + var albumID = uuidType.randomUUID(); + var pmSubscriptionInfo = executor.getContextAlbum("PMSubscriptionAlbum").getSchemaHelper().createNewInstance(); + var returnValue = true; + + if(executor.inFields.get("policyName") != null) { + executor.logger.info("nfName in receive sub event " + executor.inFields.get("nfName")); + + var changeType = executor.inFields.get("changeType") + var nfName = executor.inFields.get("nfName") + var policyName = executor.inFields.get("policyName") + var closedLoopControlName = executor.inFields.get("closedLoopControlName") + var subscription = executor.inFields.get("subscription") + var blueprintName = executor.inFields.get("blueprintName") + var blueprintVersion = executor.inFields.get("blueprintVersion") + + pmSubscriptionInfo.put("nfName", executor.inFields.get("nfName")); + pmSubscriptionInfo.put("changeType", executor.inFields.get("changeType")) + pmSubscriptionInfo.put("policyName", executor.inFields.get("policyName")) + pmSubscriptionInfo.put("closedLoopControlName", executor.inFields.get("closedLoopControlName")) + pmSubscriptionInfo.put("subscription", subscription) + pmSubscriptionInfo.put("blueprintName", blueprintName) + pmSubscriptionInfo.put("blueprintVersion", blueprintVersion) + + + executor.getContextAlbum("PMSubscriptionAlbum").put(albumID.toString(), pmSubscriptionInfo); + + executor.outFields.put("albumID", albumID) + } else { + executor.message = "Received invalid event" + returnValue = false; + } + + returnValue; + events: + key: + name: PMControlPolicy_Events + version: 0.0.1 + eventMap: + entry: + - key: + name: CDSCreateResponseEvent + version: 0.0.1 + value: + key: + name: CDSCreateResponseEvent + version: 0.0.1 + nameSpace: org.onap.policy.apex.onap.pmcontrol + source: CDS + target: APEX + parameter: + entry: + - key: actionIdentifiers + value: + key: actionIdentifiers + fieldSchemaKey: + name: CDSActionIdentifiersType + version: 0.0.1 + optional: false + - key: commonHeader + value: + key: commonHeader + fieldSchemaKey: + name: CDSResponseCommonHeaderType + version: 0.0.1 + optional: false + - key: payload + value: + key: payload + fieldSchemaKey: + name: CDSCreateResponsePayloadType + version: 0.0.1 + optional: false + - key: status + value: + key: status + fieldSchemaKey: + name: CDSResponseStatusType + version: 0.0.1 + optional: false + - key: + name: CDSCreateSubscriptionRequestEvent + version: 0.0.1 + value: + key: + name: CDSCreateSubscriptionRequestEvent + version: 0.0.1 + nameSpace: org.onap.policy.apex.onap.pmcontrol + source: APEX + target: APEX + parameter: + entry: + - key: actionIdentifiers + value: + key: actionIdentifiers + fieldSchemaKey: + name: CDSActionIdentifiersType + version: 0.0.1 + optional: false + - key: commonHeader + value: + key: commonHeader + fieldSchemaKey: + name: CDSRequestCommonHeaderType + version: 0.0.1 + optional: false + - key: payload + value: + key: payload + fieldSchemaKey: + name: CDSCreateSubscriptionPayloadType + version: 0.0.1 + optional: false + - key: + name: CDSDeleteResponseEvent + version: 0.0.1 + value: + key: + name: CDSDeleteResponseEvent + version: 0.0.1 + nameSpace: org.onap.policy.apex.onap.pmcontrol + source: CDS + target: APEX + parameter: + entry: + - key: actionIdentifiers + value: + key: actionIdentifiers + fieldSchemaKey: + name: CDSActionIdentifiersType + version: 0.0.1 + optional: false + - key: commonHeader + value: + key: commonHeader + fieldSchemaKey: + name: CDSResponseCommonHeaderType + version: 0.0.1 + optional: false + - key: payload + value: + key: payload + fieldSchemaKey: + name: CDSDeleteResponsePayloadType + version: 0.0.1 + optional: false + - key: status + value: + key: status + fieldSchemaKey: + name: CDSResponseStatusType + version: 0.0.1 + optional: false + - key: + name: CDSDeleteSubscriptionRequestEvent + version: 0.0.1 + value: + key: + name: CDSDeleteSubscriptionRequestEvent + version: 0.0.1 + nameSpace: org.onap.policy.apex.onap.pmcontrol + source: APEX + target: APEX + parameter: + entry: + - key: actionIdentifiers + value: + key: actionIdentifiers + fieldSchemaKey: + name: CDSActionIdentifiersType + version: 0.0.1 + optional: false + - key: commonHeader + value: + key: commonHeader + fieldSchemaKey: + name: CDSRequestCommonHeaderType + version: 0.0.1 + optional: false + - key: payload + value: + key: payload + fieldSchemaKey: + name: CDSDeleteSubscriptionPayloadType + version: 0.0.1 + optional: false + - key: + name: CDSResponseStatusEvent + version: 0.0.1 + value: + key: + name: CDSResponseStatusEvent + version: 0.0.1 + nameSpace: org.onap.policy.apex.onap.pmcontrol + source: APEX + target: DCAE + parameter: + entry: + - key: status + value: + key: status + fieldSchemaKey: + name: SubscriptionStatusType + version: 0.0.1 + optional: false + - key: + name: CreateSubscriptionPayloadEvent + version: 0.0.1 + value: + key: + name: CreateSubscriptionPayloadEvent + version: 0.0.1 + nameSpace: org.onap.policy.apex.onap.pmcontrol + source: APEX + target: APEX + parameter: + entry: + - key: albumID + value: + key: albumID + fieldSchemaKey: + name: UUIDType + version: 0.0.1 + optional: false + - key: payload + value: + key: payload + fieldSchemaKey: + name: CDSCreateSubscriptionPayloadType + version: 0.0.1 + optional: false + - key: + name: DeleteSubscriptionPayloadEvent + version: 0.0.1 + value: + key: + name: DeleteSubscriptionPayloadEvent + version: 0.0.1 + nameSpace: org.onap.policy.apex.onap.pmcontrol + source: APEX + target: APEX + parameter: + entry: + - key: albumID + value: + key: albumID + fieldSchemaKey: + name: UUIDType + version: 0.0.1 + optional: false + - key: payload + value: + key: payload + fieldSchemaKey: + name: CDSDeleteSubscriptionPayloadType + version: 0.0.1 + optional: false + - key: + name: MRResponseEvent + version: 0.0.1 + value: + key: + name: MRResponseEvent + version: 0.0.1 + nameSpace: org.onap.policy.apex.onap.pmcontrol + source: DCAE + target: APEX + parameter: + entry: + - key: count + value: + key: count + fieldSchemaKey: + name: SimpleIntType + version: 0.0.1 + optional: false + - key: serverTimeMs + value: + key: serverTimeMs + fieldSchemaKey: + name: SimpleIntType + version: 0.0.1 + optional: false + - key: + name: PMSubscriptionOutputEvent + version: 0.0.1 + value: + key: + name: PMSubscriptionOutputEvent + version: 0.0.1 + nameSpace: org.onap.policy.apex.onap.pmcontrol + source: APEX + target: APEX + parameter: + entry: + - key: albumID + value: + key: albumID + fieldSchemaKey: + name: UUIDType + version: 0.0.1 + optional: false + - key: + name: pmsh-operational-policy + version: 0.0.1 + value: + key: + name: pmsh-operational-policy + version: 0.0.1 + nameSpace: org.onap.policy.apex.onap.pmcontrol + source: DCAE + target: APEX + parameter: + entry: + - key: blueprintName + value: + key: blueprintName + fieldSchemaKey: + name: SimpleStringType + version: 0.0.1 + optional: false + - key: blueprintVersion + value: + key: blueprintVersion + fieldSchemaKey: + name: SimpleStringType + version: 0.0.1 + optional: false + - key: changeType + value: + key: changeType + fieldSchemaKey: + name: SimpleStringType + version: 0.0.1 + optional: false + - key: closedLoopControlName + value: + key: closedLoopControlName + fieldSchemaKey: + name: SimpleStringType + version: 0.0.1 + optional: false + - key: nfName + value: + key: nfName + fieldSchemaKey: + name: SimpleStringType + version: 0.0.1 + optional: false + - key: policyName + value: + key: policyName + fieldSchemaKey: + name: SimpleStringType + version: 0.0.1 + optional: false + - key: subscription + value: + key: subscription + fieldSchemaKey: + name: SubscriptionType + version: 0.0.1 + optional: false + albums: + key: + name: PMControlPolicy_Albums + version: 0.0.1 + albums: + entry: + - key: + name: PMSubscriptionAlbum + version: 0.0.1 + value: + key: + name: PMSubscriptionAlbum + version: 0.0.1 + scope: policy + isWritable: true + itemSchema: + name: PMSubscriptionType + version: 0.0.1 + schemas: + key: + name: PMControlPolicy_Schemas + version: 0.0.1 + schemas: + entry: + - key: + name: CDSActionIdentifiersType + version: 0.0.1 + value: + key: + name: CDSActionIdentifiersType + version: 0.0.1 + schemaFlavour: Avro + schemaDefinition: |- + { + "type": "record", + "name": "ActionIdentifiers_Type", + "namespace": "org.onap.policy.apex.onap.helloworld", + "fields": [ + { + "name": "actionName", + "type": "string" + }, + { + "name": "blueprintName", + "type": "string" + }, + { + "name": "blueprintVersion", + "type": "string" + }, + { + "name": "mode", + "type": "string" + } + ] + } + - key: + name: CDSCreateResponsePayloadType + version: 0.0.1 + value: + key: + name: CDSCreateResponsePayloadType + version: 0.0.1 + schemaFlavour: Avro + schemaDefinition: |- + { + "name": "CreateResponsePayloadEntry", + "type": "record", + "namespace": "org.onap.policy.apex.onap.helloworld", + "fields": [ + { + "name": "create_DasH_subscription_DasH_response", + "type": { + "name": "create_DasH_subscription_DasH_response", + "type": "record", + "fields": [ + { + "name": "odl_DasH_response", + "type": { + "name": "odl_DasH_response", + "type": "record", + "fields": [ + { + "name": "status", + "type": "string" + } + ] + } + } + ] + } + } + ] + } + - key: + name: CDSCreateSubscriptionPayloadType + version: 0.0.1 + value: + key: + name: CDSCreateSubscriptionPayloadType + version: 0.0.1 + schemaFlavour: Avro + schemaDefinition: |- + { + "type": "map", + "values": { + "type": "record", + "name": "CDSRequestPayloadEntry", + "fields": [ + { + "name": "create_DasH_subscription_DasH_properties", + "type": { + "name": "create_DasH_subscription_DasH_properties_record", + "type": "record", + "fields": [ + { + "name": "nfName", + "type": "string" + }, + { + "name": "subscriptionName", + "type": "string" + }, + { + "name": "administrativeState", + "type": "string" + }, + { + "name": "fileBasedGP", + "type": "string" + }, + { + "name": "fileLocation", + "type": "string" + }, + { + "name": "measurementGroups", + "type": { + "type": "array", + "items": { + "name": "measurementGroups_record", + "type": "record", + "fields": [ + { + "name": "measurementGroup", + "type": { + "name": "measurementGroup", + "type": "record", + "fields": [ + { + "name": "measurementTypes", + "type": { + "type": "array", + "items": { + "name": "measurementTypes_record", + "type": "record", + "fields": [ + { + "name": "measurementType", + "type": "string" + } + ] + } + } + }, + { + "name": "managedObjectDNsBasic", + "type": { + "type": "array", + "items": { + "name": "managedObjectDNsBasic_record", + "type": "record", + "fields": [ + { + "name": "DN", + "type": "string" + } + ] + } + } + } + ] + } + } + ] + } + } + } + ] + } + } + ] + } + } + - key: + name: CDSDeleteResponsePayloadType + version: 0.0.1 + value: + key: + name: CDSDeleteResponsePayloadType + version: 0.0.1 + schemaFlavour: Avro + schemaDefinition: |- + { + "name": "DeleteResponsePayloadEntry", + "type": "record", + "namespace": "com.acme.avro", + "fields": [ + { + "name": "delete_DasH_subscription_DasH_response", + "type": { + "name": "delete_DasH_subscription_DasH_response", + "type": "record", + "fields": [ + { + "name": "odl_DasH_response", + "type": { + "name": "odl_DasH_response", + "type": "record", + "fields": [ + { + "name": "status", + "type": "string" + } + ] + } + } + ] + } + } + ] + } + - key: + name: CDSDeleteSubscriptionPayloadType + version: 0.0.1 + value: + key: + name: CDSDeleteSubscriptionPayloadType + version: 0.0.1 + schemaFlavour: Avro + schemaDefinition: |- + { + "type": "map", + "values": { + "type": "record", + "name": "CDSRequestPayloadEntry", + "fields": [ + { + "name": "delete_DasH_subscription_DasH_properties", + "type": { + "name": "delete_DasH_subscription_DasH_properties_record", + "type": "record", + "fields": [ + { + "name": "nfName", + "type": "string" + }, + { + "name": "subscriptionName", + "type": "string" + }, + { + "name": "administrativeState", + "type": "string" + }, + { + "name": "fileBasedGP", + "type": "string" + }, + { + "name": "fileLocation", + "type": "string" + }, + { + "name": "measurementGroups", + "type": { + "type": "array", + "items": { + "name": "measurementGroups_record", + "type": "record", + "fields": [ + { + "name": "measurementGroup", + "type": { + "name": "measurementGroup", + "type": "record", + "fields": [ + { + "name": "measurementTypes", + "type": { + "type": "array", + "items": { + "name": "measurementTypes_record", + "type": "record", + "fields": [ + { + "name": "measurementType", + "type": "string" + } + ] + } + } + }, + { + "name": "managedObjectDNsBasic", + "type": { + "type": "array", + "items": { + "name": "managedObjectDNsBasic_record", + "type": "record", + "fields": [ + { + "name": "DN", + "type": "string" + } + ] + } + } + } + ] + } + } + ] + } + } + } + ] + } + } + ] + } + } + - key: + name: CDSRequestCommonHeaderType + version: 0.0.1 + value: + key: + name: CDSRequestCommonHeaderType + version: 0.0.1 + schemaFlavour: Avro + schemaDefinition: |- + { + "type": "record", + "name": "RequestCommonHeader_Type", + "namespace": "org.onap.policy.apex.onap.helloworld", + "fields": [ + { + "name": "originatorId", + "type": "string" + }, + { + "name": "requestId", + "type": "string" + }, + { + "name": "subRequestId", + "type": "string" + } + ] + } + - key: + name: CDSResponseCommonHeaderType + version: 0.0.1 + value: + key: + name: CDSResponseCommonHeaderType + version: 0.0.1 + schemaFlavour: Avro + schemaDefinition: |- + { + "type": "record", + "name": "ResponseCommonHeader_Type", + "namespace": "org.onap.policy.apex.onap.helloworld", + "fields": [ + { + "name": "originatorId", + "type": "string" + }, + { + "name": "requestId", + "type": "string" + }, + { + "name": "subRequestId", + "type": "string" + }, + { + "name": "timestamp", + "type": "string" + }, + { + "name": "flags", + "type": ["null", "string"] + } + ] + } + - key: + name: CDSResponseStatusType + version: 0.0.1 + value: + key: + name: CDSResponseStatusType + version: 0.0.1 + schemaFlavour: Avro + schemaDefinition: |- + { + "type": "record", + "name": "ResponseStatus_Type", + "namespace": "org.onap.policy.apex.onap.helloworld", + "fields": [ + { + "name": "code", + "type": "int" + }, + { + "name": "eventType", + "type": "string" + }, + { + "name": "timestamp", + "type": "string" + }, + { + "name": "message", + "type": "string" + } + ] + } + - key: + name: PMSubscriptionType + version: 0.0.1 + value: + key: + name: PMSubscriptionType + version: 0.0.1 + schemaFlavour: Avro + schemaDefinition: "{\n\t\"name\": \"PMSubscription\",\n\t\"type\": \"record\",\n\t\"namespace\": \"\ + org.onap.policy.apex.onap.pmcontrol\",\n\t\"fields\": [\n {\n \"name\": \"nfName\"\ + ,\n \"type\": \"string\"\n },\n\t {\n\t\t\t\"name\": \"changeType\",\n\t\t\t\"\ + type\": \"string\"\n\t\t},\n\t\t{\n\t\t\t\"name\": \"closedLoopControlName\",\n\t\t\t\"type\": \"\ + string\"\n\t\t},\n\t\t{\n\t\t\t\"name\": \"policyName\",\n\t\t\t\"type\": \"string\"\n\t\t},\n\t\t\ + {\n\t\t \"name\": \"blueprintName\",\n\t\t \"type\": \"string\"\n\t\t},\n\t\t{\n\t\t \"name\"\ + : \"blueprintVersion\",\n\t\t \"type\": \"string\"\n\t\t},\n\t\t{\n\t\t\t\"name\": \"subscription\"\ + ,\n\t\t\t\"type\": {\n\t\t\t\t\"name\": \"subscription\",\n\t\t\t\t\"type\": \"record\",\n\t\t\t\t\ + \"fields\": [{\n\t\t\t\t\t\t\"name\": \"subscriptionName\",\n\t\t\t\t\t\t\"type\": \"string\"\n\t\t\ + \t\t\t},\n\t\t\t\t\t{\n\t\t\t\t\t\t\"name\": \"administrativeState\",\n\t\t\t\t\t\t\"type\": \"string\"\ + \n\t\t\t\t\t},\n\t\t\t\t\t{\n\t\t\t\t\t\t\"name\": \"fileBasedGP\",\n\t\t\t\t\t\t\"type\": \"int\"\ + \n\t\t\t\t\t},\n\t\t\t\t\t{\n\t\t\t\t\t\t\"name\": \"fileLocation\",\n\t\t\t\t\t\t\"type\": \"string\"\ + \n\t\t\t\t\t},\n\t\t\t\t\t{\n\t\t\t\t\t\t\"name\": \"measurementGroups\",\n\t\t\t\t\t\t\"type\": {\n\ + \t\t\t\t\t\t\t\"type\": \"array\",\n\t\t\t\t\t\t\t\"items\": {\n\t\t\t\t\t\t\t\t\"name\": \"Measurement_Groups_Type\"\ + ,\n\t\t\t\t\t\t\t\t\"type\": \"record\",\n\t\t\t\t\t\t\t\t\"fields\": [{\n\t\t\t\t\t\t\t\t\t\"name\"\ + : \"measurementGroup\",\n\t\t\t\t\t\t\t\t\t\"type\": {\n\t\t\t\t\t\t\t\t\t\t\"name\": \"Measurement_Group_Type\"\ + ,\n\t\t\t\t\t\t\t\t\t\t\"type\": \"record\",\n\t\t\t\t\t\t\t\t\t\t\"fields\": [{\n\t\t\t\t\t\t\t\t\ + \t\t\t\t\"name\": \"measurementTypes\",\n\t\t\t\t\t\t\t\t\t\t\t\t\"type\": {\n\t\t\t\t\t\t\t\t\t\t\ + \t\t\t\"type\": \"array\",\n\t\t\t\t\t\t\t\t\t\t\t\t\t\"items\": {\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\"\ + name\": \"Measurement_Types_Type\",\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\"type\": \"record\",\n\t\t\t\t\t\ + \t\t\t\t\t\t\t\t\t\"fields\": [{\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\"name\": \"measurementType\",\n\t\ + \t\t\t\t\t\t\t\t\t\t\t\t\t\t\"type\": \"string\"\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t}]\n\t\t\t\t\t\t\t\t\ + \t\t\t\t\t}\n\t\t\t\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\t\t\t\t{\n\t\t\t\t\ + \t\t\t\t\t\t\t\t\"name\": \"managedObjectDNsBasic\",\n\t\t\t\t\t\t\t\t\t\t\t\t\"type\": {\n\t\t\t\t\ + \t\t\t\t\t\t\t\t\t\"type\": \"array\",\n\t\t\t\t\t\t\t\t\t\t\t\t\t\"items\": {\n\t\t\t\t\t\t\t\t\t\ + \t\t\t\t\t\"name\": \"Managed_Object_Dns_Basic_Type\",\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\"type\": \"record\"\ + ,\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\"fields\": [{\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\"name\": \"DN\",\n\t\ + \t\t\t\t\t\t\t\t\t\t\t\t\t\t\"type\": \"string\"\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t}]\n\t\t\t\t\t\t\t\t\ + \t\t\t\t\t}\n\t\t\t\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\t\t]\n\t\t\t\t\t\ + \t\t\t\t}\n\t\t\t\t\t\t\t\t}]\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t]\n\t\t\t}\n\t\ + \t}\n\t]\n}" + - key: + name: SimpleIntType + version: 0.0.1 + value: + key: + name: SimpleIntType + version: 0.0.1 + schemaFlavour: Java + schemaDefinition: java.lang.Integer + - key: + name: SimpleStringType + version: 0.0.1 + value: + key: + name: SimpleStringType + version: 0.0.1 + schemaFlavour: Java + schemaDefinition: java.lang.String + - key: + name: SubscriptionStatusType + version: 0.0.1 + value: + key: + name: SubscriptionStatusType + version: 0.0.1 + schemaFlavour: Avro + schemaDefinition: |- + { + "type": "record", + "name": "ActivateSubscriptionStatus_Type", + "namespace": "org.onap.policy.apex.onap.helloworld", + "fields": [ + { + "name": "subscriptionName", + "type": "string" + }, + { + "name": "nfName", + "type": "string" + }, + { + "name": "changeType", + "type": "string" + }, + { + "name": "message", + "type": "string" + } + ] + } + - key: + name: SubscriptionType + version: 0.0.1 + value: + key: + name: SubscriptionType + version: 0.0.1 + schemaFlavour: Avro + schemaDefinition: "{\n\t\"name\": \"subscription\",\n\t\"type\": \"record\",\n\t\"fields\": [{\n\t\t\ + \t\"name\": \"subscriptionName\",\n\t\t\t\"type\": \"string\"\n\t\t},\n\t\t{\n\t\t\t\"name\": \"administrativeState\"\ + ,\n\t\t\t\"type\": \"string\"\n\t\t},\n\t\t{\n\t\t\t\"name\": \"fileBasedGP\",\n\t\t\t\"type\": \"\ + int\"\n\t\t},\n\t\t{\n\t\t\t\"name\": \"fileLocation\",\n\t\t\t\"type\": \"string\"\n\t\t},\n\t\t\ + {\n\t\t\t\"name\": \"measurementGroups\",\n\t\t\t\"type\": {\n\t\t\t\t\"type\": \"array\",\n\t\t\t\ + \t\"items\": {\n\t\t\t\t\t\"name\": \"Measurement_Groups_Type\",\n\t\t\t\t\t\"type\": \"record\",\n\ + \t\t\t\t\t\"fields\": [{\n\t\t\t\t\t\t\"name\": \"measurementGroup\",\n\t\t\t\t\t\t\"type\": {\n\t\ + \t\t\t\t\t\t\"name\": \"Measurement_Group_Type\",\n\t\t\t\t\t\t\t\"type\": \"record\",\n\t\t\t\t\t\ + \t\t\"fields\": [{\n\t\t\t\t\t\t\t\t\t\"name\": \"measurementTypes\",\n\t\t\t\t\t\t\t\t\t\"type\"\ + : {\n\t\t\t\t\t\t\t\t\t\t\"type\": \"array\",\n\t\t\t\t\t\t\t\t\t\t\"items\": {\n\t\t\t\t\t\t\t\t\t\ + \t\t\"name\": \"Measurement_Types_Type\",\n\t\t\t\t\t\t\t\t\t\t\t\"type\": \"record\",\n\t\t\t\t\t\ + \t\t\t\t\t\t\"fields\": [{\n\t\t\t\t\t\t\t\t\t\t\t\t\"name\": \"measurementType\",\n\t\t\t\t\t\t\t\ + \t\t\t\t\t\"type\": \"string\"\n\t\t\t\t\t\t\t\t\t\t\t}]\n\t\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\t\ + }\n\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\t\"name\": \"managedObjectDNsBasic\",\n\ + \t\t\t\t\t\t\t\t\t\"type\": {\n\t\t\t\t\t\t\t\t\t\t\"type\": \"array\",\n\t\t\t\t\t\t\t\t\t\t\"items\"\ + : {\n\t\t\t\t\t\t\t\t\t\t\t\"name\": \"Managed_Object_Dns_Basic_Type\",\n\t\t\t\t\t\t\t\t\t\t\t\"\ + type\": \"record\",\n\t\t\t\t\t\t\t\t\t\t\t\"fields\": [{\n\t\t\t\t\t\t\t\t\t\t\t\t\"name\": \"DN\"\ + ,\n\t\t\t\t\t\t\t\t\t\t\t\t\"type\": \"string\"\n\t\t\t\t\t\t\t\t\t\t\t}]\n\t\t\t\t\t\t\t\t\t\t}\n\ + \t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t]\n\t\t\t\t\t\t}\n\t\t\t\t\t}]\n\t\t\t\t}\n\t\ + \t\t}\n\t\t}\n\t]\n}" + - key: + name: UUIDType + version: 0.0.1 + value: + key: + name: UUIDType + version: 0.0.1 + schemaFlavour: Java + schemaDefinition: java.util.UUID + 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.acm.util.Serialization$GsonInstantAdapter + eventInputParameters: + DCAEConsumer: + carrierTechnologyParameters: + carrierTechnology: RESTCLIENT + parameterClassName: org.onap.policy.apex.plugins.event.carrier.restclient.RestClientCarrierTechnologyParameters + parameters: + consumerPollTime: '50' + url: https://message-router:3905/events/unauthenticated.DCAE_CL_OUTPUT/cg1/sg1 + eventProtocolParameters: + eventProtocol: JSON + parameters: + nameAlias: policyName + eventName: pmsh-operational-policy + eventNameFilter: pmsh-operational-policy + CDSRequestConsumer: + carrierTechnologyParameters: + carrierTechnology: RESTREQUESTOR + parameterClassName: org.onap.policy.apex.plugins.event.carrier.restrequestor.RestRequestorCarrierTechnologyParameters + parameters: + url: http://10.10.10.184:30254/api/v1/execution-service/process + httpMethod: POST + restRequestTimeout: 2000 + httpHeaders: + - - Authorization + - Basic Y2NzZGthcHBzOmNjc2RrYXBwcw== + eventProtocolParameters: + eventProtocol: JSON + eventName: CDSCreateResponseEvent + eventNameFilter: CDSCreateResponseEvent + requestorMode: true + requestorPeer: CDSRequestProducer + requestorTimeout: 500 + CDSDeleteRequestConsumer: + carrierTechnologyParameters: + carrierTechnology: RESTREQUESTOR + parameterClassName: org.onap.policy.apex.plugins.event.carrier.restrequestor.RestRequestorCarrierTechnologyParameters + parameters: + url: http://10.10.10.184:30254/api/v1/execution-service/process + httpMethod: POST + restRequestTimeout: 2000 + httpHeaders: + - - Authorization + - Basic Y2NzZGthcHBzOmNjc2RrYXBwcw== + eventProtocolParameters: + eventProtocol: JSON + eventName: CDSDeleteResponseEvent + eventNameFilter: CDSDeleteResponseEvent + requestorMode: true + requestorPeer: CDSDeleteRequestProducer + requestorTimeout: 500 + CDSReplyConsumer: + carrierTechnologyParameters: + carrierTechnology: RESTREQUESTOR + parameterClassName: org.onap.policy.apex.plugins.event.carrier.restrequestor.RestRequestorCarrierTechnologyParameters + parameters: + url: https://message-router:3905/events/unauthenticated.PMSH_CL_INPUT + httpMethod: POST + restRequestTimeout: 2000 + eventProtocolParameters: + eventProtocol: JSON + eventName: MRResponseEvent + eventNameFilter: MRResponseEvent + requestorMode: true + requestorPeer: CDSReplyProducer + requestorTimeout: 500 + eventOutputParameters: + logOutputter: + carrierTechnologyParameters: + carrierTechnology: FILE + parameters: + fileName: /tmp/outputevents.log + eventProtocolParameters: + eventProtocol: JSON + StdOutOutputter: + carrierTechnologyParameters: + carrierTechnology: FILE + parameters: + standardIo: true + eventProtocolParameters: + eventProtocol: JSON + CDSRequestProducer: + carrierTechnologyParameters: + carrierTechnology: RESTREQUESTOR + parameterClassName: org.onap.policy.apex.plugins.event.carrier.restrequestor.RestRequestorCarrierTechnologyParameters + eventProtocolParameters: + eventProtocol: JSON + eventNameFilter: CDSCreateSubscriptionRequestEvent + requestorMode: true + requestorPeer: CDSRequestConsumer + requestorTimeout: 500 + CDSDeleteRequestProducer: + carrierTechnologyParameters: + carrierTechnology: RESTREQUESTOR + parameterClassName: org.onap.policy.apex.plugins.event.carrier.restrequestor.RestRequestorCarrierTechnologyParameters + eventProtocolParameters: + eventProtocol: JSON + eventNameFilter: CDSDeleteSubscriptionRequestEvent + requestorMode: true + requestorPeer: CDSDeleteRequestConsumer + requestorTimeout: 500 + CDSReplyProducer: + carrierTechnologyParameters: + carrierTechnology: RESTREQUESTOR + parameterClassName: org.onap.policy.apex.plugins.event.carrier.restrequestor.RestRequestorCarrierTechnologyParameters + eventProtocolParameters: + eventProtocol: JSON + eventNameFilter: CDSResponseStatusEvent + requestorMode: true + requestorPeer: CDSReplyConsumer + requestorTimeout: 500 diff --git a/models/src/test/resources/examples/controlloop/PMSubscriptionHandling.yaml b/models/src/test/resources/examples/controlloop/PMSubscriptionHandling.yaml deleted file mode 100644 index 8e8f3cd39..000000000 --- a/models/src/test/resources/examples/controlloop/PMSubscriptionHandling.yaml +++ /dev/null @@ -1,3325 +0,0 @@ -# ============LICENSE_START======================================================= -# Copyright (C) 2021 Nordix Foundation. -# ================================================================================ -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# -# SPDX-License-Identifier: Apache-2.0 -# ============LICENSE_END========================================================= -tosca_definitions_version: tosca_simple_yaml_1_3 -data_types: - onap.datatypes.ToscaConceptIdentifier: - derived_from: tosca.datatypes.Root - properties: - name: - type: string - required: true - version: - type: string - required: true - org.onap.datatypes.policy.clamp.controlloop.DCAEMicroserviceControlLoopElementConsulInfo: - name: org.onap.datatypes.policy.clamp.controlloop.DCAEMicroserviceControlLoopElementConsulInfo - version: 0.0.0 - derived_from: tosca.datatypes.Root - properties: - consulUrl: - name: consulUrl - type: string - typeVersion: 0.0.0 - description: Consul url for this entry - required: true - consul_body: - name: consulBody - type: string - typeVersion: 0.0.0 - description: Body of Consul entry - required: true - onap.datatypes.monitoring.managedObjectDNsBasic: - constraints: [] - properties: - DN: - name: DN - type: string - typeVersion: 0.0.0 - description: Managed object distinguished name - required: true - constraints: [] - metadata: {} - name: onap.datatypes.monitoring.managedObjectDNsBasic - version: 0.0.0 - derived_from: tosca.datatypes.Root - metadata: {} - onap.datatypes.monitoring.managedObjectDNsBasics: - constraints: [] - properties: - managedObjectDNsBasic: - name: managedObjectDNsBasic - type: map - typeVersion: 0.0.0 - description: Managed object distinguished name object - required: true - constraints: [] - entry_schema: - type: onap.datatypes.monitoring.managedObjectDNsBasic - typeVersion: 0.0.0 - constraints: [] - metadata: {} - name: onap.datatypes.monitoring.managedObjectDNsBasics - version: 0.0.0 - derived_from: tosca.datatypes.Root - metadata: {} - onap.datatypes.monitoring.measurementGroup: - constraints: [] - properties: - measurementTypes: - name: measurementTypes - type: list - typeVersion: 0.0.0 - description: List of measurement types - required: true - constraints: [] - entry_schema: - type: onap.datatypes.monitoring.measurementTypes - typeVersion: 0.0.0 - constraints: [] - metadata: {} - managedObjectDNsBasic: - name: managedObjectDNsBasic - type: list - typeVersion: 0.0.0 - description: List of managed object distinguished names - required: true - constraints: [] - entry_schema: - type: onap.datatypes.monitoring.managedObjectDNsBasics - typeVersion: 0.0.0 - constraints: [] - metadata: {} - name: onap.datatypes.monitoring.measurementGroup - version: 0.0.0 - derived_from: tosca.datatypes.Root - metadata: {} - onap.datatypes.monitoring.measurementGroups: - constraints: [] - properties: - measurementGroup: - name: measurementGroup - type: map - typeVersion: 0.0.0 - description: Measurement Group - required: true - constraints: [] - entry_schema: - type: onap.datatypes.monitoring.measurementGroup - typeVersion: 0.0.0 - constraints: [] - metadata: {} - name: onap.datatypes.monitoring.measurementGroups - version: 0.0.0 - derived_from: tosca.datatypes.Root - metadata: {} - onap.datatypes.monitoring.measurementType: - constraints: [] - properties: - measurementType: - name: measurementType - type: string - typeVersion: 0.0.0 - description: Measurement type - required: true - constraints: [] - metadata: {} - name: onap.datatypes.monitoring.measurementType - version: 0.0.0 - derived_from: tosca.datatypes.Root - metadata: {} - onap.datatypes.monitoring.measurementTypes: - constraints: [] - properties: - measurementType: - name: measurementType - type: map - typeVersion: 0.0.0 - description: Measurement type object - required: true - constraints: [] - entry_schema: - type: onap.datatypes.monitoring.measurementType - typeVersion: 0.0.0 - constraints: [] - metadata: {} - name: onap.datatypes.monitoring.measurementTypes - version: 0.0.0 - derived_from: tosca.datatypes.Root - metadata: {} - onap.datatypes.monitoring.nfFilter: - constraints: [] - properties: - modelNames: - name: modelNames - type: list - typeVersion: 0.0.0 - description: List of model names - required: true - constraints: [] - entry_schema: - type: string - typeVersion: 0.0.0 - constraints: [] - metadata: {} - modelInvariantIDs: - name: modelInvariantIDs - type: list - typeVersion: 0.0.0 - description: List of model invariant IDs - required: true - constraints: [] - entry_schema: - type: string - typeVersion: 0.0.0 - constraints: [] - metadata: {} - modelVersionIDs: - name: modelVersionIDs - type: list - typeVersion: 0.0.0 - description: List of model version IDs - required: true - constraints: [] - entry_schema: - type: string - typeVersion: 0.0.0 - constraints: [] - metadata: {} - nfNames: - name: nfNames - type: list - typeVersion: 0.0.0 - description: List of network functions - required: true - constraints: [] - entry_schema: - type: string - typeVersion: 0.0.0 - constraints: [] - metadata: {} - name: onap.datatypes.monitoring.nfFilter - version: 0.0.0 - derived_from: tosca.datatypes.Root - metadata: {} - onap.datatypes.monitoring.subscription: - constraints: [] - properties: - measurementGroups: - name: measurementGroups - type: list - typeVersion: 0.0.0 - description: Measurement Groups - required: true - constraints: [] - entry_schema: - type: onap.datatypes.monitoring.measurementGroups - typeVersion: 0.0.0 - constraints: [] - metadata: {} - fileBasedGP: - name: fileBasedGP - type: integer - typeVersion: 0.0.0 - description: File based granularity period - required: true - constraints: [] - metadata: {} - fileLocation: - name: fileLocation - type: string - typeVersion: 0.0.0 - description: ROP file location - required: true - constraints: [] - metadata: {} - subscriptionName: - name: subscriptionName - type: string - typeVersion: 0.0.0 - description: Name of the subscription - required: true - constraints: [] - metadata: {} - administrativeState: - name: administrativeState - type: string - typeVersion: 0.0.0 - description: State of the subscription - required: true - constraints: - - valid_values: - - LOCKED - - UNLOCKED - metadata: {} - nfFilter: - name: nfFilter - type: map - typeVersion: 0.0.0 - description: Network function filter - required: true - constraints: [] - entry_schema: - type: onap.datatypes.monitoring.nfFilter - typeVersion: 0.0.0 - constraints: [] - metadata: {} - name: onap.datatypes.monitoring.subscription - version: 0.0.0 - derived_from: tosca.datatypes.Root - metadata: {} -policy_types: - onap.policies.Monitoring: - derived_from: tosca.policies.Root - description: a base policy type for all policies that govern monitoring provisioning - version: 1.0.0 - name: onap.policies.Monitoring - onap.policies.monitoring.dcae-pm-subscription-handler: - properties: - pmsh_policy: - name: pmsh_policy - type: onap.datatypes.monitoring.subscription - typeVersion: 0.0.0 - description: PMSH Policy JSON - required: false - constraints: [] - metadata: {} - name: onap.policies.monitoring.dcae-pm-subscription-handler - version: 1.0.0 - derived_from: onap.policies.Monitoring - metadata: {} -node_types: - org.onap.policy.clamp.controlloop.Participant: - version: 1.0.1 - derived_from: tosca.nodetypes.Root - properties: - provider: - type: string - required: false - org.onap.policy.clamp.controlloop.ControlLoopElement: - version: 1.0.1 - derived_from: tosca.nodetypes.Root - properties: - provider: - type: string - required: false - participantType: - type: onap.datatypes.ToscaConceptIdentifier - required: true - startPhase: - type: integer - required: false - constraints: - - greater-or-equal: 0 - metadata: - common: true - description: A value indicating the start phase in which this control loop element will be started, the - first start phase is zero. Control Loop Elements are started in their start_phase order and stopped - in reverse start phase order. Control Loop Elements with the same start phase are started and - stopped simultaneously - org.onap.policy.clamp.controlloop.ControlLoop: - version: 1.0.1 - derived_from: tosca.nodetypes.Root - properties: - provider: - type: string - required: false - elements: - type: list - required: true - entry_schema: - type: onap.datatypes.ToscaConceptIdentifier - org.onap.policy.clamp.controlloop.DCAEMicroserviceControlLoopElement: - version: 1.0.1 - derived_from: org.onap.policy.clamp.controlloop.ControlLoopElement - properties: - dcae_blueprint_id: - type: onap.datatypes.ToscaConceptIdentifier - required: false - dcae_blueprint: - type: onap.dcae.cloudify_blueprint - required: false - consul_info: - type: list - required: false - entry_schema: - type: org.onap.datatypes.policy.clamp.controlloop.DCAEMicroserviceControlLoopElementConsulInfo - org.onap.policy.clamp.controlloop.PolicyControlLoopElement: - version: 1.0.1 - derived_from: org.onap.policy.clamp.controlloop.ControlLoopElement - properties: - policy_type_id: - type: onap.datatypes.ToscaConceptIdentifier - required: true - policy_id: - type: onap.datatypes.ToscaConceptIdentifier - required: false - org.onap.policy.clamp.controlloop.CDSControlLoopElement: - version: 1.0.1 - derived_from: org.onap.policy.clamp.controlloop.ControlLoopElement - properties: - cds_blueprint_id: - type: onap.datatypes.ToscaConceptIdentifier - required: true -topology_template: - inputs: - pmsh_monitoring_policy: - type: onap.datatypes.ToscaConceptIdentifier - description: The ID of the PMSH monitoring policy to use - default: - name: MICROSERVICE_vLoadBalancerMS_v1_0_dcae-pm-subscription-handler_1_0_0test - version: 1.0.0 - pmsh_operational_policy: - type: onap.datatypes.ToscaConceptIdentifier - description: The ID of the PMSH operational policy to use - default: - name: operational.apex.pmcontrol - version: 1.0.0 - node_templates: - org.onap.dcae.controlloop.DCAEMicroserviceControlLoopParticipant: - version: 2.3.4 - type: org.onap.policy.clamp.controlloop.Participant - type_version: 1.0.1 - description: Participant for DCAE microservices - properties: - provider: ONAP - org.onap.policy.controlloop.PolicyControlLoopParticipant: - version: 2.3.1 - type: org.onap.policy.clamp.controlloop.Participant - type_version: 1.0.1 - description: Participant for DCAE microservices - properties: - provider: ONAP - org.onap.ccsdk.cds.controlloop.CdsControlLoopParticipant: - version: 2.2.1 - type: org.onap.policy.clamp.controlloop.Participant - type_version: 1.0.1 - description: Participant for DCAE microservices - properties: - provider: ONAP - org.onap.domain.pmsh.PMSH_DCAEMicroservice: - version: 1.2.3 - type: org.onap.policy.clamp.controlloop.DCAEMicroserviceControlLoopElement - type_version: 1.0.0 - description: Control loop element for the DCAE microservice for Performance Management Subscription Handling - properties: - provider: Ericsson - participantType: - name: org.onap.dcae.controlloop.DCAEMicroserviceControlLoopParticipant - version: 2.3.4 - dcae_blueprint: - tosca_definitions_version: cloudify_dsl_1_3 - imports: - - https://www.getcloudify.org/spec/cloudify/4.5.5/types.yaml - - plugin:k8splugin?version=3.7.0 - - plugin:pgaas?version=1.3.0 - - plugin:clamppolicyplugin?version=1.1.0 - inputs: - tag_version: - type: string - description: Docker image to be used - default: nexus3.onap.org:10001/onap/org.onap.dcaegen2.services.pmsh:1.1.2 - replicas: - type: integer - description: Number of instances - default: 1 - operational_policy_name: - type: string - default: operational.apex.pmcontrol - control_loop_name: - type: string - default: pmsh-control-loop - pmsh_publish_topic_name: - type: string - default: unauthenticated.DCAE_CL_OUTPUT - policy_feedback_topic_name: - type: string - default: unauthenticated.PMSH_CL_INPUT - aai_notification_topic_name: - type: string - default: AAI-EVENT - publisher_client_role: - type: string - description: Client role to request secure access to topic - default: org.onap.dcae.pmPublisher - subscriber_client_role: - type: string - description: Client role to request secure access to topic - default: org.onap.dcae.pmSubscriber - dcae_location: - type: string - description: DCAE location for the subscriber, used to set up routing - default: san-francisco - cpu_limit: - type: string - default: 1000m - cpu_request: - type: string - default: 1000m - memory_limit: - type: string - default: 1024Mi - memory_request: - type: string - default: 1024Mi - pgaas_cluster_name: - type: string - default: dcae-pg-primary.onap - enable_tls: - type: boolean - default: true - protocol: - type: string - description: PMSH protocol. If enable_tls is false, set to http - default: https - policy_model_id: - type: string - default: onap.policies.monitoring.dcae-pm-subscription-handler - policy_id: - type: string - default: MICROSERVICE_vLoadBalancerMS_v1_0_dcae-pm-subscription-handler_1_0_0test - node_templates: - pgaasvm: - type: dcae.nodes.pgaas.database - properties: - writerfqdn: - get_input: pgaas_cluster_name - name: pmsh - pmsh: - type: dcae.nodes.ContainerizedServiceComponentUsingDmaap - interfaces: - cloudify.interfaces.lifecycle: - create: - inputs: - ports: - - '8443:0' - envs: - PMSH_PG_URL: - get_attribute: - - pgaasvm - - admin - - host - PMSH_PG_PASSWORD: - get_attribute: - - pgaasvm - - admin - - password - PMSH_PG_USERNAME: - get_attribute: - - pgaasvm - - admin - - user - PMSH_DB_NAME: - get_attribute: - - pgaasvm - - admin - - database - relationships: - - target: pmsh-policy - type: cloudify.relationships.depends_on - properties: - service_component_type: dcae-pmsh - service_component_name_override: dcae-pmsh - application_config: - enable_tls: - get_input: enable_tls - aaf_identity: dcae@dcae.onap.org - aaf_password: demo123456! - operational_policy_name: - get_input: operational_policy_name - control_loop_name: - get_input: control_loop_name - cert_path: /opt/app/pmsh/etc/certs/cert.pem - key_path: /opt/app/pmsh/etc/certs/key.pem - ca_cert_path: /opt/app/pmsh/etc/certs/cacert.pem - streams_publishes: - policy_pm_publisher: - type: message_router - dmaap_info: - topic_url: - concat: - - http://message-router:3904/events/ - - get_input: pmsh_publish_topic_name - streams_subscribes: - policy_pm_subscriber: - type: message_router - dmaap_info: - topic_url: - concat: - - http://message-router:3904/events/ - - get_input: policy_feedback_topic_name - aai_subscriber: - type: message_router - dmaap_info: - topic_url: - concat: - - http://message-router:3904/events/ - - get_input: aai_notification_topic_name - resource_config: - limits: - cpu: - get_input: cpu_limit - memory: - get_input: memory_limit - requests: - cpu: - get_input: cpu_request - memory: - get_input: memory_request - docker_config: - healthcheck: - endpoint: /healthcheck - interval: 15s - timeout: 1s - type: - get_input: protocol - image: - get_input: tag_version - replicas: - get_input: replicas - log_info: - log_directory: /var/log/ONAP/dcaegen2/services/pmsh - tls_info: - cert_directory: /opt/app/pmsh/etc/certs - use_tls: - get_input: enable_tls - pmsh-policy: - type: clamp.nodes.policy - properties: - policy_model_id: - get_input: policy_model_id - policy_id: - get_input: policy_id - consul_info: - - consulUrl: http://consul:31321/v1/kv/dcae-pmsh:policy - consulBody: - subscription: - subscriptionName: subscriptiona - administrativeState: UNLOCKED - fileBasedGP: 15 - fileLocation: /pm/pm.xml - nfFilter: - nfNames: - - ^pnf1.* - modelInvariantIDs: - - 5845y423-g654-6fju-po78-8n53154532k6 - - 7129e420-d396-4efb-af02-6b83499b12f8 - modelVersionIDs: - - e80a6ae3-cafd-4d24-850d-e14c084a5ca9 - measurementGroups: - - measurementGroup: - measurementTypes: - - measurementType: countera - - measurementType: counterb - managedObjectDNsBasic: - - DN: dna - - DN: dnb - - measurementGroup: - measurementTypes: - - measurementType: counterc - - measurementType: counterd - managedObjectDNsBasic: - - DN: dnc - - DN: dnd - org.onap.domain.pmsh.PMSH_MonitoringPolicyControlLoopElement: - version: 1.2.3 - type: org.onap.policy.clamp.controlloop.PolicyControlLoopElement - type_version: 1.0.0 - description: Control loop element for the monitoring policy for Performance Management Subscription Handling - properties: - provider: Ericsson - participantType: - name: org.onap.policy.controlloop.PolicyControlLoopParticipant - version: 2.3.1 - policy_type_id: - name: onap.policies.monitoring.pm-subscription-handler - version: 1.0.0 - policy_id: - get_input: pmsh_monitoring_policy - org.onap.domain.pmsh.PMSH_OperationalPolicyControlLoopElement: - version: 1.2.3 - type: org.onap.policy.clamp.controlloop.PolicyControlLoopElement - type_version: 1.0.0 - description: Control loop element for the operational policy for Performance Management Subscription Handling - properties: - provider: Ericsson - participantType: - name: org.onap.policy.controlloop.PolicyControlLoopParticipant - version: 2.2.1 - policy_type_id: - name: onap.policies.operational.pm-subscription-handler - version: 1.0.0 - policy_id: - get_input: pmsh_operational_policy - org.onap.domain.pmsh.PMSH_CDS_ControlLoopElement: - version: 1.2.3 - type: org.onap.policy.clamp.controlloop.CDSControlLoopElement - type_version: 1.0.0 - description: Control loop element for CDS for Performance Management Subscription Handling - properties: - provider: Ericsson - participantType: - name: org.onap.ccsdk.cds.controlloop.CdsControlLoopParticipant - version: 3.2.1 - cds_blueprint_id: - name: org.onap.ccsdk.cds.PMSHCdsBlueprint - version: 1.0.0 - org.onap.domain.pmsh.PMSHControlLoopDefinition: - version: 1.2.3 - type: org.onap.policy.clamp.controlloop.ControlLoop - type_version: 1.0.0 - description: Control loop for Performance Management Subscription Handling - properties: - provider: Ericsson - elements: - - name: org.onap.domain.pmsh.PMSH_DCAEMicroservice - version: 1.2.3 - - name: org.onap.domain.pmsh.PMSH_MonitoringPolicyControlLoopElement - version: 1.2.3 - - name: org.onap.domain.pmsh.PMSH_OperationalPolicyControlLoopElement - version: 1.2.3 - - name: org.onap.domain.pmsh.PMSH_CDS_ControlLoopElement - version: 1.2.3 - policies: - - MICROSERVICE_vLoadBalancerMS_v1_0_dcae-pm-subscription-handler_1_0_0test: - type: onap.policies.monitoring.dcae-pm-subscription-handler - type_version: 1.0.0 - name: MICROSERVICE_vLoadBalancerMS_v1_0_dcae-pm-subscription-handler_1_0_0test - version: 1.0.0 - metadata: - policy-id: MICROSERVICE_vLoadBalancerMS_v1_0_dcae-pm-subscription-handler_1_0_0test - policy-version: 1.0.0 - properties: - pmsh_policy: - fileBasedGP: 15 - fileLocation: /pm/pm.xml - subscriptionName: subscriptiona - administrativeState: UNLOCKED - nfFilter: - onap.datatypes.monitoring.nfFilter: - modelVersionIDs: - - e80a6ae3-cafd-4d24-850d-e14c084a5ca9 - modelInvariantIDs: - - 5845y423-g654-6fju-po78-8n53154532k6 - - 7129e420-d396-4efb-af02-6b83499b12f8 - modelNames: [] - nfNames: - - '"^pnf1.*"' - measurementGroups: - - measurementGroup: - onap.datatypes.monitoring.measurementGroup: - measurementTypes: - - measurementType: - onap.datatypes.monitoring.measurementType: - measurementType: countera - - measurementType: - onap.datatypes.monitoring.measurementType: - measurementType: counterb - managedObjectDNsBasic: - - managedObjectDNsBasic: - onap.datatypes.monitoring.managedObjectDNsBasic: - DN: dna - - managedObjectDNsBasic: - onap.datatypes.monitoring.managedObjectDNsBasic: - DN: dnb - - measurementGroup: - onap.datatypes.monitoring.measurementGroup: - measurementTypes: - - measurementType: - onap.datatypes.monitoring.measurementType: - measurementType: counterc - - measurementType: - onap.datatypes.monitoring.measurementType: - measurementType: counterd - managedObjectDNsBasic: - - managedObjectDNsBasic: - onap.datatypes.monitoring.managedObjectDNsBasic: - DN: dnc - - managedObjectDNsBasic: - onap.datatypes.monitoring.managedObjectDNsBasic: - DN: dnd - - operational.apex.pmcontrol: - type: onap.policies.controlloop.operational.common.Apex - type_version: 1.0.0 - version: 1.0.0 - metadata: - policy-id: operational.apex.pmcontrol - policy-version: 1 - properties: - engineServiceParameters: - name: MyApexEngine - version: 0.0.1 - id: 45 - instanceCount: 2 - deploymentPort: 12561 - policy_type_impl: - apexPolicyModel: - key: - name: PMControlPolicy - version: 0.0.1 - keyInformation: - key: - name: PMControlPolicy_KeyInfo - version: 0.0.1 - keyInfoMap: - entry: - - key: - name: CDSActionIdentifiersType - version: 0.0.1 - value: - key: - name: CDSActionIdentifiersType - version: 0.0.1 - UUID: 6e5fa19b-14df-37e3-a4ae-8c537e861a82 - description: Generated description for concept referred to by key "CDSActionIdentifiersType:0.0.1" - - key: - name: CDSCreateResponseEvent - version: 0.0.1 - value: - key: - name: CDSCreateResponseEvent - version: 0.0.1 - UUID: 14b29e38-ac75-3273-aa4e-8583c0aa7dad - description: Generated description for concept referred to by key "CDSCreateResponseEvent:0.0.1" - - key: - name: CDSCreateResponsePayloadType - version: 0.0.1 - value: - key: - name: CDSCreateResponsePayloadType - version: 0.0.1 - UUID: 04573f8f-e772-30a5-b1d9-d7318d4a1e13 - description: Generated description for concept referred to by key "CDSCreateResponsePayloadType:0.0.1" - - key: - name: CDSCreateResponsePolicy - version: 0.0.1 - value: - key: - name: CDSCreateResponsePolicy - version: 0.0.1 - UUID: e126c965-fc09-3bfe-8f55-70f380a4a49c - description: Generated description for concept referred to by key "CDSCreateResponsePolicy:0.0.1" - - key: - name: CDSCreateResponseTask - version: 0.0.1 - value: - key: - name: CDSCreateResponseTask - version: 0.0.1 - UUID: 6165ee82-afd2-3aab-a517-f00b3f2461d2 - description: Generated description for concept referred to by key "CDSCreateResponseTask:0.0.1" - - key: - name: CDSCreateSubscriptionPayloadType - version: 0.0.1 - value: - key: - name: CDSCreateSubscriptionPayloadType - version: 0.0.1 - UUID: 8350ac5e-c157-38b9-9614-a0f93a830e60 - description: Generated description for concept referred to by key "CDSCreateSubscriptionPayloadType:0.0.1" - - key: - name: CDSCreateSubscriptionRequestEvent - version: 0.0.1 - value: - key: - name: CDSCreateSubscriptionRequestEvent - version: 0.0.1 - UUID: cfa325ba-226b-3a31-9183-ec43e2b6e9a2 - description: Generated description for concept referred to by key "CDSCreateSubscriptionRequestEvent:0.0.1" - - key: - name: CDSDeleteResponseEvent - version: 0.0.1 - value: - key: - name: CDSDeleteResponseEvent - version: 0.0.1 - UUID: 8be9c0fa-7437-3841-aff2-b3cec6ae3bd8 - description: Generated description for concept referred to by key "CDSDeleteResponseEvent:0.0.1" - - key: - name: CDSDeleteResponsePayloadType - version: 0.0.1 - value: - key: - name: CDSDeleteResponsePayloadType - version: 0.0.1 - UUID: 3fbfe0c9-152e-34d3-a504-09cd13c058d0 - description: Generated description for concept referred to by key "CDSDeleteResponsePayloadType:0.0.1" - - key: - name: CDSDeleteResponsePolicy - version: 0.0.1 - value: - key: - name: CDSDeleteResponsePolicy - version: 0.0.1 - UUID: a780251c-edd5-3132-b865-04313246b43c - description: Generated description for concept referred to by key "CDSDeleteResponsePolicy:0.0.1" - - key: - name: CDSDeleteResponseTask - version: 0.0.1 - value: - key: - name: CDSDeleteResponseTask - version: 0.0.1 - UUID: afce4555-3aa3-3521-a7d8-ee8cdf0d3efc - description: Generated description for concept referred to by key "CDSDeleteResponseTask:0.0.1" - - key: - name: CDSDeleteSubscriptionPayloadType - version: 0.0.1 - value: - key: - name: CDSDeleteSubscriptionPayloadType - version: 0.0.1 - UUID: 12658406-9147-3c9d-a38c-5ad5e30b092b - description: Generated description for concept referred to by key "CDSDeleteSubscriptionPayloadType:0.0.1" - - key: - name: CDSDeleteSubscriptionRequestEvent - version: 0.0.1 - value: - key: - name: CDSDeleteSubscriptionRequestEvent - version: 0.0.1 - UUID: 24380c95-9289-36e6-8cbf-0edefa15ccd9 - description: Generated description for concept referred to by key "CDSDeleteSubscriptionRequestEvent:0.0.1" - - key: - name: CDSRequestCommonHeaderType - version: 0.0.1 - value: - key: - name: CDSRequestCommonHeaderType - version: 0.0.1 - UUID: 35590ac0-062c-39f1-8786-b4ff716e30b1 - description: Generated description for concept referred to by key "CDSRequestCommonHeaderType:0.0.1" - - key: - name: CDSResponseCommonHeaderType - version: 0.0.1 - value: - key: - name: CDSResponseCommonHeaderType - version: 0.0.1 - UUID: dd7e1805-885a-350b-aaf9-ed541321ae3c - description: Generated description for concept referred to by key "CDSResponseCommonHeaderType:0.0.1" - - key: - name: CDSResponseStatusEvent - version: 0.0.1 - value: - key: - name: CDSResponseStatusEvent - version: 0.0.1 - UUID: 7986e21b-32f7-302e-9554-31f21b673493 - description: Generated description for concept referred to by key "CDSResponseStatusEvent:0.0.1" - - key: - name: CDSResponseStatusType - version: 0.0.1 - value: - key: - name: CDSResponseStatusType - version: 0.0.1 - UUID: 92b8a2cf-344e-3ce1-8cc0-2b7d3cb695fa - description: Generated description for concept referred to by key "CDSResponseStatusType:0.0.1" - - key: - name: CreateSubscriptionPayloadEvent - version: 0.0.1 - value: - key: - name: CreateSubscriptionPayloadEvent - version: 0.0.1 - UUID: 92162397-1a8e-3a3f-a469-d2af7700af4a - description: Generated description for concept referred to by key "CreateSubscriptionPayloadEvent:0.0.1" - - key: - name: CreateSubscriptionPayloadTask - version: 0.0.1 - value: - key: - name: CreateSubscriptionPayloadTask - version: 0.0.1 - UUID: bc0c69f0-52ed-38ea-b468-ae4a6fd1730d - description: Generated description for concept referred to by key "CreateSubscriptionPayloadTask:0.0.1" - - key: - name: CreateSubscriptionRequestTask - version: 0.0.1 - value: - key: - name: CreateSubscriptionRequestTask - version: 0.0.1 - UUID: 89cb75e9-f06c-30d3-b4ff-698d45f63869 - description: Generated description for concept referred to by key "CreateSubscriptionRequestTask:0.0.1" - - key: - name: DeleteSubscriptionPayloadEvent - version: 0.0.1 - value: - key: - name: DeleteSubscriptionPayloadEvent - version: 0.0.1 - UUID: 994fa441-04ab-33bb-832d-1cd12ab5d074 - description: Generated description for concept referred to by key "DeleteSubscriptionPayloadEvent:0.0.1" - - key: - name: DeleteSubscriptionPayloadTask - version: 0.0.1 - value: - key: - name: DeleteSubscriptionPayloadTask - version: 0.0.1 - UUID: 0f519117-5fea-3e4b-941f-8f778100465f - description: Generated description for concept referred to by key "DeleteSubscriptionPayloadTask:0.0.1" - - key: - name: DeleteSubscriptionRequestTask - version: 0.0.1 - value: - key: - name: DeleteSubscriptionRequestTask - version: 0.0.1 - UUID: acb772fe-d442-39e3-98f9-b1080caf4150 - description: Generated description for concept referred to by key "DeleteSubscriptionRequestTask:0.0.1" - - key: - name: MRResponseEvent - version: 0.0.1 - value: - key: - name: MRResponseEvent - version: 0.0.1 - UUID: 13c747a3-6bae-3bcf-9c80-b152e01dc194 - description: Generated description for concept referred to by key "MRResponseEvent:0.0.1" - - key: - name: PMControlPolicy - version: 0.0.1 - value: - key: - name: PMControlPolicy - version: 0.0.1 - UUID: acf1e55c-7bc5-3bd5-975a-0ca54afcd8a4 - description: Generated description for concept referred to by key "PMControlPolicy:0.0.1" - - key: - name: PMControlPolicy_Albums - version: 0.0.1 - value: - key: - name: PMControlPolicy_Albums - version: 0.0.1 - UUID: b38ad204-c2c8-32f4-9b5a-dda0aeb0145b - description: Generated description for concept referred to by key "PMControlPolicy_Albums:0.0.1" - - key: - name: PMControlPolicy_Events - version: 0.0.1 - value: - key: - name: PMControlPolicy_Events - version: 0.0.1 - UUID: be3871a0-c42a-3113-a066-82d192840eca - description: Generated description for concept referred to by key "PMControlPolicy_Events:0.0.1" - - key: - name: PMControlPolicy_KeyInfo - version: 0.0.1 - value: - key: - name: PMControlPolicy_KeyInfo - version: 0.0.1 - UUID: ced37634-28a4-3178-b7f6-2980794927b0 - description: Generated description for concept referred to by key "PMControlPolicy_KeyInfo:0.0.1" - - key: - name: PMControlPolicy_Policies - version: 0.0.1 - value: - key: - name: PMControlPolicy_Policies - version: 0.0.1 - UUID: be3d180d-ef9c-3a75-8e9c-84271a038bed - description: Generated description for concept referred to by key "PMControlPolicy_Policies:0.0.1" - - key: - name: PMControlPolicy_Schemas - version: 0.0.1 - value: - key: - name: PMControlPolicy_Schemas - version: 0.0.1 - UUID: e61973f1-189c-39e5-82f6-0d3afe298a20 - description: Generated description for concept referred to by key "PMControlPolicy_Schemas:0.0.1" - - key: - name: PMControlPolicy_Tasks - version: 0.0.1 - value: - key: - name: PMControlPolicy_Tasks - version: 0.0.1 - UUID: 5658adb3-2962-30a3-a241-fae75bb8eb4a - description: Generated description for concept referred to by key "PMControlPolicy_Tasks:0.0.1" - - key: - name: PMSubscriptionAlbum - version: 0.0.1 - value: - key: - name: PMSubscriptionAlbum - version: 0.0.1 - UUID: c2bd6f0d-6854-317a-9be2-97c08338428c - description: Generated description for concept referred to by key "PMSubscriptionAlbum:0.0.1" - - key: - name: PMSubscriptionOutputEvent - version: 0.0.1 - value: - key: - name: PMSubscriptionOutputEvent - version: 0.0.1 - UUID: 992b7819-9f69-3aa0-bb0f-6e45ea15ce05 - description: Generated description for concept referred to by key "PMSubscriptionOutputEvent:0.0.1" - - key: - name: PMSubscriptionType - version: 0.0.1 - value: - key: - name: PMSubscriptionType - version: 0.0.1 - UUID: 73c1c397-4fc3-357f-93b6-a8ad707fbaae - description: Generated description for concept referred to by key "PMSubscriptionType:0.0.1" - - key: - name: ReceiveEventPolicy - version: 0.0.1 - value: - key: - name: ReceiveEventPolicy - version: 0.0.1 - UUID: 568b7345-9de1-36d3-b6a3-9b857e6809a1 - description: Generated description for concept referred to by key "ReceiveEventPolicy:0.0.1" - - key: - name: ReceiveSubscriptionTask - version: 0.0.1 - value: - key: - name: ReceiveSubscriptionTask - version: 0.0.1 - UUID: f596afc8-100c-35eb-92c8-352355ea457d - description: Generated description for concept referred to by key "ReceiveSubscriptionTask:0.0.1" - - key: - name: SimpleIntType - version: 0.0.1 - value: - key: - name: SimpleIntType - version: 0.0.1 - UUID: 153791fd-ae0a-36a7-88a5-309a7936415d - description: Generated description for concept referred to by key "SimpleIntType:0.0.1" - - key: - name: SimpleStringType - version: 0.0.1 - value: - key: - name: SimpleStringType - version: 0.0.1 - UUID: 8a4957cf-9493-3a76-8c22-a208e23259af - description: Generated description for concept referred to by key "SimpleStringType:0.0.1" - - key: - name: SubscriptionStatusType - version: 0.0.1 - value: - key: - name: SubscriptionStatusType - version: 0.0.1 - UUID: 597643b1-9db1-31ce-85d0-e1c63c43b30b - description: Generated description for concept referred to by key "SubscriptionStatusType:0.0.1" - - key: - name: SubscriptionType - version: 0.0.1 - value: - key: - name: SubscriptionType - version: 0.0.1 - UUID: 184547bb-7d64-3cb2-a273-d7185102c5ce - description: Generated description for concept referred to by key "SubscriptionType:0.0.1" - - key: - name: UUIDType - version: 0.0.1 - value: - key: - name: UUIDType - version: 0.0.1 - UUID: 6a8cc68e-dfc8-3403-9c6d-071c886b319c - description: Generated description for concept referred to by key "UUIDType:0.0.1" - - key: - name: pmsh-operational-policy - version: 0.0.1 - value: - key: - name: pmsh-operational-policy - version: 0.0.1 - UUID: fdf2c9ff-6422-3ea6-b6b6-49b12116265d - description: Generated description for concept referred to by key "pmsh-operational-policy:0.0.1" - policies: - key: - name: PMControlPolicy_Policies - version: 0.0.1 - policyMap: - entry: - - key: - name: CDSCreateResponsePolicy - version: 0.0.1 - value: - policyKey: - name: CDSCreateResponsePolicy - version: 0.0.1 - template: Freestyle - state: - entry: - - key: CDSCreateResponseState - value: - stateKey: - parentKeyName: CDSCreateResponsePolicy - parentKeyVersion: 0.0.1 - parentLocalName: 'NULL' - localName: CDSCreateResponseState - trigger: - name: CDSCreateResponseEvent - version: 0.0.1 - stateOutputs: - entry: - - key: ResponseOutput - value: - key: - parentKeyName: CDSCreateResponsePolicy - parentKeyVersion: 0.0.1 - parentLocalName: CDSCreateResponseState - localName: ResponseOutput - outgoingEvent: - name: CDSResponseStatusEvent - version: 0.0.1 - nextState: - parentKeyName: 'NULL' - parentKeyVersion: 0.0.0 - parentLocalName: 'NULL' - localName: 'NULL' - contextAlbumReference: [] - taskSelectionLogic: - key: 'NULL' - logicFlavour: UNDEFINED - logic: '' - stateFinalizerLogicMap: - entry: [] - defaultTask: - name: CDSCreateResponseTask - version: 0.0.1 - taskReferences: - entry: - - key: - name: CDSCreateResponseTask - version: 0.0.1 - value: - key: - parentKeyName: CDSCreateResponsePolicy - parentKeyVersion: 0.0.1 - parentLocalName: CDSCreateResponseState - localName: CDSCreateResponsePolicy - outputType: DIRECT - output: - parentKeyName: CDSCreateResponsePolicy - parentKeyVersion: 0.0.1 - parentLocalName: CDSCreateResponseState - localName: ResponseOutput - firstState: CDSCreateResponseState - - key: - name: CDSDeleteResponsePolicy - version: 0.0.1 - value: - policyKey: - name: CDSDeleteResponsePolicy - version: 0.0.1 - template: Freestyle - state: - entry: - - key: CDSDeleteResponseState - value: - stateKey: - parentKeyName: CDSDeleteResponsePolicy - parentKeyVersion: 0.0.1 - parentLocalName: 'NULL' - localName: CDSDeleteResponseState - trigger: - name: CDSDeleteResponseEvent - version: 0.0.1 - stateOutputs: - entry: - - key: ResponseOutput - value: - key: - parentKeyName: CDSDeleteResponsePolicy - parentKeyVersion: 0.0.1 - parentLocalName: CDSDeleteResponseState - localName: ResponseOutput - outgoingEvent: - name: CDSResponseStatusEvent - version: 0.0.1 - nextState: - parentKeyName: 'NULL' - parentKeyVersion: 0.0.0 - parentLocalName: 'NULL' - localName: 'NULL' - contextAlbumReference: [] - taskSelectionLogic: - key: 'NULL' - logicFlavour: UNDEFINED - logic: '' - stateFinalizerLogicMap: - entry: [] - defaultTask: - name: CDSDeleteResponseTask - version: 0.0.1 - taskReferences: - entry: - - key: - name: CDSDeleteResponseTask - version: 0.0.1 - value: - key: - parentKeyName: CDSDeleteResponsePolicy - parentKeyVersion: 0.0.1 - parentLocalName: CDSDeleteResponseState - localName: CDSDeleteResponsePolicy - outputType: DIRECT - output: - parentKeyName: CDSDeleteResponsePolicy - parentKeyVersion: 0.0.1 - parentLocalName: CDSDeleteResponseState - localName: ResponseOutput - firstState: CDSDeleteResponseState - - key: - name: ReceiveEventPolicy - version: 0.0.1 - value: - policyKey: - name: ReceiveEventPolicy - version: 0.0.1 - template: Freestyle - state: - entry: - - key: CreateOrDeleteState - value: - stateKey: - parentKeyName: ReceiveEventPolicy - parentKeyVersion: 0.0.1 - parentLocalName: 'NULL' - localName: CreateOrDeleteState - trigger: - name: PMSubscriptionOutputEvent - version: 0.0.1 - stateOutputs: - entry: - - key: CreateSubscriptionPayload - value: - key: - parentKeyName: ReceiveEventPolicy - parentKeyVersion: 0.0.1 - parentLocalName: CreateOrDeleteState - localName: CreateSubscriptionPayload - outgoingEvent: - name: CreateSubscriptionPayloadEvent - version: 0.0.1 - nextState: - parentKeyName: ReceiveEventPolicy - parentKeyVersion: 0.0.1 - parentLocalName: 'NULL' - localName: CreateSubscription - - key: DeleteSubscriptionPayload - value: - key: - parentKeyName: ReceiveEventPolicy - parentKeyVersion: 0.0.1 - parentLocalName: CreateOrDeleteState - localName: DeleteSubscriptionPayload - outgoingEvent: - name: DeleteSubscriptionPayloadEvent - version: 0.0.1 - nextState: - parentKeyName: ReceiveEventPolicy - parentKeyVersion: 0.0.1 - parentLocalName: 'NULL' - localName: DeleteSubscription - contextAlbumReference: - - name: PMSubscriptionAlbum - version: 0.0.1 - taskSelectionLogic: - key: TaskSelectionLogic - logicFlavour: JAVASCRIPT - logic: |- - /* - * ============LICENSE_START======================================================= - * Copyright (C) 2020 Nordix. 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); - - var pmSubscriptionInfo = executor.getContextAlbum("PMSubscriptionAlbum").get(executor.inFields.get("albumID").toString()) - var changeType = pmSubscriptionInfo.get("changeType").toString() - - executor.logger.info("Change Type is " + changeType) - - if ("CREATE".equals(changeType)) { - executor.logger.info("Choosing to create a subscription") - executor.subject.getTaskKey("CreateSubscriptionPayloadTask").copyTo(executor.selectedTask); - } - else if ("DELETE".equals(changeType)) { - executor.logger.info("Choosing to delete a subscription") - executor.subject.getTaskKey("DeleteSubscriptionPayloadTask").copyTo(executor.selectedTask); - } - - //var returnValue = executor.isTrue; - true; - stateFinalizerLogicMap: - entry: [] - defaultTask: - name: CreateSubscriptionPayloadTask - version: 0.0.1 - taskReferences: - entry: - - key: - name: CreateSubscriptionPayloadTask - version: 0.0.1 - value: - key: - parentKeyName: ReceiveEventPolicy - parentKeyVersion: 0.0.1 - parentLocalName: CreateOrDeleteState - localName: ReceiveEventPolicy - outputType: DIRECT - output: - parentKeyName: ReceiveEventPolicy - parentKeyVersion: 0.0.1 - parentLocalName: CreateOrDeleteState - localName: CreateSubscriptionPayload - - key: - name: DeleteSubscriptionPayloadTask - version: 0.0.1 - value: - key: - parentKeyName: ReceiveEventPolicy - parentKeyVersion: 0.0.1 - parentLocalName: CreateOrDeleteState - localName: ReceiveEventPolicy - outputType: DIRECT - output: - parentKeyName: ReceiveEventPolicy - parentKeyVersion: 0.0.1 - parentLocalName: CreateOrDeleteState - localName: DeleteSubscriptionPayload - - key: CreateSubscription - value: - stateKey: - parentKeyName: ReceiveEventPolicy - parentKeyVersion: 0.0.1 - parentLocalName: 'NULL' - localName: CreateSubscription - trigger: - name: CreateSubscriptionPayloadEvent - version: 0.0.1 - stateOutputs: - entry: - - key: IssueCreateSubscriptionRequestOutput - value: - key: - parentKeyName: ReceiveEventPolicy - parentKeyVersion: 0.0.1 - parentLocalName: CreateSubscription - localName: IssueCreateSubscriptionRequestOutput - outgoingEvent: - name: CDSCreateSubscriptionRequestEvent - version: 0.0.1 - nextState: - parentKeyName: 'NULL' - parentKeyVersion: 0.0.0 - parentLocalName: 'NULL' - localName: 'NULL' - contextAlbumReference: - - name: PMSubscriptionAlbum - version: 0.0.1 - taskSelectionLogic: - key: 'NULL' - logicFlavour: UNDEFINED - logic: '' - stateFinalizerLogicMap: - entry: [] - defaultTask: - name: CreateSubscriptionRequestTask - version: 0.0.1 - taskReferences: - entry: - - key: - name: CreateSubscriptionRequestTask - version: 0.0.1 - value: - key: - parentKeyName: ReceiveEventPolicy - parentKeyVersion: 0.0.1 - parentLocalName: CreateSubscription - localName: ReceiveEventPolicy - outputType: DIRECT - output: - parentKeyName: ReceiveEventPolicy - parentKeyVersion: 0.0.1 - parentLocalName: CreateSubscription - localName: IssueCreateSubscriptionRequestOutput - - key: DeleteSubscription - value: - stateKey: - parentKeyName: ReceiveEventPolicy - parentKeyVersion: 0.0.1 - parentLocalName: 'NULL' - localName: DeleteSubscription - trigger: - name: DeleteSubscriptionPayloadEvent - version: 0.0.1 - stateOutputs: - entry: - - key: IssueDeleteSubscriptionRequestOutput - value: - key: - parentKeyName: ReceiveEventPolicy - parentKeyVersion: 0.0.1 - parentLocalName: DeleteSubscription - localName: IssueDeleteSubscriptionRequestOutput - outgoingEvent: - name: CDSDeleteSubscriptionRequestEvent - version: 0.0.1 - nextState: - parentKeyName: 'NULL' - parentKeyVersion: 0.0.0 - parentLocalName: 'NULL' - localName: 'NULL' - contextAlbumReference: - - name: PMSubscriptionAlbum - version: 0.0.1 - taskSelectionLogic: - key: 'NULL' - logicFlavour: UNDEFINED - logic: '' - stateFinalizerLogicMap: - entry: [] - defaultTask: - name: DeleteSubscriptionRequestTask - version: 0.0.1 - taskReferences: - entry: - - key: - name: DeleteSubscriptionRequestTask - version: 0.0.1 - value: - key: - parentKeyName: ReceiveEventPolicy - parentKeyVersion: 0.0.1 - parentLocalName: DeleteSubscription - localName: ReceiveEventPolicy - outputType: DIRECT - output: - parentKeyName: ReceiveEventPolicy - parentKeyVersion: 0.0.1 - parentLocalName: DeleteSubscription - localName: IssueDeleteSubscriptionRequestOutput - - key: ReceiveSubscriptionState - value: - stateKey: - parentKeyName: ReceiveEventPolicy - parentKeyVersion: 0.0.1 - parentLocalName: 'NULL' - localName: ReceiveSubscriptionState - trigger: - name: pmsh-operational-policy - version: 0.0.1 - stateOutputs: - entry: - - key: ReceivePMSubscriptionOutput - value: - key: - parentKeyName: ReceiveEventPolicy - parentKeyVersion: 0.0.1 - parentLocalName: ReceiveSubscriptionState - localName: ReceivePMSubscriptionOutput - outgoingEvent: - name: PMSubscriptionOutputEvent - version: 0.0.1 - nextState: - parentKeyName: ReceiveEventPolicy - parentKeyVersion: 0.0.1 - parentLocalName: 'NULL' - localName: CreateOrDeleteState - contextAlbumReference: - - name: PMSubscriptionAlbum - version: 0.0.1 - taskSelectionLogic: - key: 'NULL' - logicFlavour: UNDEFINED - logic: '' - stateFinalizerLogicMap: - entry: [] - defaultTask: - name: ReceiveSubscriptionTask - version: 0.0.1 - taskReferences: - entry: - - key: - name: ReceiveSubscriptionTask - version: 0.0.1 - value: - key: - parentKeyName: ReceiveEventPolicy - parentKeyVersion: 0.0.1 - parentLocalName: ReceiveSubscriptionState - localName: ReceiveEventPolicy - outputType: DIRECT - output: - parentKeyName: ReceiveEventPolicy - parentKeyVersion: 0.0.1 - parentLocalName: ReceiveSubscriptionState - localName: ReceivePMSubscriptionOutput - firstState: ReceiveSubscriptionState - tasks: - key: - name: PMControlPolicy_Tasks - version: 0.0.1 - taskMap: - entry: - - key: - name: CDSCreateResponseTask - version: 0.0.1 - value: - key: - name: CDSCreateResponseTask - version: 0.0.1 - inputFields: - entry: - - key: actionIdentifiers - value: - key: actionIdentifiers - fieldSchemaKey: - name: CDSActionIdentifiersType - version: 0.0.1 - optional: false - - key: commonHeader - value: - key: commonHeader - fieldSchemaKey: - name: CDSResponseCommonHeaderType - version: 0.0.1 - optional: false - - key: payload - value: - key: payload - fieldSchemaKey: - name: CDSCreateResponsePayloadType - version: 0.0.1 - optional: false - - key: status - value: - key: status - fieldSchemaKey: - name: CDSResponseStatusType - version: 0.0.1 - optional: false - outputFields: - entry: - - key: status - value: - key: status - fieldSchemaKey: - name: SubscriptionStatusType - version: 0.0.1 - optional: false - taskParameters: - entry: [] - contextAlbumReference: - - name: PMSubscriptionAlbum - version: 0.0.1 - taskLogic: - key: TaskLogic - logicFlavour: JAVASCRIPT - logic: |- - /* - * ============LICENSE_START======================================================= - * Copyright (C) 2020 Nordix. 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); - - var commonHeader = executor.inFields.get("commonHeader") - var response = executor.inFields.get("payload") - var albumID = commonHeader.get("requestId") - - var pmSubscriptionInfo = executor.getContextAlbum("PMSubscriptionAlbum").get(albumID.toString()); - var responseStatus = executor.subject.getOutFieldSchemaHelper("status").createNewInstance(); - - responseStatus.put("subscriptionName", pmSubscriptionInfo.get("subscription").get("subscriptionName")) - responseStatus.put("nfName", pmSubscriptionInfo.get("nfName")) - responseStatus.put("changeType", pmSubscriptionInfo.get("changeType")) - - var status = response.get(pmSubscriptionInfo.get("changeType").toLowerCase() + "_DasH_subscription_DasH_response").get("odl_DasH_response").get("status") - - executor.logger.info("RESPONSE STATUS = " + status) - - if(status == "success") { - responseStatus.put("message", "success") - } else { - responseStatus.put("message", "failed") - } - - executor.outFields.put("status", responseStatus) - - //var returnValue = executor.isTrue; - true; - - key: - name: CDSDeleteResponseTask - version: 0.0.1 - value: - key: - name: CDSDeleteResponseTask - version: 0.0.1 - inputFields: - entry: - - key: actionIdentifiers - value: - key: actionIdentifiers - fieldSchemaKey: - name: CDSActionIdentifiersType - version: 0.0.1 - optional: false - - key: commonHeader - value: - key: commonHeader - fieldSchemaKey: - name: CDSResponseCommonHeaderType - version: 0.0.1 - optional: false - - key: payload - value: - key: payload - fieldSchemaKey: - name: CDSDeleteResponsePayloadType - version: 0.0.1 - optional: false - - key: status - value: - key: status - fieldSchemaKey: - name: CDSResponseStatusType - version: 0.0.1 - optional: false - outputFields: - entry: - - key: status - value: - key: status - fieldSchemaKey: - name: SubscriptionStatusType - version: 0.0.1 - optional: false - taskParameters: - entry: [] - contextAlbumReference: - - name: PMSubscriptionAlbum - version: 0.0.1 - taskLogic: - key: TaskLogic - logicFlavour: JAVASCRIPT - logic: |- - /* - * ============LICENSE_START======================================================= - * Copyright (C) 2020 Nordix. 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); - - var commonHeader = executor.inFields.get("commonHeader") - var response = executor.inFields.get("payload") - var albumID = commonHeader.get("requestId") - - var pmSubscriptionInfo = executor.getContextAlbum("PMSubscriptionAlbum").get(albumID.toString()); - var responseStatus = executor.subject.getOutFieldSchemaHelper("status").createNewInstance(); - - responseStatus.put("subscriptionName", pmSubscriptionInfo.get("subscription").get("subscriptionName")) - responseStatus.put("nfName", pmSubscriptionInfo.get("nfName")) - responseStatus.put("changeType", pmSubscriptionInfo.get("changeType")) - - var status = response.get(pmSubscriptionInfo.get("changeType").toLowerCase() + "_DasH_subscription_DasH_response").get("odl_DasH_response").get("status") - - executor.logger.info("RESPONSE STATUS = " + status) - - if(status == "success") { - responseStatus.put("message", "success") - } else { - responseStatus.put("message", "failed") - } - - executor.outFields.put("status", responseStatus) - - //var returnValue = executor.isTrue; - true; - - key: - name: CreateSubscriptionPayloadTask - version: 0.0.1 - value: - key: - name: CreateSubscriptionPayloadTask - version: 0.0.1 - inputFields: - entry: - - key: albumID - value: - key: albumID - fieldSchemaKey: - name: UUIDType - version: 0.0.1 - optional: false - outputFields: - entry: - - key: albumID - value: - key: albumID - fieldSchemaKey: - name: UUIDType - version: 0.0.1 - optional: false - - key: payload - value: - key: payload - fieldSchemaKey: - name: CDSCreateSubscriptionPayloadType - version: 0.0.1 - optional: false - taskParameters: - entry: [] - contextAlbumReference: - - name: PMSubscriptionAlbum - version: 0.0.1 - taskLogic: - key: TaskLogic - logicFlavour: JAVASCRIPT - logic: |- - /* - * ============LICENSE_START======================================================= - * Copyright (C) 2020 Nordix. 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); - - var pmSubscriptionInfo = executor.getContextAlbum("PMSubscriptionAlbum").get(executor.inFields.get("albumID").toString()) - - var changeType = pmSubscriptionInfo.get("changeType").toLowerCase() - - var payloadProperties = executor.subject.getOutFieldSchemaHelper("payload").createNewSubInstance(changeType + "_DasH_subscription_DasH_properties_record"); - - payloadProperties.put("nfName", pmSubscriptionInfo.get("nfName")) - payloadProperties.put("subscriptionName", pmSubscriptionInfo.get("subscription").get("subscriptionName")) - payloadProperties.put("administrativeState", pmSubscriptionInfo.get("subscription").get("administrativeState")) - payloadProperties.put("fileBasedGP", pmSubscriptionInfo.get("subscription").get("fileBasedGP").toString()) - payloadProperties.put("fileLocation", pmSubscriptionInfo.get("subscription").get("fileLocation")) - payloadProperties.put("measurementGroups", pmSubscriptionInfo.get("subscription").get("measurementGroups")) - - var payloadEntry = executor.subject.getOutFieldSchemaHelper("payload").createNewSubInstance("CDSRequestPayloadEntry"); - payloadEntry.put(changeType + "_DasH_subscription_DasH_properties", payloadProperties) - - var payload = executor.subject.getOutFieldSchemaHelper("payload").createNewInstance(); - payload.put(changeType + "_DasH_subscription_DasH_request", payloadEntry); - - executor.outFields.put("albumID", executor.inFields.get("albumID")) - executor.outFields.put("payload", payload); - - //var returnValue = executor.isTrue; - true; - - key: - name: CreateSubscriptionRequestTask - version: 0.0.1 - value: - key: - name: CreateSubscriptionRequestTask - version: 0.0.1 - inputFields: - entry: - - key: albumID - value: - key: albumID - fieldSchemaKey: - name: UUIDType - version: 0.0.1 - optional: false - - key: payload - value: - key: payload - fieldSchemaKey: - name: CDSCreateSubscriptionPayloadType - version: 0.0.1 - optional: false - outputFields: - entry: - - key: actionIdentifiers - value: - key: actionIdentifiers - fieldSchemaKey: - name: CDSActionIdentifiersType - version: 0.0.1 - optional: false - - key: commonHeader - value: - key: commonHeader - fieldSchemaKey: - name: CDSRequestCommonHeaderType - version: 0.0.1 - optional: false - - key: payload - value: - key: payload - fieldSchemaKey: - name: CDSCreateSubscriptionPayloadType - version: 0.0.1 - optional: false - taskParameters: - entry: [] - contextAlbumReference: - - name: PMSubscriptionAlbum - version: 0.0.1 - taskLogic: - key: TaskLogic - logicFlavour: JAVASCRIPT - logic: |- - /* - * ============LICENSE_START======================================================= - * Copyright (C) 2020 Nordix. 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); - - var pmSubscriptionInfo = executor.getContextAlbum("PMSubscriptionAlbum").get(executor.inFields.get("albumID").toString()) - - var changeType = pmSubscriptionInfo.get("changeType").toLowerCase() - var blueprintName = pmSubscriptionInfo.get("blueprintName").toLowerCase() - var blueprintVersion = pmSubscriptionInfo.get("blueprintVersion").toLowerCase() - var payload = executor.inFields.get("payload") - var actionName = changeType + "-subscription" - - var commonHeader = executor.subject.getOutFieldSchemaHelper("commonHeader").createNewInstance(); - commonHeader.put("originatorId", "sdnc"); - commonHeader.put("requestId", executor.inFields.get("albumID").toString()); - commonHeader.put("subRequestId", "sub-123456-1000"); - - var actionIdentifiers = executor.subject.getOutFieldSchemaHelper("actionIdentifiers").createNewInstance(); - actionIdentifiers.put("actionName", actionName); - actionIdentifiers.put("blueprintName", blueprintName); - actionIdentifiers.put("blueprintVersion", blueprintVersion); - actionIdentifiers.put("mode", "sync"); - - executor.outFields.put("commonHeader", commonHeader); - executor.outFields.put("actionIdentifiers", actionIdentifiers); - executor.outFields.put("payload", payload); - - //var returnValue = executor.isTrue; - true; - - key: - name: DeleteSubscriptionPayloadTask - version: 0.0.1 - value: - key: - name: DeleteSubscriptionPayloadTask - version: 0.0.1 - inputFields: - entry: - - key: albumID - value: - key: albumID - fieldSchemaKey: - name: UUIDType - version: 0.0.1 - optional: false - outputFields: - entry: - - key: albumID - value: - key: albumID - fieldSchemaKey: - name: UUIDType - version: 0.0.1 - optional: false - - key: payload - value: - key: payload - fieldSchemaKey: - name: CDSDeleteSubscriptionPayloadType - version: 0.0.1 - optional: false - taskParameters: - entry: [] - contextAlbumReference: - - name: PMSubscriptionAlbum - version: 0.0.1 - taskLogic: - key: TaskLogic - logicFlavour: JAVASCRIPT - logic: |- - /* - * ============LICENSE_START======================================================= - * Copyright (C) 2020 Nordix. 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); - - var pmSubscriptionInfo = executor.getContextAlbum("PMSubscriptionAlbum").get(executor.inFields.get("albumID").toString()) - - var changeType = pmSubscriptionInfo.get("changeType").toLowerCase() - - var payloadProperties = executor.subject.getOutFieldSchemaHelper("payload").createNewSubInstance(changeType + "_DasH_subscription_DasH_properties_record"); - - payloadProperties.put("nfName", pmSubscriptionInfo.get("nfName")) - payloadProperties.put("subscriptionName", pmSubscriptionInfo.get("subscription").get("subscriptionName")) - payloadProperties.put("administrativeState", pmSubscriptionInfo.get("subscription").get("administrativeState")) - payloadProperties.put("fileBasedGP", pmSubscriptionInfo.get("subscription").get("fileBasedGP").toString()) - payloadProperties.put("fileLocation", pmSubscriptionInfo.get("subscription").get("fileLocation")) - payloadProperties.put("measurementGroups", pmSubscriptionInfo.get("subscription").get("measurementGroups")) - - var payloadEntry = executor.subject.getOutFieldSchemaHelper("payload").createNewSubInstance("CDSRequestPayloadEntry"); - payloadEntry.put(changeType + "_DasH_subscription_DasH_properties", payloadProperties) - - var payload = executor.subject.getOutFieldSchemaHelper("payload").createNewInstance(); - payload.put(changeType + "_DasH_subscription_DasH_request", payloadEntry); - - executor.outFields.put("albumID", executor.inFields.get("albumID")) - executor.outFields.put("payload", payload); - - //var returnValue = executor.isTrue; - true; - - key: - name: DeleteSubscriptionRequestTask - version: 0.0.1 - value: - key: - name: DeleteSubscriptionRequestTask - version: 0.0.1 - inputFields: - entry: - - key: albumID - value: - key: albumID - fieldSchemaKey: - name: UUIDType - version: 0.0.1 - optional: false - - key: payload - value: - key: payload - fieldSchemaKey: - name: CDSDeleteSubscriptionPayloadType - version: 0.0.1 - optional: false - outputFields: - entry: - - key: actionIdentifiers - value: - key: actionIdentifiers - fieldSchemaKey: - name: CDSActionIdentifiersType - version: 0.0.1 - optional: false - - key: commonHeader - value: - key: commonHeader - fieldSchemaKey: - name: CDSRequestCommonHeaderType - version: 0.0.1 - optional: false - - key: payload - value: - key: payload - fieldSchemaKey: - name: CDSDeleteSubscriptionPayloadType - version: 0.0.1 - optional: false - taskParameters: - entry: [] - contextAlbumReference: - - name: PMSubscriptionAlbum - version: 0.0.1 - taskLogic: - key: TaskLogic - logicFlavour: JAVASCRIPT - logic: |- - /* - * ============LICENSE_START======================================================= - * Copyright (C) 2020 Nordix. 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); - - var pmSubscriptionInfo = executor.getContextAlbum("PMSubscriptionAlbum").get(executor.inFields.get("albumID").toString()) - - var changeType = pmSubscriptionInfo.get("changeType").toLowerCase() - var blueprintName = pmSubscriptionInfo.get("blueprintName").toLowerCase() - var blueprintVersion = pmSubscriptionInfo.get("blueprintVersion").toLowerCase() - var payload = executor.inFields.get("payload") - var actionName = changeType + "-subscription" - - var commonHeader = executor.subject.getOutFieldSchemaHelper("commonHeader").createNewInstance(); - commonHeader.put("originatorId", "sdnc"); - commonHeader.put("requestId", executor.inFields.get("albumID").toString()); - commonHeader.put("subRequestId", "sub-123456-1000"); - - var actionIdentifiers = executor.subject.getOutFieldSchemaHelper("actionIdentifiers").createNewInstance(); - actionIdentifiers.put("actionName", actionName); - actionIdentifiers.put("blueprintName", blueprintName); - actionIdentifiers.put("blueprintVersion", blueprintVersion); - actionIdentifiers.put("mode", "sync"); - - executor.outFields.put("commonHeader", commonHeader); - executor.outFields.put("actionIdentifiers", actionIdentifiers); - executor.outFields.put("payload", payload); - - //var returnValue = executor.isTrue; - true; - - key: - name: ReceiveSubscriptionTask - version: 0.0.1 - value: - key: - name: ReceiveSubscriptionTask - version: 0.0.1 - inputFields: - entry: - - key: blueprintName - value: - key: blueprintName - fieldSchemaKey: - name: SimpleStringType - version: 0.0.1 - optional: false - - key: blueprintVersion - value: - key: blueprintVersion - fieldSchemaKey: - name: SimpleStringType - version: 0.0.1 - optional: false - - key: changeType - value: - key: changeType - fieldSchemaKey: - name: SimpleStringType - version: 0.0.1 - optional: false - - key: closedLoopControlName - value: - key: closedLoopControlName - fieldSchemaKey: - name: SimpleStringType - version: 0.0.1 - optional: false - - key: nfName - value: - key: nfName - fieldSchemaKey: - name: SimpleStringType - version: 0.0.1 - optional: false - - key: policyName - value: - key: policyName - fieldSchemaKey: - name: SimpleStringType - version: 0.0.1 - optional: false - - key: subscription - value: - key: subscription - fieldSchemaKey: - name: SubscriptionType - version: 0.0.1 - optional: false - outputFields: - entry: - - key: albumID - value: - key: albumID - fieldSchemaKey: - name: UUIDType - version: 0.0.1 - optional: false - taskParameters: - entry: [] - contextAlbumReference: - - name: PMSubscriptionAlbum - version: 0.0.1 - taskLogic: - key: TaskLogic - logicFlavour: JAVASCRIPT - logic: |- - /* - * ============LICENSE_START======================================================= - * Copyright (C) 2020 Nordix. 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========================================================= - */ - var uuidType = java.util.UUID; - - executor.logger.info(executor.subject.id); - - //albumID will be used to fetch info from our album later - var albumID = uuidType.randomUUID(); - var pmSubscriptionInfo = executor.getContextAlbum("PMSubscriptionAlbum").getSchemaHelper().createNewInstance(); - var returnValue = true; - - if(executor.inFields.get("policyName") != null) { - executor.logger.info("nfName in receive sub event " + executor.inFields.get("nfName")); - - var changeType = executor.inFields.get("changeType") - var nfName = executor.inFields.get("nfName") - var policyName = executor.inFields.get("policyName") - var closedLoopControlName = executor.inFields.get("closedLoopControlName") - var subscription = executor.inFields.get("subscription") - var blueprintName = executor.inFields.get("blueprintName") - var blueprintVersion = executor.inFields.get("blueprintVersion") - - pmSubscriptionInfo.put("nfName", executor.inFields.get("nfName")); - pmSubscriptionInfo.put("changeType", executor.inFields.get("changeType")) - pmSubscriptionInfo.put("policyName", executor.inFields.get("policyName")) - pmSubscriptionInfo.put("closedLoopControlName", executor.inFields.get("closedLoopControlName")) - pmSubscriptionInfo.put("subscription", subscription) - pmSubscriptionInfo.put("blueprintName", blueprintName) - pmSubscriptionInfo.put("blueprintVersion", blueprintVersion) - - - executor.getContextAlbum("PMSubscriptionAlbum").put(albumID.toString(), pmSubscriptionInfo); - - executor.outFields.put("albumID", albumID) - } else { - executor.message = "Received invalid event" - returnValue = false; - } - - returnValue; - events: - key: - name: PMControlPolicy_Events - version: 0.0.1 - eventMap: - entry: - - key: - name: CDSCreateResponseEvent - version: 0.0.1 - value: - key: - name: CDSCreateResponseEvent - version: 0.0.1 - nameSpace: org.onap.policy.apex.onap.pmcontrol - source: CDS - target: APEX - parameter: - entry: - - key: actionIdentifiers - value: - key: actionIdentifiers - fieldSchemaKey: - name: CDSActionIdentifiersType - version: 0.0.1 - optional: false - - key: commonHeader - value: - key: commonHeader - fieldSchemaKey: - name: CDSResponseCommonHeaderType - version: 0.0.1 - optional: false - - key: payload - value: - key: payload - fieldSchemaKey: - name: CDSCreateResponsePayloadType - version: 0.0.1 - optional: false - - key: status - value: - key: status - fieldSchemaKey: - name: CDSResponseStatusType - version: 0.0.1 - optional: false - - key: - name: CDSCreateSubscriptionRequestEvent - version: 0.0.1 - value: - key: - name: CDSCreateSubscriptionRequestEvent - version: 0.0.1 - nameSpace: org.onap.policy.apex.onap.pmcontrol - source: APEX - target: APEX - parameter: - entry: - - key: actionIdentifiers - value: - key: actionIdentifiers - fieldSchemaKey: - name: CDSActionIdentifiersType - version: 0.0.1 - optional: false - - key: commonHeader - value: - key: commonHeader - fieldSchemaKey: - name: CDSRequestCommonHeaderType - version: 0.0.1 - optional: false - - key: payload - value: - key: payload - fieldSchemaKey: - name: CDSCreateSubscriptionPayloadType - version: 0.0.1 - optional: false - - key: - name: CDSDeleteResponseEvent - version: 0.0.1 - value: - key: - name: CDSDeleteResponseEvent - version: 0.0.1 - nameSpace: org.onap.policy.apex.onap.pmcontrol - source: CDS - target: APEX - parameter: - entry: - - key: actionIdentifiers - value: - key: actionIdentifiers - fieldSchemaKey: - name: CDSActionIdentifiersType - version: 0.0.1 - optional: false - - key: commonHeader - value: - key: commonHeader - fieldSchemaKey: - name: CDSResponseCommonHeaderType - version: 0.0.1 - optional: false - - key: payload - value: - key: payload - fieldSchemaKey: - name: CDSDeleteResponsePayloadType - version: 0.0.1 - optional: false - - key: status - value: - key: status - fieldSchemaKey: - name: CDSResponseStatusType - version: 0.0.1 - optional: false - - key: - name: CDSDeleteSubscriptionRequestEvent - version: 0.0.1 - value: - key: - name: CDSDeleteSubscriptionRequestEvent - version: 0.0.1 - nameSpace: org.onap.policy.apex.onap.pmcontrol - source: APEX - target: APEX - parameter: - entry: - - key: actionIdentifiers - value: - key: actionIdentifiers - fieldSchemaKey: - name: CDSActionIdentifiersType - version: 0.0.1 - optional: false - - key: commonHeader - value: - key: commonHeader - fieldSchemaKey: - name: CDSRequestCommonHeaderType - version: 0.0.1 - optional: false - - key: payload - value: - key: payload - fieldSchemaKey: - name: CDSDeleteSubscriptionPayloadType - version: 0.0.1 - optional: false - - key: - name: CDSResponseStatusEvent - version: 0.0.1 - value: - key: - name: CDSResponseStatusEvent - version: 0.0.1 - nameSpace: org.onap.policy.apex.onap.pmcontrol - source: APEX - target: DCAE - parameter: - entry: - - key: status - value: - key: status - fieldSchemaKey: - name: SubscriptionStatusType - version: 0.0.1 - optional: false - - key: - name: CreateSubscriptionPayloadEvent - version: 0.0.1 - value: - key: - name: CreateSubscriptionPayloadEvent - version: 0.0.1 - nameSpace: org.onap.policy.apex.onap.pmcontrol - source: APEX - target: APEX - parameter: - entry: - - key: albumID - value: - key: albumID - fieldSchemaKey: - name: UUIDType - version: 0.0.1 - optional: false - - key: payload - value: - key: payload - fieldSchemaKey: - name: CDSCreateSubscriptionPayloadType - version: 0.0.1 - optional: false - - key: - name: DeleteSubscriptionPayloadEvent - version: 0.0.1 - value: - key: - name: DeleteSubscriptionPayloadEvent - version: 0.0.1 - nameSpace: org.onap.policy.apex.onap.pmcontrol - source: APEX - target: APEX - parameter: - entry: - - key: albumID - value: - key: albumID - fieldSchemaKey: - name: UUIDType - version: 0.0.1 - optional: false - - key: payload - value: - key: payload - fieldSchemaKey: - name: CDSDeleteSubscriptionPayloadType - version: 0.0.1 - optional: false - - key: - name: MRResponseEvent - version: 0.0.1 - value: - key: - name: MRResponseEvent - version: 0.0.1 - nameSpace: org.onap.policy.apex.onap.pmcontrol - source: DCAE - target: APEX - parameter: - entry: - - key: count - value: - key: count - fieldSchemaKey: - name: SimpleIntType - version: 0.0.1 - optional: false - - key: serverTimeMs - value: - key: serverTimeMs - fieldSchemaKey: - name: SimpleIntType - version: 0.0.1 - optional: false - - key: - name: PMSubscriptionOutputEvent - version: 0.0.1 - value: - key: - name: PMSubscriptionOutputEvent - version: 0.0.1 - nameSpace: org.onap.policy.apex.onap.pmcontrol - source: APEX - target: APEX - parameter: - entry: - - key: albumID - value: - key: albumID - fieldSchemaKey: - name: UUIDType - version: 0.0.1 - optional: false - - key: - name: pmsh-operational-policy - version: 0.0.1 - value: - key: - name: pmsh-operational-policy - version: 0.0.1 - nameSpace: org.onap.policy.apex.onap.pmcontrol - source: DCAE - target: APEX - parameter: - entry: - - key: blueprintName - value: - key: blueprintName - fieldSchemaKey: - name: SimpleStringType - version: 0.0.1 - optional: false - - key: blueprintVersion - value: - key: blueprintVersion - fieldSchemaKey: - name: SimpleStringType - version: 0.0.1 - optional: false - - key: changeType - value: - key: changeType - fieldSchemaKey: - name: SimpleStringType - version: 0.0.1 - optional: false - - key: closedLoopControlName - value: - key: closedLoopControlName - fieldSchemaKey: - name: SimpleStringType - version: 0.0.1 - optional: false - - key: nfName - value: - key: nfName - fieldSchemaKey: - name: SimpleStringType - version: 0.0.1 - optional: false - - key: policyName - value: - key: policyName - fieldSchemaKey: - name: SimpleStringType - version: 0.0.1 - optional: false - - key: subscription - value: - key: subscription - fieldSchemaKey: - name: SubscriptionType - version: 0.0.1 - optional: false - albums: - key: - name: PMControlPolicy_Albums - version: 0.0.1 - albums: - entry: - - key: - name: PMSubscriptionAlbum - version: 0.0.1 - value: - key: - name: PMSubscriptionAlbum - version: 0.0.1 - scope: policy - isWritable: true - itemSchema: - name: PMSubscriptionType - version: 0.0.1 - schemas: - key: - name: PMControlPolicy_Schemas - version: 0.0.1 - schemas: - entry: - - key: - name: CDSActionIdentifiersType - version: 0.0.1 - value: - key: - name: CDSActionIdentifiersType - version: 0.0.1 - schemaFlavour: Avro - schemaDefinition: |- - { - "type": "record", - "name": "ActionIdentifiers_Type", - "namespace": "org.onap.policy.apex.onap.helloworld", - "fields": [ - { - "name": "actionName", - "type": "string" - }, - { - "name": "blueprintName", - "type": "string" - }, - { - "name": "blueprintVersion", - "type": "string" - }, - { - "name": "mode", - "type": "string" - } - ] - } - - key: - name: CDSCreateResponsePayloadType - version: 0.0.1 - value: - key: - name: CDSCreateResponsePayloadType - version: 0.0.1 - schemaFlavour: Avro - schemaDefinition: |- - { - "name": "CreateResponsePayloadEntry", - "type": "record", - "namespace": "org.onap.policy.apex.onap.helloworld", - "fields": [ - { - "name": "create_DasH_subscription_DasH_response", - "type": { - "name": "create_DasH_subscription_DasH_response", - "type": "record", - "fields": [ - { - "name": "odl_DasH_response", - "type": { - "name": "odl_DasH_response", - "type": "record", - "fields": [ - { - "name": "status", - "type": "string" - } - ] - } - } - ] - } - } - ] - } - - key: - name: CDSCreateSubscriptionPayloadType - version: 0.0.1 - value: - key: - name: CDSCreateSubscriptionPayloadType - version: 0.0.1 - schemaFlavour: Avro - schemaDefinition: |- - { - "type": "map", - "values": { - "type": "record", - "name": "CDSRequestPayloadEntry", - "fields": [ - { - "name": "create_DasH_subscription_DasH_properties", - "type": { - "name": "create_DasH_subscription_DasH_properties_record", - "type": "record", - "fields": [ - { - "name": "nfName", - "type": "string" - }, - { - "name": "subscriptionName", - "type": "string" - }, - { - "name": "administrativeState", - "type": "string" - }, - { - "name": "fileBasedGP", - "type": "string" - }, - { - "name": "fileLocation", - "type": "string" - }, - { - "name": "measurementGroups", - "type": { - "type": "array", - "items": { - "name": "measurementGroups_record", - "type": "record", - "fields": [ - { - "name": "measurementGroup", - "type": { - "name": "measurementGroup", - "type": "record", - "fields": [ - { - "name": "measurementTypes", - "type": { - "type": "array", - "items": { - "name": "measurementTypes_record", - "type": "record", - "fields": [ - { - "name": "measurementType", - "type": "string" - } - ] - } - } - }, - { - "name": "managedObjectDNsBasic", - "type": { - "type": "array", - "items": { - "name": "managedObjectDNsBasic_record", - "type": "record", - "fields": [ - { - "name": "DN", - "type": "string" - } - ] - } - } - } - ] - } - } - ] - } - } - } - ] - } - } - ] - } - } - - key: - name: CDSDeleteResponsePayloadType - version: 0.0.1 - value: - key: - name: CDSDeleteResponsePayloadType - version: 0.0.1 - schemaFlavour: Avro - schemaDefinition: |- - { - "name": "DeleteResponsePayloadEntry", - "type": "record", - "namespace": "com.acme.avro", - "fields": [ - { - "name": "delete_DasH_subscription_DasH_response", - "type": { - "name": "delete_DasH_subscription_DasH_response", - "type": "record", - "fields": [ - { - "name": "odl_DasH_response", - "type": { - "name": "odl_DasH_response", - "type": "record", - "fields": [ - { - "name": "status", - "type": "string" - } - ] - } - } - ] - } - } - ] - } - - key: - name: CDSDeleteSubscriptionPayloadType - version: 0.0.1 - value: - key: - name: CDSDeleteSubscriptionPayloadType - version: 0.0.1 - schemaFlavour: Avro - schemaDefinition: |- - { - "type": "map", - "values": { - "type": "record", - "name": "CDSRequestPayloadEntry", - "fields": [ - { - "name": "delete_DasH_subscription_DasH_properties", - "type": { - "name": "delete_DasH_subscription_DasH_properties_record", - "type": "record", - "fields": [ - { - "name": "nfName", - "type": "string" - }, - { - "name": "subscriptionName", - "type": "string" - }, - { - "name": "administrativeState", - "type": "string" - }, - { - "name": "fileBasedGP", - "type": "string" - }, - { - "name": "fileLocation", - "type": "string" - }, - { - "name": "measurementGroups", - "type": { - "type": "array", - "items": { - "name": "measurementGroups_record", - "type": "record", - "fields": [ - { - "name": "measurementGroup", - "type": { - "name": "measurementGroup", - "type": "record", - "fields": [ - { - "name": "measurementTypes", - "type": { - "type": "array", - "items": { - "name": "measurementTypes_record", - "type": "record", - "fields": [ - { - "name": "measurementType", - "type": "string" - } - ] - } - } - }, - { - "name": "managedObjectDNsBasic", - "type": { - "type": "array", - "items": { - "name": "managedObjectDNsBasic_record", - "type": "record", - "fields": [ - { - "name": "DN", - "type": "string" - } - ] - } - } - } - ] - } - } - ] - } - } - } - ] - } - } - ] - } - } - - key: - name: CDSRequestCommonHeaderType - version: 0.0.1 - value: - key: - name: CDSRequestCommonHeaderType - version: 0.0.1 - schemaFlavour: Avro - schemaDefinition: |- - { - "type": "record", - "name": "RequestCommonHeader_Type", - "namespace": "org.onap.policy.apex.onap.helloworld", - "fields": [ - { - "name": "originatorId", - "type": "string" - }, - { - "name": "requestId", - "type": "string" - }, - { - "name": "subRequestId", - "type": "string" - } - ] - } - - key: - name: CDSResponseCommonHeaderType - version: 0.0.1 - value: - key: - name: CDSResponseCommonHeaderType - version: 0.0.1 - schemaFlavour: Avro - schemaDefinition: |- - { - "type": "record", - "name": "ResponseCommonHeader_Type", - "namespace": "org.onap.policy.apex.onap.helloworld", - "fields": [ - { - "name": "originatorId", - "type": "string" - }, - { - "name": "requestId", - "type": "string" - }, - { - "name": "subRequestId", - "type": "string" - }, - { - "name": "timestamp", - "type": "string" - }, - { - "name": "flags", - "type": ["null", "string"] - } - ] - } - - key: - name: CDSResponseStatusType - version: 0.0.1 - value: - key: - name: CDSResponseStatusType - version: 0.0.1 - schemaFlavour: Avro - schemaDefinition: |- - { - "type": "record", - "name": "ResponseStatus_Type", - "namespace": "org.onap.policy.apex.onap.helloworld", - "fields": [ - { - "name": "code", - "type": "int" - }, - { - "name": "eventType", - "type": "string" - }, - { - "name": "timestamp", - "type": "string" - }, - { - "name": "message", - "type": "string" - } - ] - } - - key: - name: PMSubscriptionType - version: 0.0.1 - value: - key: - name: PMSubscriptionType - version: 0.0.1 - schemaFlavour: Avro - schemaDefinition: "{\n\t\"name\": \"PMSubscription\",\n\t\"type\": \"record\",\n\t\"namespace\": \"\ - org.onap.policy.apex.onap.pmcontrol\",\n\t\"fields\": [\n {\n \"name\": \"nfName\"\ - ,\n \"type\": \"string\"\n },\n\t {\n\t\t\t\"name\": \"changeType\",\n\t\t\t\"\ - type\": \"string\"\n\t\t},\n\t\t{\n\t\t\t\"name\": \"closedLoopControlName\",\n\t\t\t\"type\": \"\ - string\"\n\t\t},\n\t\t{\n\t\t\t\"name\": \"policyName\",\n\t\t\t\"type\": \"string\"\n\t\t},\n\t\t\ - {\n\t\t \"name\": \"blueprintName\",\n\t\t \"type\": \"string\"\n\t\t},\n\t\t{\n\t\t \"name\"\ - : \"blueprintVersion\",\n\t\t \"type\": \"string\"\n\t\t},\n\t\t{\n\t\t\t\"name\": \"subscription\"\ - ,\n\t\t\t\"type\": {\n\t\t\t\t\"name\": \"subscription\",\n\t\t\t\t\"type\": \"record\",\n\t\t\t\t\ - \"fields\": [{\n\t\t\t\t\t\t\"name\": \"subscriptionName\",\n\t\t\t\t\t\t\"type\": \"string\"\n\t\t\ - \t\t\t},\n\t\t\t\t\t{\n\t\t\t\t\t\t\"name\": \"administrativeState\",\n\t\t\t\t\t\t\"type\": \"string\"\ - \n\t\t\t\t\t},\n\t\t\t\t\t{\n\t\t\t\t\t\t\"name\": \"fileBasedGP\",\n\t\t\t\t\t\t\"type\": \"int\"\ - \n\t\t\t\t\t},\n\t\t\t\t\t{\n\t\t\t\t\t\t\"name\": \"fileLocation\",\n\t\t\t\t\t\t\"type\": \"string\"\ - \n\t\t\t\t\t},\n\t\t\t\t\t{\n\t\t\t\t\t\t\"name\": \"measurementGroups\",\n\t\t\t\t\t\t\"type\": {\n\ - \t\t\t\t\t\t\t\"type\": \"array\",\n\t\t\t\t\t\t\t\"items\": {\n\t\t\t\t\t\t\t\t\"name\": \"Measurement_Groups_Type\"\ - ,\n\t\t\t\t\t\t\t\t\"type\": \"record\",\n\t\t\t\t\t\t\t\t\"fields\": [{\n\t\t\t\t\t\t\t\t\t\"name\"\ - : \"measurementGroup\",\n\t\t\t\t\t\t\t\t\t\"type\": {\n\t\t\t\t\t\t\t\t\t\t\"name\": \"Measurement_Group_Type\"\ - ,\n\t\t\t\t\t\t\t\t\t\t\"type\": \"record\",\n\t\t\t\t\t\t\t\t\t\t\"fields\": [{\n\t\t\t\t\t\t\t\t\ - \t\t\t\t\"name\": \"measurementTypes\",\n\t\t\t\t\t\t\t\t\t\t\t\t\"type\": {\n\t\t\t\t\t\t\t\t\t\t\ - \t\t\t\"type\": \"array\",\n\t\t\t\t\t\t\t\t\t\t\t\t\t\"items\": {\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\"\ - name\": \"Measurement_Types_Type\",\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\"type\": \"record\",\n\t\t\t\t\t\ - \t\t\t\t\t\t\t\t\t\"fields\": [{\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\"name\": \"measurementType\",\n\t\ - \t\t\t\t\t\t\t\t\t\t\t\t\t\t\"type\": \"string\"\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t}]\n\t\t\t\t\t\t\t\t\ - \t\t\t\t\t}\n\t\t\t\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\t\t\t\t{\n\t\t\t\t\ - \t\t\t\t\t\t\t\t\"name\": \"managedObjectDNsBasic\",\n\t\t\t\t\t\t\t\t\t\t\t\t\"type\": {\n\t\t\t\t\ - \t\t\t\t\t\t\t\t\t\"type\": \"array\",\n\t\t\t\t\t\t\t\t\t\t\t\t\t\"items\": {\n\t\t\t\t\t\t\t\t\t\ - \t\t\t\t\t\"name\": \"Managed_Object_Dns_Basic_Type\",\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\"type\": \"record\"\ - ,\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\"fields\": [{\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\"name\": \"DN\",\n\t\ - \t\t\t\t\t\t\t\t\t\t\t\t\t\t\"type\": \"string\"\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t}]\n\t\t\t\t\t\t\t\t\ - \t\t\t\t\t}\n\t\t\t\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\t\t]\n\t\t\t\t\t\ - \t\t\t\t}\n\t\t\t\t\t\t\t\t}]\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t]\n\t\t\t}\n\t\ - \t}\n\t]\n}" - - key: - name: SimpleIntType - version: 0.0.1 - value: - key: - name: SimpleIntType - version: 0.0.1 - schemaFlavour: Java - schemaDefinition: java.lang.Integer - - key: - name: SimpleStringType - version: 0.0.1 - value: - key: - name: SimpleStringType - version: 0.0.1 - schemaFlavour: Java - schemaDefinition: java.lang.String - - key: - name: SubscriptionStatusType - version: 0.0.1 - value: - key: - name: SubscriptionStatusType - version: 0.0.1 - schemaFlavour: Avro - schemaDefinition: |- - { - "type": "record", - "name": "ActivateSubscriptionStatus_Type", - "namespace": "org.onap.policy.apex.onap.helloworld", - "fields": [ - { - "name": "subscriptionName", - "type": "string" - }, - { - "name": "nfName", - "type": "string" - }, - { - "name": "changeType", - "type": "string" - }, - { - "name": "message", - "type": "string" - } - ] - } - - key: - name: SubscriptionType - version: 0.0.1 - value: - key: - name: SubscriptionType - version: 0.0.1 - schemaFlavour: Avro - schemaDefinition: "{\n\t\"name\": \"subscription\",\n\t\"type\": \"record\",\n\t\"fields\": [{\n\t\t\ - \t\"name\": \"subscriptionName\",\n\t\t\t\"type\": \"string\"\n\t\t},\n\t\t{\n\t\t\t\"name\": \"administrativeState\"\ - ,\n\t\t\t\"type\": \"string\"\n\t\t},\n\t\t{\n\t\t\t\"name\": \"fileBasedGP\",\n\t\t\t\"type\": \"\ - int\"\n\t\t},\n\t\t{\n\t\t\t\"name\": \"fileLocation\",\n\t\t\t\"type\": \"string\"\n\t\t},\n\t\t\ - {\n\t\t\t\"name\": \"measurementGroups\",\n\t\t\t\"type\": {\n\t\t\t\t\"type\": \"array\",\n\t\t\t\ - \t\"items\": {\n\t\t\t\t\t\"name\": \"Measurement_Groups_Type\",\n\t\t\t\t\t\"type\": \"record\",\n\ - \t\t\t\t\t\"fields\": [{\n\t\t\t\t\t\t\"name\": \"measurementGroup\",\n\t\t\t\t\t\t\"type\": {\n\t\ - \t\t\t\t\t\t\"name\": \"Measurement_Group_Type\",\n\t\t\t\t\t\t\t\"type\": \"record\",\n\t\t\t\t\t\ - \t\t\"fields\": [{\n\t\t\t\t\t\t\t\t\t\"name\": \"measurementTypes\",\n\t\t\t\t\t\t\t\t\t\"type\"\ - : {\n\t\t\t\t\t\t\t\t\t\t\"type\": \"array\",\n\t\t\t\t\t\t\t\t\t\t\"items\": {\n\t\t\t\t\t\t\t\t\t\ - \t\t\"name\": \"Measurement_Types_Type\",\n\t\t\t\t\t\t\t\t\t\t\t\"type\": \"record\",\n\t\t\t\t\t\ - \t\t\t\t\t\t\"fields\": [{\n\t\t\t\t\t\t\t\t\t\t\t\t\"name\": \"measurementType\",\n\t\t\t\t\t\t\t\ - \t\t\t\t\t\"type\": \"string\"\n\t\t\t\t\t\t\t\t\t\t\t}]\n\t\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\t\ - }\n\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\t\"name\": \"managedObjectDNsBasic\",\n\ - \t\t\t\t\t\t\t\t\t\"type\": {\n\t\t\t\t\t\t\t\t\t\t\"type\": \"array\",\n\t\t\t\t\t\t\t\t\t\t\"items\"\ - : {\n\t\t\t\t\t\t\t\t\t\t\t\"name\": \"Managed_Object_Dns_Basic_Type\",\n\t\t\t\t\t\t\t\t\t\t\t\"\ - type\": \"record\",\n\t\t\t\t\t\t\t\t\t\t\t\"fields\": [{\n\t\t\t\t\t\t\t\t\t\t\t\t\"name\": \"DN\"\ - ,\n\t\t\t\t\t\t\t\t\t\t\t\t\"type\": \"string\"\n\t\t\t\t\t\t\t\t\t\t\t}]\n\t\t\t\t\t\t\t\t\t\t}\n\ - \t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t]\n\t\t\t\t\t\t}\n\t\t\t\t\t}]\n\t\t\t\t}\n\t\ - \t\t}\n\t\t}\n\t]\n}" - - key: - name: UUIDType - version: 0.0.1 - value: - key: - name: UUIDType - version: 0.0.1 - schemaFlavour: Java - schemaDefinition: java.util.UUID - engineParameters: - executorParameters: - JAVASCRIPT: - parameterClassName: org.onap.policy.apex.plugins.executor.javascript.JavascriptExecutorParameters - contextParameters: - parameterClassName: org.onap.policy.apex.context.parameters.ContextParameters - schemaParameters: - Avro: - parameterClassName: org.onap.policy.apex.plugins.context.schema.avro.AvroSchemaHelperParameters - Java: - parameterClassName: org.onap.policy.apex.context.impl.schema.java.JavaSchemaHelperParameters - jsonAdapters: - Instant: - adaptedClass: java.time.Instant - adaptorClass: org.onap.policy.controlloop.util.Serialization$GsonInstantAdapter - eventInputParameters: - DCAEConsumer: - carrierTechnologyParameters: - carrierTechnology: RESTCLIENT - parameterClassName: org.onap.policy.apex.plugins.event.carrier.restclient.RestClientCarrierTechnologyParameters - parameters: - consumerPollTime: '50' - url: https://message-router:3905/events/unauthenticated.DCAE_CL_OUTPUT/cg1/sg1 - eventProtocolParameters: - eventProtocol: JSON - parameters: - nameAlias: policyName - eventName: pmsh-operational-policy - eventNameFilter: pmsh-operational-policy - CDSRequestConsumer: - carrierTechnologyParameters: - carrierTechnology: RESTREQUESTOR - parameterClassName: org.onap.policy.apex.plugins.event.carrier.restrequestor.RestRequestorCarrierTechnologyParameters - parameters: - url: http://10.10.10.184:30254/api/v1/execution-service/process - httpMethod: POST - restRequestTimeout: 2000 - httpHeaders: - - - Authorization - - Basic Y2NzZGthcHBzOmNjc2RrYXBwcw== - eventProtocolParameters: - eventProtocol: JSON - eventName: CDSCreateResponseEvent - eventNameFilter: CDSCreateResponseEvent - requestorMode: true - requestorPeer: CDSRequestProducer - requestorTimeout: 500 - CDSDeleteRequestConsumer: - carrierTechnologyParameters: - carrierTechnology: RESTREQUESTOR - parameterClassName: org.onap.policy.apex.plugins.event.carrier.restrequestor.RestRequestorCarrierTechnologyParameters - parameters: - url: http://10.10.10.184:30254/api/v1/execution-service/process - httpMethod: POST - restRequestTimeout: 2000 - httpHeaders: - - - Authorization - - Basic Y2NzZGthcHBzOmNjc2RrYXBwcw== - eventProtocolParameters: - eventProtocol: JSON - eventName: CDSDeleteResponseEvent - eventNameFilter: CDSDeleteResponseEvent - requestorMode: true - requestorPeer: CDSDeleteRequestProducer - requestorTimeout: 500 - CDSReplyConsumer: - carrierTechnologyParameters: - carrierTechnology: RESTREQUESTOR - parameterClassName: org.onap.policy.apex.plugins.event.carrier.restrequestor.RestRequestorCarrierTechnologyParameters - parameters: - url: https://message-router:3905/events/unauthenticated.PMSH_CL_INPUT - httpMethod: POST - restRequestTimeout: 2000 - eventProtocolParameters: - eventProtocol: JSON - eventName: MRResponseEvent - eventNameFilter: MRResponseEvent - requestorMode: true - requestorPeer: CDSReplyProducer - requestorTimeout: 500 - eventOutputParameters: - logOutputter: - carrierTechnologyParameters: - carrierTechnology: FILE - parameters: - fileName: /tmp/outputevents.log - eventProtocolParameters: - eventProtocol: JSON - StdOutOutputter: - carrierTechnologyParameters: - carrierTechnology: FILE - parameters: - standardIo: true - eventProtocolParameters: - eventProtocol: JSON - CDSRequestProducer: - carrierTechnologyParameters: - carrierTechnology: RESTREQUESTOR - parameterClassName: org.onap.policy.apex.plugins.event.carrier.restrequestor.RestRequestorCarrierTechnologyParameters - eventProtocolParameters: - eventProtocol: JSON - eventNameFilter: CDSCreateSubscriptionRequestEvent - requestorMode: true - requestorPeer: CDSRequestConsumer - requestorTimeout: 500 - CDSDeleteRequestProducer: - carrierTechnologyParameters: - carrierTechnology: RESTREQUESTOR - parameterClassName: org.onap.policy.apex.plugins.event.carrier.restrequestor.RestRequestorCarrierTechnologyParameters - eventProtocolParameters: - eventProtocol: JSON - eventNameFilter: CDSDeleteSubscriptionRequestEvent - requestorMode: true - requestorPeer: CDSDeleteRequestConsumer - requestorTimeout: 500 - CDSReplyProducer: - carrierTechnologyParameters: - carrierTechnology: RESTREQUESTOR - parameterClassName: org.onap.policy.apex.plugins.event.carrier.restrequestor.RestRequestorCarrierTechnologyParameters - eventProtocolParameters: - eventProtocol: JSON - eventNameFilter: CDSResponseStatusEvent - requestorMode: true - requestorPeer: CDSReplyConsumer - requestorTimeout: 500 diff --git a/models/src/test/resources/json/AutomationCompositionElementNoOrderedState.json b/models/src/test/resources/json/AutomationCompositionElementNoOrderedState.json new file mode 100644 index 000000000..872499abf --- /dev/null +++ b/models/src/test/resources/json/AutomationCompositionElementNoOrderedState.json @@ -0,0 +1,13 @@ +{ + "id": "a95757ba-b34a-4049-a2a8-46773abcbe5e", + "definition": { + "name": "aceDef", + "version": "0.0.1" + }, + "participantType": { + "name": "participantType", + "version": "0.0.1" + }, + "state": "UNINITIALISED", + "orderedState": null +} diff --git a/models/src/test/resources/json/AutomationCompositionNoOrderedState.json b/models/src/test/resources/json/AutomationCompositionNoOrderedState.json new file mode 100644 index 000000000..d61a61117 --- /dev/null +++ b/models/src/test/resources/json/AutomationCompositionNoOrderedState.json @@ -0,0 +1,12 @@ +{ + "definition": { + "name": "automationCompositionDefinitionName", + "version": "0.0.1" + }, + "state": "UNINITIALISED", + "orderedState": null, + "elements": [ + ], + "name": "automation-composition", + "version": "0.0.1" +} diff --git a/models/src/test/resources/json/ControlLoopElementNoOrderedState.json b/models/src/test/resources/json/ControlLoopElementNoOrderedState.json deleted file mode 100644 index 33a63e604..000000000 --- a/models/src/test/resources/json/ControlLoopElementNoOrderedState.json +++ /dev/null @@ -1,13 +0,0 @@ -{ - "id": "a95757ba-b34a-4049-a2a8-46773abcbe5e", - "definition": { - "name": "cleDef", - "version": "0.0.1" - }, - "participantType": { - "name": "participantType", - "version": "0.0.1" - }, - "state": "UNINITIALISED", - "orderedState": null -} diff --git a/models/src/test/resources/json/ControlLoopNoOrderedState.json b/models/src/test/resources/json/ControlLoopNoOrderedState.json deleted file mode 100644 index 6bff97580..000000000 --- a/models/src/test/resources/json/ControlLoopNoOrderedState.json +++ /dev/null @@ -1,12 +0,0 @@ -{ - "definition": { - "name": "controlLoopDefinitionName", - "version": "0.0.1" - }, - "state": "UNINITIALISED", - "orderedState": null, - "elements": [ - ], - "name": "control-loop", - "version": "0.0.1" -} diff --git a/models/src/test/resources/providers/TestAcElementStatistics.json b/models/src/test/resources/providers/TestAcElementStatistics.json new file mode 100644 index 000000000..cceb91d14 --- /dev/null +++ b/models/src/test/resources/providers/TestAcElementStatistics.json @@ -0,0 +1,24 @@ +{ + "acElementStatistics":[ + { + "participantId":{ + "name":"name1", + "version":"1.001" + }, + "id": "709c62b3-8918-41b9-a747-d21eb79c6c20", + "timeStamp": "2021-01-10T13:45:00.000Z", + "state": "UNINITIALISED", + "acElementUptime":250 + }, + { + "participantId":{ + "name":"name2", + "version":"1.001" + }, + "id": "709c62b3-8918-41b9-a747-d21eb79c6c21", + "timeStamp": "2021-01-10T14:25:00.000Z", + "state": "UNINITIALISED", + "acElementUptime":330 + } + ] +} diff --git a/models/src/test/resources/providers/TestAutomationCompositions.json b/models/src/test/resources/providers/TestAutomationCompositions.json new file mode 100644 index 000000000..906785244 --- /dev/null +++ b/models/src/test/resources/providers/TestAutomationCompositions.json @@ -0,0 +1,142 @@ +{ + "automationCompositionList": [ + { + "definition": { + "name": "org.onap.domain.pmsh.PMSHAutomationCompositionDefinition", + "version": "1.0.0" + }, + "state": "UNINITIALISED", + "orderedState": "UNINITIALISED", + "elements": { + "709c62b3-8918-41b9-a747-e21eb79c6c20": { + "id": "709c62b3-8918-41b9-a747-d21eb79c6c20", + "definition": { + "name": "org.onap.domain.pmsh.PMSH_DCAEMicroservice", + "version": "1.2.3" + }, + "participantType": { + "name": "org.onap.dcae.acm.DCAEMicroserviceAutomationCompositionParticipant", + "version": "2.3.4" + }, + "state": "UNINITIALISED", + "orderedState": "UNINITIALISED", + "description": "DCAE automation composition element for the PMSH instance 0 automation composition" + }, + "709c62b3-8918-41b9-a747-e21eb79c6c21": { + "id": "709c62b3-8918-41b9-a747-d21eb79c6c21", + "definition": { + "name": "org.onap.domain.pmsh.PMSH_MonitoringPolicyAutomationCompositionElement", + "version": "1.2.3" + }, + "participantType": { + "name": "org.onap.policy.acm.PolicyAutomationCompositionParticipant", + "version": "2.3.1" + }, + "state": "UNINITIALISED", + "orderedState": "UNINITIALISED", + "description": "Monitoring Policy element for the PMSH instance 0 automation composition" + }, + "709c62b3-8918-41b9-a747-e21eb79c6c22": { + "id": "709c62b3-8918-41b9-a747-d21eb79c6c22", + "definition": { + "name": "org.onap.domain.pmsh.PMSH_OperationalPolicyAutomationCompositionElement", + "version": "1.2.3" + }, + "participantType": { + "name": "org.onap.policy.acm.PolicyAutomationCompositionParticipant", + "version": "2.3.1" + }, + "state": "UNINITIALISED", + "orderedState": "UNINITIALISED", + "description": "Operational Policy element for the PMSH instance 0 automation composition" + }, + "709c62b3-8918-41b9-a747-e21eb79c6c23": { + "id": "709c62b3-8918-41b9-a747-d21eb79c6c23", + "definition": { + "name": "org.onap.domain.pmsh.PMSH_CDS_AutomationCompositionElement", + "version": "1.2.3" + }, + "participantType": { + "name": "org.onap.ccsdk.cds.acm.CdsAutomationCompositionParticipant", + "version": "2.2.1" + }, + "state": "UNINITIALISED", + "orderedState": "UNINITIALISED", + "description": "CDS automation composition element for the PMSH instance 0 automation composition" + } + }, + "name": "PMSHInstance0", + "version": "1.0.1", + "description": "PMSH automation composition instance 0" + }, + { + "definition": { + "name": "org.onap.domain.pmsh.PMSHAutomationCompositionDefinition", + "version": "1.0.0" + }, + "state": "UNINITIALISED", + "orderedState": "UNINITIALISED", + "elements": { + "709c62b3-8918-41b9-a747-e21eb79c6c24": { + "id": "709c62b3-8918-41b9-a747-e21eb79c6c24", + "definition": { + "name": "org.onap.domain.pmsh.PMSH_DCAEMicroservice", + "version": "1.2.3" + }, + "participantType": { + "name": "org.onap.dcae.acm.DCAEMicroserviceAutomationCompositionParticipant", + "version": "2.3.4" + }, + "state": "UNINITIALISED", + "orderedState": "UNINITIALISED", + "description": "DCAE automation composition element for the PMSH instance 1 automation composition" + }, + "709c62b3-8918-41b9-a747-e21eb79c6c25": { + "id": "709c62b3-8918-41b9-a747-e21eb79c6c25", + "definition": { + "name": "org.onap.domain.pmsh.PMSH_MonitoringPolicyAutomationCompositionElement", + "version": "1.2.3" + }, + "participantType": { + "name": "org.onap.policy.acm.PolicyAutomationCompositionParticipant", + "version": "2.3.1" + }, + "state": "UNINITIALISED", + "orderedState": "UNINITIALISED", + "description": "Monitoring Policy element for the PMSH instance 1 automation composition" + }, + "709c62b3-8918-41b9-a747-e21eb79c6c26": { + "id": "709c62b3-8918-41b9-a747-e21eb79c6c26", + "definition": { + "name": "org.onap.domain.pmsh.PMSH_OperationalPolicyAutomationCompositionElement", + "version": "1.2.3" + }, + "participantType": { + "name": "org.onap.policy.acm.PolicyAutomationCompositionParticipant", + "version": "2.3.1" + }, + "state": "UNINITIALISED", + "orderedState": "UNINITIALISED", + "description": "Operational Policy element for the PMSH instance 1 automation composition" + }, + "709c62b3-8918-41b9-a747-e21eb79c6c27": { + "id": "709c62b3-8918-41b9-a747-e21eb79c6c27", + "definition": { + "name": "org.onap.domain.pmsh.PMSH_CDS_AutomationCompositionElement", + "version": "1.2.3" + }, + "participantType": { + "name": "org.onap.ccsdk.cds.acm.CdsAutomationCompositionParticipant", + "version": "2.2.1" + }, + "state": "UNINITIALISED", + "orderedState": "UNINITIALISED", + "description": "CDS element for the PMSH instance 1 automation composition" + } + }, + "name": "PMSHInstance1", + "version": "1.0.1", + "description": "PMSH automation composition instance 1" + } + ] +} diff --git a/models/src/test/resources/providers/TestClElementStatistics.json b/models/src/test/resources/providers/TestClElementStatistics.json deleted file mode 100644 index ae19e560d..000000000 --- a/models/src/test/resources/providers/TestClElementStatistics.json +++ /dev/null @@ -1,24 +0,0 @@ -{ - "clElementStatistics":[ - { - "participantId":{ - "name":"name1", - "version":"1.001" - }, - "id": "709c62b3-8918-41b9-a747-d21eb79c6c20", - "timeStamp": "2021-01-10T13:45:00.000Z", - "controlLoopState": "UNINITIALISED", - "clElementUptime":250 - }, - { - "participantId":{ - "name":"name2", - "version":"1.001" - }, - "id": "709c62b3-8918-41b9-a747-d21eb79c6c21", - "timeStamp": "2021-01-10T14:25:00.000Z", - "controlLoopState": "UNINITIALISED", - "clElementUptime":330 - } - ] -} diff --git a/models/src/test/resources/providers/TestControlLoops.json b/models/src/test/resources/providers/TestControlLoops.json deleted file mode 100644 index fedda9600..000000000 --- a/models/src/test/resources/providers/TestControlLoops.json +++ /dev/null @@ -1,142 +0,0 @@ -{ - "controlLoopList": [ - { - "definition": { - "name": "org.onap.domain.pmsh.PMSHControlLoopDefinition", - "version": "1.0.0" - }, - "state": "UNINITIALISED", - "orderedState": "UNINITIALISED", - "elements": { - "709c62b3-8918-41b9-a747-e21eb79c6c20": { - "id": "709c62b3-8918-41b9-a747-d21eb79c6c20", - "definition": { - "name": "org.onap.domain.pmsh.PMSH_DCAEMicroservice", - "version": "1.2.3" - }, - "participantType": { - "name": "org.onap.dcae.controlloop.DCAEMicroserviceControlLoopParticipant", - "version": "2.3.4" - }, - "state": "UNINITIALISED", - "orderedState": "UNINITIALISED", - "description": "DCAE Control Loop Element for the PMSH instance 0 control loop" - }, - "709c62b3-8918-41b9-a747-e21eb79c6c21": { - "id": "709c62b3-8918-41b9-a747-d21eb79c6c21", - "definition": { - "name": "org.onap.domain.pmsh.PMSH_MonitoringPolicyControlLoopElement", - "version": "1.2.3" - }, - "participantType": { - "name": "org.onap.policy.controlloop.PolicyControlLoopParticipant", - "version": "2.3.1" - }, - "state": "UNINITIALISED", - "orderedState": "UNINITIALISED", - "description": "Monitoring Policy Control Loop Element for the PMSH instance 0 control loop" - }, - "709c62b3-8918-41b9-a747-e21eb79c6c22": { - "id": "709c62b3-8918-41b9-a747-d21eb79c6c22", - "definition": { - "name": "org.onap.domain.pmsh.PMSH_OperationalPolicyControlLoopElement", - "version": "1.2.3" - }, - "participantType": { - "name": "org.onap.policy.controlloop.PolicyControlLoopParticipant", - "version": "2.3.1" - }, - "state": "UNINITIALISED", - "orderedState": "UNINITIALISED", - "description": "Operational Policy Control Loop Element for the PMSH instance 0 control loop" - }, - "709c62b3-8918-41b9-a747-e21eb79c6c23": { - "id": "709c62b3-8918-41b9-a747-d21eb79c6c23", - "definition": { - "name": "org.onap.domain.pmsh.PMSH_CDS_ControlLoopElement", - "version": "1.2.3" - }, - "participantType": { - "name": "org.onap.ccsdk.cds.controlloop.CdsControlLoopParticipant", - "version": "2.2.1" - }, - "state": "UNINITIALISED", - "orderedState": "UNINITIALISED", - "description": "CDS Control Loop Element for the PMSH instance 0 control loop" - } - }, - "name": "PMSHInstance0", - "version": "1.0.1", - "description": "PMSH control loop instance 0" - }, - { - "definition": { - "name": "org.onap.domain.pmsh.PMSHControlLoopDefinition", - "version": "1.0.0" - }, - "state": "UNINITIALISED", - "orderedState": "UNINITIALISED", - "elements": { - "709c62b3-8918-41b9-a747-e21eb79c6c24": { - "id": "709c62b3-8918-41b9-a747-e21eb79c6c24", - "definition": { - "name": "org.onap.domain.pmsh.PMSH_DCAEMicroservice", - "version": "1.2.3" - }, - "participantType": { - "name": "org.onap.dcae.controlloop.DCAEMicroserviceControlLoopParticipant", - "version": "2.3.4" - }, - "state": "UNINITIALISED", - "orderedState": "UNINITIALISED", - "description": "DCAE Control Loop Element for the PMSH instance 1 control loop" - }, - "709c62b3-8918-41b9-a747-e21eb79c6c25": { - "id": "709c62b3-8918-41b9-a747-e21eb79c6c25", - "definition": { - "name": "org.onap.domain.pmsh.PMSH_MonitoringPolicyControlLoopElement", - "version": "1.2.3" - }, - "participantType": { - "name": "org.onap.policy.controlloop.PolicyControlLoopParticipant", - "version": "2.3.1" - }, - "state": "UNINITIALISED", - "orderedState": "UNINITIALISED", - "description": "Monitoring Policy Control Loop Element for the PMSH instance 1 control loop" - }, - "709c62b3-8918-41b9-a747-e21eb79c6c26": { - "id": "709c62b3-8918-41b9-a747-e21eb79c6c26", - "definition": { - "name": "org.onap.domain.pmsh.PMSH_OperationalPolicyControlLoopElement", - "version": "1.2.3" - }, - "participantType": { - "name": "org.onap.policy.controlloop.PolicyControlLoopParticipant", - "version": "2.3.1" - }, - "state": "UNINITIALISED", - "orderedState": "UNINITIALISED", - "description": "Operational Policy Control Loop Element for the PMSH instance 1 control loop" - }, - "709c62b3-8918-41b9-a747-e21eb79c6c27": { - "id": "709c62b3-8918-41b9-a747-e21eb79c6c27", - "definition": { - "name": "org.onap.domain.pmsh.PMSH_CDS_ControlLoopElement", - "version": "1.2.3" - }, - "participantType": { - "name": "org.onap.ccsdk.cds.controlloop.CdsControlLoopParticipant", - "version": "2.2.1" - }, - "state": "UNINITIALISED", - "orderedState": "UNINITIALISED", - "description": "CDS Control Loop Element for the PMSH instance 1 control loop" - } - }, - "name": "PMSHInstance1", - "version": "1.0.1", - "description": "PMSH control loop instance 1" - } - ] -} diff --git a/models/src/test/resources/providers/TestParticipant.json b/models/src/test/resources/providers/TestParticipant.json index 4722ead9b..7e4f9540f 100644 --- a/models/src/test/resources/providers/TestParticipant.json +++ b/models/src/test/resources/providers/TestParticipant.json @@ -2,14 +2,14 @@ "name": "dummy_participant1", "version": "1.0.1", "definition":{ - "name": "org.onap.domain.pmsh.PMSHControlLoopDefinition", + "name": "org.onap.domain.pmsh.PMSHAutomationCompositionDefinition", "version": "1.0.0" }, "participantState": "PASSIVE", "healthStatus": "HEALTHY", "description": "A dummy PMSH participant1", "participantType":{ - "name": "org.onap.domain.pmsh.PolicyControlLoopDefinition", + "name": "org.onap.domain.pmsh.PolicyAutomationCompositionDefinition", "version": "1.0.0" } } diff --git a/models/src/test/resources/providers/UpdateAutomationCompositions.json b/models/src/test/resources/providers/UpdateAutomationCompositions.json new file mode 100644 index 000000000..f118ea799 --- /dev/null +++ b/models/src/test/resources/providers/UpdateAutomationCompositions.json @@ -0,0 +1,73 @@ +{ + "automationCompositionList": [ + { + "name": "PMSHInstance0", + "version": "1.0.1", + "definition": { + "name": "org.onap.domain.pmsh.PMSHAutomationCompositionDefinition", + "version": "1.0.0" + }, + "state": "RUNNING", + "orderedState": "RUNNING", + "description": "PMSH automation composition instance 0", + "elements": { + "709c62b3-8918-41b9-a747-d21eb79c6c20": { + "id": "709c62b3-8918-41b9-a747-d21eb79c6c20", + "definition": { + "name": "org.onap.domain.pmsh.PMSH_DCAEMicroservice", + "version": "1.2.3" + }, + "participantType": { + "name": "org.onap.dcae.acm.DCAEMicroserviceAutomationCompositionParticipant", + "version": "2.3.4" + }, + "state": "RUNNING", + "orderedState": "RUNNING", + "description": "DCAE element for the PMSH instance 0 automation composition" + }, + "709c62b3-8918-41b9-a747-d21eb79c6c21": { + "id": "709c62b3-8918-41b9-a747-d21eb79c6c21", + "definition": { + "name": "org.onap.domain.pmsh.PMSH_MonitoringPolicyAutomationCompositionElement", + "version": "1.2.3" + }, + "participantType": { + "name": "org.onap.policy.acm.PolicyAutomationCompositionParticipant", + "version": "2.3.1" + }, + "state": "RUNNING", + "orderedState": "RUNNING", + "description": "Monitoring Policy element for the PMSH instance 0 automation composition" + }, + "709c62b3-8918-41b9-a747-d21eb79c6c22": { + "id": "709c62b3-8918-41b9-a747-d21eb79c6c22", + "definition": { + "name": "org.onap.domain.pmsh.PMSH_OperationalPolicyAutomationCompositionElement", + "version": "2.3.1" + }, + "participantType": { + "name": "org.onap.policy.acm.PolicyAutomationCompositionParticipant", + "version": "1.0.0" + }, + "state": "RUNNING", + "orderedState": "RUNNING", + "description": "Operational Policy element for the PMSH instance 0 automation composition" + }, + "709c62b3-8918-41b9-a747-d21eb79c6c23": { + "id": "709c62b3-8918-41b9-a747-d21eb79c6c23", + "definition": { + "name": "org.onap.domain.pmsh.PMSH_CDS_AutomationCompositionElement", + "version": "1.2.3" + }, + "participantType": { + "name": "org.onap.ccsdk.cds.acm.CdsAutomationCompositionParticipant", + "version": "2.2.1" + }, + "state": "RUNNING", + "orderedState": "RUNNING", + "description": "CDS element for the PMSH instance 0 automation composition" + } + } + } + ] +} diff --git a/models/src/test/resources/providers/UpdateControlLoops.json b/models/src/test/resources/providers/UpdateControlLoops.json deleted file mode 100644 index 2d6bd0753..000000000 --- a/models/src/test/resources/providers/UpdateControlLoops.json +++ /dev/null @@ -1,73 +0,0 @@ -{ - "controlLoopList": [ - { - "name": "PMSHInstance0", - "version": "1.0.1", - "definition": { - "name": "org.onap.domain.pmsh.PMSHControlLoopDefinition", - "version": "1.0.0" - }, - "state": "RUNNING", - "orderedState": "RUNNING", - "description": "PMSH control loop instance 0", - "elements": { - "709c62b3-8918-41b9-a747-d21eb79c6c20": { - "id": "709c62b3-8918-41b9-a747-d21eb79c6c20", - "definition": { - "name": "org.onap.domain.pmsh.PMSH_DCAEMicroservice", - "version": "1.2.3" - }, - "participantType": { - "name": "org.onap.dcae.controlloop.DCAEMicroserviceControlLoopParticipant", - "version": "2.3.4" - }, - "state": "RUNNING", - "orderedState": "RUNNING", - "description": "DCAE Control Loop Element for the PMSH instance 0 control loop" - }, - "709c62b3-8918-41b9-a747-d21eb79c6c21": { - "id": "709c62b3-8918-41b9-a747-d21eb79c6c21", - "definition": { - "name": "org.onap.domain.pmsh.PMSH_MonitoringPolicyControlLoopElement", - "version": "1.2.3" - }, - "participantType": { - "name": "org.onap.policy.controlloop.PolicyControlLoopParticipant", - "version": "2.3.1" - }, - "state": "RUNNING", - "orderedState": "RUNNING", - "description": "Monitoring Policy Control Loop Element for the PMSH instance 0 control loop" - }, - "709c62b3-8918-41b9-a747-d21eb79c6c22": { - "id": "709c62b3-8918-41b9-a747-d21eb79c6c22", - "definition": { - "name": "org.onap.domain.pmsh.PMSH_OperationalPolicyControlLoopElement", - "version": "2.3.1" - }, - "participantType": { - "name": "org.onap.policy.controlloop.PolicyControlLoopParticipant", - "version": "1.0.0" - }, - "state": "RUNNING", - "orderedState": "RUNNING", - "description": "Operational Policy Control Loop Element for the PMSH instance 0 control loop" - }, - "709c62b3-8918-41b9-a747-d21eb79c6c23": { - "id": "709c62b3-8918-41b9-a747-d21eb79c6c23", - "definition": { - "name": "org.onap.domain.pmsh.PMSH_CDS_ControlLoopElement", - "version": "1.2.3" - }, - "participantType": { - "name": "org.onap.ccsdk.cds.controlloop.CdsControlLoopParticipant", - "version": "2.2.1" - }, - "state": "RUNNING", - "orderedState": "RUNNING", - "description": "CDS Control Loop Element for the PMSH instance 0 control loop" - } - } - } - ] -} diff --git a/packages/policy-clamp-docker/pom.xml b/packages/policy-clamp-docker/pom.xml index 08511e03f..6415d2d79 100644 --- a/packages/policy-clamp-docker/pom.xml +++ b/packages/policy-clamp-docker/pom.xml @@ -92,10 +92,10 @@ - onap/policy-clamp-cl-runtime + onap/policy-clamp-runtime-acm try - ClRuntimeDockerfile + AcmRuntimeDockerfile ${project.version} ${project.version}-${maven.build.timestamp} @@ -109,11 +109,11 @@ org.onap.policy.clamp:policy-clamp-tarball /lib - policy-controlloop-runtime.tar.gz + policy-clamp-runtime-acm.tar.gz - org.onap.policy.clamp:policy-clamp-runtime-controlloop + org.onap.policy.clamp:policy-clamp-runtime-acm app.jar @@ -123,8 +123,8 @@ - onap/policy-clamp-cl-pf-ppnt - onap-policy-clamp-cl-pf-ppnt + onap/policy-clamp-ac-pf-ppnt + onap-policy-clamp-ac-pf-ppnt try PolicyParticipantDockerfile @@ -155,8 +155,8 @@ - onap/policy-clamp-cl-k8s-ppnt - onap-policy-clamp-cl-k8s-ppnt + onap/policy-clamp-ac-k8s-ppnt + onap-policy-clamp-ac-k8s-ppnt try KubernetesParticipantDockerfile @@ -187,8 +187,8 @@ - onap/policy-clamp-cl-http-ppnt - onap-policy-clamp-cl-http-ppnt + onap/policy-clamp-ac-http-ppnt + onap-policy-clamp-ac-http-ppnt try HttpParticipantDockerfile @@ -248,9 +248,6 @@ build push - - onap/policy-clamp - diff --git a/packages/policy-clamp-docker/src/main/docker/AcmRuntimeDockerfile b/packages/policy-clamp-docker/src/main/docker/AcmRuntimeDockerfile new file mode 100644 index 000000000..021a58676 --- /dev/null +++ b/packages/policy-clamp-docker/src/main/docker/AcmRuntimeDockerfile @@ -0,0 +1,53 @@ +#------------------------------------------------------------------------------- +# ============LICENSE_START======================================================= +# Copyright (C) 2021 Nordix Foundation. +# ================================================================================ +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# SPDX-License-Identifier: Apache-2.0 +# ============LICENSE_END========================================================= +#------------------------------------------------------------------------------- + +# +# Docker file to build an image that runs the CLAMP ACM runtime on Java 11 or better in alpine +# +FROM onap/policy-jre-alpine:2.4.0 + +LABEL maintainer="Policy Team" + +ARG POLICY_LOGS=/var/log/onap/policy/clamp + +ENV POLICY_LOGS=$POLICY_LOGS +ENV POLICY_HOME=$POLICY_HOME/clamp + +RUN mkdir -p $POLICY_LOGS $POLICY_HOME $POLICY_HOME/bin && \ + chown -R policy:policy $POLICY_HOME $POLICY_LOGS && \ + mkdir /packages +COPY /maven/lib/policy-clamp-runtime-acm.tar.gz /packages + +RUN tar xvfz /packages/policy-clamp-runtime-acm.tar.gz --directory $POLICY_HOME && \ + rm /packages/policy-clamp-runtime-acm.tar.gz + +WORKDIR $POLICY_HOME +COPY acm-runtime.sh bin/. +COPY /maven/app.jar /app + +RUN chown -R policy:policy * && \ + chmod 755 bin/*.sh && \ + chown -R policy:policy /app + +EXPOSE 6969 + +USER policy +WORKDIR $POLICY_HOME/bin +ENTRYPOINT [ "./acm-runtime.sh" ] diff --git a/packages/policy-clamp-docker/src/main/docker/ClRuntimeDockerfile b/packages/policy-clamp-docker/src/main/docker/ClRuntimeDockerfile deleted file mode 100644 index b66fddcc4..000000000 --- a/packages/policy-clamp-docker/src/main/docker/ClRuntimeDockerfile +++ /dev/null @@ -1,53 +0,0 @@ -#------------------------------------------------------------------------------- -# ============LICENSE_START======================================================= -# Copyright (C) 2021 Nordix Foundation. -# ================================================================================ -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# -# SPDX-License-Identifier: Apache-2.0 -# ============LICENSE_END========================================================= -#------------------------------------------------------------------------------- - -# -# Docker file to build an image that runs CLAMP on Java 11 or better in alpine -# -FROM onap/policy-jre-alpine:2.4.0 - -LABEL maintainer="Policy Team" - -ARG POLICY_LOGS=/var/log/onap/policy/clamp - -ENV POLICY_LOGS=$POLICY_LOGS -ENV POLICY_HOME=$POLICY_HOME/clamp - -RUN mkdir -p $POLICY_LOGS $POLICY_HOME $POLICY_HOME/bin && \ - chown -R policy:policy $POLICY_HOME $POLICY_LOGS && \ - mkdir /packages -COPY /maven/lib/policy-controlloop-runtime.tar.gz /packages - -RUN tar xvfz /packages/policy-controlloop-runtime.tar.gz --directory $POLICY_HOME && \ - rm /packages/policy-controlloop-runtime.tar.gz - -WORKDIR $POLICY_HOME -COPY controlloop-runtime.sh bin/. -COPY /maven/app.jar /app - -RUN chown -R policy:policy * && \ - chmod 755 bin/*.sh && \ - chown -R policy:policy /app - -EXPOSE 6969 - -USER policy -WORKDIR $POLICY_HOME/bin -ENTRYPOINT [ "./controlloop-runtime.sh" ] diff --git a/packages/policy-clamp-docker/src/main/docker/HttpParticipantDockerfile b/packages/policy-clamp-docker/src/main/docker/HttpParticipantDockerfile index 2497f5d3b..b6f2c44eb 100644 --- a/packages/policy-clamp-docker/src/main/docker/HttpParticipantDockerfile +++ b/packages/policy-clamp-docker/src/main/docker/HttpParticipantDockerfile @@ -19,7 +19,7 @@ #------------------------------------------------------------------------------- # -# Docker file to build an image that runs CLAMP on Java 11 or better in alpine +# Docker file to build an image that runs the CLAMP ACM HTTP Participant on Java 11 or better in alpine # FROM onap/policy-jre-alpine:2.4.0 diff --git a/packages/policy-clamp-docker/src/main/docker/KubernetesParticipantDockerfile b/packages/policy-clamp-docker/src/main/docker/KubernetesParticipantDockerfile index e7fc89021..688e68d09 100644 --- a/packages/policy-clamp-docker/src/main/docker/KubernetesParticipantDockerfile +++ b/packages/policy-clamp-docker/src/main/docker/KubernetesParticipantDockerfile @@ -19,7 +19,7 @@ #------------------------------------------------------------------------------- # -# Docker file to build an image that runs CLAMP on Java 11 or better in alpine +# Docker file to build an image that runs the CLAMP ACM K8S Participant on Java 11 or better in alpine # FROM onap/policy-jre-alpine:2.4.0 diff --git a/packages/policy-clamp-docker/src/main/docker/PolicyParticipantDockerfile b/packages/policy-clamp-docker/src/main/docker/PolicyParticipantDockerfile index a0d003292..50d4210bf 100644 --- a/packages/policy-clamp-docker/src/main/docker/PolicyParticipantDockerfile +++ b/packages/policy-clamp-docker/src/main/docker/PolicyParticipantDockerfile @@ -19,7 +19,7 @@ #------------------------------------------------------------------------------- # -# Docker file to build an image that runs CLAMP on Java 11 or better in alpine +# Docker file to build an image that runs the CLAMP ACM Policy Framework Participant on Java 11 or better in alpine # FROM onap/policy-jre-alpine:2.4.0 diff --git a/packages/policy-clamp-docker/src/main/docker/acm-runtime.sh b/packages/policy-clamp-docker/src/main/docker/acm-runtime.sh new file mode 100644 index 000000000..84550de82 --- /dev/null +++ b/packages/policy-clamp-docker/src/main/docker/acm-runtime.sh @@ -0,0 +1,71 @@ +#!/usr/bin/env sh +# +# ============LICENSE_START======================================================= +# Copyright (C) 2021 Nordix Foundation. +# ================================================================================ +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# SPDX-License-Identifier: Apache-2.0 +# ============LICENSE_END========================================================= +# + +JAVA_HOME=/usr/lib/jvm/java-11-openjdk/ +KEYSTORE="${KEYSTORE:-$POLICY_HOME/etc/ssl/policy-keystore}" +TRUSTSTORE="${TRUSTSTORE:-$POLICY_HOME/etc/ssl/policy-truststore}" +KEYSTORE_PASSWD="${KEYSTORE_PASSWD:-Pol1cy_0nap}" +TRUSTSTORE_PASSWD="${TRUSTSTORE_PASSWD:-Pol1cy_0nap}" + +if [ "$#" -eq 1 ]; then + CONFIG_FILE=$1 +else + CONFIG_FILE=${CONFIG_FILE} +fi + +if [ -z "$CONFIG_FILE" ]; then + CONFIG_FILE="${POLICY_HOME}/etc/AcRuntimeParameters.yaml" +fi + +echo "Policy clamp config file: $CONFIG_FILE" + +if [ -f "${POLICY_HOME}/etc/mounted/policy-truststore" ]; then + echo "overriding policy-truststore" + cp -f "${POLICY_HOME}"/etc/mounted/policy-truststore "${TRUSTSTORE}" +fi + +if [ -f "${POLICY_HOME}/etc/mounted/policy-keystore" ]; then + echo "overriding policy-keystore" + cp -f "${POLICY_HOME}"/etc/mounted/policy-keystore "${KEYSTORE}" +fi + +if [ -f "${POLICY_HOME}/etc/mounted/logback.xml" ]; then + echo "overriding logback xml files" + cp -f "${POLICY_HOME}"/etc/mounted/logback*.xml "${POLICY_HOME}"/etc/ +fi + +touch /app/app.jar +mkdir -p "${POLICY_HOME}"/config/ +cp -f "${CONFIG_FILE}" "${POLICY_HOME}"/config/AcRuntimeParameters.yaml + +$JAVA_HOME/bin/java -Dserver.ssl.enabled="true" \ + -Dserver.ssl.keyStore="${KEYSTORE}" \ + -Dserver.ssl.keyStorePassword="${KEYSTORE_PASSWD}" \ + -Djavax.net.ssl.trustStore="${TRUSTSTORE}" \ + -Djavax.net.ssl.trustStorePassword="${TRUSTSTORE_PASSWD}" \ + -Dcom.sun.management.jmxremote.rmi.port=9090 \ + -Dcom.sun.management.jmxremote=true \ + -Dcom.sun.management.jmxremote.port=9090 \ + -Dcom.sun.management.jmxremote.ssl=false \ + -Dcom.sun.management.jmxremote.authenticate=false \ + -Dcom.sun.management.jmxremote.local.only=false \ + -jar /app/app.jar \ + --spring.config.location="${POLICY_HOME}/config/AcRuntimeParameters.yaml" diff --git a/packages/policy-clamp-docker/src/main/docker/controlloop-runtime.sh b/packages/policy-clamp-docker/src/main/docker/controlloop-runtime.sh deleted file mode 100644 index c428fd553..000000000 --- a/packages/policy-clamp-docker/src/main/docker/controlloop-runtime.sh +++ /dev/null @@ -1,71 +0,0 @@ -#!/usr/bin/env sh -# -# ============LICENSE_START======================================================= -# Copyright (C) 2021 Nordix Foundation. -# ================================================================================ -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# -# SPDX-License-Identifier: Apache-2.0 -# ============LICENSE_END========================================================= -# - -JAVA_HOME=/usr/lib/jvm/java-11-openjdk/ -KEYSTORE="${KEYSTORE:-$POLICY_HOME/etc/ssl/policy-keystore}" -TRUSTSTORE="${TRUSTSTORE:-$POLICY_HOME/etc/ssl/policy-truststore}" -KEYSTORE_PASSWD="${KEYSTORE_PASSWD:-Pol1cy_0nap}" -TRUSTSTORE_PASSWD="${TRUSTSTORE_PASSWD:-Pol1cy_0nap}" - -if [ "$#" -eq 1 ]; then - CONFIG_FILE=$1 -else - CONFIG_FILE=${CONFIG_FILE} -fi - -if [ -z "$CONFIG_FILE" ]; then - CONFIG_FILE="${POLICY_HOME}/etc/ClRuntimeParameters.yaml" -fi - -echo "Policy clamp config file: $CONFIG_FILE" - -if [ -f "${POLICY_HOME}/etc/mounted/policy-truststore" ]; then - echo "overriding policy-truststore" - cp -f "${POLICY_HOME}"/etc/mounted/policy-truststore "${TRUSTSTORE}" -fi - -if [ -f "${POLICY_HOME}/etc/mounted/policy-keystore" ]; then - echo "overriding policy-keystore" - cp -f "${POLICY_HOME}"/etc/mounted/policy-keystore "${KEYSTORE}" -fi - -if [ -f "${POLICY_HOME}/etc/mounted/logback.xml" ]; then - echo "overriding logback xml files" - cp -f "${POLICY_HOME}"/etc/mounted/logback*.xml "${POLICY_HOME}"/etc/ -fi - -touch /app/app.jar -mkdir -p "${POLICY_HOME}"/config/ -cp -f "${CONFIG_FILE}" "${POLICY_HOME}"/config/ClRuntimeParameters.yaml - -$JAVA_HOME/bin/java -Dserver.ssl.enabled="true" \ - -Dserver.ssl.keyStore="${KEYSTORE}" \ - -Dserver.ssl.keyStorePassword="${KEYSTORE_PASSWD}" \ - -Djavax.net.ssl.trustStore="${TRUSTSTORE}" \ - -Djavax.net.ssl.trustStorePassword="${TRUSTSTORE_PASSWD}" \ - -Dcom.sun.management.jmxremote.rmi.port=9090 \ - -Dcom.sun.management.jmxremote=true \ - -Dcom.sun.management.jmxremote.port=9090 \ - -Dcom.sun.management.jmxremote.ssl=false \ - -Dcom.sun.management.jmxremote.authenticate=false \ - -Dcom.sun.management.jmxremote.local.only=false \ - -jar /app/app.jar \ - --spring.config.location="${POLICY_HOME}/config/ClRuntimeParameters.yaml" diff --git a/packages/policy-clamp-tarball/pom.xml b/packages/policy-clamp-tarball/pom.xml index 6b4a370fc..36aab6b92 100644 --- a/packages/policy-clamp-tarball/pom.xml +++ b/packages/policy-clamp-tarball/pom.xml @@ -34,7 +34,7 @@ org.onap.policy.clamp - policy-clamp-runtime-controlloop + policy-clamp-runtime-acm ${project.version} diff --git a/packages/policy-clamp-tarball/src/main/resources/etc/AcRuntimeParameters.yaml b/packages/policy-clamp-tarball/src/main/resources/etc/AcRuntimeParameters.yaml new file mode 100644 index 000000000..f17d3eb6e --- /dev/null +++ b/packages/policy-clamp-tarball/src/main/resources/etc/AcRuntimeParameters.yaml @@ -0,0 +1,68 @@ +spring: + security: + user: + name: runtimeUser + password: zb!XztG34 + http: + converters: + preferred-json-mapper: gson + datasource: + url: jdbc:mariadb://${mariadb.host:mariadb}:${mariadb.port:3306}/clamp-acm + driverClassName: org.mariadb.jdbc.Driver + username: policy_user + password: policy_user + hikari: + connectionTimeout: 30000 + idleTimeout: 600000 + maxLifetime: 1800000 + maximumPoolSize: 10 + jpa: + hibernate: + ddl-auto: update + naming: + physical-strategy: org.hibernate.boot.model.naming.PhysicalNamingStrategyStandardImpl + implicit-strategy: org.onap.policy.common.spring.utils.CustomImplicitNamingStrategy + properties: + hibernate: + dialect: org.hibernate.dialect.MariaDB103Dialect + format_sql: true + +security: + enable-csrf: false + +server: + port: 6969 + servlet: + context-path: /onap/policy/clamp/acm + error: + path: /error + +runtime: + participantParameters: + heartBeatMs: 20000 + maxStatusWaitMs: 100000 + updateParameters: + maxRetryCount: 3 + maxWaitMs: 20000 + topicParameterGroup: + topicSources: + - + topic: POLICY-ACRUNTIME-PARTICIPANT + servers: + - ${topicServer:message-router} + topicCommInfrastructure: dmaap + fetchTimeout: 15000 + useHttps: true + topicSinks: + - + topic: POLICY-ACRUNTIME-PARTICIPANT + servers: + - ${topicServer:message-router} + topicCommInfrastructure: dmaap + useHttps: true + +management: + endpoints: + web: + exposure: + include: health, metrics, prometheus diff --git a/packages/policy-clamp-tarball/src/main/resources/etc/ClRuntimeParameters.yaml b/packages/policy-clamp-tarball/src/main/resources/etc/ClRuntimeParameters.yaml deleted file mode 100644 index 462448921..000000000 --- a/packages/policy-clamp-tarball/src/main/resources/etc/ClRuntimeParameters.yaml +++ /dev/null @@ -1,69 +0,0 @@ -spring: - security: - user: - name: runtimeUser - password: zb!XztG34 - http: - converters: - preferred-json-mapper: gson - datasource: - url: jdbc:mariadb://${mariadb.host:mariadb}:${mariadb.port:3306}/controlloop - driverClassName: org.mariadb.jdbc.Driver - username: policy_user - password: policy_user - hikari: - connectionTimeout: 30000 - idleTimeout: 600000 - maxLifetime: 1800000 - maximumPoolSize: 10 - jpa: - hibernate: - ddl-auto: update - naming: - physical-strategy: org.hibernate.boot.model.naming.PhysicalNamingStrategyStandardImpl - implicit-strategy: org.onap.policy.common.spring.utils.CustomImplicitNamingStrategy - properties: - hibernate: - dialect: org.hibernate.dialect.MariaDB103Dialect - format_sql: true - -security: - enable-csrf: false - -server: - port: 6969 - servlet: - context-path: /onap/controlloop - error: - path: /error - - -runtime: - participantParameters: - heartBeatMs: 20000 - maxStatusWaitMs: 100000 - updateParameters: - maxRetryCount: 3 - maxWaitMs: 20000 - topicParameterGroup: - topicSources: - - - topic: POLICY-CLRUNTIME-PARTICIPANT - servers: - - ${topicServer:message-router} - topicCommInfrastructure: dmaap - fetchTimeout: 15000 - useHttps: true - topicSinks: - - - topic: POLICY-CLRUNTIME-PARTICIPANT - servers: - - ${topicServer:message-router} - topicCommInfrastructure: dmaap - useHttps: true - -management: - endpoints: - web: - exposure: - include: health, metrics, prometheus diff --git a/packages/policy-clamp-tarball/src/main/resources/etc/HttpParticipantParameters.yaml b/packages/policy-clamp-tarball/src/main/resources/etc/HttpParticipantParameters.yaml index b13059a69..529b095a1 100644 --- a/packages/policy-clamp-tarball/src/main/resources/etc/HttpParticipantParameters.yaml +++ b/packages/policy-clamp-tarball/src/main/resources/etc/HttpParticipantParameters.yaml @@ -13,18 +13,18 @@ participant: name: HttpParticipant0 version: 1.0.0 participantType: - name: org.onap.k8s.controlloop.HttpControlLoopParticipant + name: org.onap.policy.clamp.acm.HttpParticipant version: 2.3.4 - clampControlLoopTopics: + clampAutomationCompositionTopics: topicSources: - - topic: POLICY-CLRUNTIME-PARTICIPANT + - topic: POLICY-ACRUNTIME-PARTICIPANT servers: - ${topicServer:message-router} topicCommInfrastructure: dmaap fetchTimeout: 15000 useHttps: true topicSinks: - - topic: POLICY-CLRUNTIME-PARTICIPANT + - topic: POLICY-ACRUNTIME-PARTICIPANT servers: - ${topicServer:message-router} topicCommInfrastructure: dmaap @@ -37,4 +37,4 @@ management: server: port: 8084 servlet: - context-path: /onap/httpparticipant + context-path: /onap/policy/clamp/acm/httpparticipant diff --git a/packages/policy-clamp-tarball/src/main/resources/etc/KubernetesParticipantParameters.yaml b/packages/policy-clamp-tarball/src/main/resources/etc/KubernetesParticipantParameters.yaml index 0d94e2e94..c6acf4052 100644 --- a/packages/policy-clamp-tarball/src/main/resources/etc/KubernetesParticipantParameters.yaml +++ b/packages/policy-clamp-tarball/src/main/resources/etc/KubernetesParticipantParameters.yaml @@ -16,12 +16,12 @@ participant: name: K8sParticipant0 version: 1.0.0 participantType: - name: org.onap.k8s.controlloop.K8SControlLoopParticipant + name: org.onap.policy.clamp.acm.KubernetesParticipant version: 2.3.4 - clampControlLoopTopics: + clampAutomationCompositionTopics: topicSources: - - topic: POLICY-CLRUNTIME-PARTICIPANT + topic: POLICY-ACRUNTIME-PARTICIPANT servers: - ${topicServer:message-router} topicCommInfrastructure: dmaap @@ -29,7 +29,7 @@ participant: useHttps: true topicSinks: - - topic: POLICY-CLRUNTIME-PARTICIPANT + topic: POLICY-ACRUNTIME-PARTICIPANT servers: - ${topicServer:message-router} topicCommInfrastructure: dmaap @@ -43,7 +43,7 @@ management: server: port: 8083 servlet: - context-path: /onap/k8sparticipant + context-path: /onap/policy/clamp/acm/k8sparticipant logging: # Configuration of logging @@ -52,7 +52,7 @@ logging: org.springframework: ERROR org.springframework.data: ERROR org.springframework.web.reactive.function.client.ExchangeFunctions: ERROR - org.onap.policy.clamp.controlloop.participant.kubernetes: INFO + org.onap.policy.clamp.acm.participant.kubernetes: INFO file: name: /var/log/onap/policy/clamp/application.log diff --git a/packages/policy-clamp-tarball/src/main/resources/etc/PolicyParticipantParameters.yaml b/packages/policy-clamp-tarball/src/main/resources/etc/PolicyParticipantParameters.yaml index 14660a9ff..1cb4e6dc7 100644 --- a/packages/policy-clamp-tarball/src/main/resources/etc/PolicyParticipantParameters.yaml +++ b/packages/policy-clamp-tarball/src/main/resources/etc/PolicyParticipantParameters.yaml @@ -30,12 +30,12 @@ participant: name: org.onap.PM_Policy version: 1.0.0 participantType: - name: org.onap.policy.controlloop.PolicyControlLoopParticipant + name: org.onap.policy.clamp.acm.PolicyParticipant version: 2.3.1 - clampControlLoopTopics: + clampAutomationCompositionTopics: topicSources: - - topic: POLICY-CLRUNTIME-PARTICIPANT + topic: POLICY-ACRUNTIME-PARTICIPANT servers: - ${topicServer:message-router} topicCommInfrastructure: dmaap @@ -43,7 +43,7 @@ participant: useHttps: true topicSinks: - - topic: POLICY-CLRUNTIME-PARTICIPANT + topic: POLICY-ACRUNTIME-PARTICIPANT servers: - ${topicServer:message-router} topicCommInfrastructure: dmaap @@ -56,4 +56,4 @@ management: server: port: 8085 servlet: - context-path: /onap/policyparticipant + context-path: /onap/policy/clamp/acm/policyparticipant diff --git a/participant/participant-impl/participant-impl-cds/pom.xml b/participant/participant-impl/participant-impl-cds/pom.xml index 0f806a602..0b85867c3 100644 --- a/participant/participant-impl/participant-impl-cds/pom.xml +++ b/participant/participant-impl/participant-impl-cds/pom.xml @@ -30,5 +30,5 @@ policy-clamp-participant-impl-cds ${project.artifactId} - CDS participant, that allows CDS to partake in control loops + CDS participant, that allows CDS to partake in automation compositions diff --git a/participant/participant-impl/participant-impl-http/src/main/java/org/onap/policy/clamp/acm/participant/http/Application.java b/participant/participant-impl/participant-impl-http/src/main/java/org/onap/policy/clamp/acm/participant/http/Application.java new file mode 100644 index 000000000..2f26a8659 --- /dev/null +++ b/participant/participant-impl/participant-impl-http/src/main/java/org/onap/policy/clamp/acm/participant/http/Application.java @@ -0,0 +1,49 @@ +/*- + * ============LICENSE_START======================================================= + * Copyright (C) 2021 Nordix Foundation. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * SPDX-License-Identifier: Apache-2.0 + * ============LICENSE_END========================================================= + */ + +package org.onap.policy.clamp.acm.participant.http; + +import org.springframework.boot.SpringApplication; +import org.springframework.boot.autoconfigure.SpringBootApplication; +import org.springframework.boot.context.properties.ConfigurationPropertiesScan; +import org.springframework.context.annotation.ComponentScan; + +/** + * Starter. + * + */ +// @formatter:off +@SpringBootApplication +@ComponentScan({ + "org.onap.policy.clamp.acm.participant.http", + "org.onap.policy.clamp.acm.participant.intermediary" +}) +@ConfigurationPropertiesScan("org.onap.policy.clamp.acm.participant.http.parameters") +//@formatter:on +public class Application { + /** + * Main class. + * + * @param args args + */ + public static void main(String[] args) { + SpringApplication.run(Application.class, args); + } +} diff --git a/participant/participant-impl/participant-impl-http/src/main/java/org/onap/policy/clamp/acm/participant/http/config/ParticipantConfig.java b/participant/participant-impl/participant-impl-http/src/main/java/org/onap/policy/clamp/acm/participant/http/config/ParticipantConfig.java new file mode 100644 index 000000000..e2b5d1718 --- /dev/null +++ b/participant/participant-impl/participant-impl-http/src/main/java/org/onap/policy/clamp/acm/participant/http/config/ParticipantConfig.java @@ -0,0 +1,43 @@ +/*- + * ============LICENSE_START======================================================= + * Copyright (C) 2021 Nordix Foundation. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * SPDX-License-Identifier: Apache-2.0 + * ============LICENSE_END========================================================= + */ + +package org.onap.policy.clamp.acm.participant.http.config; + +import org.onap.policy.clamp.acm.participant.http.main.handler.AutomationCompositionElementHandler; +import org.onap.policy.clamp.acm.participant.intermediary.api.ParticipantIntermediaryApi; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.context.annotation.Configuration; + +@Configuration +public class ParticipantConfig { + + /** + * Register AutomationCompositionElementListener. + * + * @param intermediaryApi the ParticipantIntermediaryApi + * @param acElementHandler the AutomationComposition Element Handler + */ + @Autowired + public void registerAutomationCompositionElementListener(ParticipantIntermediaryApi intermediaryApi, + AutomationCompositionElementHandler acElementHandler) { + intermediaryApi.registerAutomationCompositionElementListener(acElementHandler); + acElementHandler.setIntermediaryApi(intermediaryApi); + } +} diff --git a/participant/participant-impl/participant-impl-http/src/main/java/org/onap/policy/clamp/acm/participant/http/config/SecurityConfig.java b/participant/participant-impl/participant-impl-http/src/main/java/org/onap/policy/clamp/acm/participant/http/config/SecurityConfig.java new file mode 100644 index 000000000..25a945e7e --- /dev/null +++ b/participant/participant-impl/participant-impl-http/src/main/java/org/onap/policy/clamp/acm/participant/http/config/SecurityConfig.java @@ -0,0 +1,45 @@ +/*- + * ========================LICENSE_START================================= + * Copyright (C) 2021 Nordix Foundation. All rights reserved. + * ====================================================================== + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ========================LICENSE_END=================================== + */ + +package org.onap.policy.clamp.acm.participant.http.config; + +import org.springframework.beans.factory.annotation.Value; +import org.springframework.context.annotation.Configuration; +import org.springframework.security.config.annotation.web.builders.HttpSecurity; +import org.springframework.security.config.annotation.web.configuration.WebSecurityConfigurerAdapter; + +@Configuration +public class SecurityConfig extends WebSecurityConfigurerAdapter { + + @Value("${security.enable-csrf:true}") + private boolean csrfEnabled = true; + + @Override + protected void configure(HttpSecurity http) throws Exception { + // @formatter:off + http.authorizeRequests() + .antMatchers().authenticated() + .anyRequest().authenticated() + .and().httpBasic(); + // @formatter:on + + if (!csrfEnabled) { + http.csrf().disable(); + } + } +} diff --git a/participant/participant-impl/participant-impl-http/src/main/java/org/onap/policy/clamp/acm/participant/http/main/exception/HttpWebClientException.java b/participant/participant-impl/participant-impl-http/src/main/java/org/onap/policy/clamp/acm/participant/http/main/exception/HttpWebClientException.java new file mode 100644 index 000000000..8978e88ec --- /dev/null +++ b/participant/participant-impl/participant-impl-http/src/main/java/org/onap/policy/clamp/acm/participant/http/main/exception/HttpWebClientException.java @@ -0,0 +1,33 @@ +/*- + * ============LICENSE_START======================================================= + * Copyright (C) 2021 Nordix Foundation. + * Modifications Copyright (C) 2021 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * SPDX-License-Identifier: Apache-2.0 + * ============LICENSE_END========================================================= + */ + +package org.onap.policy.clamp.acm.participant.http.main.exception; + + +import org.springframework.web.reactive.function.client.WebClientResponseException; + +public class HttpWebClientException extends WebClientResponseException { + private static final long serialVersionUID = 1L; + + public HttpWebClientException(int statusCode, String statusText) { + super(statusCode, statusText, null, null, null); + } +} diff --git a/participant/participant-impl/participant-impl-http/src/main/java/org/onap/policy/clamp/acm/participant/http/main/handler/AutomationCompositionElementHandler.java b/participant/participant-impl/participant-impl-http/src/main/java/org/onap/policy/clamp/acm/participant/http/main/handler/AutomationCompositionElementHandler.java new file mode 100644 index 000000000..89c98400e --- /dev/null +++ b/participant/participant-impl/participant-impl-http/src/main/java/org/onap/policy/clamp/acm/participant/http/main/handler/AutomationCompositionElementHandler.java @@ -0,0 +1,180 @@ +/*- + * ============LICENSE_START======================================================= + * Copyright (C) 2021-2022 Nordix Foundation. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * SPDX-License-Identifier: Apache-2.0 + * ============LICENSE_END========================================================= + */ + +package org.onap.policy.clamp.acm.participant.http.main.handler; + +import java.io.Closeable; +import java.io.IOException; +import java.lang.invoke.MethodHandles; +import java.util.List; +import java.util.Map; +import java.util.Set; +import java.util.UUID; +import java.util.concurrent.ConcurrentHashMap; +import java.util.concurrent.ExecutionException; +import java.util.concurrent.ExecutorService; +import java.util.concurrent.Executors; +import java.util.concurrent.Future; +import java.util.stream.Collectors; +import javax.validation.ConstraintViolation; +import javax.validation.Validation; +import javax.validation.ValidationException; +import lombok.Setter; +import org.apache.commons.lang3.tuple.Pair; +import org.onap.policy.clamp.acm.participant.http.main.models.ConfigRequest; +import org.onap.policy.clamp.acm.participant.http.main.webclient.AcHttpClient; +import org.onap.policy.clamp.acm.participant.intermediary.api.AutomationCompositionElementListener; +import org.onap.policy.clamp.acm.participant.intermediary.api.ParticipantIntermediaryApi; +import org.onap.policy.clamp.models.acm.concepts.AutomationCompositionElement; +import org.onap.policy.clamp.models.acm.concepts.AutomationCompositionOrderedState; +import org.onap.policy.clamp.models.acm.concepts.AutomationCompositionState; +import org.onap.policy.clamp.models.acm.messages.dmaap.participant.ParticipantMessageType; +import org.onap.policy.common.utils.coder.Coder; +import org.onap.policy.common.utils.coder.CoderException; +import org.onap.policy.common.utils.coder.StandardCoder; +import org.onap.policy.models.base.PfModelException; +import org.onap.policy.models.tosca.authorative.concepts.ToscaConceptIdentifier; +import org.onap.policy.models.tosca.authorative.concepts.ToscaNodeTemplate; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.http.HttpStatus; +import org.springframework.stereotype.Component; + +/** + * This class handles implementation of automationCompositionElement updates. + */ +@Component +public class AutomationCompositionElementHandler implements AutomationCompositionElementListener, Closeable { + + private static final Coder CODER = new StandardCoder(); + + private static final Logger LOGGER = LoggerFactory.getLogger(MethodHandles.lookup().lookupClass()); + + private final ExecutorService executor = Executors.newFixedThreadPool(Runtime.getRuntime().availableProcessors()); + + private final Map> restResponseMap = new ConcurrentHashMap<>(); + + @Setter + private ParticipantIntermediaryApi intermediaryApi; + + /** + * Handle automationCompositionElement statistics. + * + * @param automationCompositionElementId automation composition element id + */ + @Override + public void handleStatistics(UUID automationCompositionElementId) { + // Implementation not needed for http participant + + } + + /** + * Handle a automation composition element state change. + * + * @param automationCompositionElementId the ID of the automation composition element + * @param currentState the current state of the automation composition element + * @param newState the state to which the automation composition element is changing to + * @throws PfModelException in case of a model exception + */ + @Override + public void automationCompositionElementStateChange(ToscaConceptIdentifier automationCompositionId, + UUID automationCompositionElementId, AutomationCompositionState currentState, + AutomationCompositionOrderedState newState) { + switch (newState) { + case UNINITIALISED: + intermediaryApi.updateAutomationCompositionElementState(automationCompositionId, + automationCompositionElementId, newState, AutomationCompositionState.UNINITIALISED, + ParticipantMessageType.AUTOMATION_COMPOSITION_STATE_CHANGE); + break; + case PASSIVE: + intermediaryApi.updateAutomationCompositionElementState(automationCompositionId, + automationCompositionElementId, newState, AutomationCompositionState.PASSIVE, + ParticipantMessageType.AUTOMATION_COMPOSITION_STATE_CHANGE); + break; + case RUNNING: + intermediaryApi.updateAutomationCompositionElementState(automationCompositionId, + automationCompositionElementId, newState, AutomationCompositionState.RUNNING, + ParticipantMessageType.AUTOMATION_COMPOSITION_STATE_CHANGE); + break; + default: + LOGGER.warn("Cannot transition from state {} to state {}", currentState, newState); + break; + } + } + + /** + * Callback method to handle an update on a automation composition element. + * + * @param element the information on the automation composition element + * @param nodeTemplate toscaNodeTemplate + */ + @Override + public void automationCompositionElementUpdate(ToscaConceptIdentifier automationCompositionId, + AutomationCompositionElement element, ToscaNodeTemplate nodeTemplate) { + try { + var configRequest = CODER.convert(nodeTemplate.getProperties(), ConfigRequest.class); + Set> violations = + Validation.buildDefaultValidatorFactory().getValidator().validate(configRequest); + if (violations.isEmpty()) { + invokeHttpClient(configRequest); + List> failedResponseStatus = restResponseMap.values().stream() + .filter(response -> !HttpStatus.valueOf(response.getKey()) + .is2xxSuccessful()).collect(Collectors.toList()); + if (failedResponseStatus.isEmpty()) { + intermediaryApi.updateAutomationCompositionElementState(automationCompositionId, element.getId(), + AutomationCompositionOrderedState.PASSIVE, AutomationCompositionState.PASSIVE, + ParticipantMessageType.AUTOMATION_COMPOSITION_STATE_CHANGE); + } else { + LOGGER.error("Error on Invoking the http request: {}", failedResponseStatus); + } + } else { + LOGGER.error("Violations found in the config request parameters: {}", violations); + throw new ValidationException("Constraint violations in the config request"); + } + } catch (CoderException | ValidationException | InterruptedException | ExecutionException e) { + LOGGER.error("Error invoking the http request for the config ", e); + } + } + + /** + * Invoke a runnable thread to execute http requests. + * + * @param configRequest ConfigRequest + */ + public void invokeHttpClient(ConfigRequest configRequest) throws ExecutionException, InterruptedException { + // Invoke runnable thread to execute https requests of all config entities + Future result = executor.submit(new AcHttpClient(configRequest, restResponseMap), restResponseMap); + if (!result.get().isEmpty()) { + LOGGER.debug("Http Request Completed: {}", result.isDone()); + } + } + + /** + * Closes this stream and releases any system resources associated + * with it. If the stream is already closed then invoking this + * method has no effect. + * + * @throws IOException if an I/O error occurs + */ + @Override + public void close() throws IOException { + executor.shutdown(); + } +} diff --git a/participant/participant-impl/participant-impl-http/src/main/java/org/onap/policy/clamp/acm/participant/http/main/models/ConfigRequest.java b/participant/participant-impl/participant-impl-http/src/main/java/org/onap/policy/clamp/acm/participant/http/main/models/ConfigRequest.java new file mode 100644 index 000000000..c630b3c7c --- /dev/null +++ b/participant/participant-impl/participant-impl-http/src/main/java/org/onap/policy/clamp/acm/participant/http/main/models/ConfigRequest.java @@ -0,0 +1,51 @@ +/*- + * ============LICENSE_START======================================================= + * Copyright (C) 2021 Nordix Foundation. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * SPDX-License-Identifier: Apache-2.0 + * ============LICENSE_END========================================================= + */ + +package org.onap.policy.clamp.acm.participant.http.main.models; + +import java.util.List; +import java.util.Map; +import javax.validation.Valid; +import javax.validation.constraints.Min; +import javax.validation.constraints.NotBlank; +import javax.validation.constraints.NotNull; +import javax.ws.rs.DefaultValue; +import lombok.AllArgsConstructor; +import lombok.Data; + +@Data +@AllArgsConstructor +public class ConfigRequest { + + @NotBlank + private String baseUrl; + + @NotNull + private Map httpHeaders; + + @NotNull + @Valid + private List configurationEntities; + + @Min(value = 1) + @DefaultValue("20") + private int uninitializedToPassiveTimeout; + +} diff --git a/participant/participant-impl/participant-impl-http/src/main/java/org/onap/policy/clamp/acm/participant/http/main/models/ConfigurationEntity.java b/participant/participant-impl/participant-impl-http/src/main/java/org/onap/policy/clamp/acm/participant/http/main/models/ConfigurationEntity.java new file mode 100644 index 000000000..6ac2edb56 --- /dev/null +++ b/participant/participant-impl/participant-impl-http/src/main/java/org/onap/policy/clamp/acm/participant/http/main/models/ConfigurationEntity.java @@ -0,0 +1,40 @@ +/*- + * ============LICENSE_START======================================================= + * Copyright (C) 2021 Nordix Foundation. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * SPDX-License-Identifier: Apache-2.0 + * ============LICENSE_END========================================================= + */ + +package org.onap.policy.clamp.acm.participant.http.main.models; + +import java.util.List; +import javax.validation.Valid; +import javax.validation.constraints.NotNull; +import lombok.AllArgsConstructor; +import lombok.Data; +import org.onap.policy.models.tosca.authorative.concepts.ToscaConceptIdentifier; + +@Data +@AllArgsConstructor +public class ConfigurationEntity { + + @NotNull + private ToscaConceptIdentifier configurationEntityId; + + @NotNull + @Valid + private List restSequence; +} diff --git a/participant/participant-impl/participant-impl-http/src/main/java/org/onap/policy/clamp/acm/participant/http/main/models/RestParams.java b/participant/participant-impl/participant-impl-http/src/main/java/org/onap/policy/clamp/acm/participant/http/main/models/RestParams.java new file mode 100644 index 000000000..717131f5a --- /dev/null +++ b/participant/participant-impl/participant-impl-http/src/main/java/org/onap/policy/clamp/acm/participant/http/main/models/RestParams.java @@ -0,0 +1,54 @@ +/*- + * ============LICENSE_START======================================================= + * Copyright (C) 2021 Nordix Foundation. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * SPDX-License-Identifier: Apache-2.0 + * ============LICENSE_END========================================================= + */ + +package org.onap.policy.clamp.acm.participant.http.main.models; + +import java.util.Map; +import javax.validation.constraints.Max; +import javax.validation.constraints.Min; +import javax.validation.constraints.NotNull; +import lombok.AllArgsConstructor; +import lombok.Data; +import org.onap.policy.models.tosca.authorative.concepts.ToscaConceptIdentifier; + +@Data +@AllArgsConstructor +public class RestParams { + + @NotNull + private ToscaConceptIdentifier restRequestId; + + @NotNull + private String httpMethod; + + @NotNull + private String path; + + @Min(100) + @Max(599) + private int expectedResponse; + + private Map pathParams; + + private Map queryParams; + + private String body; + +} diff --git a/participant/participant-impl/participant-impl-http/src/main/java/org/onap/policy/clamp/acm/participant/http/main/webclient/AcHttpClient.java b/participant/participant-impl/participant-impl-http/src/main/java/org/onap/policy/clamp/acm/participant/http/main/webclient/AcHttpClient.java new file mode 100644 index 000000000..563daecd9 --- /dev/null +++ b/participant/participant-impl/participant-impl-http/src/main/java/org/onap/policy/clamp/acm/participant/http/main/webclient/AcHttpClient.java @@ -0,0 +1,135 @@ +/*- + * ============LICENSE_START======================================================= + * Copyright (C) 2021 Nordix Foundation. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * SPDX-License-Identifier: Apache-2.0 + * ============LICENSE_END========================================================= + */ + +package org.onap.policy.clamp.acm.participant.http.main.webclient; + +import java.lang.invoke.MethodHandles; +import java.time.Duration; +import java.util.Map; +import java.util.Objects; +import org.apache.commons.lang3.tuple.ImmutablePair; +import org.apache.commons.lang3.tuple.Pair; +import org.onap.policy.clamp.acm.participant.http.main.exception.HttpWebClientException; +import org.onap.policy.clamp.acm.participant.http.main.models.ConfigRequest; +import org.onap.policy.clamp.acm.participant.http.main.models.ConfigurationEntity; +import org.onap.policy.clamp.acm.participant.http.main.models.RestParams; +import org.onap.policy.models.tosca.authorative.concepts.ToscaConceptIdentifier; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.http.HttpHeaders; +import org.springframework.http.HttpMethod; +import org.springframework.web.reactive.function.BodyInserters; +import org.springframework.web.reactive.function.client.WebClient; +import org.springframework.web.util.UriComponentsBuilder; +import reactor.core.publisher.Mono; + +public class AcHttpClient implements Runnable { + + private static final Logger LOGGER = LoggerFactory.getLogger(MethodHandles.lookup().lookupClass()); + + private final ConfigRequest configRequest; + + private Map> responseMap; + + /** + * Constructor. + */ + public AcHttpClient(ConfigRequest configRequest, Map> responseMap) { + this.configRequest = configRequest; + this.responseMap = responseMap; + } + + /** + * Runnable to execute http requests. + */ + @Override + public void run() { + + var webClient = WebClient.builder() + .baseUrl(configRequest.getBaseUrl()) + .defaultHeaders(httpHeaders -> httpHeaders.addAll(createHeaders(configRequest))) + .build(); + + for (ConfigurationEntity configurationEntity : configRequest.getConfigurationEntities()) { + LOGGER.info("Executing http requests for the config entity {}", + configurationEntity.getConfigurationEntityId()); + + executeRequest(webClient, configurationEntity); + } + } + + private void executeRequest(WebClient client, ConfigurationEntity configurationEntity) { + + // Iterate the sequence of http requests + for (RestParams request: configurationEntity.getRestSequence()) { + String response = null; + try { + var httpMethod = Objects.requireNonNull(HttpMethod.resolve(request.getHttpMethod())); + var uri = createUriString(request); + LOGGER.info("Executing HTTP request: {} for the Rest request id: {}", httpMethod, + request.getRestRequestId()); + + response = client.method(httpMethod) + .uri(uri) + .body(request.getBody() == null ? BodyInserters.empty() + : BodyInserters.fromValue(request.getBody())) + .exchangeToMono(clientResponse -> + clientResponse.statusCode().value() == request.getExpectedResponse() + ? clientResponse.bodyToMono(String.class) + : Mono.error(new HttpWebClientException(clientResponse.statusCode().value(), + clientResponse.bodyToMono(String.class).toString()))) + .block(Duration.ofMillis(configRequest.getUninitializedToPassiveTimeout() * 1000L)); + + LOGGER.info("HTTP response for the {} request : {}", httpMethod, response); + responseMap.put(request.getRestRequestId(), new ImmutablePair<>(request.getExpectedResponse(), + response)); + + } catch (HttpWebClientException ex) { + LOGGER.error("Error occurred on the HTTP request ", ex); + responseMap.put(request.getRestRequestId(), new ImmutablePair<>(ex.getStatusCode().value(), + ex.getResponseBodyAsString())); + } + } + } + + private HttpHeaders createHeaders(ConfigRequest request) { + var headers = new HttpHeaders(); + for (Map.Entry entry: request.getHttpHeaders().entrySet()) { + headers.add(entry.getKey(), entry.getValue()); + } + return headers; + } + + private String createUriString(RestParams restParams) { + var uriComponentsBuilder = UriComponentsBuilder.fromUriString(restParams.getPath()); + // Add path params if present + if (restParams.getPathParams() != null) { + uriComponentsBuilder.uriVariables(restParams.getPathParams()); + } + // Add query params if present + if (restParams.getQueryParams() != null) { + for (Map.Entry entry : restParams.getQueryParams().entrySet()) { + uriComponentsBuilder.queryParam(entry.getKey(), entry.getValue()); + } + } + return uriComponentsBuilder.build().toUriString(); + } + +} diff --git a/participant/participant-impl/participant-impl-http/src/main/java/org/onap/policy/clamp/acm/participant/http/parameters/ParticipantHttpParameters.java b/participant/participant-impl/participant-impl-http/src/main/java/org/onap/policy/clamp/acm/participant/http/parameters/ParticipantHttpParameters.java new file mode 100644 index 000000000..c0f3c6a7a --- /dev/null +++ b/participant/participant-impl/participant-impl-http/src/main/java/org/onap/policy/clamp/acm/participant/http/parameters/ParticipantHttpParameters.java @@ -0,0 +1,46 @@ +/*- + * ============LICENSE_START======================================================= + * Copyright (C) 2021 Nordix Foundation. + * Modifications Copyright (C) 2021 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * SPDX-License-Identifier: Apache-2.0 + * ============LICENSE_END========================================================= + */ + +package org.onap.policy.clamp.acm.participant.http.parameters; + +import javax.validation.Valid; +import javax.validation.constraints.NotNull; +import lombok.Getter; +import lombok.Setter; +import org.onap.policy.clamp.acm.participant.intermediary.parameters.ParticipantIntermediaryParameters; +import org.onap.policy.clamp.acm.participant.intermediary.parameters.ParticipantParameters; +import org.springframework.boot.context.properties.ConfigurationProperties; +import org.springframework.validation.annotation.Validated; + +/** + * Class to hold all parameters needed for the http participant. + * + */ +@Validated +@Getter +@Setter +@ConfigurationProperties(prefix = "participant") +public class ParticipantHttpParameters implements ParticipantParameters { + + @NotNull + @Valid + private ParticipantIntermediaryParameters intermediaryParameters; +} diff --git a/participant/participant-impl/participant-impl-http/src/main/java/org/onap/policy/clamp/controlloop/participant/http/Application.java b/participant/participant-impl/participant-impl-http/src/main/java/org/onap/policy/clamp/controlloop/participant/http/Application.java deleted file mode 100644 index 4f8096502..000000000 --- a/participant/participant-impl/participant-impl-http/src/main/java/org/onap/policy/clamp/controlloop/participant/http/Application.java +++ /dev/null @@ -1,45 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * Copyright (C) 2021 Nordix Foundation. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - * SPDX-License-Identifier: Apache-2.0 - * ============LICENSE_END========================================================= - */ - -package org.onap.policy.clamp.controlloop.participant.http; - -import org.springframework.boot.SpringApplication; -import org.springframework.boot.autoconfigure.SpringBootApplication; -import org.springframework.boot.context.properties.ConfigurationPropertiesScan; -import org.springframework.context.annotation.ComponentScan; - -/** - * Starter. - * - */ -@SpringBootApplication -@ComponentScan({"org.onap.policy.clamp.controlloop.participant.http", - "org.onap.policy.clamp.controlloop.participant.intermediary"}) -@ConfigurationPropertiesScan("org.onap.policy.clamp.controlloop.participant.http.parameters") -public class Application { - /** - * Main class. - * - * @param args args - */ - public static void main(String[] args) { - SpringApplication.run(Application.class, args); - } -} diff --git a/participant/participant-impl/participant-impl-http/src/main/java/org/onap/policy/clamp/controlloop/participant/http/config/ParticipantConfig.java b/participant/participant-impl/participant-impl-http/src/main/java/org/onap/policy/clamp/controlloop/participant/http/config/ParticipantConfig.java deleted file mode 100644 index ce013a765..000000000 --- a/participant/participant-impl/participant-impl-http/src/main/java/org/onap/policy/clamp/controlloop/participant/http/config/ParticipantConfig.java +++ /dev/null @@ -1,43 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * Copyright (C) 2021 Nordix Foundation. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - * SPDX-License-Identifier: Apache-2.0 - * ============LICENSE_END========================================================= - */ - -package org.onap.policy.clamp.controlloop.participant.http.config; - -import org.onap.policy.clamp.controlloop.participant.http.main.handler.ControlLoopElementHandler; -import org.onap.policy.clamp.controlloop.participant.intermediary.api.ParticipantIntermediaryApi; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.context.annotation.Configuration; - -@Configuration -public class ParticipantConfig { - - /** - * Register ControlLoopElementListener. - * - * @param intermediaryApi the ParticipantIntermediaryApi - * @param clElementHandler the ControlLoop Element Handler - */ - @Autowired - public void registerControlLoopElementListener(ParticipantIntermediaryApi intermediaryApi, - ControlLoopElementHandler clElementHandler) { - intermediaryApi.registerControlLoopElementListener(clElementHandler); - clElementHandler.setIntermediaryApi(intermediaryApi); - } -} diff --git a/participant/participant-impl/participant-impl-http/src/main/java/org/onap/policy/clamp/controlloop/participant/http/config/SecurityConfig.java b/participant/participant-impl/participant-impl-http/src/main/java/org/onap/policy/clamp/controlloop/participant/http/config/SecurityConfig.java deleted file mode 100644 index 499bbe153..000000000 --- a/participant/participant-impl/participant-impl-http/src/main/java/org/onap/policy/clamp/controlloop/participant/http/config/SecurityConfig.java +++ /dev/null @@ -1,45 +0,0 @@ -/*- - * ========================LICENSE_START================================= - * Copyright (C) 2021 Nordix Foundation. All rights reserved. - * ====================================================================== - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ========================LICENSE_END=================================== - */ - -package org.onap.policy.clamp.controlloop.participant.http.config; - -import org.springframework.beans.factory.annotation.Value; -import org.springframework.context.annotation.Configuration; -import org.springframework.security.config.annotation.web.builders.HttpSecurity; -import org.springframework.security.config.annotation.web.configuration.WebSecurityConfigurerAdapter; - -@Configuration -public class SecurityConfig extends WebSecurityConfigurerAdapter { - - @Value("${security.enable-csrf:true}") - private boolean csrfEnabled = true; - - @Override - protected void configure(HttpSecurity http) throws Exception { - // @formatter:off - http.authorizeRequests() - .antMatchers().authenticated() - .anyRequest().authenticated() - .and().httpBasic(); - // @formatter:on - - if (!csrfEnabled) { - http.csrf().disable(); - } - } -} diff --git a/participant/participant-impl/participant-impl-http/src/main/java/org/onap/policy/clamp/controlloop/participant/http/main/exception/HttpWebClientException.java b/participant/participant-impl/participant-impl-http/src/main/java/org/onap/policy/clamp/controlloop/participant/http/main/exception/HttpWebClientException.java deleted file mode 100644 index 6b27700c4..000000000 --- a/participant/participant-impl/participant-impl-http/src/main/java/org/onap/policy/clamp/controlloop/participant/http/main/exception/HttpWebClientException.java +++ /dev/null @@ -1,33 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * Copyright (C) 2021 Nordix Foundation. - * Modifications Copyright (C) 2021 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - * SPDX-License-Identifier: Apache-2.0 - * ============LICENSE_END========================================================= - */ - -package org.onap.policy.clamp.controlloop.participant.http.main.exception; - - -import org.springframework.web.reactive.function.client.WebClientResponseException; - -public class HttpWebClientException extends WebClientResponseException { - private static final long serialVersionUID = 1L; - - public HttpWebClientException(int statusCode, String statusText) { - super(statusCode, statusText, null, null, null); - } -} diff --git a/participant/participant-impl/participant-impl-http/src/main/java/org/onap/policy/clamp/controlloop/participant/http/main/handler/ControlLoopElementHandler.java b/participant/participant-impl/participant-impl-http/src/main/java/org/onap/policy/clamp/controlloop/participant/http/main/handler/ControlLoopElementHandler.java deleted file mode 100644 index 69d8c750a..000000000 --- a/participant/participant-impl/participant-impl-http/src/main/java/org/onap/policy/clamp/controlloop/participant/http/main/handler/ControlLoopElementHandler.java +++ /dev/null @@ -1,178 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * Copyright (C) 2021-2022 Nordix Foundation. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - * SPDX-License-Identifier: Apache-2.0 - * ============LICENSE_END========================================================= - */ - -package org.onap.policy.clamp.controlloop.participant.http.main.handler; - -import java.io.Closeable; -import java.io.IOException; -import java.lang.invoke.MethodHandles; -import java.util.List; -import java.util.Map; -import java.util.Set; -import java.util.UUID; -import java.util.concurrent.ConcurrentHashMap; -import java.util.concurrent.ExecutionException; -import java.util.concurrent.ExecutorService; -import java.util.concurrent.Executors; -import java.util.concurrent.Future; -import java.util.stream.Collectors; -import javax.validation.ConstraintViolation; -import javax.validation.Validation; -import javax.validation.ValidationException; -import lombok.Setter; -import org.apache.commons.lang3.tuple.Pair; -import org.onap.policy.clamp.controlloop.models.controlloop.concepts.ControlLoopElement; -import org.onap.policy.clamp.controlloop.models.controlloop.concepts.ControlLoopOrderedState; -import org.onap.policy.clamp.controlloop.models.controlloop.concepts.ControlLoopState; -import org.onap.policy.clamp.controlloop.models.messages.dmaap.participant.ParticipantMessageType; -import org.onap.policy.clamp.controlloop.participant.http.main.models.ConfigRequest; -import org.onap.policy.clamp.controlloop.participant.http.main.webclient.ClHttpClient; -import org.onap.policy.clamp.controlloop.participant.intermediary.api.ControlLoopElementListener; -import org.onap.policy.clamp.controlloop.participant.intermediary.api.ParticipantIntermediaryApi; -import org.onap.policy.common.utils.coder.Coder; -import org.onap.policy.common.utils.coder.CoderException; -import org.onap.policy.common.utils.coder.StandardCoder; -import org.onap.policy.models.base.PfModelException; -import org.onap.policy.models.tosca.authorative.concepts.ToscaConceptIdentifier; -import org.onap.policy.models.tosca.authorative.concepts.ToscaNodeTemplate; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; -import org.springframework.http.HttpStatus; -import org.springframework.stereotype.Component; - -/** - * This class handles implementation of controlLoopElement updates. - */ -@Component -public class ControlLoopElementHandler implements ControlLoopElementListener, Closeable { - - private static final Coder CODER = new StandardCoder(); - - private static final Logger LOGGER = LoggerFactory.getLogger(MethodHandles.lookup().lookupClass()); - - private ExecutorService executor = Executors.newFixedThreadPool(Runtime.getRuntime().availableProcessors()); - - private Map> restResponseMap = new ConcurrentHashMap<>(); - - @Setter - private ParticipantIntermediaryApi intermediaryApi; - - /** - * Handle controlLoopElement statistics. - * - * @param controlLoopElementId controlloop element id - */ - @Override - public void handleStatistics(UUID controlLoopElementId) throws PfModelException { - // Implementation not needed for http participant - - } - - /** - * Handle a control loop element state change. - * - * @param controlLoopElementId the ID of the control loop element - * @param currentState the current state of the control loop element - * @param newState the state to which the control loop element is changing to - * @throws PfModelException in case of a model exception - */ - @Override - public void controlLoopElementStateChange(ToscaConceptIdentifier controlLoopId, UUID controlLoopElementId, - ControlLoopState currentState, ControlLoopOrderedState newState) throws PfModelException { - switch (newState) { - case UNINITIALISED: - intermediaryApi.updateControlLoopElementState(controlLoopId, - controlLoopElementId, newState, ControlLoopState.UNINITIALISED, - ParticipantMessageType.CONTROL_LOOP_STATE_CHANGE); - break; - case PASSIVE: - intermediaryApi.updateControlLoopElementState(controlLoopId, - controlLoopElementId, newState, ControlLoopState.PASSIVE, - ParticipantMessageType.CONTROL_LOOP_STATE_CHANGE); - break; - case RUNNING: - intermediaryApi.updateControlLoopElementState(controlLoopId, - controlLoopElementId, newState, ControlLoopState.RUNNING, - ParticipantMessageType.CONTROL_LOOP_STATE_CHANGE); - break; - default: - LOGGER.warn("Cannot transition from state {} to state {}", currentState, newState); - break; - } - } - - /** - * Callback method to handle an update on a control loop element. - * - * @param element the information on the control loop element - * @param nodeTemplate toscaNodeTemplate - */ - @Override - public void controlLoopElementUpdate(ToscaConceptIdentifier controlLoopId, ControlLoopElement element, - ToscaNodeTemplate nodeTemplate) { - try { - var configRequest = CODER.convert(nodeTemplate.getProperties(), ConfigRequest.class); - Set> violations = Validation.buildDefaultValidatorFactory() - .getValidator().validate(configRequest); - if (violations.isEmpty()) { - invokeHttpClient(configRequest); - List> failedResponseStatus = restResponseMap.values().stream() - .filter(response -> !HttpStatus.valueOf(response.getKey()) - .is2xxSuccessful()).collect(Collectors.toList()); - if (failedResponseStatus.isEmpty()) { - intermediaryApi.updateControlLoopElementState(controlLoopId, element.getId(), - ControlLoopOrderedState.PASSIVE, ControlLoopState.PASSIVE, - ParticipantMessageType.CONTROL_LOOP_STATE_CHANGE); - } else { - LOGGER.error("Error on Invoking the http request: {}", failedResponseStatus); - } - } else { - LOGGER.error("Violations found in the config request parameters: {}", violations); - throw new ValidationException("Constraint violations in the config request"); - } - } catch (CoderException | ValidationException | InterruptedException | ExecutionException e) { - LOGGER.error("Error invoking the http request for the config ", e); - } - } - - /** - * Invoke a runnable thread to execute http requests. - * @param configRequest ConfigRequest - */ - public void invokeHttpClient(ConfigRequest configRequest) throws ExecutionException, InterruptedException { - // Invoke runnable thread to execute https requests of all config entities - Future result = executor.submit(new ClHttpClient(configRequest, restResponseMap), restResponseMap); - if (!result.get().isEmpty()) { - LOGGER.debug("Http Request Completed: {}", result.isDone()); - } - } - - /** - * Closes this stream and releases any system resources associated - * with it. If the stream is already closed then invoking this - * method has no effect. - * - * @throws IOException if an I/O error occurs - */ - @Override - public void close() throws IOException { - executor.shutdown(); - } -} diff --git a/participant/participant-impl/participant-impl-http/src/main/java/org/onap/policy/clamp/controlloop/participant/http/main/models/ConfigRequest.java b/participant/participant-impl/participant-impl-http/src/main/java/org/onap/policy/clamp/controlloop/participant/http/main/models/ConfigRequest.java deleted file mode 100644 index 87cab88a7..000000000 --- a/participant/participant-impl/participant-impl-http/src/main/java/org/onap/policy/clamp/controlloop/participant/http/main/models/ConfigRequest.java +++ /dev/null @@ -1,51 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * Copyright (C) 2021 Nordix Foundation. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - * SPDX-License-Identifier: Apache-2.0 - * ============LICENSE_END========================================================= - */ - -package org.onap.policy.clamp.controlloop.participant.http.main.models; - -import java.util.List; -import java.util.Map; -import javax.validation.Valid; -import javax.validation.constraints.Min; -import javax.validation.constraints.NotBlank; -import javax.validation.constraints.NotNull; -import javax.ws.rs.DefaultValue; -import lombok.AllArgsConstructor; -import lombok.Data; - -@Data -@AllArgsConstructor -public class ConfigRequest { - - @NotBlank - private String baseUrl; - - @NotNull - private Map httpHeaders; - - @NotNull - @Valid - private List configurationEntities; - - @Min(value = 1) - @DefaultValue("20") - private int uninitializedToPassiveTimeout; - -} diff --git a/participant/participant-impl/participant-impl-http/src/main/java/org/onap/policy/clamp/controlloop/participant/http/main/models/ConfigurationEntity.java b/participant/participant-impl/participant-impl-http/src/main/java/org/onap/policy/clamp/controlloop/participant/http/main/models/ConfigurationEntity.java deleted file mode 100644 index 8703a9d21..000000000 --- a/participant/participant-impl/participant-impl-http/src/main/java/org/onap/policy/clamp/controlloop/participant/http/main/models/ConfigurationEntity.java +++ /dev/null @@ -1,40 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * Copyright (C) 2021 Nordix Foundation. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - * SPDX-License-Identifier: Apache-2.0 - * ============LICENSE_END========================================================= - */ - -package org.onap.policy.clamp.controlloop.participant.http.main.models; - -import java.util.List; -import javax.validation.Valid; -import javax.validation.constraints.NotNull; -import lombok.AllArgsConstructor; -import lombok.Data; -import org.onap.policy.models.tosca.authorative.concepts.ToscaConceptIdentifier; - -@Data -@AllArgsConstructor -public class ConfigurationEntity { - - @NotNull - private ToscaConceptIdentifier configurationEntityId; - - @NotNull - @Valid - private List restSequence; -} diff --git a/participant/participant-impl/participant-impl-http/src/main/java/org/onap/policy/clamp/controlloop/participant/http/main/models/RestParams.java b/participant/participant-impl/participant-impl-http/src/main/java/org/onap/policy/clamp/controlloop/participant/http/main/models/RestParams.java deleted file mode 100644 index fc4e02897..000000000 --- a/participant/participant-impl/participant-impl-http/src/main/java/org/onap/policy/clamp/controlloop/participant/http/main/models/RestParams.java +++ /dev/null @@ -1,54 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * Copyright (C) 2021 Nordix Foundation. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - * SPDX-License-Identifier: Apache-2.0 - * ============LICENSE_END========================================================= - */ - -package org.onap.policy.clamp.controlloop.participant.http.main.models; - -import java.util.Map; -import javax.validation.constraints.Max; -import javax.validation.constraints.Min; -import javax.validation.constraints.NotNull; -import lombok.AllArgsConstructor; -import lombok.Data; -import org.onap.policy.models.tosca.authorative.concepts.ToscaConceptIdentifier; - -@Data -@AllArgsConstructor -public class RestParams { - - @NotNull - private ToscaConceptIdentifier restRequestId; - - @NotNull - private String httpMethod; - - @NotNull - private String path; - - @Min(100) - @Max(599) - private int expectedResponse; - - private Map pathParams; - - private Map queryParams; - - private String body; - -} diff --git a/participant/participant-impl/participant-impl-http/src/main/java/org/onap/policy/clamp/controlloop/participant/http/main/webclient/ClHttpClient.java b/participant/participant-impl/participant-impl-http/src/main/java/org/onap/policy/clamp/controlloop/participant/http/main/webclient/ClHttpClient.java deleted file mode 100644 index 0e0ea557e..000000000 --- a/participant/participant-impl/participant-impl-http/src/main/java/org/onap/policy/clamp/controlloop/participant/http/main/webclient/ClHttpClient.java +++ /dev/null @@ -1,135 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * Copyright (C) 2021 Nordix Foundation. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - * SPDX-License-Identifier: Apache-2.0 - * ============LICENSE_END========================================================= - */ - -package org.onap.policy.clamp.controlloop.participant.http.main.webclient; - -import java.lang.invoke.MethodHandles; -import java.time.Duration; -import java.util.Map; -import java.util.Objects; -import org.apache.commons.lang3.tuple.ImmutablePair; -import org.apache.commons.lang3.tuple.Pair; -import org.onap.policy.clamp.controlloop.participant.http.main.exception.HttpWebClientException; -import org.onap.policy.clamp.controlloop.participant.http.main.models.ConfigRequest; -import org.onap.policy.clamp.controlloop.participant.http.main.models.ConfigurationEntity; -import org.onap.policy.clamp.controlloop.participant.http.main.models.RestParams; -import org.onap.policy.models.tosca.authorative.concepts.ToscaConceptIdentifier; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; -import org.springframework.http.HttpHeaders; -import org.springframework.http.HttpMethod; -import org.springframework.web.reactive.function.BodyInserters; -import org.springframework.web.reactive.function.client.WebClient; -import org.springframework.web.util.UriComponentsBuilder; -import reactor.core.publisher.Mono; - -public class ClHttpClient implements Runnable { - - private static final Logger LOGGER = LoggerFactory.getLogger(MethodHandles.lookup().lookupClass()); - - private final ConfigRequest configRequest; - - private Map> responseMap; - - /** - * Constructor. - */ - public ClHttpClient(ConfigRequest configRequest, Map> responseMap) { - this.configRequest = configRequest; - this.responseMap = responseMap; - } - - /** - * Runnable to execute http requests. - */ - @Override - public void run() { - - var webClient = WebClient.builder() - .baseUrl(configRequest.getBaseUrl()) - .defaultHeaders(httpHeaders -> httpHeaders.addAll(createHeaders(configRequest))) - .build(); - - for (ConfigurationEntity configurationEntity : configRequest.getConfigurationEntities()) { - LOGGER.info("Executing http requests for the config entity {}", - configurationEntity.getConfigurationEntityId()); - - executeRequest(webClient, configurationEntity); - } - } - - private void executeRequest(WebClient client, ConfigurationEntity configurationEntity) { - - // Iterate the sequence of http requests - for (RestParams request: configurationEntity.getRestSequence()) { - String response = null; - try { - var httpMethod = Objects.requireNonNull(HttpMethod.resolve(request.getHttpMethod())); - var uri = createUriString(request); - LOGGER.info("Executing HTTP request: {} for the Rest request id: {}", httpMethod, - request.getRestRequestId()); - - response = client.method(httpMethod) - .uri(uri) - .body(request.getBody() == null ? BodyInserters.empty() - : BodyInserters.fromValue(request.getBody())) - .exchangeToMono(clientResponse -> - clientResponse.statusCode().value() == request.getExpectedResponse() - ? clientResponse.bodyToMono(String.class) - : Mono.error(new HttpWebClientException(clientResponse.statusCode().value(), - clientResponse.bodyToMono(String.class).toString()))) - .block(Duration.ofMillis(configRequest.getUninitializedToPassiveTimeout() * 1000L)); - - LOGGER.info("HTTP response for the {} request : {}", httpMethod, response); - responseMap.put(request.getRestRequestId(), new ImmutablePair<>(request.getExpectedResponse(), - response)); - - } catch (HttpWebClientException ex) { - LOGGER.error("Error occurred on the HTTP request ", ex); - responseMap.put(request.getRestRequestId(), new ImmutablePair<>(ex.getStatusCode().value(), - ex.getResponseBodyAsString())); - } - } - } - - private HttpHeaders createHeaders(ConfigRequest request) { - var headers = new HttpHeaders(); - for (Map.Entry entry: request.getHttpHeaders().entrySet()) { - headers.add(entry.getKey(), entry.getValue()); - } - return headers; - } - - private String createUriString(RestParams restParams) { - var uriComponentsBuilder = UriComponentsBuilder.fromUriString(restParams.getPath()); - // Add path params if present - if (restParams.getPathParams() != null) { - uriComponentsBuilder.uriVariables(restParams.getPathParams()); - } - // Add query params if present - if (restParams.getQueryParams() != null) { - for (Map.Entry entry : restParams.getQueryParams().entrySet()) { - uriComponentsBuilder.queryParam(entry.getKey(), entry.getValue()); - } - } - return uriComponentsBuilder.build().toUriString(); - } - -} diff --git a/participant/participant-impl/participant-impl-http/src/main/java/org/onap/policy/clamp/controlloop/participant/http/parameters/ParticipantHttpParameters.java b/participant/participant-impl/participant-impl-http/src/main/java/org/onap/policy/clamp/controlloop/participant/http/parameters/ParticipantHttpParameters.java deleted file mode 100644 index 62bbd7593..000000000 --- a/participant/participant-impl/participant-impl-http/src/main/java/org/onap/policy/clamp/controlloop/participant/http/parameters/ParticipantHttpParameters.java +++ /dev/null @@ -1,47 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * Copyright (C) 2021 Nordix Foundation. - * Modifications Copyright (C) 2021 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - * SPDX-License-Identifier: Apache-2.0 - * ============LICENSE_END========================================================= - */ - -package org.onap.policy.clamp.controlloop.participant.http.parameters; - -import javax.validation.Valid; -import javax.validation.constraints.NotNull; -import lombok.Getter; -import lombok.Setter; -import org.onap.policy.clamp.controlloop.participant.intermediary.parameters.ParticipantIntermediaryParameters; -import org.onap.policy.clamp.controlloop.participant.intermediary.parameters.ParticipantParameters; -import org.springframework.boot.context.properties.ConfigurationProperties; -import org.springframework.validation.annotation.Validated; - -/** - * Class to hold all parameters needed for the http participant. - * - */ -@Validated -@Getter -@Setter -@ConfigurationProperties(prefix = "participant") -public class ParticipantHttpParameters implements ParticipantParameters { - - @NotNull - @Valid - private ParticipantIntermediaryParameters intermediaryParameters; - -} diff --git a/participant/participant-impl/participant-impl-http/src/main/resources/config/application.yaml b/participant/participant-impl/participant-impl-http/src/main/resources/config/application.yaml index df0ad7df3..8a3d0fbf2 100644 --- a/participant/participant-impl/participant-impl-http/src/main/resources/config/application.yaml +++ b/participant/participant-impl/participant-impl-http/src/main/resources/config/application.yaml @@ -13,17 +13,17 @@ participant: name: HttpParticipant0 version: 1.0.0 participantType: - name: org.onap.k8s.controlloop.HttpControlLoopParticipant + name: org.onap.policy.clamp.acm.HttpParticipant version: 2.3.4 - clampControlLoopTopics: + clampAutomationCompositionTopics: topicSources: - - topic: POLICY-CLRUNTIME-PARTICIPANT + - topic: POLICY-ACRUNTIME-PARTICIPANT servers: - ${topicServer:message-router} topicCommInfrastructure: dmaap fetchTimeout: 15000 topicSinks: - - topic: POLICY-CLRUNTIME-PARTICIPANT + - topic: POLICY-ACRUNTIME-PARTICIPANT servers: - ${topicServer:message-router} topicCommInfrastructure: dmaap @@ -35,4 +35,4 @@ management: server: port: 8084 servlet: - context-path: /onap/httpparticipant + context-path: /onap/policy/clamp/acm/httpparticipant diff --git a/participant/participant-impl/participant-impl-http/src/test/java/org/onap/policy/clamp/acm/participant/http/handler/AcElementHandlerTest.java b/participant/participant-impl/participant-impl-http/src/test/java/org/onap/policy/clamp/acm/participant/http/handler/AcElementHandlerTest.java new file mode 100644 index 000000000..fbb689448 --- /dev/null +++ b/participant/participant-impl/participant-impl-http/src/test/java/org/onap/policy/clamp/acm/participant/http/handler/AcElementHandlerTest.java @@ -0,0 +1,106 @@ +/*- + * ============LICENSE_START======================================================= + * Copyright (C) 2021 Nordix Foundation. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * SPDX-License-Identifier: Apache-2.0 + * ============LICENSE_END========================================================= + */ + +package org.onap.policy.clamp.acm.participant.http.handler; + +import static org.junit.jupiter.api.Assertions.assertDoesNotThrow; +import static org.mockito.ArgumentMatchers.any; +import static org.mockito.Mockito.doNothing; + +import java.io.IOException; +import java.util.Map; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.ExtendWith; +import org.mockito.InjectMocks; +import org.mockito.Mock; +import org.mockito.Mockito; +import org.mockito.Spy; +import org.onap.policy.clamp.acm.participant.http.main.handler.AutomationCompositionElementHandler; +import org.onap.policy.clamp.acm.participant.http.main.models.ConfigRequest; +import org.onap.policy.clamp.acm.participant.http.utils.CommonTestData; +import org.onap.policy.clamp.acm.participant.http.utils.ToscaUtils; +import org.onap.policy.clamp.acm.participant.intermediary.api.ParticipantIntermediaryApi; +import org.onap.policy.clamp.models.acm.concepts.AutomationCompositionElement; +import org.onap.policy.clamp.models.acm.concepts.AutomationCompositionOrderedState; +import org.onap.policy.clamp.models.acm.concepts.AutomationCompositionState; +import org.onap.policy.common.utils.coder.CoderException; +import org.onap.policy.models.tosca.authorative.concepts.ToscaNodeTemplate; +import org.onap.policy.models.tosca.authorative.concepts.ToscaServiceTemplate; +import org.springframework.test.context.junit.jupiter.SpringExtension; + +@ExtendWith(SpringExtension.class) +class AcElementHandlerTest { + + @InjectMocks + @Spy + private AutomationCompositionElementHandler automationCompositionElementHandler = + new AutomationCompositionElementHandler(); + + @Mock + private ParticipantIntermediaryApi participantIntermediaryApi; + + private CommonTestData commonTestData = new CommonTestData(); + + private static ToscaServiceTemplate serviceTemplate; + private static final String HTTP_AUTOMATION_COMPOSITION_ELEMENT = + "org.onap.domain.database.Http_PMSHMicroserviceAutomationCompositionElement"; + + @BeforeAll + static void init() throws CoderException { + serviceTemplate = ToscaUtils.readAutomationCompositionFromTosca(); + } + + @Test + void test_automationCompositionElementeStateChange() throws IOException { + var automationCompositionId = commonTestData.getAutomationCompositionId(); + var element = commonTestData.getAutomationCompositionElement(); + var automationCompositionElementId = element.getId(); + + var config = Mockito.mock(ConfigRequest.class); + assertDoesNotThrow(() -> automationCompositionElementHandler.invokeHttpClient(config)); + + assertDoesNotThrow(() -> automationCompositionElementHandler.automationCompositionElementStateChange( + automationCompositionId, automationCompositionElementId, AutomationCompositionState.PASSIVE, + AutomationCompositionOrderedState.PASSIVE)); + + assertDoesNotThrow(() -> automationCompositionElementHandler.automationCompositionElementStateChange( + automationCompositionId, automationCompositionElementId, AutomationCompositionState.PASSIVE, + AutomationCompositionOrderedState.UNINITIALISED)); + + assertDoesNotThrow(() -> automationCompositionElementHandler.automationCompositionElementStateChange( + automationCompositionId, automationCompositionElementId, AutomationCompositionState.PASSIVE, + AutomationCompositionOrderedState.RUNNING)); + + automationCompositionElementHandler.close(); + } + + @Test + void test_AutomationCompositionElementUpdate() throws Exception { + doNothing().when(automationCompositionElementHandler).invokeHttpClient(any()); + AutomationCompositionElement element = commonTestData.getAutomationCompositionElement(); + + Map nodeTemplatesMap = serviceTemplate.getToscaTopologyTemplate().getNodeTemplates(); + + assertDoesNotThrow(() -> automationCompositionElementHandler.automationCompositionElementUpdate( + commonTestData.getAutomationCompositionId(), element, + nodeTemplatesMap.get(HTTP_AUTOMATION_COMPOSITION_ELEMENT))); + } +} diff --git a/participant/participant-impl/participant-impl-http/src/test/java/org/onap/policy/clamp/acm/participant/http/rest/ActuatorControllerTest.java b/participant/participant-impl/participant-impl-http/src/test/java/org/onap/policy/clamp/acm/participant/http/rest/ActuatorControllerTest.java new file mode 100644 index 000000000..f0a465fa2 --- /dev/null +++ b/participant/participant-impl/participant-impl-http/src/test/java/org/onap/policy/clamp/acm/participant/http/rest/ActuatorControllerTest.java @@ -0,0 +1,92 @@ +/*- + * ============LICENSE_START======================================================= + * Copyright (C) 2021 Nordix Foundation. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * SPDX-License-Identifier: Apache-2.0 + * ============LICENSE_END========================================================= + */ + +package org.onap.policy.clamp.acm.participant.http.rest; + +import static org.junit.jupiter.api.Assertions.assertEquals; + +import javax.ws.rs.client.Invocation; +import javax.ws.rs.core.Response; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.ExtendWith; +import org.onap.policy.clamp.acm.participant.http.utils.CommonActuatorController; +import org.springframework.boot.test.autoconfigure.actuate.metrics.AutoConfigureMetrics; +import org.springframework.boot.test.context.SpringBootTest; +import org.springframework.boot.test.context.SpringBootTest.WebEnvironment; +import org.springframework.boot.web.server.LocalServerPort; +import org.springframework.test.context.TestPropertySource; +import org.springframework.test.context.junit.jupiter.SpringExtension; + +@AutoConfigureMetrics +@ExtendWith(SpringExtension.class) +@SpringBootTest(webEnvironment = WebEnvironment.RANDOM_PORT) +@TestPropertySource(locations = {"classpath:application_test.properties"}) +class ActuatorControllerTest extends CommonActuatorController { + + private static final String HEALTH_ENDPOINT = "health"; + private static final String METRICS_ENDPOINT = "metrics"; + private static final String PROMETHEUS_ENDPOINT = "prometheus"; + + @LocalServerPort + private int randomServerPort; + + @BeforeEach + public void setUpPort() { + super.setHttpPrefix(randomServerPort); + } + + @Test + void testGetHealth_Unauthorized() throws Exception { + assertUnauthorizedActGet(HEALTH_ENDPOINT); + } + + @Test + void testGetMetrics_Unauthorized() throws Exception { + assertUnauthorizedActGet(METRICS_ENDPOINT); + } + + @Test + void testGetPrometheus_Unauthorized() throws Exception { + assertUnauthorizedActGet(PROMETHEUS_ENDPOINT); + } + + @Test + void testGetHealth() throws Exception { + Invocation.Builder invocationBuilder = super.sendActRequest(HEALTH_ENDPOINT); + Response rawresp = invocationBuilder.buildGet().invoke(); + assertEquals(Response.Status.OK.getStatusCode(), rawresp.getStatus()); + } + + @Test + void testGetMetrics() throws Exception { + Invocation.Builder invocationBuilder = super.sendActRequest(METRICS_ENDPOINT); + Response rawresp = invocationBuilder.buildGet().invoke(); + assertEquals(Response.Status.OK.getStatusCode(), rawresp.getStatus()); + } + + @Test + void testGePrometheus() throws Exception { + Invocation.Builder invocationBuilder = super.sendActRequest(PROMETHEUS_ENDPOINT); + Response rawresp = invocationBuilder.buildGet().invoke(); + assertEquals(Response.Status.OK.getStatusCode(), rawresp.getStatus()); + } + +} diff --git a/participant/participant-impl/participant-impl-http/src/test/java/org/onap/policy/clamp/acm/participant/http/utils/CommonActuatorController.java b/participant/participant-impl/participant-impl-http/src/test/java/org/onap/policy/clamp/acm/participant/http/utils/CommonActuatorController.java new file mode 100644 index 000000000..cfe3ec2c3 --- /dev/null +++ b/participant/participant-impl/participant-impl-http/src/test/java/org/onap/policy/clamp/acm/participant/http/utils/CommonActuatorController.java @@ -0,0 +1,114 @@ +/*- + * ============LICENSE_START======================================================= + * Copyright (C) 2021 Nordix Foundation. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * SPDX-License-Identifier: Apache-2.0 + * ============LICENSE_END========================================================= + */ + +package org.onap.policy.clamp.acm.participant.http.utils; + +import static org.junit.Assert.assertEquals; + +import javax.ws.rs.client.Client; +import javax.ws.rs.client.ClientBuilder; +import javax.ws.rs.client.Invocation; +import javax.ws.rs.client.WebTarget; +import javax.ws.rs.core.MediaType; +import javax.ws.rs.core.Response; +import org.glassfish.jersey.client.ClientProperties; +import org.glassfish.jersey.client.authentication.HttpAuthenticationFeature; +import org.onap.policy.common.gson.GsonMessageBodyHandler; +import org.onap.policy.common.utils.network.NetworkUtil; + +/** + * Class to perform Rest unit tests. + * + */ +public class CommonActuatorController { + + public static final String SELF = NetworkUtil.getHostname(); + public static final String CONTEXT_PATH = "onap/policy/clamp/acm/httpparticipant"; + public static final String ACTUATOR_ENDPOINT = CONTEXT_PATH + "/actuator/"; + + private static String httpPrefix; + + /** + * Sends a request to an actuator endpoint. + * + * @param endpoint the target endpoint + * @return a request builder + * @throws Exception if an error occurs + */ + protected Invocation.Builder sendActRequest(final String endpoint) throws Exception { + return sendFqeRequest(httpPrefix + ACTUATOR_ENDPOINT + endpoint, true); + } + + /** + * Sends a request to an actuator endpoint, without any authorization header. + * + * @param endpoint the target endpoint + * @return a request builder + * @throws Exception if an error occurs + */ + protected Invocation.Builder sendNoAuthActRequest(final String endpoint) throws Exception { + return sendFqeRequest(httpPrefix + ACTUATOR_ENDPOINT + endpoint, false); + } + + /** + * Sends a request to a fully qualified endpoint. + * + * @param fullyQualifiedEndpoint the fully qualified target endpoint + * @param includeAuth if authorization header should be included + * @return a request builder + * @throws Exception if an error occurs + */ + protected Invocation.Builder sendFqeRequest(final String fullyQualifiedEndpoint, boolean includeAuth) + throws Exception { + final Client client = ClientBuilder.newBuilder().build(); + + client.property(ClientProperties.METAINF_SERVICES_LOOKUP_DISABLE, "true"); + client.register(GsonMessageBodyHandler.class); + + if (includeAuth) { + client.register(HttpAuthenticationFeature.basic("participantUser", "zb!XztG34")); + } + + final WebTarget webTarget = client.target(fullyQualifiedEndpoint); + + return webTarget.request(MediaType.APPLICATION_JSON, MediaType.TEXT_PLAIN); + } + + /** + * Assert that GET call to actuator endpoint is Unauthorized. + * + * @param endPoint the endpoint + * @throws Exception if an error occurs + */ + protected void assertUnauthorizedActGet(final String endPoint) throws Exception { + Response rawresp = sendNoAuthActRequest(endPoint).buildGet().invoke(); + assertEquals(Response.Status.UNAUTHORIZED.getStatusCode(), rawresp.getStatus()); + } + + /** + * Set Up httpPrefix. + * + * @param port the port + */ + protected void setHttpPrefix(int port) { + httpPrefix = "http://" + SELF + ":" + port + "/"; + } + +} diff --git a/participant/participant-impl/participant-impl-http/src/test/java/org/onap/policy/clamp/acm/participant/http/utils/CommonTestData.java b/participant/participant-impl/participant-impl-http/src/test/java/org/onap/policy/clamp/acm/participant/http/utils/CommonTestData.java new file mode 100644 index 000000000..010d29a66 --- /dev/null +++ b/participant/participant-impl/participant-impl-http/src/test/java/org/onap/policy/clamp/acm/participant/http/utils/CommonTestData.java @@ -0,0 +1,137 @@ +/*- + * ============LICENSE_START======================================================= + * Copyright (C) 2021 Nordix Foundation. + * Modifications Copyright (C) 2021 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * SPDX-License-Identifier: Apache-2.0 + * ============LICENSE_END========================================================= + */ + +package org.onap.policy.clamp.acm.participant.http.utils; + +import java.util.List; +import java.util.Map; +import java.util.UUID; +import org.onap.policy.clamp.acm.participant.http.main.models.ConfigurationEntity; +import org.onap.policy.clamp.acm.participant.http.main.models.RestParams; +import org.onap.policy.clamp.models.acm.concepts.AutomationCompositionElement; +import org.onap.policy.clamp.models.acm.concepts.AutomationCompositionOrderedState; +import org.onap.policy.models.tosca.authorative.concepts.ToscaConceptIdentifier; + +public class CommonTestData { + + private static final String TEST_KEY_NAME = + "org.onap.domain.database.Http_PMSHMicroserviceAutomationCompositionElement"; + + /** + * Get a automationComposition Element. + * + * @return automationCompositionElement object + */ + public AutomationCompositionElement getAutomationCompositionElement() { + AutomationCompositionElement element = new AutomationCompositionElement(); + element.setId(UUID.randomUUID()); + element.setDefinition(new ToscaConceptIdentifier(TEST_KEY_NAME, "1.0.1")); + element.setOrderedState(AutomationCompositionOrderedState.PASSIVE); + return element; + } + + /** + * Get query params. + * + * @return Map of query params + */ + public Map getQueryParams() { + return Map.of("name", "dummy", "version", "1.0"); + } + + /** + * Get path params. + * + * @return Map of path params + */ + public Map getPathParams() { + return Map.of("id", "123", "name", "dummy"); + } + + /** + * Rest params with GET request. + * + * @return RestParams obj + */ + public RestParams restParamsWithGet() { + return new RestParams(new ToscaConceptIdentifier("getRequest", "1.0"), "GET", "get", 200, null, + getQueryParams(), null); + } + + /** + * Rest params with POST request. + * + * @return RestParams obj + */ + public RestParams restParamsWithPost() { + return new RestParams(new ToscaConceptIdentifier("postRequest", "1.0"), "POST", "post", 200, null, + getQueryParams(), "Test body"); + } + + /** + * Rest params with POST request. + * + * @return RestParams obj + */ + public RestParams restParamsWithInvalidPost() { + return new RestParams(new ToscaConceptIdentifier("postRequest", "1.0"), "POST", "post/{id}/{name}", 200, + getPathParams(), getQueryParams(), "Test body"); + } + + /** + * Get invalid configuration entity. + * + * @return ConfigurationEntity obj + */ + public ConfigurationEntity getInvalidConfigurationEntity() { + return new ConfigurationEntity(new ToscaConceptIdentifier("config1", "1.0.1"), + List.of(restParamsWithGet(), restParamsWithInvalidPost())); + } + + /** + * Get configuration entity. + * + * @return ConfigurationEntity obj + */ + public ConfigurationEntity getConfigurationEntity() { + return new ConfigurationEntity(new ToscaConceptIdentifier("config1", "1.0.1"), + List.of(restParamsWithGet(), restParamsWithPost())); + } + + /** + * Get automation composition id. + * + * @return ToscaConceptIdentifier automationCompositionId + */ + public ToscaConceptIdentifier getAutomationCompositionId() { + return new ToscaConceptIdentifier("PMSHInstance0", "1.0.0"); + } + + /** + * Get headers for config request. + * + * @return Map of headers + */ + public Map getHeaders() { + return Map.of("Content-Type", "application/json", "Accept", "application/json"); + } + +} diff --git a/participant/participant-impl/participant-impl-http/src/test/java/org/onap/policy/clamp/acm/participant/http/utils/ToscaUtils.java b/participant/participant-impl/participant-impl-http/src/test/java/org/onap/policy/clamp/acm/participant/http/utils/ToscaUtils.java new file mode 100644 index 000000000..9e46212bf --- /dev/null +++ b/participant/participant-impl/participant-impl-http/src/test/java/org/onap/policy/clamp/acm/participant/http/utils/ToscaUtils.java @@ -0,0 +1,51 @@ +/*- + * ============LICENSE_START======================================================= + * Copyright (C) 2021 Nordix Foundation. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * SPDX-License-Identifier: Apache-2.0 + * ============LICENSE_END========================================================= + */ + +package org.onap.policy.clamp.acm.participant.http.utils; + +import lombok.AccessLevel; +import lombok.NoArgsConstructor; +import org.onap.policy.common.utils.coder.YamlJsonTranslator; +import org.onap.policy.common.utils.resources.ResourceUtils; +import org.onap.policy.models.tosca.authorative.concepts.ToscaServiceTemplate; + +/** + * Util class for Test scope. + */ +@NoArgsConstructor(access = AccessLevel.PRIVATE) +public final class ToscaUtils { + + private static final YamlJsonTranslator yamlTranslator = new YamlJsonTranslator(); + private static final String TOSCA_TEMPLATE_YAML = "src/test/resources/HttpParticipantConfig.yaml"; + + + /** + * Read a service template yaml. + * @return ToscaServiceTemplate + */ + public static ToscaServiceTemplate readAutomationCompositionFromTosca() { + return serializeAutomationCompositionYaml(TOSCA_TEMPLATE_YAML); + } + + private static ToscaServiceTemplate serializeAutomationCompositionYaml(String automationCompositionFilePath) { + String automationCompositionString = ResourceUtils.getResourceAsString(automationCompositionFilePath); + return yamlTranslator.fromYaml(automationCompositionString, ToscaServiceTemplate.class); + } +} diff --git a/participant/participant-impl/participant-impl-http/src/test/java/org/onap/policy/clamp/acm/participant/http/webclient/AcHttpClientTest.java b/participant/participant-impl/participant-impl-http/src/test/java/org/onap/policy/clamp/acm/participant/http/webclient/AcHttpClientTest.java new file mode 100644 index 000000000..44ef50848 --- /dev/null +++ b/participant/participant-impl/participant-impl-http/src/test/java/org/onap/policy/clamp/acm/participant/http/webclient/AcHttpClientTest.java @@ -0,0 +1,129 @@ +/*- + * ============LICENSE_START======================================================= + * Copyright (C) 2021 Nordix Foundation. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * SPDX-License-Identifier: Apache-2.0 + * ============LICENSE_END========================================================= + */ + +package org.onap.policy.clamp.acm.participant.http.webclient; + +import static org.assertj.core.api.Assertions.assertThat; +import static org.junit.jupiter.api.Assertions.assertDoesNotThrow; +import static org.mockserver.model.HttpRequest.request; +import static org.mockserver.model.HttpResponse.response; + +import java.io.IOException; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import javax.ws.rs.core.MediaType; +import org.apache.commons.lang3.tuple.Pair; +import org.junit.jupiter.api.AfterAll; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.ExtendWith; +import org.mockserver.integration.ClientAndServer; +import org.mockserver.model.Parameter; +import org.onap.policy.clamp.acm.participant.http.main.models.ConfigRequest; +import org.onap.policy.clamp.acm.participant.http.main.models.ConfigurationEntity; +import org.onap.policy.clamp.acm.participant.http.main.webclient.AcHttpClient; +import org.onap.policy.clamp.acm.participant.http.utils.CommonTestData; +import org.onap.policy.common.utils.network.NetworkUtil; +import org.onap.policy.models.tosca.authorative.concepts.ToscaConceptIdentifier; +import org.springframework.test.context.junit.jupiter.SpringExtension; + +@ExtendWith(SpringExtension.class) +class AcHttpClientTest { + + private static CommonTestData commonTestData; + + private static int mockServerPort; + + private String testMockUrl = "http://localhost"; + + private Map> responseMap = new HashMap<>(); + + private static ClientAndServer mockServer; + + /** + * Set up Mock server. + */ + @BeforeAll + static void setUpMockServer() throws IOException { + mockServerPort = NetworkUtil.allocPort(); + mockServer = ClientAndServer.startClientAndServer(mockServerPort); + commonTestData = new CommonTestData(); + List queryParams = new ArrayList<>(); + commonTestData.getQueryParams().forEach((k, v) -> queryParams.add(new Parameter(k, v))); + + mockServer.when(request().withMethod("GET").withPath("/get") + .withHeader("Content-type", MediaType.APPLICATION_JSON) + .withHeader("Accept", MediaType.APPLICATION_JSON).withQueryStringParameters(queryParams)) + .respond(response().withBody("dummy body").withStatusCode(200) + .withHeader("Content-Type", MediaType.APPLICATION_JSON)); + + mockServer.when(request().withMethod("POST").withPath("/post") + .withHeader("Content-type", MediaType.APPLICATION_JSON) + .withHeader("Accept", MediaType.APPLICATION_JSON).withQueryStringParameters(queryParams) + .withBody("Test body")) + .respond(response().withStatusCode(200)); + } + + @AfterAll + public static void stopServer() { + mockServer.stop(); + mockServer = null; + } + + + @Test + void test_validRequest() { + //Add valid rest requests POST, GET + ConfigurationEntity configurationEntity = commonTestData.getConfigurationEntity(); + + Map headers = commonTestData.getHeaders(); + ConfigRequest configRequest = new ConfigRequest(testMockUrl + ":" + mockServerPort, headers, + List.of(configurationEntity), 10); + + AcHttpClient client = new AcHttpClient(configRequest, responseMap); + assertDoesNotThrow(client::run); + assertThat(responseMap).hasSize(2).containsKey(commonTestData + .restParamsWithGet().getRestRequestId()); + + Pair restResponseMap = responseMap.get(commonTestData + .restParamsWithGet().getRestRequestId()); + assertThat(restResponseMap.getKey()).isEqualTo(200); + } + + @Test + void test_invalidRequest() { + //Add rest requests Invalid POST, Valid GET + ConfigurationEntity configurationEntity = commonTestData.getInvalidConfigurationEntity(); + + Map headers = commonTestData.getHeaders(); + ConfigRequest configRequest = new ConfigRequest(testMockUrl + ":" + mockServerPort, headers, + List.of(configurationEntity), 10); + + AcHttpClient client = new AcHttpClient(configRequest, responseMap); + assertDoesNotThrow(client::run); + assertThat(responseMap).hasSize(2).containsKey(commonTestData + .restParamsWithGet().getRestRequestId()); + Pair response = responseMap + .get(commonTestData.restParamsWithInvalidPost().getRestRequestId()); + assertThat(response.getKey()).isEqualTo(404); + } +} diff --git a/participant/participant-impl/participant-impl-http/src/test/java/org/onap/policy/clamp/controlloop/participant/http/handler/ClElementHandlerTest.java b/participant/participant-impl/participant-impl-http/src/test/java/org/onap/policy/clamp/controlloop/participant/http/handler/ClElementHandlerTest.java deleted file mode 100644 index 08f008ef3..000000000 --- a/participant/participant-impl/participant-impl-http/src/test/java/org/onap/policy/clamp/controlloop/participant/http/handler/ClElementHandlerTest.java +++ /dev/null @@ -1,108 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * Copyright (C) 2021-2022 Nordix Foundation. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - * SPDX-License-Identifier: Apache-2.0 - * ============LICENSE_END========================================================= - */ - -package org.onap.policy.clamp.controlloop.participant.http.handler; - -import static org.junit.jupiter.api.Assertions.assertDoesNotThrow; -import static org.mockito.ArgumentMatchers.any; -import static org.mockito.Mockito.doNothing; - -import java.io.IOException; -import java.util.Map; -import java.util.concurrent.ExecutionException; -import org.junit.jupiter.api.BeforeAll; -import org.junit.jupiter.api.Test; -import org.junit.jupiter.api.extension.ExtendWith; -import org.mockito.InjectMocks; -import org.mockito.Mock; -import org.mockito.Mockito; -import org.mockito.Spy; -import org.onap.policy.clamp.controlloop.models.controlloop.concepts.ControlLoopElement; -import org.onap.policy.clamp.controlloop.models.controlloop.concepts.ControlLoopOrderedState; -import org.onap.policy.clamp.controlloop.models.controlloop.concepts.ControlLoopState; -import org.onap.policy.clamp.controlloop.participant.http.main.handler.ControlLoopElementHandler; -import org.onap.policy.clamp.controlloop.participant.http.main.models.ConfigRequest; -import org.onap.policy.clamp.controlloop.participant.http.utils.CommonTestData; -import org.onap.policy.clamp.controlloop.participant.http.utils.ToscaUtils; -import org.onap.policy.clamp.controlloop.participant.intermediary.api.ParticipantIntermediaryApi; -import org.onap.policy.common.utils.coder.CoderException; -import org.onap.policy.models.tosca.authorative.concepts.ToscaNodeTemplate; -import org.onap.policy.models.tosca.authorative.concepts.ToscaServiceTemplate; -import org.springframework.test.context.junit.jupiter.SpringExtension; - - -@ExtendWith(SpringExtension.class) -class ClElementHandlerTest { - - @InjectMocks - @Spy - private ControlLoopElementHandler controlLoopElementHandler = new ControlLoopElementHandler(); - - @Mock - private ParticipantIntermediaryApi participantIntermediaryApi; - - private CommonTestData commonTestData = new CommonTestData(); - - private static ToscaServiceTemplate serviceTemplate; - private static final String HTTP_CONTROL_LOOP_ELEMENT = - "org.onap.domain.database.Http_PMSHMicroserviceControlLoopElement"; - - @BeforeAll - static void init() throws CoderException { - serviceTemplate = ToscaUtils.readControlLoopFromTosca(); - } - - @Test - void test_controlLoopElementeStateChange() throws IOException { - var controlLoopId = commonTestData.getControlLoopId(); - var element = commonTestData.getControlLoopElement(); - var controlLoopElementId = element.getId(); - - var config = Mockito.mock(ConfigRequest.class); - assertDoesNotThrow(() -> controlLoopElementHandler.invokeHttpClient(config)); - - assertDoesNotThrow(() -> controlLoopElementHandler - .controlLoopElementStateChange(controlLoopId, - controlLoopElementId, ControlLoopState.PASSIVE, ControlLoopOrderedState.PASSIVE)); - - assertDoesNotThrow(() -> controlLoopElementHandler - .controlLoopElementStateChange(controlLoopId, - controlLoopElementId, ControlLoopState.PASSIVE, ControlLoopOrderedState.UNINITIALISED)); - - assertDoesNotThrow(() -> controlLoopElementHandler - .controlLoopElementStateChange(controlLoopId, - controlLoopElementId, ControlLoopState.PASSIVE, ControlLoopOrderedState.RUNNING)); - - controlLoopElementHandler.close(); - } - - @Test - void test_ControlLoopElementUpdate() throws ExecutionException, InterruptedException { - doNothing().when(controlLoopElementHandler).invokeHttpClient(any()); - ControlLoopElement element = commonTestData.getControlLoopElement(); - - Map nodeTemplatesMap = - serviceTemplate.getToscaTopologyTemplate().getNodeTemplates(); - - assertDoesNotThrow(() -> controlLoopElementHandler - .controlLoopElementUpdate(commonTestData.getControlLoopId(), element, - nodeTemplatesMap.get(HTTP_CONTROL_LOOP_ELEMENT))); - } -} diff --git a/participant/participant-impl/participant-impl-http/src/test/java/org/onap/policy/clamp/controlloop/participant/http/rest/ActuatorControllerTest.java b/participant/participant-impl/participant-impl-http/src/test/java/org/onap/policy/clamp/controlloop/participant/http/rest/ActuatorControllerTest.java deleted file mode 100644 index 8efff8f6a..000000000 --- a/participant/participant-impl/participant-impl-http/src/test/java/org/onap/policy/clamp/controlloop/participant/http/rest/ActuatorControllerTest.java +++ /dev/null @@ -1,92 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * Copyright (C) 2021 Nordix Foundation. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - * SPDX-License-Identifier: Apache-2.0 - * ============LICENSE_END========================================================= - */ - -package org.onap.policy.clamp.controlloop.participant.http.rest; - -import static org.junit.jupiter.api.Assertions.assertEquals; - -import javax.ws.rs.client.Invocation; -import javax.ws.rs.core.Response; -import org.junit.jupiter.api.BeforeEach; -import org.junit.jupiter.api.Test; -import org.junit.jupiter.api.extension.ExtendWith; -import org.onap.policy.clamp.controlloop.participant.http.utils.CommonActuatorController; -import org.springframework.boot.test.autoconfigure.actuate.metrics.AutoConfigureMetrics; -import org.springframework.boot.test.context.SpringBootTest; -import org.springframework.boot.test.context.SpringBootTest.WebEnvironment; -import org.springframework.boot.web.server.LocalServerPort; -import org.springframework.test.context.TestPropertySource; -import org.springframework.test.context.junit.jupiter.SpringExtension; - -@AutoConfigureMetrics -@ExtendWith(SpringExtension.class) -@SpringBootTest(webEnvironment = WebEnvironment.RANDOM_PORT) -@TestPropertySource(locations = {"classpath:application_test.properties"}) -class ActuatorControllerTest extends CommonActuatorController { - - private static final String HEALTH_ENDPOINT = "health"; - private static final String METRICS_ENDPOINT = "metrics"; - private static final String PROMETHEUS_ENDPOINT = "prometheus"; - - @LocalServerPort - private int randomServerPort; - - @BeforeEach - public void setUpPort() { - super.setHttpPrefix(randomServerPort); - } - - @Test - void testGetHealth_Unauthorized() throws Exception { - assertUnauthorizedActGet(HEALTH_ENDPOINT); - } - - @Test - void testGetMetrics_Unauthorized() throws Exception { - assertUnauthorizedActGet(METRICS_ENDPOINT); - } - - @Test - void testGetPrometheus_Unauthorized() throws Exception { - assertUnauthorizedActGet(PROMETHEUS_ENDPOINT); - } - - @Test - void testGetHealth() throws Exception { - Invocation.Builder invocationBuilder = super.sendActRequest(HEALTH_ENDPOINT); - Response rawresp = invocationBuilder.buildGet().invoke(); - assertEquals(Response.Status.OK.getStatusCode(), rawresp.getStatus()); - } - - @Test - void testGetMetrics() throws Exception { - Invocation.Builder invocationBuilder = super.sendActRequest(METRICS_ENDPOINT); - Response rawresp = invocationBuilder.buildGet().invoke(); - assertEquals(Response.Status.OK.getStatusCode(), rawresp.getStatus()); - } - - @Test - void testGePrometheus() throws Exception { - Invocation.Builder invocationBuilder = super.sendActRequest(PROMETHEUS_ENDPOINT); - Response rawresp = invocationBuilder.buildGet().invoke(); - assertEquals(Response.Status.OK.getStatusCode(), rawresp.getStatus()); - } - -} diff --git a/participant/participant-impl/participant-impl-http/src/test/java/org/onap/policy/clamp/controlloop/participant/http/utils/CommonActuatorController.java b/participant/participant-impl/participant-impl-http/src/test/java/org/onap/policy/clamp/controlloop/participant/http/utils/CommonActuatorController.java deleted file mode 100644 index 5ebce8126..000000000 --- a/participant/participant-impl/participant-impl-http/src/test/java/org/onap/policy/clamp/controlloop/participant/http/utils/CommonActuatorController.java +++ /dev/null @@ -1,114 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * Copyright (C) 2021 Nordix Foundation. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - * SPDX-License-Identifier: Apache-2.0 - * ============LICENSE_END========================================================= - */ - -package org.onap.policy.clamp.controlloop.participant.http.utils; - -import static org.junit.Assert.assertEquals; - -import javax.ws.rs.client.Client; -import javax.ws.rs.client.ClientBuilder; -import javax.ws.rs.client.Invocation; -import javax.ws.rs.client.WebTarget; -import javax.ws.rs.core.MediaType; -import javax.ws.rs.core.Response; -import org.glassfish.jersey.client.ClientProperties; -import org.glassfish.jersey.client.authentication.HttpAuthenticationFeature; -import org.onap.policy.common.gson.GsonMessageBodyHandler; -import org.onap.policy.common.utils.network.NetworkUtil; - -/** - * Class to perform Rest unit tests. - * - */ -public class CommonActuatorController { - - public static final String SELF = NetworkUtil.getHostname(); - public static final String CONTEXT_PATH = "onap/httpparticipant"; - public static final String ACTUATOR_ENDPOINT = CONTEXT_PATH + "/actuator/"; - - private static String httpPrefix; - - /** - * Sends a request to an actuator endpoint. - * - * @param endpoint the target endpoint - * @return a request builder - * @throws Exception if an error occurs - */ - protected Invocation.Builder sendActRequest(final String endpoint) throws Exception { - return sendFqeRequest(httpPrefix + ACTUATOR_ENDPOINT + endpoint, true); - } - - /** - * Sends a request to an actuator endpoint, without any authorization header. - * - * @param endpoint the target endpoint - * @return a request builder - * @throws Exception if an error occurs - */ - protected Invocation.Builder sendNoAuthActRequest(final String endpoint) throws Exception { - return sendFqeRequest(httpPrefix + ACTUATOR_ENDPOINT + endpoint, false); - } - - /** - * Sends a request to a fully qualified endpoint. - * - * @param fullyQualifiedEndpoint the fully qualified target endpoint - * @param includeAuth if authorization header should be included - * @return a request builder - * @throws Exception if an error occurs - */ - protected Invocation.Builder sendFqeRequest(final String fullyQualifiedEndpoint, boolean includeAuth) - throws Exception { - final Client client = ClientBuilder.newBuilder().build(); - - client.property(ClientProperties.METAINF_SERVICES_LOOKUP_DISABLE, "true"); - client.register(GsonMessageBodyHandler.class); - - if (includeAuth) { - client.register(HttpAuthenticationFeature.basic("participantUser", "zb!XztG34")); - } - - final WebTarget webTarget = client.target(fullyQualifiedEndpoint); - - return webTarget.request(MediaType.APPLICATION_JSON, MediaType.TEXT_PLAIN); - } - - /** - * Assert that GET call to actuator endpoint is Unauthorized. - * - * @param endPoint the endpoint - * @throws Exception if an error occurs - */ - protected void assertUnauthorizedActGet(final String endPoint) throws Exception { - Response rawresp = sendNoAuthActRequest(endPoint).buildGet().invoke(); - assertEquals(Response.Status.UNAUTHORIZED.getStatusCode(), rawresp.getStatus()); - } - - /** - * Set Up httpPrefix. - * - * @param port the port - */ - protected void setHttpPrefix(int port) { - httpPrefix = "http://" + SELF + ":" + port + "/"; - } - -} diff --git a/participant/participant-impl/participant-impl-http/src/test/java/org/onap/policy/clamp/controlloop/participant/http/utils/CommonTestData.java b/participant/participant-impl/participant-impl-http/src/test/java/org/onap/policy/clamp/controlloop/participant/http/utils/CommonTestData.java deleted file mode 100644 index 1f92a86e0..000000000 --- a/participant/participant-impl/participant-impl-http/src/test/java/org/onap/policy/clamp/controlloop/participant/http/utils/CommonTestData.java +++ /dev/null @@ -1,152 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * Copyright (C) 2021 Nordix Foundation. - * Modifications Copyright (C) 2021 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - * SPDX-License-Identifier: Apache-2.0 - * ============LICENSE_END========================================================= - */ - -package org.onap.policy.clamp.controlloop.participant.http.utils; - -import java.util.List; -import java.util.Map; -import java.util.UUID; -import org.onap.policy.clamp.controlloop.models.controlloop.concepts.ControlLoopElement; -import org.onap.policy.clamp.controlloop.models.controlloop.concepts.ControlLoopOrderedState; -import org.onap.policy.clamp.controlloop.participant.http.main.models.ConfigurationEntity; -import org.onap.policy.clamp.controlloop.participant.http.main.models.RestParams; -import org.onap.policy.models.tosca.authorative.concepts.ToscaConceptIdentifier; - -public class CommonTestData { - - private static final String TEST_KEY_NAME = "org.onap.domain.database.Http_PMSHMicroserviceControlLoopElement"; - - - /** - * Get a controlLoop Element. - * @return controlLoopElement object - */ - public ControlLoopElement getControlLoopElement() { - ControlLoopElement element = new ControlLoopElement(); - element.setId(UUID.randomUUID()); - element.setDefinition(new ToscaConceptIdentifier(TEST_KEY_NAME, "1.0.1")); - element.setOrderedState(ControlLoopOrderedState.PASSIVE); - return element; - } - - /** - * Get query params. - * @return Map of query params - */ - public Map getQueryParams() { - return Map.of("name", "dummy", "version", "1.0"); - } - - /** - * Get path params. - * @return Map of path params - */ - public Map getPathParams() { - return Map.of("id", "123", "name", "dummy"); - } - - /** - * Rest params with GET request. - * @return RestParams obj - */ - public RestParams restParamsWithGet() { - return new RestParams( - new ToscaConceptIdentifier("getRequest", "1.0"), - "GET", - "get", - 200, - null, - getQueryParams(), - null - ); - } - - /** - * Rest params with POST request. - * @return RestParams obj - */ - public RestParams restParamsWithPost() { - return new RestParams( - new ToscaConceptIdentifier("postRequest", "1.0"), - "POST", - "post", - 200, - null, - getQueryParams(), - "Test body" - ); - } - - /** - * Rest params with POST request. - * @return RestParams obj - */ - public RestParams restParamsWithInvalidPost() { - return new RestParams( - new ToscaConceptIdentifier("postRequest", "1.0"), - "POST", - "post/{id}/{name}", - 200, - getPathParams(), - getQueryParams(), - "Test body" - ); - } - - /** - * Get invalid configuration entity. - * @return ConfigurationEntity obj - */ - public ConfigurationEntity getInvalidConfigurationEntity() { - return new ConfigurationEntity( - new ToscaConceptIdentifier("config1", "1.0.1"), - List.of(restParamsWithGet(), restParamsWithInvalidPost()) - ); - } - - /** - * Get configuration entity. - * @return ConfigurationEntity obj - */ - public ConfigurationEntity getConfigurationEntity() { - return new ConfigurationEntity( - new ToscaConceptIdentifier("config1", "1.0.1"), - List.of(restParamsWithGet(), restParamsWithPost()) - ); - } - - /** - * Get controlloop id. - * @return ToscaConceptIdentifier controlLoopId - */ - public ToscaConceptIdentifier getControlLoopId() { - return new ToscaConceptIdentifier("PMSHInstance0", "1.0.0"); - } - - /** - * Get headers for config request. - * @return Map of headers - */ - public Map getHeaders() { - return Map.of("Content-Type", "application/json", "Accept", "application/json"); - } - -} diff --git a/participant/participant-impl/participant-impl-http/src/test/java/org/onap/policy/clamp/controlloop/participant/http/utils/ToscaUtils.java b/participant/participant-impl/participant-impl-http/src/test/java/org/onap/policy/clamp/controlloop/participant/http/utils/ToscaUtils.java deleted file mode 100644 index fdba28c0e..000000000 --- a/participant/participant-impl/participant-impl-http/src/test/java/org/onap/policy/clamp/controlloop/participant/http/utils/ToscaUtils.java +++ /dev/null @@ -1,51 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * Copyright (C) 2021 Nordix Foundation. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - * SPDX-License-Identifier: Apache-2.0 - * ============LICENSE_END========================================================= - */ - -package org.onap.policy.clamp.controlloop.participant.http.utils; - -import lombok.AccessLevel; -import lombok.NoArgsConstructor; -import org.onap.policy.common.utils.coder.YamlJsonTranslator; -import org.onap.policy.common.utils.resources.ResourceUtils; -import org.onap.policy.models.tosca.authorative.concepts.ToscaServiceTemplate; - -/** - * Util class for Test scope. - */ -@NoArgsConstructor(access = AccessLevel.PRIVATE) -public final class ToscaUtils { - - private static final YamlJsonTranslator yamlTranslator = new YamlJsonTranslator(); - private static final String TOSCA_TEMPLATE_YAML = "src/test/resources/HttpParticipantConfig.yaml"; - - - /** - * Read a service template yaml. - * @return ToscaServiceTemplate - */ - public static ToscaServiceTemplate readControlLoopFromTosca() { - return serializeControlLoopYaml(TOSCA_TEMPLATE_YAML); - } - - private static ToscaServiceTemplate serializeControlLoopYaml(String controlLoopFilePath) { - String controlLoopString = ResourceUtils.getResourceAsString(controlLoopFilePath); - return yamlTranslator.fromYaml(controlLoopString, ToscaServiceTemplate.class); - } -} diff --git a/participant/participant-impl/participant-impl-http/src/test/java/org/onap/policy/clamp/controlloop/participant/http/webclient/ClHttpClientTest.java b/participant/participant-impl/participant-impl-http/src/test/java/org/onap/policy/clamp/controlloop/participant/http/webclient/ClHttpClientTest.java deleted file mode 100644 index e3ff9dbba..000000000 --- a/participant/participant-impl/participant-impl-http/src/test/java/org/onap/policy/clamp/controlloop/participant/http/webclient/ClHttpClientTest.java +++ /dev/null @@ -1,129 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * Copyright (C) 2021 Nordix Foundation. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - * SPDX-License-Identifier: Apache-2.0 - * ============LICENSE_END========================================================= - */ - -package org.onap.policy.clamp.controlloop.participant.http.webclient; - -import static org.assertj.core.api.Assertions.assertThat; -import static org.junit.jupiter.api.Assertions.assertDoesNotThrow; -import static org.mockserver.model.HttpRequest.request; -import static org.mockserver.model.HttpResponse.response; - -import java.io.IOException; -import java.util.ArrayList; -import java.util.HashMap; -import java.util.List; -import java.util.Map; -import javax.ws.rs.core.MediaType; -import org.apache.commons.lang3.tuple.Pair; -import org.junit.jupiter.api.AfterAll; -import org.junit.jupiter.api.BeforeAll; -import org.junit.jupiter.api.Test; -import org.junit.jupiter.api.extension.ExtendWith; -import org.mockserver.integration.ClientAndServer; -import org.mockserver.model.Parameter; -import org.onap.policy.clamp.controlloop.participant.http.main.models.ConfigRequest; -import org.onap.policy.clamp.controlloop.participant.http.main.models.ConfigurationEntity; -import org.onap.policy.clamp.controlloop.participant.http.main.webclient.ClHttpClient; -import org.onap.policy.clamp.controlloop.participant.http.utils.CommonTestData; -import org.onap.policy.common.utils.network.NetworkUtil; -import org.onap.policy.models.tosca.authorative.concepts.ToscaConceptIdentifier; -import org.springframework.test.context.junit.jupiter.SpringExtension; - -@ExtendWith(SpringExtension.class) -class ClHttpClientTest { - - private static CommonTestData commonTestData; - - private static int mockServerPort; - - private String testMockUrl = "http://localhost"; - - private Map> responseMap = new HashMap<>(); - - private static ClientAndServer mockServer; - - /** - * Set up Mock server. - */ - @BeforeAll - static void setUpMockServer() throws IOException { - mockServerPort = NetworkUtil.allocPort(); - mockServer = ClientAndServer.startClientAndServer(mockServerPort); - commonTestData = new CommonTestData(); - List queryParams = new ArrayList<>(); - commonTestData.getQueryParams().forEach((k, v) -> queryParams.add(new Parameter(k, v))); - - mockServer.when(request().withMethod("GET").withPath("/get") - .withHeader("Content-type", MediaType.APPLICATION_JSON) - .withHeader("Accept", MediaType.APPLICATION_JSON).withQueryStringParameters(queryParams)) - .respond(response().withBody("dummy body").withStatusCode(200) - .withHeader("Content-Type", MediaType.APPLICATION_JSON)); - - mockServer.when(request().withMethod("POST").withPath("/post") - .withHeader("Content-type", MediaType.APPLICATION_JSON) - .withHeader("Accept", MediaType.APPLICATION_JSON).withQueryStringParameters(queryParams) - .withBody("Test body")) - .respond(response().withStatusCode(200)); - } - - @AfterAll - public static void stopServer() { - mockServer.stop(); - mockServer = null; - } - - - @Test - void test_validRequest() { - //Add valid rest requests POST, GET - ConfigurationEntity configurationEntity = commonTestData.getConfigurationEntity(); - - Map headers = commonTestData.getHeaders(); - ConfigRequest configRequest = new ConfigRequest(testMockUrl + ":" + mockServerPort, headers, - List.of(configurationEntity), 10); - - ClHttpClient client = new ClHttpClient(configRequest, responseMap); - assertDoesNotThrow(client::run); - assertThat(responseMap).hasSize(2).containsKey(commonTestData - .restParamsWithGet().getRestRequestId()); - - Pair restResponseMap = responseMap.get(commonTestData - .restParamsWithGet().getRestRequestId()); - assertThat(restResponseMap.getKey()).isEqualTo(200); - } - - @Test - void test_invalidRequest() { - //Add rest requests Invalid POST, Valid GET - ConfigurationEntity configurationEntity = commonTestData.getInvalidConfigurationEntity(); - - Map headers = commonTestData.getHeaders(); - ConfigRequest configRequest = new ConfigRequest(testMockUrl + ":" + mockServerPort, headers, - List.of(configurationEntity), 10); - - ClHttpClient client = new ClHttpClient(configRequest, responseMap); - assertDoesNotThrow(client::run); - assertThat(responseMap).hasSize(2).containsKey(commonTestData - .restParamsWithGet().getRestRequestId()); - Pair response = responseMap - .get(commonTestData.restParamsWithInvalidPost().getRestRequestId()); - assertThat(response.getKey()).isEqualTo(404); - } -} diff --git a/participant/participant-impl/participant-impl-http/src/test/resources/HttpParticipantConfig.yaml b/participant/participant-impl/participant-impl-http/src/test/resources/HttpParticipantConfig.yaml index f221bcbd7..57c6e40d1 100644 --- a/participant/participant-impl/participant-impl-http/src/test/resources/HttpParticipantConfig.yaml +++ b/participant/participant-impl/participant-impl-http/src/test/resources/HttpParticipantConfig.yaml @@ -27,7 +27,7 @@ data_types: type: string required: true - org.onap.datatypes.policy.clamp.controlloop.httpControlLoopElement.RestRequest: + org.onap.datatypes.policy.clamp.acm.httpAutomationCompositionElement.RestRequest: version: 1.0.0 derived_from: tosca.datatypes.Root properties: @@ -56,7 +56,7 @@ data_types: constraints: - in_range: [100, 599] description: THe expected HTTP status code for the REST request - org.onap.datatypes.policy.clamp.controlloop.httpControlLoopElement.ConfigurationEntity: + org.onap.datatypes.policy.clamp.acm.httpAutomationCompositionElement.ConfigurationEntity: version: 1.0.0 derived_from: tosca.datatypes.Root properties: @@ -64,24 +64,24 @@ data_types: type: onap.datatypes.ToscaConceptIdentifier typeVersion: 1.0.0 required: true - description: The name and version of a Configuration Entity to be handled by the HTTP Control Loop Element + description: The name and version of a Configuration Entity to be handled by the HTTP Automation Composition Element restSequence: type: list entry_schema: - type: org.onap.datatypes.policy.clamp.controlloop.httpControlLoopElement.RestRequest + type: org.onap.datatypes.policy.clamp.acm.httpAutomationCompositionElement.RestRequest typeVersion: 1.0.0 description: A sequence of REST commands to send to the REST endpoint node_types: - org.onap.policy.clamp.controlloop.Participant: + org.onap.policy.clamp.acm.Participant: version: 1.0.1 derived_from: tosca.nodetypes.Root properties: provider: type: string requred: false - org.onap.policy.clamp.controlloop.ControlLoopElement: + org.onap.policy.clamp.acm.AutomationCompositionElement: version: 1.0.1 derived_from: tosca.nodetypes.Root properties: @@ -98,11 +98,11 @@ node_types: - greater-or-equal: 0 metadata: common: true - description: A value indicating the start phase in which this control loop element will be started, the - first start phase is zero. Control Loop Elements are started in their start_phase order and stopped - in reverse start phase order. Control Loop Elements with the same start phase are started and + description: A value indicating the start phase in which this automation composition element will be started, the + first start phase is zero. Automation Composition Elements are started in their start_phase order and stopped + in reverse start phase order. Automation Composition Elements with the same start phase are started and stopped simultaneously - org.onap.policy.clamp.controlloop.ControlLoop: + org.onap.policy.clamp.acm.AutomationComposition: version: 1.0.1 derived_from: tosca.nodetypes.Root properties: @@ -114,9 +114,9 @@ node_types: required: true entry_schema: type: onap.datatypes.ToscaConceptIdentifier - org.onap.policy.clamp.controlloop.HttpControlLoopElement: + org.onap.policy.clamp.acm.HttpAutomationCompositionElement: version: 1.0.1 - derived_from: org.onap.policy.clamp.controlloop.ControlLoopElement + derived_from: org.onap.policy.clamp.acm.AutomationCompositionElement properties: baseUrl: type: string @@ -132,29 +132,29 @@ node_types: type: map required: true entry_schema: - type: org.onap.datatypes.policy.clamp.controlloop.httpControlLoopElement.ConfigurationEntity + type: org.onap.datatypes.policy.clamp.acm.httpAutomationCompositionElement.ConfigurationEntity typeVersion: 1.0.0 - description: The connfiguration entities the Control Loop Element is managing and their associated REST requests + description: The connfiguration entities the Automation Composition Element is managing and their associated REST requests topology_template: node_templates: - org.onap.k8s.controlloop.HttpControlLoopParticipant: + org.onap.k8s.acm.HttpAutomationCompositionParticipant: version: 2.3.4 - type: org.onap.policy.clamp.controlloop.Participant + type: org.onap.policy.clamp.acm.Participant type_version: 1.0.1 description: Participant for Http requests properties: provider: ONAP - org.onap.domain.database.Http_PMSHMicroserviceControlLoopElement: + org.onap.domain.database.Http_PMSHMicroserviceAutomationCompositionElement: # Http config for PMSH. version: 1.2.3 - type: org.onap.policy.clamp.controlloop.HttpControlLoopElement + type: org.onap.policy.clamp.acm.HttpAutomationCompositionElement type_version: 1.0.1 - description: Control loop element for the http requests of PMSH microservice + description: Automation composition element for the http requests of PMSH microservice properties: provider: ONAP participantType: - name: org.onap.controlloop.HttpControlLoopParticipant + name: org.onap.acm.HttpAutomationCompositionParticipant version: 2.3.4 startPhase: 1 uninitializedToPassiveTimeout: 180 @@ -208,13 +208,13 @@ topology_template: expectedResponse: 200 - org.onap.domain.sample.GenericK8s_ControlLoopDefinition: + org.onap.domain.sample.GenericK8s_AutomationCompositionDefinition: version: 1.2.3 - type: org.onap.policy.clamp.controlloop.ControlLoop + type: org.onap.policy.clamp.acm.AutomationComposition type_version: 1.0.0 - description: Control loop for HTTP request + description: Automation composition for HTTP request properties: provider: ONAP elements: - - name: org.onap.domain.database.Http_PMSHMicroserviceControlLoopElement + - name: org.onap.domain.database.Http_PMSHMicroserviceAutomationCompositionElement version: 1.2.3 diff --git a/participant/participant-impl/participant-impl-http/src/test/resources/application_test.properties b/participant/participant-impl/participant-impl-http/src/test/resources/application_test.properties index 698a965b8..e9f3b37cb 100644 --- a/participant/participant-impl/participant-impl-http/src/test/resources/application_test.properties +++ b/participant/participant-impl/participant-impl-http/src/test/resources/application_test.properties @@ -1,24 +1,24 @@ spring.security.user.name=participantUser spring.security.user.password=zb!XztG34 -server.servlet.context-path=/onap/httpparticipant +server.servlet.context-path=/onap/policy/clamp/acm/httpparticipant server.error.path=/error server.http-port=8084 -participant.name=ControlLoopParticipant Http Test +participant.name=AutomationCompositionParticipant Http Test participant.intermediaryParameters.name=Participant parameters participant.intermediaryParameters.reportingTimeInterval=120000 participant.intermediaryParameters.description=Participant Description participant.intermediaryParameters.participantId.name=HttpParticipant0 participant.intermediaryParameters.participantId.version=1.0.0 -participant.intermediaryParameters.participantType.name=org.onap.k8s.controlloop.HttpControlLoopParticipant +participant.intermediaryParameters.participantType.name=org.onap.clamp.acm.HttpParticipant participant.intermediaryParameters.participantType.version=2.3.4 -participant.intermediaryParameters.clampControlLoopTopics.name=ControlLoop Topics -participant.intermediaryParameters.clampControlLoopTopics.topicSources[0].topic=POLICY-CLRUNTIME-PARTICIPANT -participant.intermediaryParameters.clampControlLoopTopics.topicSources[0].servers[0]=localhost -participant.intermediaryParameters.clampControlLoopTopics.topicSources[0].topicCommInfrastructure=dmaap -participant.intermediaryParameters.clampControlLoopTopics.topicSources[0].fetchTimeout=15000 -participant.intermediaryParameters.clampControlLoopTopics.topicSinks[0].topic=POLICY-CLRUNTIME-PARTICIPANT -participant.intermediaryParameters.clampControlLoopTopics.topicSinks[0].servers[0]=localhost -participant.intermediaryParameters.clampControlLoopTopics.topicSinks[0].topicCommInfrastructure=dmaap +participant.intermediaryParameters.clampAutomationCompositionTopics.name=AutomationComposition Topics +participant.intermediaryParameters.clampAutomationCompositionTopics.topicSources[0].topic=POLICY-ACRUNTIME-PARTICIPANT +participant.intermediaryParameters.clampAutomationCompositionTopics.topicSources[0].servers[0]=localhost +participant.intermediaryParameters.clampAutomationCompositionTopics.topicSources[0].topicCommInfrastructure=dmaap +participant.intermediaryParameters.clampAutomationCompositionTopics.topicSources[0].fetchTimeout=15000 +participant.intermediaryParameters.clampAutomationCompositionTopics.topicSinks[0].topic=POLICY-ACRUNTIME-PARTICIPANT +participant.intermediaryParameters.clampAutomationCompositionTopics.topicSinks[0].servers[0]=localhost +participant.intermediaryParameters.clampAutomationCompositionTopics.topicSinks[0].topicCommInfrastructure=dmaap management.endpoints.web.exposure.include=health,metrics,prometheus diff --git a/participant/participant-impl/participant-impl-kubernetes/pom.xml b/participant/participant-impl/participant-impl-kubernetes/pom.xml index 6bbf01757..e92021b92 100644 --- a/participant/participant-impl/participant-impl-kubernetes/pom.xml +++ b/participant/participant-impl/participant-impl-kubernetes/pom.xml @@ -30,7 +30,7 @@ policy-clamp-participant-impl-kubernetes ${project.artifactId} - Kubernetes participant, that allows k8s pods to partake in control loops + Kubernetes participant, that allows k8s pods to partake in automation compositions diff --git a/participant/participant-impl/participant-impl-kubernetes/src/main/java/org/onap/policy/clamp/acm/participant/kubernetes/Application.java b/participant/participant-impl/participant-impl-kubernetes/src/main/java/org/onap/policy/clamp/acm/participant/kubernetes/Application.java new file mode 100644 index 000000000..6908b2760 --- /dev/null +++ b/participant/participant-impl/participant-impl-kubernetes/src/main/java/org/onap/policy/clamp/acm/participant/kubernetes/Application.java @@ -0,0 +1,49 @@ +/*- + * ============LICENSE_START======================================================= + * Copyright (C) 2021 Nordix Foundation. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * SPDX-License-Identifier: Apache-2.0 + * ============LICENSE_END========================================================= + */ + +package org.onap.policy.clamp.acm.participant.kubernetes; + +import org.springframework.boot.SpringApplication; +import org.springframework.boot.autoconfigure.SpringBootApplication; +import org.springframework.boot.context.properties.ConfigurationPropertiesScan; +import org.springframework.context.annotation.ComponentScan; + +/** + * Starter. + * + */ +// @formatter:off +@SpringBootApplication +@ComponentScan({ + "org.onap.policy.clamp.acm.participant.kubernetes", + "org.onap.policy.clamp.acm.participant.intermediary" +}) +@ConfigurationPropertiesScan("org.onap.policy.clamp.acm.participant.kubernetes.parameters") +//@formatter:on +public class Application { + /** + * Main class. + * + * @param args args + */ + public static void main(String[] args) { + SpringApplication.run(Application.class, args); + } +} diff --git a/participant/participant-impl/participant-impl-kubernetes/src/main/java/org/onap/policy/clamp/acm/participant/kubernetes/configurations/ParticipantConfig.java b/participant/participant-impl/participant-impl-kubernetes/src/main/java/org/onap/policy/clamp/acm/participant/kubernetes/configurations/ParticipantConfig.java new file mode 100644 index 000000000..428819be9 --- /dev/null +++ b/participant/participant-impl/participant-impl-kubernetes/src/main/java/org/onap/policy/clamp/acm/participant/kubernetes/configurations/ParticipantConfig.java @@ -0,0 +1,44 @@ +/*- + * ========================LICENSE_START================================= + * Copyright (C) 2021 Nordix Foundation. All rights reserved. + * ====================================================================== + * Modifications Copyright (C) 2021 AT&T Intellectual Property. All rights reserved. + * ====================================================================== + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ========================LICENSE_END=================================== + */ + +package org.onap.policy.clamp.acm.participant.kubernetes.configurations; + +import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.Configuration; +import org.springframework.web.multipart.MultipartResolver; +import org.springframework.web.multipart.commons.CommonsMultipartResolver; + +/** + * Bean Factory class for helm client. + */ +@Configuration +public class ParticipantConfig { + + /** + * Method to create multipartResolver bean. + * @return MultipartResolver + */ + @Bean(name = "multipartResolver") + public MultipartResolver multipartResolver() { + var multipartResolver = new CommonsMultipartResolver(); + multipartResolver.setMaxUploadSize(100000); + return multipartResolver; + } +} diff --git a/participant/participant-impl/participant-impl-kubernetes/src/main/java/org/onap/policy/clamp/acm/participant/kubernetes/configurations/ParticipantIntermediaryConfig.java b/participant/participant-impl/participant-impl-kubernetes/src/main/java/org/onap/policy/clamp/acm/participant/kubernetes/configurations/ParticipantIntermediaryConfig.java new file mode 100644 index 000000000..878b43f48 --- /dev/null +++ b/participant/participant-impl/participant-impl-kubernetes/src/main/java/org/onap/policy/clamp/acm/participant/kubernetes/configurations/ParticipantIntermediaryConfig.java @@ -0,0 +1,43 @@ +/*- + * ============LICENSE_START======================================================= + * Copyright (C) 2021 Nordix Foundation. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * SPDX-License-Identifier: Apache-2.0 + * ============LICENSE_END========================================================= + */ + +package org.onap.policy.clamp.acm.participant.kubernetes.configurations; + +import org.onap.policy.clamp.acm.participant.intermediary.api.ParticipantIntermediaryApi; +import org.onap.policy.clamp.acm.participant.kubernetes.handler.AutomationCompositionElementHandler; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.context.annotation.Configuration; + +@Configuration +public class ParticipantIntermediaryConfig { + + /** + * Register AutomationCompositionElementListener. + * + * @param intermediaryApi the ParticipantIntermediaryApi + * @param acElementHandler the AutomationComposition Element Handler + */ + @Autowired + public void registerAutomationCompositionElementListener(ParticipantIntermediaryApi intermediaryApi, + AutomationCompositionElementHandler acElementHandler) { + intermediaryApi.registerAutomationCompositionElementListener(acElementHandler); + acElementHandler.setIntermediaryApi(intermediaryApi); + } +} diff --git a/participant/participant-impl/participant-impl-kubernetes/src/main/java/org/onap/policy/clamp/acm/participant/kubernetes/configurations/SecurityConfig.java b/participant/participant-impl/participant-impl-kubernetes/src/main/java/org/onap/policy/clamp/acm/participant/kubernetes/configurations/SecurityConfig.java new file mode 100644 index 000000000..da5762b43 --- /dev/null +++ b/participant/participant-impl/participant-impl-kubernetes/src/main/java/org/onap/policy/clamp/acm/participant/kubernetes/configurations/SecurityConfig.java @@ -0,0 +1,45 @@ +/*- + * ========================LICENSE_START================================= + * Copyright (C) 2021 Nordix Foundation. All rights reserved. + * ====================================================================== + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ========================LICENSE_END=================================== + */ + +package org.onap.policy.clamp.acm.participant.kubernetes.configurations; + +import org.springframework.beans.factory.annotation.Value; +import org.springframework.context.annotation.Configuration; +import org.springframework.security.config.annotation.web.builders.HttpSecurity; +import org.springframework.security.config.annotation.web.configuration.WebSecurityConfigurerAdapter; + +@Configuration +public class SecurityConfig extends WebSecurityConfigurerAdapter { + + @Value("${security.enable-csrf:true}") + private boolean csrfEnabled = true; + + @Override + protected void configure(HttpSecurity http) throws Exception { + // @formatter:off + http.authorizeRequests() + .antMatchers().authenticated() + .anyRequest().authenticated() + .and().httpBasic(); + // @formatter:on + + if (!csrfEnabled) { + http.csrf().disable(); + } + } +} diff --git a/participant/participant-impl/participant-impl-kubernetes/src/main/java/org/onap/policy/clamp/acm/participant/kubernetes/configurations/SpringFoxConfig.java b/participant/participant-impl/participant-impl-kubernetes/src/main/java/org/onap/policy/clamp/acm/participant/kubernetes/configurations/SpringFoxConfig.java new file mode 100644 index 000000000..cfa98bd65 --- /dev/null +++ b/participant/participant-impl/participant-impl-kubernetes/src/main/java/org/onap/policy/clamp/acm/participant/kubernetes/configurations/SpringFoxConfig.java @@ -0,0 +1,45 @@ +/*- + * ============LICENSE_START======================================================= + * Copyright (C) 2021 Nordix Foundation. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * SPDX-License-Identifier: Apache-2.0 + * ============LICENSE_END========================================================= + */ + +package org.onap.policy.clamp.acm.participant.kubernetes.configurations; + +import org.onap.policy.clamp.acm.participant.kubernetes.controller.ChartController; +import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.Configuration; +import springfox.documentation.builders.PathSelectors; +import springfox.documentation.builders.RequestHandlerSelectors; +import springfox.documentation.spi.DocumentationType; +import springfox.documentation.spring.web.plugins.Docket; + +@Configuration +public class SpringFoxConfig { + + /** + * Docket Spring Fox Config. + * + * @return Docket + */ + @Bean + public Docket api() { + return new Docket(DocumentationType.SWAGGER_2).select() + .apis(RequestHandlerSelectors.basePackage(ChartController.class.getPackageName())) + .paths(PathSelectors.any()).build(); + } +} diff --git a/participant/participant-impl/participant-impl-kubernetes/src/main/java/org/onap/policy/clamp/acm/participant/kubernetes/controller/ChartController.java b/participant/participant-impl/participant-impl-kubernetes/src/main/java/org/onap/policy/clamp/acm/participant/kubernetes/controller/ChartController.java new file mode 100644 index 000000000..19ab4bbab --- /dev/null +++ b/participant/participant-impl/participant-impl-kubernetes/src/main/java/org/onap/policy/clamp/acm/participant/kubernetes/controller/ChartController.java @@ -0,0 +1,195 @@ +/*- + * ========================LICENSE_START================================= + * Copyright (C) 2021-2022 Nordix Foundation. All rights reserved. + * ====================================================================== + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ========================LICENSE_END=================================== + */ + +package org.onap.policy.clamp.acm.participant.kubernetes.controller; + +import io.swagger.annotations.Api; +import io.swagger.annotations.ApiOperation; +import io.swagger.annotations.ApiResponse; +import io.swagger.annotations.ApiResponses; +import java.io.IOException; +import java.util.ArrayList; +import org.onap.policy.clamp.acm.participant.kubernetes.exception.ServiceException; +import org.onap.policy.clamp.acm.participant.kubernetes.models.ChartInfo; +import org.onap.policy.clamp.acm.participant.kubernetes.models.ChartList; +import org.onap.policy.clamp.acm.participant.kubernetes.models.HelmRepository; +import org.onap.policy.clamp.acm.participant.kubernetes.models.InstallationInfo; +import org.onap.policy.clamp.acm.participant.kubernetes.service.ChartService; +import org.onap.policy.common.utils.coder.CoderException; +import org.onap.policy.common.utils.coder.StandardCoder; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.boot.autoconfigure.condition.ConditionalOnExpression; +import org.springframework.http.HttpStatus; +import org.springframework.http.MediaType; +import org.springframework.http.ResponseEntity; +import org.springframework.web.bind.annotation.DeleteMapping; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.PathVariable; +import org.springframework.web.bind.annotation.PostMapping; +import org.springframework.web.bind.annotation.RequestBody; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RequestParam; +import org.springframework.web.bind.annotation.RequestPart; +import org.springframework.web.bind.annotation.RestController; +import org.springframework.web.multipart.MultipartFile; + +@RestController("chartController") +@ConditionalOnExpression("${chart.api.enabled:false}") +@RequestMapping("helm") +@Api(tags = {"k8s-participant"}) +public class ChartController { + + @Autowired + private ChartService chartService; + + private static final StandardCoder CODER = new StandardCoder(); + + /** + * REST endpoint to get all the charts. + * + * @return List of charts installed + */ + @GetMapping(path = "/charts", produces = MediaType.APPLICATION_JSON_VALUE) + @ApiOperation(value = "Return all Charts") + @ApiResponses(value = {@ApiResponse(code = 200, message = "chart List")}) + public ResponseEntity getAllCharts() { + return new ResponseEntity<>(ChartList.builder().charts(new ArrayList<>(chartService.getAllCharts())).build(), + HttpStatus.OK); + } + + /** + * REST endpoint to install a helm chart. + * + * @param info Info of the chart to be installed + * @return Status of the install operation + * @throws ServiceException in case of error + * @throws IOException in case of IO error + */ + @PostMapping(path = "/install", consumes = MediaType.APPLICATION_JSON_VALUE, + produces = MediaType.APPLICATION_JSON_VALUE) + @ApiOperation(value = "Install the chart") + @ApiResponses(value = {@ApiResponse(code = 201, message = "chart Installed")}) + public ResponseEntity installChart(@RequestBody InstallationInfo info) + throws ServiceException, IOException { + ChartInfo chart = chartService.getChart(info.getName(), info.getVersion()); + if (chart == null) { + return new ResponseEntity<>(HttpStatus.NOT_FOUND); + } + + chartService.installChart(chart); + return new ResponseEntity<>(HttpStatus.CREATED); + } + + /** + * REST endpoint to uninstall a specific chart. + * + * @param name name of the chart + * @param version version of the chart + * @return Status of operation + * @throws ServiceException in case of error. + */ + @DeleteMapping(path = "/uninstall/{name}/{version}", produces = MediaType.APPLICATION_JSON_VALUE) + @ApiOperation(value = "Uninstall the Chart") + @ApiResponses(value = {@ApiResponse(code = 201, message = "chart Uninstalled")}) + public ResponseEntity uninstallChart(@PathVariable("name") String name, + @PathVariable("version") String version) throws ServiceException { + ChartInfo chart = chartService.getChart(name, version); + if (chart == null) { + return new ResponseEntity<>(HttpStatus.NOT_FOUND); + } + + chartService.uninstallChart(chart); + return new ResponseEntity<>(HttpStatus.NO_CONTENT); + } + + /** + * REST endpoint to onboard a chart. + * + * @param chartFile Multipart file for the helm chart + * @param infoJson AppInfo of the chart + * @param overrideFile the file for overriding the chart + * @return Status of onboard operation + * @throws ServiceException in case of error + * @throws IOException in case of IO error + */ + @PostMapping(path = "/onboard/chart", consumes = MediaType.MULTIPART_FORM_DATA_VALUE, + produces = MediaType.APPLICATION_JSON_VALUE) + @ApiOperation(value = "Onboard the Chart") + @ApiResponses(value = {@ApiResponse(code = 201, message = "Chart Onboarded")}) + public ResponseEntity onboardChart(@RequestPart("chart") MultipartFile chartFile, + @RequestParam(name = "values", required = false) MultipartFile overrideFile, + @RequestParam("info") String infoJson) throws ServiceException, IOException { + + ChartInfo info; + try { + info = CODER.decode(infoJson, ChartInfo.class); + } catch (CoderException e) { + throw new ServiceException("Error parsing the chart information", e); + } + + chartService.saveChart(info, chartFile, overrideFile); + return new ResponseEntity<>(HttpStatus.OK); + } + + /** + * REST endpoint to delete a specific helm chart. + * + * @param name name of the chart + * @param version version of the chart + * @return Status of operation + */ + @DeleteMapping(path = "/chart/{name}/{version}") + @ApiOperation(value = "Delete the chart") + @ApiResponses(value = {@ApiResponse(code = 204, message = "Chart Deleted")}) + public ResponseEntity deleteChart(@PathVariable("name") String name, + @PathVariable("version") String version) { + + ChartInfo chart = chartService.getChart(name, version); + if (chart == null) { + return new ResponseEntity<>(HttpStatus.NOT_FOUND); + } + + chartService.deleteChart(chart); + return new ResponseEntity<>(HttpStatus.NO_CONTENT); + } + + /** + * REST endpoint to configure a helm Repository. + * + * @param repo Helm repository to be configured + * @return Status of the operation + * @throws ServiceException in case of error + * @throws IOException in case of IO error + */ + @PostMapping(path = "/repo", consumes = MediaType.APPLICATION_JSON_VALUE, + produces = MediaType.APPLICATION_JSON_VALUE) + @ApiOperation(value = "Configure helm repository") + @ApiResponses(value = {@ApiResponse(code = 201, message = "Repository added")}) + public ResponseEntity configureRepo(@RequestBody String repo) + throws ServiceException, IOException { + HelmRepository repository; + try { + repository = CODER.decode(repo, HelmRepository.class); + } catch (CoderException e) { + throw new ServiceException("Error parsing the repository information", e); + } + chartService.configureRepository(repository); + + return new ResponseEntity<>(HttpStatus.CREATED); + } +} diff --git a/participant/participant-impl/participant-impl-kubernetes/src/main/java/org/onap/policy/clamp/acm/participant/kubernetes/exception/ServiceException.java b/participant/participant-impl/participant-impl-kubernetes/src/main/java/org/onap/policy/clamp/acm/participant/kubernetes/exception/ServiceException.java new file mode 100644 index 000000000..6414f2fa9 --- /dev/null +++ b/participant/participant-impl/participant-impl-kubernetes/src/main/java/org/onap/policy/clamp/acm/participant/kubernetes/exception/ServiceException.java @@ -0,0 +1,32 @@ +/*- + * ========================LICENSE_START================================= + * Copyright (C) 2021 Nordix Foundation. All rights reserved. + * ====================================================================== + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ========================LICENSE_END=================================== + */ + +package org.onap.policy.clamp.acm.participant.kubernetes.exception; + +public class ServiceException extends Exception { + + private static final long serialVersionUID = 6810785674716590648L; + + public ServiceException(String message) { + super(message); + } + + public ServiceException(String message, Exception originalException) { + super(message, originalException); + } +} diff --git a/participant/participant-impl/participant-impl-kubernetes/src/main/java/org/onap/policy/clamp/acm/participant/kubernetes/handler/AutomationCompositionElementHandler.java b/participant/participant-impl/participant-impl-kubernetes/src/main/java/org/onap/policy/clamp/acm/participant/kubernetes/handler/AutomationCompositionElementHandler.java new file mode 100644 index 000000000..753608686 --- /dev/null +++ b/participant/participant-impl/participant-impl-kubernetes/src/main/java/org/onap/policy/clamp/acm/participant/kubernetes/handler/AutomationCompositionElementHandler.java @@ -0,0 +1,197 @@ +/*- + * ============LICENSE_START======================================================= + * Copyright (C) 2021-2022 Nordix Foundation. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * SPDX-License-Identifier: Apache-2.0 + * ============LICENSE_END========================================================= + */ + +package org.onap.policy.clamp.acm.participant.kubernetes.handler; + +import java.io.IOException; +import java.lang.invoke.MethodHandles; +import java.time.Instant; +import java.util.HashMap; +import java.util.Map; +import java.util.UUID; +import java.util.concurrent.ConcurrentHashMap; +import java.util.concurrent.ExecutionException; +import java.util.concurrent.ExecutorService; +import java.util.concurrent.Executors; +import java.util.concurrent.Future; +import lombok.AccessLevel; +import lombok.Getter; +import lombok.Setter; +import org.onap.policy.clamp.acm.participant.intermediary.api.AutomationCompositionElementListener; +import org.onap.policy.clamp.acm.participant.intermediary.api.ParticipantIntermediaryApi; +import org.onap.policy.clamp.acm.participant.kubernetes.exception.ServiceException; +import org.onap.policy.clamp.acm.participant.kubernetes.helm.PodStatusValidator; +import org.onap.policy.clamp.acm.participant.kubernetes.models.ChartInfo; +import org.onap.policy.clamp.acm.participant.kubernetes.service.ChartService; +import org.onap.policy.clamp.models.acm.concepts.AcElementStatistics; +import org.onap.policy.clamp.models.acm.concepts.AutomationCompositionElement; +import org.onap.policy.clamp.models.acm.concepts.AutomationCompositionOrderedState; +import org.onap.policy.clamp.models.acm.concepts.AutomationCompositionState; +import org.onap.policy.clamp.models.acm.messages.dmaap.participant.ParticipantMessageType; +import org.onap.policy.common.utils.coder.Coder; +import org.onap.policy.common.utils.coder.CoderException; +import org.onap.policy.common.utils.coder.StandardCoder; +import org.onap.policy.models.base.PfModelException; +import org.onap.policy.models.tosca.authorative.concepts.ToscaConceptIdentifier; +import org.onap.policy.models.tosca.authorative.concepts.ToscaNodeTemplate; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Component; + +/** + * This class handles implementation of automationCompositionElement updates. + */ +@Component +public class AutomationCompositionElementHandler implements AutomationCompositionElementListener { + private static final Logger LOGGER = LoggerFactory.getLogger(MethodHandles.lookup().lookupClass()); + + private ExecutorService executor = Executors.newFixedThreadPool(Runtime.getRuntime().availableProcessors()); + + // Map of helm installation and the status of corresponding pods + @Getter + private static Map> podStatusMap = new ConcurrentHashMap<>(); + private static final Coder CODER = new StandardCoder(); + + @Autowired + private ChartService chartService; + + @Setter + private ParticipantIntermediaryApi intermediaryApi; + + // Map of acElement Id and installed Helm charts + @Getter(AccessLevel.PACKAGE) + private final Map chartMap = new HashMap<>(); + + // Default thread config values + private static class ThreadConfig { + private int uninitializedToPassiveTimeout = 60; + private int podStatusCheckInterval = 30; + } + + /** + * Callback method to handle a automation composition element state change. + * + * @param automationCompositionElementId the ID of the automation composition element + * @param currentState the current state of the automation composition element + * @param newState the state to which the automation composition element is changing to + */ + @Override + public synchronized void automationCompositionElementStateChange(ToscaConceptIdentifier automationCompositionId, + UUID automationCompositionElementId, AutomationCompositionState currentState, + AutomationCompositionOrderedState newState) { + switch (newState) { + case UNINITIALISED: + ChartInfo chart = chartMap.get(automationCompositionElementId); + if (chart != null) { + LOGGER.info("Helm deployment to be deleted {} ", chart.getReleaseName()); + try { + chartService.uninstallChart(chart); + intermediaryApi.updateAutomationCompositionElementState(automationCompositionId, + automationCompositionElementId, newState, AutomationCompositionState.UNINITIALISED, + ParticipantMessageType.AUTOMATION_COMPOSITION_STATE_CHANGE); + chartMap.remove(automationCompositionElementId); + podStatusMap.remove(chart.getReleaseName()); + } catch (ServiceException se) { + LOGGER.warn("Deletion of Helm deployment failed", se); + } + } + break; + case PASSIVE: + intermediaryApi.updateAutomationCompositionElementState(automationCompositionId, + automationCompositionElementId, newState, AutomationCompositionState.PASSIVE, + ParticipantMessageType.AUTOMATION_COMPOSITION_STATE_CHANGE); + break; + case RUNNING: + intermediaryApi.updateAutomationCompositionElementState(automationCompositionId, + automationCompositionElementId, newState, AutomationCompositionState.RUNNING, + ParticipantMessageType.AUTOMATION_COMPOSITION_STATE_CHANGE); + break; + default: + LOGGER.warn("Cannot transition from state {} to state {}", currentState, newState); + break; + } + } + + /** + * Callback method to handle an update on a automation composition element. + * + * @param element the information on the automation composition element + * @param nodeTemplate toscaNodeTemplate + * @throws PfModelException in case of an exception + */ + @Override + public synchronized void automationCompositionElementUpdate(ToscaConceptIdentifier automationCompositionId, + AutomationCompositionElement element, ToscaNodeTemplate nodeTemplate) throws PfModelException { + @SuppressWarnings("unchecked") + Map chartData = (Map) nodeTemplate.getProperties().get("chart"); + + LOGGER.info("Installation request received for the Helm Chart {} ", chartData); + try { + var chartInfo = CODER.convert(chartData, ChartInfo.class); + chartService.installChart(chartInfo); + chartMap.put(element.getId(), chartInfo); + + var config = CODER.convert(nodeTemplate.getProperties(), ThreadConfig.class); + checkPodStatus(automationCompositionId, element.getId(), chartInfo, config.uninitializedToPassiveTimeout, + config.podStatusCheckInterval); + + } catch (ServiceException | CoderException | IOException | ExecutionException + | InterruptedException e) { + LOGGER.warn("Installation of Helm chart failed", e); + } + } + + /** + * Invoke a new thread to check the status of deployed pods. + * + * @param chart ChartInfo + */ + public void checkPodStatus(ToscaConceptIdentifier controlLoopId, UUID elementId, + ChartInfo chart, int timeout, int podStatusCheckInterval) throws ExecutionException, InterruptedException { + // Invoke runnable thread to check pod status + Future result = executor.submit(new PodStatusValidator(chart, timeout, + podStatusCheckInterval), "Done"); + if (!result.get().isEmpty()) { + LOGGER.info("Pod Status Validator Completed: {}", result.isDone()); + intermediaryApi.updateAutomationCompositionElementState(controlLoopId, elementId, + AutomationCompositionOrderedState.PASSIVE, AutomationCompositionState.PASSIVE, + ParticipantMessageType.AUTOMATION_COMPOSITION_STATE_CHANGE); + } + } + + /** + * Overridden method. + * + * @param automationCompositionElementId automationCompositionElement id + * @throws PfModelException in case of error + */ + @Override + public synchronized void handleStatistics(UUID automationCompositionElementId) throws PfModelException { + var acElement = intermediaryApi.getAutomationCompositionElement(automationCompositionElementId); + if (acElement != null) { + var acElementStatistics = new AcElementStatistics(); + acElementStatistics.setState(acElement.getState()); + acElementStatistics.setTimeStamp(Instant.now()); + intermediaryApi.updateAutomationCompositionElementStatistics(automationCompositionElementId, + acElementStatistics); + } + } +} diff --git a/participant/participant-impl/participant-impl-kubernetes/src/main/java/org/onap/policy/clamp/acm/participant/kubernetes/helm/HelmClient.java b/participant/participant-impl/participant-impl-kubernetes/src/main/java/org/onap/policy/clamp/acm/participant/kubernetes/helm/HelmClient.java new file mode 100644 index 000000000..87199688e --- /dev/null +++ b/participant/participant-impl/participant-impl-kubernetes/src/main/java/org/onap/policy/clamp/acm/participant/kubernetes/helm/HelmClient.java @@ -0,0 +1,279 @@ +/*- + * ========================LICENSE_START================================= + * Copyright (C) 2021-2022 Nordix Foundation. All rights reserved. + * ====================================================================== + * Modifications Copyright (C) 2021 AT&T Intellectual Property. All rights reserved. + * ====================================================================== + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ========================LICENSE_END=================================== + */ + +package org.onap.policy.clamp.acm.participant.kubernetes.helm; + +import java.io.File; +import java.io.IOException; +import java.lang.invoke.MethodHandles; +import java.nio.charset.StandardCharsets; +import java.util.ArrayList; +import java.util.List; +import java.util.Map; +import org.apache.commons.io.IOUtils; +import org.onap.policy.clamp.acm.participant.kubernetes.exception.ServiceException; +import org.onap.policy.clamp.acm.participant.kubernetes.models.ChartInfo; +import org.onap.policy.clamp.acm.participant.kubernetes.models.HelmRepository; +import org.onap.policy.clamp.acm.participant.kubernetes.service.ChartStore; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Component; + +/** + * Client to talk with Helm cli. Supports helm3 + version + */ +@Component +public class HelmClient { + + @Autowired + private ChartStore chartStore; + + private static final Logger logger = LoggerFactory.getLogger(MethodHandles.lookup().lookupClass()); + private static final String PATH_DELIMITER = "/"; + + /** + * Install a chart. + * + * @param chart name and version. + * @throws ServiceException incase of error + */ + public void installChart(ChartInfo chart) throws ServiceException { + if (! checkNamespaceExists(chart.getNamespace())) { + var processBuilder = prepareCreateNamespaceCommand(chart.getNamespace()); + executeCommand(processBuilder); + } + var processBuilder = prepareInstallCommand(chart); + logger.info("Installing helm chart {} from the repository {} ", chart.getChartId().getName(), + chart.getRepository().getRepoName()); + executeCommand(processBuilder); + logger.info("Chart {} installed successfully", chart.getChartId().getName()); + } + + /** + * Add repository if doesn't exist. + * @param repo HelmRepository + * @throws ServiceException incase of error + */ + public void addRepository(HelmRepository repo) throws ServiceException { + String output = executeCommand(prepareVerifyRepoCommand(repo)); + if (output.isEmpty()) { + logger.info("Adding repository to helm client"); + executeCommand(prepareRepoAddCommand(repo)); + logger.debug("Added repository {} to the helm client", repo.getRepoName()); + } else { + logger.info("Repository already exists"); + } + } + + + /** + * Finds helm chart repository for the chart. + * + * @param chart ChartInfo. + * @return the chart repository as a string + * @throws ServiceException in case of error + * @throws IOException in case of IO errors + */ + public String findChartRepository(ChartInfo chart) throws ServiceException, IOException { + if (updateHelmRepo()) { + String repository = verifyConfiguredRepo(chart); + if (repository != null) { + logger.info("Helm chart located in the repository {} ", repository); + return repository; + } + } + var localHelmChartDir = chartStore.getAppPath(chart.getChartId()).toString(); + logger.info("Chart not found in helm repositories, verifying local repo {} ", localHelmChartDir); + if (verifyLocalHelmRepo(new File(localHelmChartDir + PATH_DELIMITER + chart.getChartId().getName()))) { + return localHelmChartDir; + } + return null; + } + + /** + * Verify helm chart in configured repositories. + * @param chart chartInfo + * @return repo name + * @throws IOException incase of error + * @throws ServiceException incase of error + */ + public String verifyConfiguredRepo(ChartInfo chart) throws IOException, ServiceException { + logger.info("Looking for helm chart {} in all the configured helm repositories", chart.getChartId().getName()); + String repository = null; + var builder = helmRepoVerifyCommand(chart.getChartId().getName()); + String output = executeCommand(builder); + repository = verifyOutput(output, chart.getChartId().getName()); + return repository; + } + + /** + * Uninstall a chart. + * + * @param chart name and version. + * @throws ServiceException incase of error + */ + public void uninstallChart(ChartInfo chart) throws ServiceException { + executeCommand(prepareUnInstallCommand(chart)); + } + + + /** + * Execute helm cli bash commands . + * @param processBuilder processbuilder + * @return string output + * @throws ServiceException incase of error. + */ + public static String executeCommand(ProcessBuilder processBuilder) throws ServiceException { + var commandStr = toString(processBuilder); + + try { + var process = processBuilder.start(); + process.waitFor(); + int exitValue = process.exitValue(); + + if (exitValue != 0) { + var error = IOUtils.toString(process.getErrorStream(), StandardCharsets.UTF_8); + if (! error.isEmpty()) { + throw new ServiceException("Command execution failed: " + commandStr + " " + error); + } + } + + var output = IOUtils.toString(process.getInputStream(), StandardCharsets.UTF_8); + logger.debug("Command <{}> execution, output: {}", commandStr, output); + return output; + + } catch (InterruptedException ie) { + Thread.currentThread().interrupt(); + throw new ServiceException("Failed to execute the Command: " + commandStr + ", the command was interrupted", + ie); + } catch (Exception exc) { + throw new ServiceException("Failed to execute the Command: " + commandStr, exc); + } + } + + private boolean checkNamespaceExists(String namespace) throws ServiceException { + logger.info("Check if namespace {} exists on the cluster", namespace); + String output = executeCommand(prepareVerifyNamespaceCommand(namespace)); + return !output.isEmpty(); + } + + private String verifyOutput(String output, String value) { + for (var line: output.split("\\R")) { + if (line.contains(value)) { + return line.split("/")[0]; + } + } + return null; + } + + private ProcessBuilder prepareRepoAddCommand(HelmRepository repo) { + var url = repo.getProtocol() + "://" + repo.getAddress(); + if (repo.getPort() != null) { + url = url + ":" + repo.getPort(); + } + // @formatter:off + List helmArguments = new ArrayList<>( + List.of( + "helm", + "repo", + "add", repo.getRepoName(), url + )); + if (repo.getUserName() != null && repo.getPassword() != null) { + helmArguments.addAll(List.of("--username", repo.getUserName(), "--password", repo.getPassword())); + } + return new ProcessBuilder().command(helmArguments); + } + + private ProcessBuilder prepareVerifyRepoCommand(HelmRepository repo) { + List helmArguments = List.of("sh", "-c", "helm repo ls | grep " + repo.getRepoName()); + return new ProcessBuilder().command(helmArguments); + } + + private ProcessBuilder prepareVerifyNamespaceCommand(String namespace) { + List helmArguments = List.of("sh", "-c", "kubectl get ns | grep " + namespace); + return new ProcessBuilder().command(helmArguments); + } + + private ProcessBuilder prepareInstallCommand(ChartInfo chart) { + + // @formatter:off + List helmArguments = new ArrayList<>( + List.of( + "helm", + "install", chart.getReleaseName(), chart.getRepository().getRepoName() + "/" + + chart.getChartId().getName(), + "--version", chart.getChartId().getVersion(), + "--namespace", chart.getNamespace() + )); + // @formatter:on + + // Verify if values.yaml/override parameters available for the chart + var localOverrideYaml = chartStore.getOverrideFile(chart); + + if (verifyLocalHelmRepo(localOverrideYaml)) { + logger.info("Override yaml available for the helm chart"); + helmArguments.addAll(List.of("--values", localOverrideYaml.getPath())); + } + + if (chart.getOverrideParams() != null) { + for (Map.Entry entry : chart.getOverrideParams().entrySet()) { + helmArguments.addAll(List.of("--set", entry.getKey() + "=" + entry.getValue())); + } + } + return new ProcessBuilder().command(helmArguments); + } + + private ProcessBuilder prepareUnInstallCommand(ChartInfo chart) { + return new ProcessBuilder("helm", "delete", chart.getReleaseName(), "--namespace", + chart.getNamespace()); + } + + private ProcessBuilder prepareCreateNamespaceCommand(String namespace) { + return new ProcessBuilder().command("kubectl", "create", "namespace", namespace); + } + + private ProcessBuilder helmRepoVerifyCommand(String chartName) { + return new ProcessBuilder().command("sh", "-c", "helm search repo | grep " + chartName); + } + + + private boolean updateHelmRepo() { + try { + logger.info("Updating local helm repositories before verifying the chart"); + executeCommand(new ProcessBuilder().command("helm", "repo", "update")); + logger.debug("Helm repositories updated successfully"); + } catch (ServiceException e) { + logger.error("Failed to update the helm repo: ", e); + return false; + } + return true; + + + } + + private boolean verifyLocalHelmRepo(File localFile) { + return localFile.exists(); + } + + protected static String toString(ProcessBuilder processBuilder) { + return String.join(" ", processBuilder.command()); + } +} diff --git a/participant/participant-impl/participant-impl-kubernetes/src/main/java/org/onap/policy/clamp/acm/participant/kubernetes/helm/PodStatusValidator.java b/participant/participant-impl/participant-impl-kubernetes/src/main/java/org/onap/policy/clamp/acm/participant/kubernetes/helm/PodStatusValidator.java new file mode 100644 index 000000000..f8b08a6be --- /dev/null +++ b/participant/participant-impl/participant-impl-kubernetes/src/main/java/org/onap/policy/clamp/acm/participant/kubernetes/helm/PodStatusValidator.java @@ -0,0 +1,119 @@ +/*- + * ========================LICENSE_START================================= + * Copyright (C) 2021 Nordix Foundation. All rights reserved. + * ====================================================================== + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ========================LICENSE_END=================================== + */ + +package org.onap.policy.clamp.acm.participant.kubernetes.helm; + +import java.io.BufferedReader; +import java.io.IOException; +import java.io.InputStreamReader; +import java.lang.invoke.MethodHandles; +import java.nio.charset.StandardCharsets; +import java.util.HashMap; +import java.util.Map; +import lombok.SneakyThrows; +import org.apache.commons.io.IOUtils; +import org.onap.policy.clamp.acm.participant.kubernetes.exception.ServiceException; +import org.onap.policy.clamp.acm.participant.kubernetes.handler.AutomationCompositionElementHandler; +import org.onap.policy.clamp.acm.participant.kubernetes.models.ChartInfo; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + + +public class PodStatusValidator implements Runnable { + + private static final Logger logger = LoggerFactory.getLogger(MethodHandles.lookup().lookupClass()); + + private final int statusCheckInterval; + + //Timeout for the thread to exit. + private final int timeout; + + private ChartInfo chart; + + /** + * Constructor for PodStatusValidator. + * @param chart chartInfo + * @param timeout timeout for the thread to exit + * @param statusCheckInterval Interval to check pod status + */ + public PodStatusValidator(ChartInfo chart, int timeout, int statusCheckInterval) { + this.chart = chart; + this.timeout = timeout; + this.statusCheckInterval = statusCheckInterval; + } + + + @SneakyThrows + @Override + public void run() { + logger.info("Polling the status of deployed pods for the chart {}", chart.getChartId().getName()); + Map podStatusMap; + String output = null; + var isVerified = false; + long endTime = System.currentTimeMillis() + (timeout * 1000L); + + while (!isVerified && System.currentTimeMillis() < endTime) { + try { + output = HelmClient.executeCommand(verifyPodStatusCommand(chart)); + podStatusMap = mapPodStatus(output); + isVerified = podStatusMap.values() + .stream() + .allMatch("Running"::equals); + if (! isVerified) { + logger.info("Waiting for the pods to be active for the chart {}", chart.getChartId().getName()); + podStatusMap.forEach((key, value) -> logger.info("Pod: {} , state: {}", key, value)); + AutomationCompositionElementHandler.getPodStatusMap().put(chart.getReleaseName(), podStatusMap); + // Recheck status of pods in specific intervals. + Thread.sleep(statusCheckInterval * 1000L); + } else { + logger.info("All pods are in running state for the helm chart {}", chart.getChartId().getName()); + AutomationCompositionElementHandler.getPodStatusMap().put(chart.getReleaseName(), podStatusMap); + } + } catch (ServiceException | IOException e) { + throw new ServiceException("Error verifying the status of the pod. Exiting", e); + } + } + } + + private ProcessBuilder verifyPodStatusCommand(ChartInfo chart) { + String podName = chart.getReleaseName() + "-" + chart.getChartId().getName(); + String cmd = "kubectl get pods --namespace " + chart.getNamespace() + " | grep " + podName; + return new ProcessBuilder("sh", "-c", cmd); + } + + + private Map mapPodStatus(String output) throws IOException, ServiceException { + Map podStatusMap = new HashMap<>(); + try (var reader = new BufferedReader(new InputStreamReader(IOUtils.toInputStream(output, + StandardCharsets.UTF_8)))) { + var line = reader.readLine(); + while (line != null) { + if (line.contains(chart.getChartId().getName())) { + var result = line.split("\\s+"); + podStatusMap.put(result[0], result[2]); + } + line = reader.readLine(); + } + } + if (!podStatusMap.isEmpty()) { + return podStatusMap; + } else { + throw new ServiceException("Status of Pod is empty"); + } + } +} diff --git a/participant/participant-impl/participant-impl-kubernetes/src/main/java/org/onap/policy/clamp/acm/participant/kubernetes/models/ChartInfo.java b/participant/participant-impl/participant-impl-kubernetes/src/main/java/org/onap/policy/clamp/acm/participant/kubernetes/models/ChartInfo.java new file mode 100644 index 000000000..b925e782d --- /dev/null +++ b/participant/participant-impl/participant-impl-kubernetes/src/main/java/org/onap/policy/clamp/acm/participant/kubernetes/models/ChartInfo.java @@ -0,0 +1,44 @@ +/*- + * ========================LICENSE_START================================= + * Copyright (C) 2021 Nordix Foundation. All rights reserved. + * ====================================================================== + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ========================LICENSE_END=================================== + */ + +package org.onap.policy.clamp.acm.participant.kubernetes.models; + +import java.util.Map; +import lombok.Data; +import lombok.NonNull; +import lombok.RequiredArgsConstructor; +import org.onap.policy.models.tosca.authorative.concepts.ToscaConceptIdentifier; + +@Data +@RequiredArgsConstructor +public class ChartInfo { + + @NonNull + private String releaseName; + + @NonNull + private ToscaConceptIdentifier chartId; + + @NonNull + private String namespace; + + private HelmRepository repository; + + private Map overrideParams; + +} diff --git a/participant/participant-impl/participant-impl-kubernetes/src/main/java/org/onap/policy/clamp/acm/participant/kubernetes/models/ChartList.java b/participant/participant-impl/participant-impl-kubernetes/src/main/java/org/onap/policy/clamp/acm/participant/kubernetes/models/ChartList.java new file mode 100644 index 000000000..951bdaa1b --- /dev/null +++ b/participant/participant-impl/participant-impl-kubernetes/src/main/java/org/onap/policy/clamp/acm/participant/kubernetes/models/ChartList.java @@ -0,0 +1,31 @@ +/*- + * ========================LICENSE_START================================= + * Copyright (C) 2021 Nordix Foundation. All rights reserved. + * ====================================================================== + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ========================LICENSE_END=================================== + */ + +package org.onap.policy.clamp.acm.participant.kubernetes.models; + +import java.util.List; +import lombok.Builder; +import lombok.Getter; +import lombok.Setter; + +@Getter +@Setter +@Builder +public class ChartList { + private List charts; +} diff --git a/participant/participant-impl/participant-impl-kubernetes/src/main/java/org/onap/policy/clamp/acm/participant/kubernetes/models/HelmRepository.java b/participant/participant-impl/participant-impl-kubernetes/src/main/java/org/onap/policy/clamp/acm/participant/kubernetes/models/HelmRepository.java new file mode 100644 index 000000000..2e25e42a6 --- /dev/null +++ b/participant/participant-impl/participant-impl-kubernetes/src/main/java/org/onap/policy/clamp/acm/participant/kubernetes/models/HelmRepository.java @@ -0,0 +1,39 @@ +/*- + * ========================LICENSE_START================================= + * Copyright (C) 2021 Nordix Foundation. All rights reserved. + * ====================================================================== + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ========================LICENSE_END=================================== + */ + +package org.onap.policy.clamp.acm.participant.kubernetes.models; + +import lombok.Builder; +import lombok.Data; + +@Data +@Builder +public class HelmRepository { + + private String repoName; + + private String protocol; + + private String address; + + private String port; + + private String userName; + + private String password; +} diff --git a/participant/participant-impl/participant-impl-kubernetes/src/main/java/org/onap/policy/clamp/acm/participant/kubernetes/models/InstallationInfo.java b/participant/participant-impl/participant-impl-kubernetes/src/main/java/org/onap/policy/clamp/acm/participant/kubernetes/models/InstallationInfo.java new file mode 100644 index 000000000..6ef6865cb --- /dev/null +++ b/participant/participant-impl/participant-impl-kubernetes/src/main/java/org/onap/policy/clamp/acm/participant/kubernetes/models/InstallationInfo.java @@ -0,0 +1,29 @@ +/*- + * ========================LICENSE_START================================= + * Copyright (C) 2021 Nordix Foundation. All rights reserved. + * ====================================================================== + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ========================LICENSE_END=================================== + */ + +package org.onap.policy.clamp.acm.participant.kubernetes.models; + +import lombok.Getter; +import org.immutables.gson.Gson; + +@Getter +@Gson.TypeAdapters +public class InstallationInfo { + private String name; + private String version; +} diff --git a/participant/participant-impl/participant-impl-kubernetes/src/main/java/org/onap/policy/clamp/acm/participant/kubernetes/parameters/ParticipantK8sParameters.java b/participant/participant-impl/participant-impl-kubernetes/src/main/java/org/onap/policy/clamp/acm/participant/kubernetes/parameters/ParticipantK8sParameters.java new file mode 100644 index 000000000..b95756ec5 --- /dev/null +++ b/participant/participant-impl/participant-impl-kubernetes/src/main/java/org/onap/policy/clamp/acm/participant/kubernetes/parameters/ParticipantK8sParameters.java @@ -0,0 +1,52 @@ +/*- + * ============LICENSE_START======================================================= + * Copyright (C) 2021 Nordix Foundation. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * SPDX-License-Identifier: Apache-2.0 + * ============LICENSE_END========================================================= + */ + +package org.onap.policy.clamp.acm.participant.kubernetes.parameters; + +import javax.validation.Valid; +import javax.validation.constraints.NotBlank; +import javax.validation.constraints.NotNull; +import lombok.Getter; +import lombok.Setter; +import org.onap.policy.clamp.acm.participant.intermediary.parameters.ParticipantIntermediaryParameters; +import org.onap.policy.clamp.acm.participant.intermediary.parameters.ParticipantParameters; +import org.springframework.boot.context.properties.ConfigurationProperties; +import org.springframework.validation.annotation.Validated; + +/** + * Class to hold all parameters needed for the kubernetes participant. + * + */ +@Validated +@Getter +@Setter +@ConfigurationProperties(prefix = "participant") +public class ParticipantK8sParameters implements ParticipantParameters { + + @NotNull + @Valid + private ParticipantIntermediaryParameters intermediaryParameters; + + @NotBlank + private String localChartDirectory; + + @NotBlank + private String infoFileName; +} diff --git a/participant/participant-impl/participant-impl-kubernetes/src/main/java/org/onap/policy/clamp/acm/participant/kubernetes/service/ChartService.java b/participant/participant-impl/participant-impl-kubernetes/src/main/java/org/onap/policy/clamp/acm/participant/kubernetes/service/ChartService.java new file mode 100644 index 000000000..344d161b7 --- /dev/null +++ b/participant/participant-impl/participant-impl-kubernetes/src/main/java/org/onap/policy/clamp/acm/participant/kubernetes/service/ChartService.java @@ -0,0 +1,141 @@ +/*- + * ========================LICENSE_START================================= + * Copyright (C) 2021 Nordix Foundation. All rights reserved. + * ====================================================================== + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ========================LICENSE_END=================================== + */ + +package org.onap.policy.clamp.acm.participant.kubernetes.service; + +import java.io.IOException; +import java.lang.invoke.MethodHandles; +import java.util.Collection; +import org.onap.policy.clamp.acm.participant.kubernetes.exception.ServiceException; +import org.onap.policy.clamp.acm.participant.kubernetes.helm.HelmClient; +import org.onap.policy.clamp.acm.participant.kubernetes.models.ChartInfo; +import org.onap.policy.clamp.acm.participant.kubernetes.models.HelmRepository; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; +import org.springframework.web.multipart.MultipartFile; + +@Service +public class ChartService { + private final Logger logger = LoggerFactory.getLogger(MethodHandles.lookup().lookupClass()); + + @Autowired + private ChartStore chartStore; + + @Autowired + private HelmClient helmClient; + + /** + * Get all the installed charts. + * @return list of charts. + */ + public Collection getAllCharts() { + return chartStore.getAllCharts(); + } + + /** + * Get specific chart info. + * @param name name of the app + * @param version version of the app + * @return chart + */ + public ChartInfo getChart(String name, String version) { + return chartStore.getChart(name, version); + } + + /** + * Save a helm chart. + * @param chartInfo name and version of the app. + * @param chartFile Helm chart file + * @param overrideFile override file + * @return chart details of the helm chart + * @throws IOException in case of IO error + * @throws ServiceException in case of error + */ + public ChartInfo saveChart(ChartInfo chartInfo, MultipartFile chartFile, MultipartFile overrideFile) + throws IOException, ServiceException { + return chartStore.saveChart(chartInfo, chartFile, overrideFile); + } + + /** + * Delete a helm chart. + * @param chart name and version of the chart. + */ + public void deleteChart(ChartInfo chart) { + chartStore.deleteChart(chart); + } + + /** + * Install a helm chart. + * @param chart name and version. + * @throws ServiceException in case of error + * @throws IOException in case of IO errors + */ + public void installChart(ChartInfo chart) throws ServiceException, IOException { + if (chart.getRepository() == null) { + String repoName = findChartRepo(chart); + if (repoName == null) { + logger.error("Chart repository could not be found. Skipping chart Installation " + + "for the chart {} ", chart.getChartId().getName()); + return; + } else { + HelmRepository repo = HelmRepository.builder().repoName(repoName).build(); + chart.setRepository(repo); + } + } else { + // Add remote repository if passed via TOSCA + configureRepository(chart.getRepository()); + } + helmClient.installChart(chart); + } + + + /** + * Configure remote repository. + * @param repo HelmRepository + * @throws ServiceException incase of error + */ + public void configureRepository(HelmRepository repo) throws ServiceException { + if (repo.getAddress() != null) { + helmClient.addRepository(repo); + } + } + + /** + * Finds helm chart repository for a given chart. + * @param chart chartInfo. + * @return the chart repo as a string + * @throws ServiceException in case of error + * @throws IOException in case of IO errors + */ + public String findChartRepo(ChartInfo chart) throws ServiceException, IOException { + logger.info("Fetching helm chart repository for the given chart {} ", chart.getChartId().getName()); + return helmClient.findChartRepository(chart); + } + + /** + * Uninstall a helm chart. + * @param chart name and version + * @throws ServiceException in case of error. + */ + public void uninstallChart(ChartInfo chart) throws ServiceException { + logger.info("Uninstalling helm deployment {}", chart.getReleaseName()); + helmClient.uninstallChart(chart); + } +} diff --git a/participant/participant-impl/participant-impl-kubernetes/src/main/java/org/onap/policy/clamp/acm/participant/kubernetes/service/ChartStore.java b/participant/participant-impl/participant-impl-kubernetes/src/main/java/org/onap/policy/clamp/acm/participant/kubernetes/service/ChartStore.java new file mode 100644 index 000000000..52c1b1f04 --- /dev/null +++ b/participant/participant-impl/participant-impl-kubernetes/src/main/java/org/onap/policy/clamp/acm/participant/kubernetes/service/ChartStore.java @@ -0,0 +1,219 @@ +/*- + * ========================LICENSE_START================================= + * Copyright (C) 2021 Nordix Foundation. All rights reserved. + * ====================================================================== + * Modifications Copyright (C) 2021 AT&T Intellectual Property. All rights reserved. + * ====================================================================== + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ========================LICENSE_END=================================== + */ + +package org.onap.policy.clamp.acm.participant.kubernetes.service; + +import java.io.File; +import java.io.FileOutputStream; +import java.io.IOException; +import java.io.PrintStream; +import java.lang.invoke.MethodHandles; +import java.nio.file.FileVisitResult; +import java.nio.file.Files; +import java.nio.file.Path; +import java.nio.file.Paths; +import java.nio.file.SimpleFileVisitor; +import java.nio.file.attribute.BasicFileAttributes; +import java.util.ArrayList; +import java.util.List; +import java.util.Map; +import java.util.concurrent.ConcurrentHashMap; +import lombok.AccessLevel; +import lombok.Getter; +import org.onap.policy.clamp.acm.participant.kubernetes.exception.ServiceException; +import org.onap.policy.clamp.acm.participant.kubernetes.models.ChartInfo; +import org.onap.policy.clamp.acm.participant.kubernetes.parameters.ParticipantK8sParameters; +import org.onap.policy.common.utils.coder.CoderException; +import org.onap.policy.common.utils.coder.StandardCoder; +import org.onap.policy.models.tosca.authorative.concepts.ToscaConceptIdentifier; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.stereotype.Component; +import org.springframework.util.FileSystemUtils; +import org.springframework.web.multipart.MultipartFile; + +@Component +public class ChartStore { + private static final Logger LOGGER = LoggerFactory.getLogger(MethodHandles.lookup().lookupClass()); + + private static final StandardCoder STANDARD_CODER = new StandardCoder(); + + private final ParticipantK8sParameters participantK8sParameters; + + // ChartStore map contains chart name as key & ChartInfo as value. + @Getter(AccessLevel.PACKAGE) + private Map localChartMap = new ConcurrentHashMap<>(); + + /** + * Constructor method. + */ + public ChartStore(ParticipantK8sParameters participantK8sParameters) { + this.participantK8sParameters = participantK8sParameters; + this.restoreFromLocalFileSystem(); + } + + /** + * Get local helm chart file. + * + * @param chart ChartInfo + * @return the chart file. + */ + public File getHelmChartFile(ChartInfo chart) { + var appPath = getAppPath(chart.getChartId()); + return new File(appPath.toFile(), chart.getChartId().getName()); + } + + /** + * Get the override yaml file. + * + * @param chart ChartInfo + * @return the override yaml file + */ + public File getOverrideFile(ChartInfo chart) { + var appPath = getAppPath(chart.getChartId()); + return new File(appPath.toFile(), "values.yaml"); + } + + + /** + * Saves the helm chart. + * + * @param chartInfo chartInfo + * @param chartFile helm chart file. + * @param overrideFile override file. + * @return chart + * @throws IOException incase of IO error + * @throws ServiceException incase of error. + */ + public synchronized ChartInfo saveChart(ChartInfo chartInfo, MultipartFile chartFile, MultipartFile overrideFile) + throws IOException, ServiceException { + if (localChartMap.containsKey(key(chartInfo))) { + throw new ServiceException("Chart already exist"); + } + var appPath = getAppPath(chartInfo.getChartId()); + Files.createDirectories(appPath); + + chartFile.transferTo(getHelmChartFile(chartInfo)); + if (overrideFile != null) { + overrideFile.transferTo(getOverrideFile(chartInfo)); + } + + localChartMap.put(key(chartInfo), chartInfo); + storeChartInFile(chartInfo); + return chartInfo; + } + + /** + * Get the chart info. + * + * @param name name of the chart + * @param version version of the chart + * @return chart + */ + public synchronized ChartInfo getChart(String name, String version) { + return localChartMap.get(key(name, version)); + } + + /** + * Get all the charts installed. + * + * @return list of charts. + */ + public synchronized List getAllCharts() { + return new ArrayList<>(localChartMap.values()); + } + + /** + * Delete a chart. + * + * @param chart chart info + */ + public synchronized void deleteChart(ChartInfo chart) { + var appPath = getAppPath(chart.getChartId()); + try { + FileSystemUtils.deleteRecursively(appPath); + } catch (IOException exc) { + LOGGER.warn("Could not delete chart from local file system : {}", appPath, exc); + } + + localChartMap.remove(key(chart)); + } + + /** + * Fetch the local chart directory of specific chart. + * + * @param chartId Id of the chart + * @return path + */ + public Path getAppPath(ToscaConceptIdentifier chartId) { + return Path.of(participantK8sParameters.getLocalChartDirectory(), chartId.getName(), chartId.getVersion()); + } + + private void storeChartInFile(ChartInfo chart) { + try (var out = new PrintStream(new FileOutputStream(getFile(chart)))) { + out.print(STANDARD_CODER.encode(chart)); + } catch (Exception exc) { + LOGGER.warn("Could not store chart: {}", chart.getChartId(), exc); + } + } + + private File getFile(ChartInfo chart) { + var appPath = getAppPath(chart.getChartId()).toString(); + return Path.of(appPath, participantK8sParameters.getInfoFileName()).toFile(); + } + + private synchronized void restoreFromLocalFileSystem() { + try { + var localChartDirectoryPath = Paths.get(participantK8sParameters.getLocalChartDirectory()); + Files.createDirectories(localChartDirectoryPath); + restoreFromLocalFileSystem(localChartDirectoryPath); + } catch (Exception ioe) { + LOGGER.warn("Could not restore charts from local file system", ioe); + } + } + + private synchronized void restoreFromLocalFileSystem(Path localChartDirectoryPath) + throws IOException { + + Files.walkFileTree(localChartDirectoryPath, new SimpleFileVisitor() { + @Override + public FileVisitResult visitFile(Path localChartFile, BasicFileAttributes attrs) throws IOException { + try { + // Decode only the json file excluding the helm charts + if (localChartFile.endsWith(participantK8sParameters.getInfoFileName())) { + ChartInfo chart = STANDARD_CODER.decode(localChartFile.toFile(), ChartInfo.class); + localChartMap.put(key(chart), chart); + } + return FileVisitResult.CONTINUE; + } catch (CoderException ce) { + throw new IOException("Error decoding chart file", ce); + } + } + }); + } + + private String key(ChartInfo chart) { + return key(chart.getChartId().getName(), chart.getChartId().getVersion()); + } + + private String key(String chartName, String chartVersion) { + return chartName + "_" + chartVersion; + } +} diff --git a/participant/participant-impl/participant-impl-kubernetes/src/main/java/org/onap/policy/clamp/controlloop/participant/kubernetes/Application.java b/participant/participant-impl/participant-impl-kubernetes/src/main/java/org/onap/policy/clamp/controlloop/participant/kubernetes/Application.java deleted file mode 100644 index 5d9d203fe..000000000 --- a/participant/participant-impl/participant-impl-kubernetes/src/main/java/org/onap/policy/clamp/controlloop/participant/kubernetes/Application.java +++ /dev/null @@ -1,45 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * Copyright (C) 2021 Nordix Foundation. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - * SPDX-License-Identifier: Apache-2.0 - * ============LICENSE_END========================================================= - */ - -package org.onap.policy.clamp.controlloop.participant.kubernetes; - -import org.springframework.boot.SpringApplication; -import org.springframework.boot.autoconfigure.SpringBootApplication; -import org.springframework.boot.context.properties.ConfigurationPropertiesScan; -import org.springframework.context.annotation.ComponentScan; - -/** - * Starter. - * - */ -@SpringBootApplication -@ComponentScan({"org.onap.policy.clamp.controlloop.participant.kubernetes", - "org.onap.policy.clamp.controlloop.participant.intermediary"}) -@ConfigurationPropertiesScan("org.onap.policy.clamp.controlloop.participant.kubernetes.parameters") -public class Application { - /** - * Main class. - * - * @param args args - */ - public static void main(String[] args) { - SpringApplication.run(Application.class, args); - } -} diff --git a/participant/participant-impl/participant-impl-kubernetes/src/main/java/org/onap/policy/clamp/controlloop/participant/kubernetes/configurations/ParticipantConfig.java b/participant/participant-impl/participant-impl-kubernetes/src/main/java/org/onap/policy/clamp/controlloop/participant/kubernetes/configurations/ParticipantConfig.java deleted file mode 100644 index 54627d557..000000000 --- a/participant/participant-impl/participant-impl-kubernetes/src/main/java/org/onap/policy/clamp/controlloop/participant/kubernetes/configurations/ParticipantConfig.java +++ /dev/null @@ -1,44 +0,0 @@ -/*- - * ========================LICENSE_START================================= - * Copyright (C) 2021 Nordix Foundation. All rights reserved. - * ====================================================================== - * Modifications Copyright (C) 2021 AT&T Intellectual Property. All rights reserved. - * ====================================================================== - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ========================LICENSE_END=================================== - */ - -package org.onap.policy.clamp.controlloop.participant.kubernetes.configurations; - -import org.springframework.context.annotation.Bean; -import org.springframework.context.annotation.Configuration; -import org.springframework.web.multipart.MultipartResolver; -import org.springframework.web.multipart.commons.CommonsMultipartResolver; - -/** - * Bean Factory class for helm client. - */ -@Configuration -public class ParticipantConfig { - - /** - * Method to create multipartResolver bean. - * @return MultipartResolver - */ - @Bean(name = "multipartResolver") - public MultipartResolver multipartResolver() { - var multipartResolver = new CommonsMultipartResolver(); - multipartResolver.setMaxUploadSize(100000); - return multipartResolver; - } -} diff --git a/participant/participant-impl/participant-impl-kubernetes/src/main/java/org/onap/policy/clamp/controlloop/participant/kubernetes/configurations/ParticipantIntermediaryConfig.java b/participant/participant-impl/participant-impl-kubernetes/src/main/java/org/onap/policy/clamp/controlloop/participant/kubernetes/configurations/ParticipantIntermediaryConfig.java deleted file mode 100644 index bfbed66b7..000000000 --- a/participant/participant-impl/participant-impl-kubernetes/src/main/java/org/onap/policy/clamp/controlloop/participant/kubernetes/configurations/ParticipantIntermediaryConfig.java +++ /dev/null @@ -1,43 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * Copyright (C) 2021 Nordix Foundation. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - * SPDX-License-Identifier: Apache-2.0 - * ============LICENSE_END========================================================= - */ - -package org.onap.policy.clamp.controlloop.participant.kubernetes.configurations; - -import org.onap.policy.clamp.controlloop.participant.intermediary.api.ParticipantIntermediaryApi; -import org.onap.policy.clamp.controlloop.participant.kubernetes.handler.ControlLoopElementHandler; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.context.annotation.Configuration; - -@Configuration -public class ParticipantIntermediaryConfig { - - /** - * Register ControlLoopElementListener. - * - * @param intermediaryApi the ParticipantIntermediaryApi - * @param clElementHandler the ControlLoop Element Handler - */ - @Autowired - public void registerControlLoopElementListener(ParticipantIntermediaryApi intermediaryApi, - ControlLoopElementHandler clElementHandler) { - intermediaryApi.registerControlLoopElementListener(clElementHandler); - clElementHandler.setIntermediaryApi(intermediaryApi); - } -} diff --git a/participant/participant-impl/participant-impl-kubernetes/src/main/java/org/onap/policy/clamp/controlloop/participant/kubernetes/configurations/SecurityConfig.java b/participant/participant-impl/participant-impl-kubernetes/src/main/java/org/onap/policy/clamp/controlloop/participant/kubernetes/configurations/SecurityConfig.java deleted file mode 100644 index 6b4fb0a75..000000000 --- a/participant/participant-impl/participant-impl-kubernetes/src/main/java/org/onap/policy/clamp/controlloop/participant/kubernetes/configurations/SecurityConfig.java +++ /dev/null @@ -1,45 +0,0 @@ -/*- - * ========================LICENSE_START================================= - * Copyright (C) 2021 Nordix Foundation. All rights reserved. - * ====================================================================== - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ========================LICENSE_END=================================== - */ - -package org.onap.policy.clamp.controlloop.participant.kubernetes.configurations; - -import org.springframework.beans.factory.annotation.Value; -import org.springframework.context.annotation.Configuration; -import org.springframework.security.config.annotation.web.builders.HttpSecurity; -import org.springframework.security.config.annotation.web.configuration.WebSecurityConfigurerAdapter; - -@Configuration -public class SecurityConfig extends WebSecurityConfigurerAdapter { - - @Value("${security.enable-csrf:true}") - private boolean csrfEnabled = true; - - @Override - protected void configure(HttpSecurity http) throws Exception { - // @formatter:off - http.authorizeRequests() - .antMatchers().authenticated() - .anyRequest().authenticated() - .and().httpBasic(); - // @formatter:on - - if (!csrfEnabled) { - http.csrf().disable(); - } - } -} diff --git a/participant/participant-impl/participant-impl-kubernetes/src/main/java/org/onap/policy/clamp/controlloop/participant/kubernetes/configurations/SpringFoxConfig.java b/participant/participant-impl/participant-impl-kubernetes/src/main/java/org/onap/policy/clamp/controlloop/participant/kubernetes/configurations/SpringFoxConfig.java deleted file mode 100644 index 09a497705..000000000 --- a/participant/participant-impl/participant-impl-kubernetes/src/main/java/org/onap/policy/clamp/controlloop/participant/kubernetes/configurations/SpringFoxConfig.java +++ /dev/null @@ -1,45 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * Copyright (C) 2021 Nordix Foundation. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - * SPDX-License-Identifier: Apache-2.0 - * ============LICENSE_END========================================================= - */ - -package org.onap.policy.clamp.controlloop.participant.kubernetes.configurations; - -import org.onap.policy.clamp.controlloop.participant.kubernetes.controller.ChartController; -import org.springframework.context.annotation.Bean; -import org.springframework.context.annotation.Configuration; -import springfox.documentation.builders.PathSelectors; -import springfox.documentation.builders.RequestHandlerSelectors; -import springfox.documentation.spi.DocumentationType; -import springfox.documentation.spring.web.plugins.Docket; - -@Configuration -public class SpringFoxConfig { - - /** - * Docket Spring Fox Config. - * - * @return Docket - */ - @Bean - public Docket api() { - return new Docket(DocumentationType.SWAGGER_2).select() - .apis(RequestHandlerSelectors.basePackage(ChartController.class.getPackageName())) - .paths(PathSelectors.any()).build(); - } -} diff --git a/participant/participant-impl/participant-impl-kubernetes/src/main/java/org/onap/policy/clamp/controlloop/participant/kubernetes/controller/ChartController.java b/participant/participant-impl/participant-impl-kubernetes/src/main/java/org/onap/policy/clamp/controlloop/participant/kubernetes/controller/ChartController.java deleted file mode 100644 index e2ccda4d5..000000000 --- a/participant/participant-impl/participant-impl-kubernetes/src/main/java/org/onap/policy/clamp/controlloop/participant/kubernetes/controller/ChartController.java +++ /dev/null @@ -1,195 +0,0 @@ -/*- - * ========================LICENSE_START================================= - * Copyright (C) 2021-2022 Nordix Foundation. All rights reserved. - * ====================================================================== - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ========================LICENSE_END=================================== - */ - -package org.onap.policy.clamp.controlloop.participant.kubernetes.controller; - -import io.swagger.annotations.Api; -import io.swagger.annotations.ApiOperation; -import io.swagger.annotations.ApiResponse; -import io.swagger.annotations.ApiResponses; -import java.io.IOException; -import java.util.ArrayList; -import org.onap.policy.clamp.controlloop.participant.kubernetes.exception.ServiceException; -import org.onap.policy.clamp.controlloop.participant.kubernetes.models.ChartInfo; -import org.onap.policy.clamp.controlloop.participant.kubernetes.models.ChartList; -import org.onap.policy.clamp.controlloop.participant.kubernetes.models.HelmRepository; -import org.onap.policy.clamp.controlloop.participant.kubernetes.models.InstallationInfo; -import org.onap.policy.clamp.controlloop.participant.kubernetes.service.ChartService; -import org.onap.policy.common.utils.coder.CoderException; -import org.onap.policy.common.utils.coder.StandardCoder; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.boot.autoconfigure.condition.ConditionalOnExpression; -import org.springframework.http.HttpStatus; -import org.springframework.http.MediaType; -import org.springframework.http.ResponseEntity; -import org.springframework.web.bind.annotation.DeleteMapping; -import org.springframework.web.bind.annotation.GetMapping; -import org.springframework.web.bind.annotation.PathVariable; -import org.springframework.web.bind.annotation.PostMapping; -import org.springframework.web.bind.annotation.RequestBody; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RequestParam; -import org.springframework.web.bind.annotation.RequestPart; -import org.springframework.web.bind.annotation.RestController; -import org.springframework.web.multipart.MultipartFile; - -@RestController("chartController") -@ConditionalOnExpression("${chart.api.enabled:false}") -@RequestMapping("helm") -@Api(tags = {"k8s-participant"}) -public class ChartController { - - @Autowired - private ChartService chartService; - - private static final StandardCoder CODER = new StandardCoder(); - - /** - * REST endpoint to get all the charts. - * - * @return List of charts installed - */ - @GetMapping(path = "/charts", produces = MediaType.APPLICATION_JSON_VALUE) - @ApiOperation(value = "Return all Charts") - @ApiResponses(value = {@ApiResponse(code = 200, message = "chart List")}) - public ResponseEntity getAllCharts() { - return new ResponseEntity<>(ChartList.builder().charts(new ArrayList<>(chartService.getAllCharts())).build(), - HttpStatus.OK); - } - - /** - * REST endpoint to install a helm chart. - * - * @param info Info of the chart to be installed - * @return Status of the install operation - * @throws ServiceException in case of error - * @throws IOException in case of IO error - */ - @PostMapping(path = "/install", consumes = MediaType.APPLICATION_JSON_VALUE, - produces = MediaType.APPLICATION_JSON_VALUE) - @ApiOperation(value = "Install the chart") - @ApiResponses(value = {@ApiResponse(code = 201, message = "chart Installed")}) - public ResponseEntity installChart(@RequestBody InstallationInfo info) - throws ServiceException, IOException { - ChartInfo chart = chartService.getChart(info.getName(), info.getVersion()); - if (chart == null) { - return new ResponseEntity<>(HttpStatus.NOT_FOUND); - } - - chartService.installChart(chart); - return new ResponseEntity<>(HttpStatus.CREATED); - } - - /** - * REST endpoint to uninstall a specific chart. - * - * @param name name of the chart - * @param version version of the chart - * @return Status of operation - * @throws ServiceException in case of error. - */ - @DeleteMapping(path = "/uninstall/{name}/{version}", produces = MediaType.APPLICATION_JSON_VALUE) - @ApiOperation(value = "Uninstall the Chart") - @ApiResponses(value = {@ApiResponse(code = 201, message = "chart Uninstalled")}) - public ResponseEntity uninstallChart(@PathVariable("name") String name, - @PathVariable("version") String version) throws ServiceException { - ChartInfo chart = chartService.getChart(name, version); - if (chart == null) { - return new ResponseEntity<>(HttpStatus.NOT_FOUND); - } - - chartService.uninstallChart(chart); - return new ResponseEntity<>(HttpStatus.NO_CONTENT); - } - - /** - * REST endpoint to onboard a chart. - * - * @param chartFile Multipart file for the helm chart - * @param infoJson AppInfo of the chart - * @param overrideFile the file for overriding the chart - * @return Status of onboard operation - * @throws ServiceException in case of error - * @throws IOException in case of IO error - */ - @PostMapping(path = "/onboard/chart", consumes = MediaType.MULTIPART_FORM_DATA_VALUE, - produces = MediaType.APPLICATION_JSON_VALUE) - @ApiOperation(value = "Onboard the Chart") - @ApiResponses(value = {@ApiResponse(code = 201, message = "Chart Onboarded")}) - public ResponseEntity onboardChart(@RequestPart("chart") MultipartFile chartFile, - @RequestParam(name = "values", required = false) MultipartFile overrideFile, - @RequestParam("info") String infoJson) throws ServiceException, IOException { - - ChartInfo info; - try { - info = CODER.decode(infoJson, ChartInfo.class); - } catch (CoderException e) { - throw new ServiceException("Error parsing the chart information", e); - } - - chartService.saveChart(info, chartFile, overrideFile); - return new ResponseEntity<>(HttpStatus.OK); - } - - /** - * REST endpoint to delete a specific helm chart. - * - * @param name name of the chart - * @param version version of the chart - * @return Status of operation - */ - @DeleteMapping(path = "/chart/{name}/{version}") - @ApiOperation(value = "Delete the chart") - @ApiResponses(value = {@ApiResponse(code = 204, message = "Chart Deleted")}) - public ResponseEntity deleteChart(@PathVariable("name") String name, - @PathVariable("version") String version) { - - ChartInfo chart = chartService.getChart(name, version); - if (chart == null) { - return new ResponseEntity<>(HttpStatus.NOT_FOUND); - } - - chartService.deleteChart(chart); - return new ResponseEntity<>(HttpStatus.NO_CONTENT); - } - - /** - * REST endpoint to configure a helm Repository. - * - * @param repo Helm repository to be configured - * @return Status of the operation - * @throws ServiceException in case of error - * @throws IOException in case of IO error - */ - @PostMapping(path = "/repo", consumes = MediaType.APPLICATION_JSON_VALUE, - produces = MediaType.APPLICATION_JSON_VALUE) - @ApiOperation(value = "Configure helm repository") - @ApiResponses(value = {@ApiResponse(code = 201, message = "Repository added")}) - public ResponseEntity configureRepo(@RequestBody String repo) - throws ServiceException, IOException { - HelmRepository repository; - try { - repository = CODER.decode(repo, HelmRepository.class); - } catch (CoderException e) { - throw new ServiceException("Error parsing the repository information", e); - } - chartService.configureRepository(repository); - - return new ResponseEntity<>(HttpStatus.CREATED); - } -} diff --git a/participant/participant-impl/participant-impl-kubernetes/src/main/java/org/onap/policy/clamp/controlloop/participant/kubernetes/exception/ServiceException.java b/participant/participant-impl/participant-impl-kubernetes/src/main/java/org/onap/policy/clamp/controlloop/participant/kubernetes/exception/ServiceException.java deleted file mode 100644 index 9a825cf75..000000000 --- a/participant/participant-impl/participant-impl-kubernetes/src/main/java/org/onap/policy/clamp/controlloop/participant/kubernetes/exception/ServiceException.java +++ /dev/null @@ -1,32 +0,0 @@ -/*- - * ========================LICENSE_START================================= - * Copyright (C) 2021 Nordix Foundation. All rights reserved. - * ====================================================================== - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ========================LICENSE_END=================================== - */ - -package org.onap.policy.clamp.controlloop.participant.kubernetes.exception; - -public class ServiceException extends Exception { - - private static final long serialVersionUID = 6810785674716590648L; - - public ServiceException(String message) { - super(message); - } - - public ServiceException(String message, Exception originalException) { - super(message, originalException); - } -} diff --git a/participant/participant-impl/participant-impl-kubernetes/src/main/java/org/onap/policy/clamp/controlloop/participant/kubernetes/handler/ControlLoopElementHandler.java b/participant/participant-impl/participant-impl-kubernetes/src/main/java/org/onap/policy/clamp/controlloop/participant/kubernetes/handler/ControlLoopElementHandler.java deleted file mode 100644 index a8a746254..000000000 --- a/participant/participant-impl/participant-impl-kubernetes/src/main/java/org/onap/policy/clamp/controlloop/participant/kubernetes/handler/ControlLoopElementHandler.java +++ /dev/null @@ -1,196 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * Copyright (C) 2021-2022 Nordix Foundation. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - * SPDX-License-Identifier: Apache-2.0 - * ============LICENSE_END========================================================= - */ - -package org.onap.policy.clamp.controlloop.participant.kubernetes.handler; - -import java.io.IOException; -import java.lang.invoke.MethodHandles; -import java.time.Instant; -import java.util.HashMap; -import java.util.Map; -import java.util.UUID; -import java.util.concurrent.ConcurrentHashMap; -import java.util.concurrent.ExecutionException; -import java.util.concurrent.ExecutorService; -import java.util.concurrent.Executors; -import java.util.concurrent.Future; -import lombok.AccessLevel; -import lombok.Getter; -import lombok.Setter; -import org.onap.policy.clamp.controlloop.models.controlloop.concepts.ClElementStatistics; -import org.onap.policy.clamp.controlloop.models.controlloop.concepts.ControlLoopElement; -import org.onap.policy.clamp.controlloop.models.controlloop.concepts.ControlLoopOrderedState; -import org.onap.policy.clamp.controlloop.models.controlloop.concepts.ControlLoopState; -import org.onap.policy.clamp.controlloop.models.messages.dmaap.participant.ParticipantMessageType; -import org.onap.policy.clamp.controlloop.participant.intermediary.api.ControlLoopElementListener; -import org.onap.policy.clamp.controlloop.participant.intermediary.api.ParticipantIntermediaryApi; -import org.onap.policy.clamp.controlloop.participant.kubernetes.exception.ServiceException; -import org.onap.policy.clamp.controlloop.participant.kubernetes.helm.PodStatusValidator; -import org.onap.policy.clamp.controlloop.participant.kubernetes.models.ChartInfo; -import org.onap.policy.clamp.controlloop.participant.kubernetes.service.ChartService; -import org.onap.policy.common.utils.coder.Coder; -import org.onap.policy.common.utils.coder.CoderException; -import org.onap.policy.common.utils.coder.StandardCoder; -import org.onap.policy.models.base.PfModelException; -import org.onap.policy.models.tosca.authorative.concepts.ToscaConceptIdentifier; -import org.onap.policy.models.tosca.authorative.concepts.ToscaNodeTemplate; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.stereotype.Component; - -/** - * This class handles implementation of controlLoopElement updates. - */ -@Component -public class ControlLoopElementHandler implements ControlLoopElementListener { - private static final Logger LOGGER = LoggerFactory.getLogger(MethodHandles.lookup().lookupClass()); - - private ExecutorService executor = Executors.newFixedThreadPool(Runtime.getRuntime().availableProcessors()); - - // Map of helm installation and the status of corresponding pods - @Getter - private static Map> podStatusMap = new ConcurrentHashMap<>(); - private static final Coder CODER = new StandardCoder(); - - @Autowired - private ChartService chartService; - - @Setter - private ParticipantIntermediaryApi intermediaryApi; - - // Map of CLElement Id and installed Helm charts - @Getter(AccessLevel.PACKAGE) - private final Map chartMap = new HashMap<>(); - - // Default thread config values - private static class ThreadConfig { - private int uninitializedToPassiveTimeout = 60; - private int podStatusCheckInterval = 30; - } - - /** - * Callback method to handle a control loop element state change. - * - * @param controlLoopElementId the ID of the control loop element - * @param currentState the current state of the control loop element - * @param newState the state to which the control loop element is changing to - */ - @Override - public synchronized void controlLoopElementStateChange(ToscaConceptIdentifier controlLoopId, - UUID controlLoopElementId, ControlLoopState currentState, ControlLoopOrderedState newState) { - switch (newState) { - case UNINITIALISED: - ChartInfo chart = chartMap.get(controlLoopElementId); - if (chart != null) { - LOGGER.info("Helm deployment to be deleted {} ", chart.getReleaseName()); - try { - chartService.uninstallChart(chart); - intermediaryApi.updateControlLoopElementState(controlLoopId, - controlLoopElementId, newState, ControlLoopState.UNINITIALISED, - ParticipantMessageType.CONTROL_LOOP_STATE_CHANGE); - chartMap.remove(controlLoopElementId); - podStatusMap.remove(chart.getReleaseName()); - } catch (ServiceException se) { - LOGGER.warn("Deletion of Helm deployment failed", se); - } - } - break; - case PASSIVE: - intermediaryApi.updateControlLoopElementState(controlLoopId, - controlLoopElementId, newState, ControlLoopState.PASSIVE, - ParticipantMessageType.CONTROL_LOOP_STATE_CHANGE); - break; - case RUNNING: - intermediaryApi.updateControlLoopElementState(controlLoopId, - controlLoopElementId, newState, ControlLoopState.RUNNING, - ParticipantMessageType.CONTROL_LOOP_STATE_CHANGE); - break; - default: - LOGGER.warn("Cannot transition from state {} to state {}", currentState, newState); - break; - } - } - - - /** - * Callback method to handle an update on a control loop element. - * - * @param element the information on the control loop element - * @param nodeTemplate toscaNodeTemplate - * @throws PfModelException in case of an exception - */ - @Override - public synchronized void controlLoopElementUpdate(ToscaConceptIdentifier controlLoopId, - ControlLoopElement element, ToscaNodeTemplate nodeTemplate) throws PfModelException { - @SuppressWarnings("unchecked") - Map chartData = - (Map) nodeTemplate.getProperties().get("chart"); - - LOGGER.info("Installation request received for the Helm Chart {} ", chartData); - try { - var chartInfo = CODER.convert(chartData, ChartInfo.class); - chartService.installChart(chartInfo); - chartMap.put(element.getId(), chartInfo); - - var config = CODER.convert(nodeTemplate.getProperties(), ThreadConfig.class); - checkPodStatus(controlLoopId, element.getId(), chartInfo, config.uninitializedToPassiveTimeout, - config.podStatusCheckInterval); - - } catch (ServiceException | CoderException | IOException | ExecutionException - | InterruptedException e) { - LOGGER.warn("Installation of Helm chart failed", e); - } - } - - /** - * Invoke a new thread to check the status of deployed pods. - * @param chart ChartInfo - */ - public void checkPodStatus(ToscaConceptIdentifier controlLoopId, UUID elementId, - ChartInfo chart, int timeout, int podStatusCheckInterval) throws ExecutionException, InterruptedException { - // Invoke runnable thread to check pod status - Future result = executor.submit(new PodStatusValidator(chart, timeout, - podStatusCheckInterval), "Done"); - if (!result.get().isEmpty()) { - LOGGER.info("Pod Status Validator Completed: {}", result.isDone()); - intermediaryApi.updateControlLoopElementState(controlLoopId, elementId, - ControlLoopOrderedState.PASSIVE, ControlLoopState.PASSIVE, - ParticipantMessageType.CONTROL_LOOP_STATE_CHANGE); - } - } - - /** - * Overridden method. - * - * @param controlLoopElementId controlLoopElement id - * @throws PfModelException in case of error - */ - @Override - public synchronized void handleStatistics(UUID controlLoopElementId) throws PfModelException { - var clElement = intermediaryApi.getControlLoopElement(controlLoopElementId); - if (clElement != null) { - var clElementStatistics = new ClElementStatistics(); - clElementStatistics.setControlLoopState(clElement.getState()); - clElementStatistics.setTimeStamp(Instant.now()); - intermediaryApi.updateControlLoopElementStatistics(controlLoopElementId, clElementStatistics); - } - } -} diff --git a/participant/participant-impl/participant-impl-kubernetes/src/main/java/org/onap/policy/clamp/controlloop/participant/kubernetes/helm/HelmClient.java b/participant/participant-impl/participant-impl-kubernetes/src/main/java/org/onap/policy/clamp/controlloop/participant/kubernetes/helm/HelmClient.java deleted file mode 100644 index 6133c7ebd..000000000 --- a/participant/participant-impl/participant-impl-kubernetes/src/main/java/org/onap/policy/clamp/controlloop/participant/kubernetes/helm/HelmClient.java +++ /dev/null @@ -1,279 +0,0 @@ -/*- - * ========================LICENSE_START================================= - * Copyright (C) 2021-2022 Nordix Foundation. All rights reserved. - * ====================================================================== - * Modifications Copyright (C) 2021 AT&T Intellectual Property. All rights reserved. - * ====================================================================== - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ========================LICENSE_END=================================== - */ - -package org.onap.policy.clamp.controlloop.participant.kubernetes.helm; - -import java.io.File; -import java.io.IOException; -import java.lang.invoke.MethodHandles; -import java.nio.charset.StandardCharsets; -import java.util.ArrayList; -import java.util.List; -import java.util.Map; -import org.apache.commons.io.IOUtils; -import org.onap.policy.clamp.controlloop.participant.kubernetes.exception.ServiceException; -import org.onap.policy.clamp.controlloop.participant.kubernetes.models.ChartInfo; -import org.onap.policy.clamp.controlloop.participant.kubernetes.models.HelmRepository; -import org.onap.policy.clamp.controlloop.participant.kubernetes.service.ChartStore; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.stereotype.Component; - -/** - * Client to talk with Helm cli. Supports helm3 + version - */ -@Component -public class HelmClient { - - @Autowired - private ChartStore chartStore; - - private static final Logger logger = LoggerFactory.getLogger(MethodHandles.lookup().lookupClass()); - private static final String PATH_DELIMITER = "/"; - - /** - * Install a chart. - * - * @param chart name and version. - * @throws ServiceException incase of error - */ - public void installChart(ChartInfo chart) throws ServiceException { - if (! checkNamespaceExists(chart.getNamespace())) { - var processBuilder = prepareCreateNamespaceCommand(chart.getNamespace()); - executeCommand(processBuilder); - } - var processBuilder = prepareInstallCommand(chart); - logger.info("Installing helm chart {} from the repository {} ", chart.getChartId().getName(), - chart.getRepository().getRepoName()); - executeCommand(processBuilder); - logger.info("Chart {} installed successfully", chart.getChartId().getName()); - } - - /** - * Add repository if doesn't exist. - * @param repo HelmRepository - * @throws ServiceException incase of error - */ - public void addRepository(HelmRepository repo) throws ServiceException { - String output = executeCommand(prepareVerifyRepoCommand(repo)); - if (output.isEmpty()) { - logger.info("Adding repository to helm client"); - executeCommand(prepareRepoAddCommand(repo)); - logger.debug("Added repository {} to the helm client", repo.getRepoName()); - } else { - logger.info("Repository already exists"); - } - } - - - /** - * Finds helm chart repository for the chart. - * - * @param chart ChartInfo. - * @return the chart repository as a string - * @throws ServiceException in case of error - * @throws IOException in case of IO errors - */ - public String findChartRepository(ChartInfo chart) throws ServiceException, IOException { - if (updateHelmRepo()) { - String repository = verifyConfiguredRepo(chart); - if (repository != null) { - logger.info("Helm chart located in the repository {} ", repository); - return repository; - } - } - var localHelmChartDir = chartStore.getAppPath(chart.getChartId()).toString(); - logger.info("Chart not found in helm repositories, verifying local repo {} ", localHelmChartDir); - if (verifyLocalHelmRepo(new File(localHelmChartDir + PATH_DELIMITER + chart.getChartId().getName()))) { - return localHelmChartDir; - } - return null; - } - - /** - * Verify helm chart in configured repositories. - * @param chart chartInfo - * @return repo name - * @throws IOException incase of error - * @throws ServiceException incase of error - */ - public String verifyConfiguredRepo(ChartInfo chart) throws IOException, ServiceException { - logger.info("Looking for helm chart {} in all the configured helm repositories", chart.getChartId().getName()); - String repository = null; - var builder = helmRepoVerifyCommand(chart.getChartId().getName()); - String output = executeCommand(builder); - repository = verifyOutput(output, chart.getChartId().getName()); - return repository; - } - - /** - * Uninstall a chart. - * - * @param chart name and version. - * @throws ServiceException incase of error - */ - public void uninstallChart(ChartInfo chart) throws ServiceException { - executeCommand(prepareUnInstallCommand(chart)); - } - - - /** - * Execute helm cli bash commands . - * @param processBuilder processbuilder - * @return string output - * @throws ServiceException incase of error. - */ - public static String executeCommand(ProcessBuilder processBuilder) throws ServiceException { - var commandStr = toString(processBuilder); - - try { - var process = processBuilder.start(); - process.waitFor(); - int exitValue = process.exitValue(); - - if (exitValue != 0) { - var error = IOUtils.toString(process.getErrorStream(), StandardCharsets.UTF_8); - if (! error.isEmpty()) { - throw new ServiceException("Command execution failed: " + commandStr + " " + error); - } - } - - var output = IOUtils.toString(process.getInputStream(), StandardCharsets.UTF_8); - logger.debug("Command <{}> execution, output: {}", commandStr, output); - return output; - - } catch (InterruptedException ie) { - Thread.currentThread().interrupt(); - throw new ServiceException("Failed to execute the Command: " + commandStr + ", the command was interrupted", - ie); - } catch (Exception exc) { - throw new ServiceException("Failed to execute the Command: " + commandStr, exc); - } - } - - private boolean checkNamespaceExists(String namespace) throws ServiceException { - logger.info("Check if namespace {} exists on the cluster", namespace); - String output = executeCommand(prepareVerifyNamespaceCommand(namespace)); - return !output.isEmpty(); - } - - private String verifyOutput(String output, String value) { - for (var line: output.split("\\R")) { - if (line.contains(value)) { - return line.split("/")[0]; - } - } - return null; - } - - private ProcessBuilder prepareRepoAddCommand(HelmRepository repo) { - var url = repo.getProtocol() + "://" + repo.getAddress(); - if (repo.getPort() != null) { - url = url + ":" + repo.getPort(); - } - // @formatter:off - List helmArguments = new ArrayList<>( - List.of( - "helm", - "repo", - "add", repo.getRepoName(), url - )); - if (repo.getUserName() != null && repo.getPassword() != null) { - helmArguments.addAll(List.of("--username", repo.getUserName(), "--password", repo.getPassword())); - } - return new ProcessBuilder().command(helmArguments); - } - - private ProcessBuilder prepareVerifyRepoCommand(HelmRepository repo) { - List helmArguments = List.of("sh", "-c", "helm repo ls | grep " + repo.getRepoName()); - return new ProcessBuilder().command(helmArguments); - } - - private ProcessBuilder prepareVerifyNamespaceCommand(String namespace) { - List helmArguments = List.of("sh", "-c", "kubectl get ns | grep " + namespace); - return new ProcessBuilder().command(helmArguments); - } - - private ProcessBuilder prepareInstallCommand(ChartInfo chart) { - - // @formatter:off - List helmArguments = new ArrayList<>( - List.of( - "helm", - "install", chart.getReleaseName(), chart.getRepository().getRepoName() + "/" - + chart.getChartId().getName(), - "--version", chart.getChartId().getVersion(), - "--namespace", chart.getNamespace() - )); - // @formatter:on - - // Verify if values.yaml/override parameters available for the chart - var localOverrideYaml = chartStore.getOverrideFile(chart); - - if (verifyLocalHelmRepo(localOverrideYaml)) { - logger.info("Override yaml available for the helm chart"); - helmArguments.addAll(List.of("--values", localOverrideYaml.getPath())); - } - - if (chart.getOverrideParams() != null) { - for (Map.Entry entry : chart.getOverrideParams().entrySet()) { - helmArguments.addAll(List.of("--set", entry.getKey() + "=" + entry.getValue())); - } - } - return new ProcessBuilder().command(helmArguments); - } - - private ProcessBuilder prepareUnInstallCommand(ChartInfo chart) { - return new ProcessBuilder("helm", "delete", chart.getReleaseName(), "--namespace", - chart.getNamespace()); - } - - private ProcessBuilder prepareCreateNamespaceCommand(String namespace) { - return new ProcessBuilder().command("kubectl", "create", "namespace", namespace); - } - - private ProcessBuilder helmRepoVerifyCommand(String chartName) { - return new ProcessBuilder().command("sh", "-c", "helm search repo | grep " + chartName); - } - - - private boolean updateHelmRepo() { - try { - logger.info("Updating local helm repositories before verifying the chart"); - executeCommand(new ProcessBuilder().command("helm", "repo", "update")); - logger.debug("Helm repositories updated successfully"); - } catch (ServiceException e) { - logger.error("Failed to update the helm repo: ", e); - return false; - } - return true; - - - } - - private boolean verifyLocalHelmRepo(File localFile) { - return localFile.exists(); - } - - protected static String toString(ProcessBuilder processBuilder) { - return String.join(" ", processBuilder.command()); - } -} diff --git a/participant/participant-impl/participant-impl-kubernetes/src/main/java/org/onap/policy/clamp/controlloop/participant/kubernetes/helm/PodStatusValidator.java b/participant/participant-impl/participant-impl-kubernetes/src/main/java/org/onap/policy/clamp/controlloop/participant/kubernetes/helm/PodStatusValidator.java deleted file mode 100644 index d55fd6658..000000000 --- a/participant/participant-impl/participant-impl-kubernetes/src/main/java/org/onap/policy/clamp/controlloop/participant/kubernetes/helm/PodStatusValidator.java +++ /dev/null @@ -1,119 +0,0 @@ -/*- - * ========================LICENSE_START================================= - * Copyright (C) 2021 Nordix Foundation. All rights reserved. - * ====================================================================== - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ========================LICENSE_END=================================== - */ - -package org.onap.policy.clamp.controlloop.participant.kubernetes.helm; - -import java.io.BufferedReader; -import java.io.IOException; -import java.io.InputStreamReader; -import java.lang.invoke.MethodHandles; -import java.nio.charset.StandardCharsets; -import java.util.HashMap; -import java.util.Map; -import lombok.SneakyThrows; -import org.apache.commons.io.IOUtils; -import org.onap.policy.clamp.controlloop.participant.kubernetes.exception.ServiceException; -import org.onap.policy.clamp.controlloop.participant.kubernetes.handler.ControlLoopElementHandler; -import org.onap.policy.clamp.controlloop.participant.kubernetes.models.ChartInfo; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - - -public class PodStatusValidator implements Runnable { - - private static final Logger logger = LoggerFactory.getLogger(MethodHandles.lookup().lookupClass()); - - private final int statusCheckInterval; - - //Timeout for the thread to exit. - private final int timeout; - - private ChartInfo chart; - - /** - * Constructor for PodStatusValidator. - * @param chart chartInfo - * @param timeout timeout for the thread to exit - * @param statusCheckInterval Interval to check pod status - */ - public PodStatusValidator(ChartInfo chart, int timeout, int statusCheckInterval) { - this.chart = chart; - this.timeout = timeout; - this.statusCheckInterval = statusCheckInterval; - } - - - @SneakyThrows - @Override - public void run() { - logger.info("Polling the status of deployed pods for the chart {}", chart.getChartId().getName()); - Map podStatusMap; - String output = null; - var isVerified = false; - long endTime = System.currentTimeMillis() + (timeout * 1000L); - - while (!isVerified && System.currentTimeMillis() < endTime) { - try { - output = HelmClient.executeCommand(verifyPodStatusCommand(chart)); - podStatusMap = mapPodStatus(output); - isVerified = podStatusMap.values() - .stream() - .allMatch("Running"::equals); - if (! isVerified) { - logger.info("Waiting for the pods to be active for the chart {}", chart.getChartId().getName()); - podStatusMap.forEach((key, value) -> logger.info("Pod: {} , state: {}", key, value)); - ControlLoopElementHandler.getPodStatusMap().put(chart.getReleaseName(), podStatusMap); - // Recheck status of pods in specific intervals. - Thread.sleep(statusCheckInterval * 1000L); - } else { - logger.info("All pods are in running state for the helm chart {}", chart.getChartId().getName()); - ControlLoopElementHandler.getPodStatusMap().put(chart.getReleaseName(), podStatusMap); - } - } catch (ServiceException | IOException e) { - throw new ServiceException("Error verifying the status of the pod. Exiting", e); - } - } - } - - private ProcessBuilder verifyPodStatusCommand(ChartInfo chart) { - String podName = chart.getReleaseName() + "-" + chart.getChartId().getName(); - String cmd = "kubectl get pods --namespace " + chart.getNamespace() + " | grep " + podName; - return new ProcessBuilder("sh", "-c", cmd); - } - - - private Map mapPodStatus(String output) throws IOException, ServiceException { - Map podStatusMap = new HashMap<>(); - try (var reader = new BufferedReader(new InputStreamReader(IOUtils.toInputStream(output, - StandardCharsets.UTF_8)))) { - var line = reader.readLine(); - while (line != null) { - if (line.contains(chart.getChartId().getName())) { - var result = line.split("\\s+"); - podStatusMap.put(result[0], result[2]); - } - line = reader.readLine(); - } - } - if (!podStatusMap.isEmpty()) { - return podStatusMap; - } else { - throw new ServiceException("Status of Pod is empty"); - } - } -} diff --git a/participant/participant-impl/participant-impl-kubernetes/src/main/java/org/onap/policy/clamp/controlloop/participant/kubernetes/models/ChartInfo.java b/participant/participant-impl/participant-impl-kubernetes/src/main/java/org/onap/policy/clamp/controlloop/participant/kubernetes/models/ChartInfo.java deleted file mode 100644 index 5cbc203ec..000000000 --- a/participant/participant-impl/participant-impl-kubernetes/src/main/java/org/onap/policy/clamp/controlloop/participant/kubernetes/models/ChartInfo.java +++ /dev/null @@ -1,44 +0,0 @@ -/*- - * ========================LICENSE_START================================= - * Copyright (C) 2021 Nordix Foundation. All rights reserved. - * ====================================================================== - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ========================LICENSE_END=================================== - */ - -package org.onap.policy.clamp.controlloop.participant.kubernetes.models; - -import java.util.Map; -import lombok.Data; -import lombok.NonNull; -import lombok.RequiredArgsConstructor; -import org.onap.policy.models.tosca.authorative.concepts.ToscaConceptIdentifier; - -@Data -@RequiredArgsConstructor -public class ChartInfo { - - @NonNull - private String releaseName; - - @NonNull - private ToscaConceptIdentifier chartId; - - @NonNull - private String namespace; - - private HelmRepository repository; - - private Map overrideParams; - -} diff --git a/participant/participant-impl/participant-impl-kubernetes/src/main/java/org/onap/policy/clamp/controlloop/participant/kubernetes/models/ChartList.java b/participant/participant-impl/participant-impl-kubernetes/src/main/java/org/onap/policy/clamp/controlloop/participant/kubernetes/models/ChartList.java deleted file mode 100644 index 7f46bbde5..000000000 --- a/participant/participant-impl/participant-impl-kubernetes/src/main/java/org/onap/policy/clamp/controlloop/participant/kubernetes/models/ChartList.java +++ /dev/null @@ -1,31 +0,0 @@ -/*- - * ========================LICENSE_START================================= - * Copyright (C) 2021 Nordix Foundation. All rights reserved. - * ====================================================================== - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ========================LICENSE_END=================================== - */ - -package org.onap.policy.clamp.controlloop.participant.kubernetes.models; - -import java.util.List; -import lombok.Builder; -import lombok.Getter; -import lombok.Setter; - -@Getter -@Setter -@Builder -public class ChartList { - private List charts; -} diff --git a/participant/participant-impl/participant-impl-kubernetes/src/main/java/org/onap/policy/clamp/controlloop/participant/kubernetes/models/HelmRepository.java b/participant/participant-impl/participant-impl-kubernetes/src/main/java/org/onap/policy/clamp/controlloop/participant/kubernetes/models/HelmRepository.java deleted file mode 100644 index a495c7b5c..000000000 --- a/participant/participant-impl/participant-impl-kubernetes/src/main/java/org/onap/policy/clamp/controlloop/participant/kubernetes/models/HelmRepository.java +++ /dev/null @@ -1,39 +0,0 @@ -/*- - * ========================LICENSE_START================================= - * Copyright (C) 2021 Nordix Foundation. All rights reserved. - * ====================================================================== - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ========================LICENSE_END=================================== - */ - -package org.onap.policy.clamp.controlloop.participant.kubernetes.models; - -import lombok.Builder; -import lombok.Data; - -@Data -@Builder -public class HelmRepository { - - private String repoName; - - private String protocol; - - private String address; - - private String port; - - private String userName; - - private String password; -} diff --git a/participant/participant-impl/participant-impl-kubernetes/src/main/java/org/onap/policy/clamp/controlloop/participant/kubernetes/models/InstallationInfo.java b/participant/participant-impl/participant-impl-kubernetes/src/main/java/org/onap/policy/clamp/controlloop/participant/kubernetes/models/InstallationInfo.java deleted file mode 100644 index b21e93a01..000000000 --- a/participant/participant-impl/participant-impl-kubernetes/src/main/java/org/onap/policy/clamp/controlloop/participant/kubernetes/models/InstallationInfo.java +++ /dev/null @@ -1,29 +0,0 @@ -/*- - * ========================LICENSE_START================================= - * Copyright (C) 2021 Nordix Foundation. All rights reserved. - * ====================================================================== - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ========================LICENSE_END=================================== - */ - -package org.onap.policy.clamp.controlloop.participant.kubernetes.models; - -import lombok.Getter; -import org.immutables.gson.Gson; - -@Getter -@Gson.TypeAdapters -public class InstallationInfo { - private String name; - private String version; -} diff --git a/participant/participant-impl/participant-impl-kubernetes/src/main/java/org/onap/policy/clamp/controlloop/participant/kubernetes/parameters/ParticipantK8sParameters.java b/participant/participant-impl/participant-impl-kubernetes/src/main/java/org/onap/policy/clamp/controlloop/participant/kubernetes/parameters/ParticipantK8sParameters.java deleted file mode 100644 index 3b2b3732b..000000000 --- a/participant/participant-impl/participant-impl-kubernetes/src/main/java/org/onap/policy/clamp/controlloop/participant/kubernetes/parameters/ParticipantK8sParameters.java +++ /dev/null @@ -1,52 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * Copyright (C) 2021 Nordix Foundation. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - * SPDX-License-Identifier: Apache-2.0 - * ============LICENSE_END========================================================= - */ - -package org.onap.policy.clamp.controlloop.participant.kubernetes.parameters; - -import javax.validation.Valid; -import javax.validation.constraints.NotBlank; -import javax.validation.constraints.NotNull; -import lombok.Getter; -import lombok.Setter; -import org.onap.policy.clamp.controlloop.participant.intermediary.parameters.ParticipantIntermediaryParameters; -import org.onap.policy.clamp.controlloop.participant.intermediary.parameters.ParticipantParameters; -import org.springframework.boot.context.properties.ConfigurationProperties; -import org.springframework.validation.annotation.Validated; - -/** - * Class to hold all parameters needed for the kubernetes participant. - * - */ -@Validated -@Getter -@Setter -@ConfigurationProperties(prefix = "participant") -public class ParticipantK8sParameters implements ParticipantParameters { - - @NotNull - @Valid - private ParticipantIntermediaryParameters intermediaryParameters; - - @NotBlank - private String localChartDirectory; - - @NotBlank - private String infoFileName; -} diff --git a/participant/participant-impl/participant-impl-kubernetes/src/main/java/org/onap/policy/clamp/controlloop/participant/kubernetes/service/ChartService.java b/participant/participant-impl/participant-impl-kubernetes/src/main/java/org/onap/policy/clamp/controlloop/participant/kubernetes/service/ChartService.java deleted file mode 100644 index a07fca596..000000000 --- a/participant/participant-impl/participant-impl-kubernetes/src/main/java/org/onap/policy/clamp/controlloop/participant/kubernetes/service/ChartService.java +++ /dev/null @@ -1,141 +0,0 @@ -/*- - * ========================LICENSE_START================================= - * Copyright (C) 2021 Nordix Foundation. All rights reserved. - * ====================================================================== - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ========================LICENSE_END=================================== - */ - -package org.onap.policy.clamp.controlloop.participant.kubernetes.service; - -import java.io.IOException; -import java.lang.invoke.MethodHandles; -import java.util.Collection; -import org.onap.policy.clamp.controlloop.participant.kubernetes.exception.ServiceException; -import org.onap.policy.clamp.controlloop.participant.kubernetes.helm.HelmClient; -import org.onap.policy.clamp.controlloop.participant.kubernetes.models.ChartInfo; -import org.onap.policy.clamp.controlloop.participant.kubernetes.models.HelmRepository; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.stereotype.Service; -import org.springframework.web.multipart.MultipartFile; - -@Service -public class ChartService { - private final Logger logger = LoggerFactory.getLogger(MethodHandles.lookup().lookupClass()); - - @Autowired - private ChartStore chartStore; - - @Autowired - private HelmClient helmClient; - - /** - * Get all the installed charts. - * @return list of charts. - */ - public Collection getAllCharts() { - return chartStore.getAllCharts(); - } - - /** - * Get specific chart info. - * @param name name of the app - * @param version version of the app - * @return chart - */ - public ChartInfo getChart(String name, String version) { - return chartStore.getChart(name, version); - } - - /** - * Save a helm chart. - * @param chartInfo name and version of the app. - * @param chartFile Helm chart file - * @param overrideFile override file - * @return chart details of the helm chart - * @throws IOException in case of IO error - * @throws ServiceException in case of error - */ - public ChartInfo saveChart(ChartInfo chartInfo, MultipartFile chartFile, MultipartFile overrideFile) - throws IOException, ServiceException { - return chartStore.saveChart(chartInfo, chartFile, overrideFile); - } - - /** - * Delete a helm chart. - * @param chart name and version of the chart. - */ - public void deleteChart(ChartInfo chart) { - chartStore.deleteChart(chart); - } - - /** - * Install a helm chart. - * @param chart name and version. - * @throws ServiceException in case of error - * @throws IOException in case of IO errors - */ - public void installChart(ChartInfo chart) throws ServiceException, IOException { - if (chart.getRepository() == null) { - String repoName = findChartRepo(chart); - if (repoName == null) { - logger.error("Chart repository could not be found. Skipping chart Installation " - + "for the chart {} ", chart.getChartId().getName()); - return; - } else { - HelmRepository repo = HelmRepository.builder().repoName(repoName).build(); - chart.setRepository(repo); - } - } else { - // Add remote repository if passed via TOSCA - configureRepository(chart.getRepository()); - } - helmClient.installChart(chart); - } - - - /** - * Configure remote repository. - * @param repo HelmRepository - * @throws ServiceException incase of error - */ - public void configureRepository(HelmRepository repo) throws ServiceException { - if (repo.getAddress() != null) { - helmClient.addRepository(repo); - } - } - - /** - * Finds helm chart repository for a given chart. - * @param chart chartInfo. - * @return the chart repo as a string - * @throws ServiceException in case of error - * @throws IOException in case of IO errors - */ - public String findChartRepo(ChartInfo chart) throws ServiceException, IOException { - logger.info("Fetching helm chart repository for the given chart {} ", chart.getChartId().getName()); - return helmClient.findChartRepository(chart); - } - - /** - * Uninstall a helm chart. - * @param chart name and version - * @throws ServiceException in case of error. - */ - public void uninstallChart(ChartInfo chart) throws ServiceException { - logger.info("Uninstalling helm deployment {}", chart.getReleaseName()); - helmClient.uninstallChart(chart); - } -} diff --git a/participant/participant-impl/participant-impl-kubernetes/src/main/java/org/onap/policy/clamp/controlloop/participant/kubernetes/service/ChartStore.java b/participant/participant-impl/participant-impl-kubernetes/src/main/java/org/onap/policy/clamp/controlloop/participant/kubernetes/service/ChartStore.java deleted file mode 100644 index ed53d0352..000000000 --- a/participant/participant-impl/participant-impl-kubernetes/src/main/java/org/onap/policy/clamp/controlloop/participant/kubernetes/service/ChartStore.java +++ /dev/null @@ -1,219 +0,0 @@ -/*- - * ========================LICENSE_START================================= - * Copyright (C) 2021 Nordix Foundation. All rights reserved. - * ====================================================================== - * Modifications Copyright (C) 2021 AT&T Intellectual Property. All rights reserved. - * ====================================================================== - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ========================LICENSE_END=================================== - */ - -package org.onap.policy.clamp.controlloop.participant.kubernetes.service; - -import java.io.File; -import java.io.FileOutputStream; -import java.io.IOException; -import java.io.PrintStream; -import java.lang.invoke.MethodHandles; -import java.nio.file.FileVisitResult; -import java.nio.file.Files; -import java.nio.file.Path; -import java.nio.file.Paths; -import java.nio.file.SimpleFileVisitor; -import java.nio.file.attribute.BasicFileAttributes; -import java.util.ArrayList; -import java.util.List; -import java.util.Map; -import java.util.concurrent.ConcurrentHashMap; -import lombok.AccessLevel; -import lombok.Getter; -import org.onap.policy.clamp.controlloop.participant.kubernetes.exception.ServiceException; -import org.onap.policy.clamp.controlloop.participant.kubernetes.models.ChartInfo; -import org.onap.policy.clamp.controlloop.participant.kubernetes.parameters.ParticipantK8sParameters; -import org.onap.policy.common.utils.coder.CoderException; -import org.onap.policy.common.utils.coder.StandardCoder; -import org.onap.policy.models.tosca.authorative.concepts.ToscaConceptIdentifier; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; -import org.springframework.stereotype.Component; -import org.springframework.util.FileSystemUtils; -import org.springframework.web.multipart.MultipartFile; - -@Component -public class ChartStore { - private static final Logger LOGGER = LoggerFactory.getLogger(MethodHandles.lookup().lookupClass()); - - private static final StandardCoder STANDARD_CODER = new StandardCoder(); - - private final ParticipantK8sParameters participantK8sParameters; - - // ChartStore map contains chart name as key & ChartInfo as value. - @Getter(AccessLevel.PACKAGE) - private Map localChartMap = new ConcurrentHashMap<>(); - - /** - * Constructor method. - */ - public ChartStore(ParticipantK8sParameters participantK8sParameters) { - this.participantK8sParameters = participantK8sParameters; - this.restoreFromLocalFileSystem(); - } - - /** - * Get local helm chart file. - * - * @param chart ChartInfo - * @return the chart file. - */ - public File getHelmChartFile(ChartInfo chart) { - var appPath = getAppPath(chart.getChartId()); - return new File(appPath.toFile(), chart.getChartId().getName()); - } - - /** - * Get the override yaml file. - * - * @param chart ChartInfo - * @return the override yaml file - */ - public File getOverrideFile(ChartInfo chart) { - var appPath = getAppPath(chart.getChartId()); - return new File(appPath.toFile(), "values.yaml"); - } - - - /** - * Saves the helm chart. - * - * @param chartInfo chartInfo - * @param chartFile helm chart file. - * @param overrideFile override file. - * @return chart - * @throws IOException incase of IO error - * @throws ServiceException incase of error. - */ - public synchronized ChartInfo saveChart(ChartInfo chartInfo, MultipartFile chartFile, MultipartFile overrideFile) - throws IOException, ServiceException { - if (localChartMap.containsKey(key(chartInfo))) { - throw new ServiceException("Chart already exist"); - } - var appPath = getAppPath(chartInfo.getChartId()); - Files.createDirectories(appPath); - - chartFile.transferTo(getHelmChartFile(chartInfo)); - if (overrideFile != null) { - overrideFile.transferTo(getOverrideFile(chartInfo)); - } - - localChartMap.put(key(chartInfo), chartInfo); - storeChartInFile(chartInfo); - return chartInfo; - } - - /** - * Get the chart info. - * - * @param name name of the chart - * @param version version of the chart - * @return chart - */ - public synchronized ChartInfo getChart(String name, String version) { - return localChartMap.get(key(name, version)); - } - - /** - * Get all the charts installed. - * - * @return list of charts. - */ - public synchronized List getAllCharts() { - return new ArrayList<>(localChartMap.values()); - } - - /** - * Delete a chart. - * - * @param chart chart info - */ - public synchronized void deleteChart(ChartInfo chart) { - var appPath = getAppPath(chart.getChartId()); - try { - FileSystemUtils.deleteRecursively(appPath); - } catch (IOException exc) { - LOGGER.warn("Could not delete chart from local file system : {}", appPath, exc); - } - - localChartMap.remove(key(chart)); - } - - /** - * Fetch the local chart directory of specific chart. - * - * @param chartId Id of the chart - * @return path - */ - public Path getAppPath(ToscaConceptIdentifier chartId) { - return Path.of(participantK8sParameters.getLocalChartDirectory(), chartId.getName(), chartId.getVersion()); - } - - private void storeChartInFile(ChartInfo chart) { - try (var out = new PrintStream(new FileOutputStream(getFile(chart)))) { - out.print(STANDARD_CODER.encode(chart)); - } catch (Exception exc) { - LOGGER.warn("Could not store chart: {}", chart.getChartId(), exc); - } - } - - private File getFile(ChartInfo chart) { - var appPath = getAppPath(chart.getChartId()).toString(); - return Path.of(appPath, participantK8sParameters.getInfoFileName()).toFile(); - } - - private synchronized void restoreFromLocalFileSystem() { - try { - var localChartDirectoryPath = Paths.get(participantK8sParameters.getLocalChartDirectory()); - Files.createDirectories(localChartDirectoryPath); - restoreFromLocalFileSystem(localChartDirectoryPath); - } catch (Exception ioe) { - LOGGER.warn("Could not restore charts from local file system", ioe); - } - } - - private synchronized void restoreFromLocalFileSystem(Path localChartDirectoryPath) - throws IOException { - - Files.walkFileTree(localChartDirectoryPath, new SimpleFileVisitor() { - @Override - public FileVisitResult visitFile(Path localChartFile, BasicFileAttributes attrs) throws IOException { - try { - // Decode only the json file excluding the helm charts - if (localChartFile.endsWith(participantK8sParameters.getInfoFileName())) { - ChartInfo chart = STANDARD_CODER.decode(localChartFile.toFile(), ChartInfo.class); - localChartMap.put(key(chart), chart); - } - return FileVisitResult.CONTINUE; - } catch (CoderException ce) { - throw new IOException("Error decoding chart file", ce); - } - } - }); - } - - private String key(ChartInfo chart) { - return key(chart.getChartId().getName(), chart.getChartId().getVersion()); - } - - private String key(String chartName, String chartVersion) { - return chartName + "_" + chartVersion; - } -} diff --git a/participant/participant-impl/participant-impl-kubernetes/src/main/resources/config/application.yaml b/participant/participant-impl/participant-impl-kubernetes/src/main/resources/config/application.yaml index b266fe337..3be0fb2c0 100644 --- a/participant/participant-impl/participant-impl-kubernetes/src/main/resources/config/application.yaml +++ b/participant/participant-impl/participant-impl-kubernetes/src/main/resources/config/application.yaml @@ -13,22 +13,22 @@ participant: reportingTimeIntervalMs: 120000 description: Participant Description participantId: - name: K8sParticipant0 - version: 1.0.0 + name: org.onap.policy.clamp.acm.KubernetesParticipant + version: 2.3.4 participantType: - name: org.onap.k8s.controlloop.K8sControlLoopParticipant + name: org.onap.k8s.acm.K8SAutomationCompositionParticipant version: 2.3.4 - clampControlLoopTopics: + clampAutomationCompositionTopics: topicSources: - - topic: POLICY-CLRUNTIME-PARTICIPANT + topic: POLICY-ACRUNTIME-PARTICIPANT servers: - ${topicServer:localhost} topicCommInfrastructure: dmaap fetchTimeout: 15000 topicSinks: - - topic: POLICY-CLRUNTIME-PARTICIPANT + topic: POLICY-ACRUNTIME-PARTICIPANT servers: - ${topicServer:localhost} topicCommInfrastructure: dmaap @@ -41,7 +41,7 @@ management: server: port: 8083 servlet: - context-path: /onap/k8sparticipant + context-path: /onap/policy/clamp/acm/k8sparticipant logging: # Configuration of logging @@ -50,7 +50,7 @@ logging: org.springframework: ERROR org.springframework.data: ERROR org.springframework.web.reactive.function.client.ExchangeFunctions: ERROR - org.onap.policy.clamp.controlloop.participant.kubernetes: INFO + org.onap.policy.clamp.acm.participant.kubernetes: INFO file: name: /var/log/onap/policy/clamp/application.log diff --git a/participant/participant-impl/participant-impl-kubernetes/src/test/java/org/onap/policy/clamp/acm/participant/kubernetes/handler/AutomationCompositionElementHandlerTest.java b/participant/participant-impl/participant-impl-kubernetes/src/test/java/org/onap/policy/clamp/acm/participant/kubernetes/handler/AutomationCompositionElementHandlerTest.java new file mode 100644 index 000000000..dc74afc1a --- /dev/null +++ b/participant/participant-impl/participant-impl-kubernetes/src/test/java/org/onap/policy/clamp/acm/participant/kubernetes/handler/AutomationCompositionElementHandlerTest.java @@ -0,0 +1,182 @@ +/*- + * ============LICENSE_START======================================================= + * Copyright (C) 2021 Nordix Foundation. + * Modifications Copyright (C) 2021 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * SPDX-License-Identifier: Apache-2.0 + * ============LICENSE_END========================================================= + */ + +package org.onap.policy.clamp.acm.participant.kubernetes.handler; + +import static org.assertj.core.api.Assertions.assertThat; +import static org.junit.jupiter.api.Assertions.assertDoesNotThrow; +import static org.mockito.ArgumentMatchers.any; +import static org.mockito.ArgumentMatchers.anyInt; +import static org.mockito.Mockito.doNothing; +import static org.mockito.Mockito.doReturn; +import static org.mockito.Mockito.doThrow; +import static org.mockito.Mockito.when; + +import java.io.File; +import java.io.IOException; +import java.util.List; +import java.util.Map; +import java.util.UUID; +import java.util.concurrent.ExecutionException; +import java.util.concurrent.ExecutorService; +import java.util.concurrent.Future; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.ExtendWith; +import org.mockito.InjectMocks; +import org.mockito.Mock; +import org.mockito.Mockito; +import org.mockito.Spy; +import org.onap.policy.clamp.acm.participant.intermediary.api.ParticipantIntermediaryApi; +import org.onap.policy.clamp.acm.participant.kubernetes.exception.ServiceException; +import org.onap.policy.clamp.acm.participant.kubernetes.models.ChartInfo; +import org.onap.policy.clamp.acm.participant.kubernetes.models.ChartList; +import org.onap.policy.clamp.acm.participant.kubernetes.parameters.CommonTestData; +import org.onap.policy.clamp.acm.participant.kubernetes.service.ChartService; +import org.onap.policy.clamp.acm.participant.kubernetes.utils.TestUtils; +import org.onap.policy.clamp.models.acm.concepts.AutomationCompositionElement; +import org.onap.policy.clamp.models.acm.concepts.AutomationCompositionOrderedState; +import org.onap.policy.clamp.models.acm.concepts.AutomationCompositionState; +import org.onap.policy.common.utils.coder.Coder; +import org.onap.policy.common.utils.coder.CoderException; +import org.onap.policy.common.utils.coder.StandardCoder; +import org.onap.policy.models.base.PfModelException; +import org.onap.policy.models.tosca.authorative.concepts.ToscaConceptIdentifier; +import org.onap.policy.models.tosca.authorative.concepts.ToscaNodeTemplate; +import org.onap.policy.models.tosca.authorative.concepts.ToscaServiceTemplate; +import org.springframework.test.context.junit.jupiter.SpringExtension; + +@ExtendWith(SpringExtension.class) +class AutomationCompositionElementHandlerTest { + + private static final Coder CODER = new StandardCoder(); + private static final String CHART_INFO_YAML = "src/test/resources/ChartList.json"; + private static final String KEY_NAME = + "org.onap.domain.database.HelloWorld_K8SMicroserviceAutomationCompositionElement"; + private static List charts; + private static ToscaServiceTemplate toscaServiceTemplate; + private static final String K8S_AUTOMATION_COMPOSITION_ELEMENT = + "org.onap.domain.database.PMSH_K8SMicroserviceAutomationCompositionElement"; + private CommonTestData commonTestData = new CommonTestData(); + + @InjectMocks + @Spy + private AutomationCompositionElementHandler automationCompositionElementHandler = + new AutomationCompositionElementHandler(); + + @Mock + private ChartService chartService; + + @Mock + private ParticipantIntermediaryApi participantIntermediaryApi; + + @Mock + private ExecutorService executor; + @Mock + private Future result; + + @BeforeAll + static void init() throws CoderException { + charts = CODER.decode(new File(CHART_INFO_YAML), ChartList.class).getCharts(); + toscaServiceTemplate = TestUtils.testAutomationCompositionRead(); + } + + @Test + void test_AutomationCompositionElementStateChange() throws ServiceException { + UUID automationCompositionElementId1 = UUID.randomUUID(); + UUID automationCompositionElementId2 = UUID.randomUUID(); + + automationCompositionElementHandler.getChartMap().put(automationCompositionElementId1, charts.get(0)); + automationCompositionElementHandler.getChartMap().put(automationCompositionElementId2, charts.get(1)); + + doNothing().when(chartService).uninstallChart(charts.get(0)); + + automationCompositionElementHandler.automationCompositionElementStateChange( + commonTestData.getAutomationCompositionId(), automationCompositionElementId1, + AutomationCompositionState.PASSIVE, AutomationCompositionOrderedState.UNINITIALISED); + + doThrow(new ServiceException("Error uninstalling the chart")).when(chartService).uninstallChart(charts.get(0)); + + assertDoesNotThrow(() -> automationCompositionElementHandler.automationCompositionElementStateChange( + commonTestData.getAutomationCompositionId(), automationCompositionElementId1, + AutomationCompositionState.PASSIVE, AutomationCompositionOrderedState.PASSIVE)); + + assertDoesNotThrow(() -> automationCompositionElementHandler.automationCompositionElementStateChange( + commonTestData.getAutomationCompositionId(), automationCompositionElementId1, + AutomationCompositionState.PASSIVE, AutomationCompositionOrderedState.UNINITIALISED)); + + assertDoesNotThrow(() -> automationCompositionElementHandler.automationCompositionElementStateChange( + commonTestData.getAutomationCompositionId(), automationCompositionElementId1, + AutomationCompositionState.PASSIVE, AutomationCompositionOrderedState.RUNNING)); + + } + + @Test + void test_AutomationCompositionElementUpdate() throws PfModelException, IOException, ServiceException, + ExecutionException, InterruptedException { + doNothing().when(automationCompositionElementHandler).checkPodStatus(any(), any(), any(), anyInt(), anyInt()); + UUID elementId1 = UUID.randomUUID(); + AutomationCompositionElement element = new AutomationCompositionElement(); + element.setId(elementId1); + element.setDefinition(new ToscaConceptIdentifier(KEY_NAME, "1.0.1")); + element.setOrderedState(AutomationCompositionOrderedState.PASSIVE); + + Map nodeTemplatesMap = + toscaServiceTemplate.getToscaTopologyTemplate().getNodeTemplates(); + automationCompositionElementHandler.automationCompositionElementUpdate( + commonTestData.getAutomationCompositionId(), element, + nodeTemplatesMap.get(K8S_AUTOMATION_COMPOSITION_ELEMENT)); + + assertThat(automationCompositionElementHandler.getChartMap()).hasSize(1).containsKey(elementId1); + + doThrow(new ServiceException("Error installing the chart")).when(chartService).installChart(Mockito.any()); + + UUID elementId2 = UUID.randomUUID(); + element.setId(elementId2); + automationCompositionElementHandler.automationCompositionElementUpdate( + commonTestData.getAutomationCompositionId(), element, + nodeTemplatesMap.get(K8S_AUTOMATION_COMPOSITION_ELEMENT)); + + assertThat(automationCompositionElementHandler.getChartMap().containsKey(elementId2)).isFalse(); + } + + @Test + void test_handleStatistics() throws PfModelException { + UUID elementId1 = UUID.randomUUID(); + automationCompositionElementHandler.getChartMap().put(elementId1, charts.get(0)); + when(participantIntermediaryApi.getAutomationCompositionElement(elementId1)) + .thenReturn(new AutomationCompositionElement()); + assertDoesNotThrow(() -> automationCompositionElementHandler.handleStatistics(elementId1)); + } + + @Test + void test_checkPodStatus() throws ExecutionException, InterruptedException { + doReturn(result).when(executor).submit(any(Runnable.class), any()); + doReturn("Done").when(result).get(); + doReturn(true).when(result).isDone(); + var chartInfo = charts.get(0); + ToscaConceptIdentifier controlLoopId = new ToscaConceptIdentifier(); + AutomationCompositionElement element = new AutomationCompositionElement(); + assertDoesNotThrow( + () -> automationCompositionElementHandler.checkPodStatus(controlLoopId, element.getId(), chartInfo, + 1, 1)); + } +} diff --git a/participant/participant-impl/participant-impl-kubernetes/src/test/java/org/onap/policy/clamp/acm/participant/kubernetes/helm/HelmClientTest.java b/participant/participant-impl/participant-impl-kubernetes/src/test/java/org/onap/policy/clamp/acm/participant/kubernetes/helm/HelmClientTest.java new file mode 100644 index 000000000..7f1943c97 --- /dev/null +++ b/participant/participant-impl/participant-impl-kubernetes/src/test/java/org/onap/policy/clamp/acm/participant/kubernetes/helm/HelmClientTest.java @@ -0,0 +1,158 @@ +/*- + * ============LICENSE_START======================================================= + * Copyright (C) 2021 Nordix Foundation. + * Modifications Copyright (C) 2021 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * SPDX-License-Identifier: Apache-2.0 + * ============LICENSE_END========================================================= + */ + +package org.onap.policy.clamp.acm.participant.kubernetes.helm; + +import static org.assertj.core.api.Assertions.assertThat; +import static org.assertj.core.api.Assertions.assertThatThrownBy; +import static org.junit.Assert.assertNull; +import static org.junit.jupiter.api.Assertions.assertDoesNotThrow; +import static org.junit.jupiter.api.Assertions.assertNotNull; +import static org.mockito.ArgumentMatchers.any; +import static org.mockito.Mockito.doReturn; +import static org.mockito.Mockito.mockStatic; +import static org.mockito.Mockito.when; + +import java.io.File; +import java.io.IOException; +import java.nio.file.Path; +import java.util.List; +import org.junit.jupiter.api.AfterAll; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.ExtendWith; +import org.mockito.InjectMocks; +import org.mockito.Mock; +import org.mockito.MockedStatic; +import org.mockito.Mockito; +import org.mockito.Spy; +import org.onap.policy.clamp.acm.participant.kubernetes.exception.ServiceException; +import org.onap.policy.clamp.acm.participant.kubernetes.models.ChartInfo; +import org.onap.policy.clamp.acm.participant.kubernetes.models.ChartList; +import org.onap.policy.clamp.acm.participant.kubernetes.models.HelmRepository; +import org.onap.policy.clamp.acm.participant.kubernetes.service.ChartStore; +import org.onap.policy.common.utils.coder.Coder; +import org.onap.policy.common.utils.coder.CoderException; +import org.onap.policy.common.utils.coder.StandardCoder; +import org.springframework.test.context.junit.jupiter.SpringExtension; +import org.springframework.util.FileSystemUtils; + + +@ExtendWith(SpringExtension.class) +class HelmClientTest { + + private static final Coder CODER = new StandardCoder(); + private static final String CHART_INFO_YAML = "src/test/resources/ChartList.json"; + private static List charts; + + @InjectMocks + @Spy + private HelmClient helmClient = new HelmClient(); + + @Mock + ChartStore chartStore; + + @Mock + HelmRepository repo; + + private static MockedStatic mockedClient; + + @BeforeAll + static void init() throws CoderException { + charts = CODER.decode(new File(CHART_INFO_YAML), ChartList.class).getCharts(); + //Mock static method for bash command execution + mockedClient = mockStatic(HelmClient.class); + } + + @AfterAll + public static void close() throws IOException { + mockedClient.close(); + FileSystemUtils.deleteRecursively(Path.of("target/tmp")); + } + + @Test + void test_installChart() throws IOException { + mockedClient.when(() -> HelmClient.executeCommand(any())) + .thenReturn("success"); + doReturn(new File("/target/tmp/override.yaml")).when(chartStore) + .getOverrideFile(any()); + var chartinfo = charts.get(0); + + assertDoesNotThrow(() -> helmClient.installChart(chartinfo)); + chartinfo.setNamespace(""); + assertDoesNotThrow(() -> helmClient.installChart(chartinfo)); + + mockedClient.when(() -> HelmClient.executeCommand(any())) + .thenReturn(new String()); + assertDoesNotThrow(() -> helmClient.installChart(chartinfo)); + + } + + @Test + void test_addRepository() throws IOException { + mockedClient.when(() -> HelmClient.executeCommand(any())) + .thenReturn(new String()); + when(repo.getRepoName()).thenReturn("RepoName"); + assertDoesNotThrow(() -> helmClient.addRepository(repo)); + + mockedClient.when(() -> HelmClient.executeCommand(any())) + .thenReturn("failed"); + assertDoesNotThrow(() -> helmClient.addRepository(repo)); + } + + @Test + void test_findChartRepository() throws IOException, ServiceException { + String tmpPath = "target/tmp/dummyChart/1.0/"; + mockedClient.when(() -> HelmClient.executeCommand(Mockito.any())) + .thenReturn("nginx-stable/nginx-ingress\t0.9.3\t1.11.3" + + " \tNGINX Ingress Controller"); + String configuredRepo = helmClient.findChartRepository(charts.get(1)); + assertThat(configuredRepo).isEqualTo("nginx-stable"); + + File tmpFile = new File(tmpPath + charts.get(1).getChartId().getName()); + tmpFile.mkdirs(); + doReturn(Path.of(tmpPath)).when(chartStore).getAppPath(charts.get(1).getChartId()); + + doReturn(null).when(helmClient).verifyConfiguredRepo(charts.get(1)); + + String localRepoName = helmClient.findChartRepository(charts.get(1)); + assertNotNull(localRepoName); + assertThat(localRepoName).endsWith(charts.get(0).getChartId().getVersion()); + } + + @Test + void test_uninstallChart() throws ServiceException { + helmClient.uninstallChart(charts.get(0)); + mockedClient.when(() -> HelmClient.executeCommand(any())).thenThrow(new ServiceException("error in execution")); + + assertThatThrownBy(() -> helmClient.uninstallChart(charts.get(0))) + .isInstanceOf(ServiceException.class); + } + + @Test + void test_verifyConfiguredRepoForInvalidChart() throws IOException, ServiceException { + mockedClient.when(() -> HelmClient.executeCommand(Mockito.any())) + .thenReturn(""); + String configuredRepo = helmClient.verifyConfiguredRepo(charts.get(1)); + assertNull(configuredRepo); + } + +} diff --git a/participant/participant-impl/participant-impl-kubernetes/src/test/java/org/onap/policy/clamp/acm/participant/kubernetes/helm/PodStatusValidatorTest.java b/participant/participant-impl/participant-impl-kubernetes/src/test/java/org/onap/policy/clamp/acm/participant/kubernetes/helm/PodStatusValidatorTest.java new file mode 100644 index 000000000..89b077044 --- /dev/null +++ b/participant/participant-impl/participant-impl-kubernetes/src/test/java/org/onap/policy/clamp/acm/participant/kubernetes/helm/PodStatusValidatorTest.java @@ -0,0 +1,107 @@ +/*- + * ============LICENSE_START======================================================= + * Copyright (C) 2021 Nordix Foundation. + * Modifications Copyright (C) 2021 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * SPDX-License-Identifier: Apache-2.0 + * ============LICENSE_END========================================================= + */ + +package org.onap.policy.clamp.acm.participant.kubernetes.helm; + +import static org.assertj.core.api.Assertions.assertThat; +import static org.assertj.core.api.Assertions.assertThatThrownBy; +import static org.junit.jupiter.api.Assertions.assertDoesNotThrow; +import static org.mockito.ArgumentMatchers.any; +import static org.mockito.Mockito.mockStatic; + +import java.io.File; +import java.util.List; +import java.util.Map; +import org.junit.jupiter.api.AfterAll; +import org.junit.jupiter.api.AfterEach; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.ExtendWith; +import org.mockito.InjectMocks; +import org.mockito.MockedStatic; +import org.onap.policy.clamp.acm.participant.kubernetes.exception.ServiceException; +import org.onap.policy.clamp.acm.participant.kubernetes.handler.AutomationCompositionElementHandler; +import org.onap.policy.clamp.acm.participant.kubernetes.models.ChartInfo; +import org.onap.policy.clamp.acm.participant.kubernetes.models.ChartList; +import org.onap.policy.common.utils.coder.Coder; +import org.onap.policy.common.utils.coder.CoderException; +import org.onap.policy.common.utils.coder.StandardCoder; +import org.springframework.test.context.junit.jupiter.SpringExtension; + +@ExtendWith(SpringExtension.class) +class PodStatusValidatorTest { + + + private static final Coder CODER = new StandardCoder(); + private static final String CHART_INFO_YAML = "src/test/resources/ChartList.json"; + private static List charts; + private static int timeout = 60; + private static int statusCheckInterval = 30; + + + @InjectMocks + private static PodStatusValidator podStatusValidator; + + private static MockedStatic mockedClient; + + + @BeforeAll + static void init() throws CoderException { + charts = CODER.decode(new File(CHART_INFO_YAML), ChartList.class).getCharts(); + mockedClient = mockStatic(HelmClient.class); + podStatusValidator = new PodStatusValidator(charts.get(0), timeout, statusCheckInterval); + } + + @AfterEach + void clearPodStatusMap() { + AutomationCompositionElementHandler.getPodStatusMap().clear(); + } + + @AfterAll + public static void close() { + mockedClient.close(); + } + + + @Test + void test_RunningPodState() { + String runningPod = "NAME\tREADY\tSTATUS\tRESTARTS\tAGE\r\nHelloWorld-54777df9f8-qpzqr\t1/1\tRunning\t0\t9h"; + mockedClient.when(() -> HelmClient.executeCommand(any())) + .thenReturn(runningPod); + assertDoesNotThrow(() -> podStatusValidator.run()); + assertThat(AutomationCompositionElementHandler.getPodStatusMap()).hasSize(1); + assertThat(AutomationCompositionElementHandler.getPodStatusMap()).containsKey(charts.get(0).getReleaseName()); + assertThat(AutomationCompositionElementHandler.getPodStatusMap()) + .containsValue(Map.of("HelloWorld-54777df9f8-qpzqr", "Running")); + } + + + @Test + void test_InvalidPodState() { + String invalidPod = "NAME\tREADY\tSTATUS\tRESTARTS\tAGE\nhellofromdocker-54777df9f8-qpzqr\t1/1\tInit\t0\t9h"; + mockedClient.when(() -> HelmClient.executeCommand(any())) + .thenReturn(invalidPod); + assertThatThrownBy(() -> podStatusValidator.run()) + .isInstanceOf(ServiceException.class).hasMessage("Error verifying the status of the pod. Exiting"); + assertThat(AutomationCompositionElementHandler.getPodStatusMap()).isEmpty(); + } + +} diff --git a/participant/participant-impl/participant-impl-kubernetes/src/test/java/org/onap/policy/clamp/acm/participant/kubernetes/parameters/CommonTestData.java b/participant/participant-impl/participant-impl-kubernetes/src/test/java/org/onap/policy/clamp/acm/participant/kubernetes/parameters/CommonTestData.java new file mode 100644 index 000000000..13f8edc15 --- /dev/null +++ b/participant/participant-impl/participant-impl-kubernetes/src/test/java/org/onap/policy/clamp/acm/participant/kubernetes/parameters/CommonTestData.java @@ -0,0 +1,161 @@ +/*- + * ============LICENSE_START======================================================= + * Copyright (C) 2021 Nordix Foundation. + * Modifications Copyright (C) 2021 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * SPDX-License-Identifier: Apache-2.0 + * ============LICENSE_END========================================================= + */ + +package org.onap.policy.clamp.acm.participant.kubernetes.parameters; + +import java.util.Arrays; +import java.util.List; +import java.util.Map; +import java.util.TreeMap; +import org.onap.policy.common.endpoints.parameters.TopicParameters; +import org.onap.policy.common.utils.coder.Coder; +import org.onap.policy.common.utils.coder.CoderException; +import org.onap.policy.common.utils.coder.StandardCoder; +import org.onap.policy.models.tosca.authorative.concepts.ToscaConceptIdentifier; + +public class CommonTestData { + + public static final String PARTICIPANT_GROUP_NAME = "AutomationCompositionParticipantGroup"; + public static final String DESCRIPTION = "Participant description"; + public static final long TIME_INTERVAL = 2000; + public static final List TOPIC_PARAMS = Arrays.asList(getTopicParams()); + public static final Coder CODER = new StandardCoder(); + + + /** + * Get ParticipantK8sParameters. + * + * @return ParticipantK8sParameters + */ + public ParticipantK8sParameters getParticipantK8sParameters() { + try { + return CODER.convert(getParticipantK8sParametersMap(PARTICIPANT_GROUP_NAME), + ParticipantK8sParameters.class); + } catch (final CoderException e) { + throw new RuntimeException("cannot create ParticipantK8sParameters from map", e); + } + } + + /** + * Returns a property map for a ParticipantK8sParameters map for test cases. + * + * @param name name of the parameters + * + * @return a property map suitable for constructing an object + */ + public Map getParticipantK8sParametersMap(final String name) { + final Map map = new TreeMap<>(); + + map.put("name", name); + map.put("intermediaryParameters", getIntermediaryParametersMap(false)); + map.put("localChartDirectory", getLocalChartDir()); + map.put("infoFileName", getInfoFileName()); + return map; + } + + + /** + * Returns string value of local chart Directory. + * @return a string value + */ + public String getLocalChartDir() { + return "/var/helm-manager/local-charts"; + } + + /** + * Returns string value of Info file name. + * @return string value + */ + public String getInfoFileName() { + return "CHART-INFO.json"; + } + + + + /** + * Returns a property map for a intermediaryParameters map for test cases. + * + * @param isEmpty boolean value to represent that object created should be empty or not + * @return a property map suitable for constructing an object + */ + public Map getIntermediaryParametersMap(final boolean isEmpty) { + final Map map = new TreeMap<>(); + if (!isEmpty) { + map.put("name", "Participant parameters"); + map.put("reportingTimeIntervalMs", TIME_INTERVAL); + map.put("description", DESCRIPTION); + map.put("participantId", getParticipantId()); + map.put("participantType", getParticipantId()); + map.put("clampAutomationCompositionTopics", getTopicParametersMap(false)); + } + + return map; + } + + /** + * Returns participantId for test cases. + * + * @return participant Id + */ + public static ToscaConceptIdentifier getParticipantId() { + final ToscaConceptIdentifier participantId = new ToscaConceptIdentifier(); + participantId.setName("K8sParticipant0"); + participantId.setVersion("1.0.0"); + return participantId; + } + + + /** + * Returns a property map for a TopicParameters map for test cases. + * + * @param isEmpty boolean value to represent that object created should be empty or not + * @return a property map suitable for constructing an object + */ + public Map getTopicParametersMap(final boolean isEmpty) { + final Map map = new TreeMap<>(); + if (!isEmpty) { + map.put("topicSources", TOPIC_PARAMS); + map.put("topicSinks", TOPIC_PARAMS); + } + return map; + } + + /** + * Returns topic parameters for test cases. + * + * @return topic parameters + */ + public static TopicParameters getTopicParams() { + final TopicParameters topicParams = new TopicParameters(); + topicParams.setTopic("POLICY-ACRUNTIME-PARTICIPANT"); + topicParams.setTopicCommInfrastructure("dmaap"); + topicParams.setServers(Arrays.asList("localhost")); + return topicParams; + } + + /** + * Get automation composition id. + * @return ToscaConceptIdentifier automationCompositionId + */ + public ToscaConceptIdentifier getAutomationCompositionId() { + return new ToscaConceptIdentifier("PMSHInstance0", "1.0.0"); + } +} diff --git a/participant/participant-impl/participant-impl-kubernetes/src/test/java/org/onap/policy/clamp/acm/participant/kubernetes/parameters/ParticipantK8sParametersTest.java b/participant/participant-impl/participant-impl-kubernetes/src/test/java/org/onap/policy/clamp/acm/participant/kubernetes/parameters/ParticipantK8sParametersTest.java new file mode 100644 index 000000000..09ea74afe --- /dev/null +++ b/participant/participant-impl/participant-impl-kubernetes/src/test/java/org/onap/policy/clamp/acm/participant/kubernetes/parameters/ParticipantK8sParametersTest.java @@ -0,0 +1,89 @@ +/*- + * ============LICENSE_START======================================================= + * Copyright (C) 2021 Nordix Foundation. + * Modifications Copyright (C) 2021 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * SPDX-License-Identifier: Apache-2.0 + * ============LICENSE_END========================================================= + */ + +package org.onap.policy.clamp.acm.participant.kubernetes.parameters; + +import static org.assertj.core.api.Assertions.assertThat; + +import java.util.Set; +import javax.validation.ConstraintViolation; +import javax.validation.Validation; +import javax.validation.ValidatorFactory; +import org.junit.jupiter.api.Test; + +class ParticipantK8sParametersTest { + + private CommonTestData commonTestData = new CommonTestData(); + private ValidatorFactory validatorFactory = Validation.buildDefaultValidatorFactory(); + + @Test + void testParticipantPolicyParameters() { + final ParticipantK8sParameters participantParameters = commonTestData.getParticipantK8sParameters(); + assertThat(validatorFactory.getValidator().validate(participantParameters)).isNullOrEmpty(); + } + + @Test + void testParticipantK8sParameters_NullTopicSinks() { + final ParticipantK8sParameters participantParameters = commonTestData.getParticipantK8sParameters(); + participantParameters.getIntermediaryParameters().getClampAutomationCompositionTopics().setTopicSinks(null); + assertThat(validatorFactory.getValidator().validate(participantParameters)).isNotEmpty(); + } + + @Test + void testParticipantK8sParameters_NullTopicSources() { + final ParticipantK8sParameters participantParameters = commonTestData.getParticipantK8sParameters(); + participantParameters.getIntermediaryParameters().getClampAutomationCompositionTopics().setTopicSources(null); + assertThat(validatorFactory.getValidator().validate(participantParameters)).isNotEmpty(); + } + + @Test + void testParticipantK8sParameters_BlankLocalChartDirParameter() { + final ParticipantK8sParameters participantParameters = commonTestData.getParticipantK8sParameters(); + participantParameters.setLocalChartDirectory(" "); + Set> violations = validatorFactory.getValidator() + .validate(participantParameters); + assertThat(violations.size()).isEqualTo(1); + } + + @Test + void testParticipantK8sParameters_BlankInfoFileParameter() { + final ParticipantK8sParameters participantParameters = commonTestData.getParticipantK8sParameters(); + participantParameters.setInfoFileName(""); + Set> violations = validatorFactory.getValidator() + .validate(participantParameters); + assertThat(violations.size()).isEqualTo(1); + } + + @Test + void testNoIntermediaryParameters() { + final ParticipantK8sParameters participantParameters = commonTestData.getParticipantK8sParameters(); + participantParameters.setIntermediaryParameters(null); + assertThat(validatorFactory.getValidator().validate(participantParameters)).isNotEmpty(); + } + + @Test + void testNoParticipantId() { + final ParticipantK8sParameters participantParameters = commonTestData.getParticipantK8sParameters(); + participantParameters.getIntermediaryParameters().setParticipantId(null); + assertThat(validatorFactory.getValidator().validate(participantParameters)).isNotEmpty(); + } + +} diff --git a/participant/participant-impl/participant-impl-kubernetes/src/test/java/org/onap/policy/clamp/acm/participant/kubernetes/rest/ActuatorControllerTest.java b/participant/participant-impl/participant-impl-kubernetes/src/test/java/org/onap/policy/clamp/acm/participant/kubernetes/rest/ActuatorControllerTest.java new file mode 100644 index 000000000..8d05d2bf6 --- /dev/null +++ b/participant/participant-impl/participant-impl-kubernetes/src/test/java/org/onap/policy/clamp/acm/participant/kubernetes/rest/ActuatorControllerTest.java @@ -0,0 +1,92 @@ +/*- + * ============LICENSE_START======================================================= + * Copyright (C) 2021 Nordix Foundation. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * SPDX-License-Identifier: Apache-2.0 + * ============LICENSE_END========================================================= + */ + +package org.onap.policy.clamp.acm.participant.kubernetes.rest; + +import static org.junit.jupiter.api.Assertions.assertEquals; + +import javax.ws.rs.client.Invocation; +import javax.ws.rs.core.Response; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.ExtendWith; +import org.onap.policy.clamp.acm.participant.kubernetes.utils.CommonActuatorController; +import org.springframework.boot.test.autoconfigure.actuate.metrics.AutoConfigureMetrics; +import org.springframework.boot.test.context.SpringBootTest; +import org.springframework.boot.test.context.SpringBootTest.WebEnvironment; +import org.springframework.boot.web.server.LocalServerPort; +import org.springframework.test.context.TestPropertySource; +import org.springframework.test.context.junit.jupiter.SpringExtension; + +@AutoConfigureMetrics +@ExtendWith(SpringExtension.class) +@SpringBootTest(webEnvironment = WebEnvironment.RANDOM_PORT) +@TestPropertySource(locations = {"classpath:application_test.properties"}) +class ActuatorControllerTest extends CommonActuatorController { + + private static final String HEALTH_ENDPOINT = "health"; + private static final String METRICS_ENDPOINT = "metrics"; + private static final String PROMETHEUS_ENDPOINT = "prometheus"; + + @LocalServerPort + private int randomServerPort; + + @BeforeEach + public void setUpPort() { + super.setHttpPrefix(randomServerPort); + } + + @Test + void testGetHealth_Unauthorized() throws Exception { + assertUnauthorizedActGet(HEALTH_ENDPOINT); + } + + @Test + void testGetMetrics_Unauthorized() throws Exception { + assertUnauthorizedActGet(METRICS_ENDPOINT); + } + + @Test + void testGetPrometheus_Unauthorized() throws Exception { + assertUnauthorizedActGet(PROMETHEUS_ENDPOINT); + } + + @Test + void testGetHealth() throws Exception { + Invocation.Builder invocationBuilder = super.sendActRequest(HEALTH_ENDPOINT); + Response rawresp = invocationBuilder.buildGet().invoke(); + assertEquals(Response.Status.OK.getStatusCode(), rawresp.getStatus()); + } + + @Test + void testGetMetrics() throws Exception { + Invocation.Builder invocationBuilder = super.sendActRequest(METRICS_ENDPOINT); + Response rawresp = invocationBuilder.buildGet().invoke(); + assertEquals(Response.Status.OK.getStatusCode(), rawresp.getStatus()); + } + + @Test + void testGePrometheus() throws Exception { + Invocation.Builder invocationBuilder = super.sendActRequest(PROMETHEUS_ENDPOINT); + Response rawresp = invocationBuilder.buildGet().invoke(); + assertEquals(Response.Status.OK.getStatusCode(), rawresp.getStatus()); + } + +} diff --git a/participant/participant-impl/participant-impl-kubernetes/src/test/java/org/onap/policy/clamp/acm/participant/kubernetes/rest/ChartControllerTest.java b/participant/participant-impl/participant-impl-kubernetes/src/test/java/org/onap/policy/clamp/acm/participant/kubernetes/rest/ChartControllerTest.java new file mode 100644 index 000000000..73c5c98a1 --- /dev/null +++ b/participant/participant-impl/participant-impl-kubernetes/src/test/java/org/onap/policy/clamp/acm/participant/kubernetes/rest/ChartControllerTest.java @@ -0,0 +1,249 @@ +/*- + * ============LICENSE_START======================================================= + * Copyright (C) 2021-2022 Nordix Foundation. + * Modifications Copyright (C) 2021 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * SPDX-License-Identifier: Apache-2.0 + * ============LICENSE_END========================================================= + */ + +package org.onap.policy.clamp.acm.participant.kubernetes.rest; + +import static org.hamcrest.CoreMatchers.is; +import static org.mockito.Mockito.doNothing; +import static org.mockito.Mockito.when; +import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.content; +import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.jsonPath; +import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status; + +import java.io.File; +import java.io.IOException; +import java.nio.charset.StandardCharsets; +import java.util.List; +import org.apache.commons.io.FileUtils; +import org.json.JSONObject; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.ExtendWith; +import org.onap.policy.clamp.acm.participant.kubernetes.controller.ChartController; +import org.onap.policy.clamp.acm.participant.kubernetes.models.ChartInfo; +import org.onap.policy.clamp.acm.participant.kubernetes.models.ChartList; +import org.onap.policy.clamp.acm.participant.kubernetes.parameters.ParticipantK8sParameters; +import org.onap.policy.clamp.acm.participant.kubernetes.service.ChartService; +import org.onap.policy.common.utils.coder.Coder; +import org.onap.policy.common.utils.coder.CoderException; +import org.onap.policy.common.utils.coder.StandardCoder; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.boot.context.properties.EnableConfigurationProperties; +import org.springframework.boot.test.autoconfigure.web.servlet.WebMvcTest; +import org.springframework.boot.test.mock.mockito.MockBean; +import org.springframework.http.MediaType; +import org.springframework.mock.web.MockMultipartFile; +import org.springframework.test.context.junit.jupiter.SpringExtension; +import org.springframework.test.web.servlet.MockMvc; +import org.springframework.test.web.servlet.RequestBuilder; +import org.springframework.test.web.servlet.request.MockMvcRequestBuilders; +import org.springframework.test.web.servlet.setup.MockMvcBuilders; +import org.springframework.web.context.WebApplicationContext; + + +@ExtendWith(SpringExtension.class) +@WebMvcTest(value = ChartController.class, properties = "chart.api.enabled=true") +@EnableConfigurationProperties(value = ParticipantK8sParameters.class) +class ChartControllerTest { + + private static final Coder CODER = new StandardCoder(); + private static final String CHART_INFO_YAML = "src/test/resources/ChartList.json"; + private static List charts; + private static String RETRIEVE_CHART_URL = "/helm/charts"; + private static String INSTALL_CHART_URL = "/helm/install"; + private static String UNINSTALL_CHART_URL = "/helm/uninstall/"; + private static String ONBOARD_CHART_URL = "/helm/onboard/chart"; + private static String DELETE_CHART_URL = "/helm/chart"; + private static String CONFIGURE_REPO_URL = "/helm/repo"; + + @Autowired + private MockMvc mockMvc; + + @MockBean + private ChartService chartService; + + @Autowired + private WebApplicationContext context; + + /** + * Read input chart info json. + * @throws Exception incase of error. + */ + @BeforeAll + static void setupParams() throws CoderException { + charts = CODER.decode(new File(CHART_INFO_YAML), ChartList.class).getCharts(); + } + + /** + * Mock service layer in Controller. + * @throws Exception incase of error. + */ + @BeforeEach + void mockServiceClass() { + when(chartService.getAllCharts()).thenReturn(charts); + when(chartService.getChart(charts.get(0).getChartId().getName(), charts.get(0).getChartId().getVersion())) + .thenReturn(charts.get(0)); + + this.mockMvc = MockMvcBuilders.webAppContextSetup(this.context).build(); + } + + /** + * Test endpoint for retrieving all charts. + * @throws Exception incase of error. + */ + @Test + void retrieveAllCharts() throws Exception { + RequestBuilder requestBuilder; + requestBuilder = MockMvcRequestBuilders.get(RETRIEVE_CHART_URL).accept(MediaType.APPLICATION_JSON_VALUE); + + mockMvc.perform(requestBuilder).andExpect(status().isOk()) + .andExpect(content().contentTypeCompatibleWith(MediaType.APPLICATION_JSON)) + .andExpect(jsonPath("$.charts.[0].chartId.name", is("HelloWorld"))); + } + + /** + * Test endpoint for installing a chart. + * @throws Exception incase of error. + */ + @Test + void installChart() throws Exception { + RequestBuilder requestBuilder; + + //Mocking successful installation for void install method + doNothing().when(chartService).installChart(charts.get(0)); + + requestBuilder = MockMvcRequestBuilders.post(INSTALL_CHART_URL).accept(MediaType.APPLICATION_JSON_VALUE) + .content(getInstallationJson(charts.get(0).getChartId().getName(), charts.get(0).getChartId().getVersion())) + .contentType(MediaType.APPLICATION_JSON_VALUE); + + mockMvc.perform(requestBuilder).andExpect(status().isCreated()); + + //Install Invalid chart, expects HTTP status NOT_FOUND + requestBuilder = MockMvcRequestBuilders.post(INSTALL_CHART_URL).accept(MediaType.APPLICATION_JSON_VALUE) + .content(getInstallationJson("invalidName", "invalidVersion")) + .contentType(MediaType.APPLICATION_JSON_VALUE); + + mockMvc.perform(requestBuilder).andExpect(status().isNotFound()); + } + + /** + * Test endpoint for uninstalling a chart. + * @throws Exception incase of error. + */ + @Test + void uninstallChart() throws Exception { + RequestBuilder requestBuilder; + + //Mocking successful scenario for void uninstall method + doNothing().when(chartService).uninstallChart(charts.get(0)); + + requestBuilder = MockMvcRequestBuilders.delete(UNINSTALL_CHART_URL + charts.get(0) + .getChartId().getName() + "/" + charts.get(0).getChartId().getVersion()) + .accept(MediaType.APPLICATION_JSON_VALUE).contentType(MediaType.APPLICATION_JSON_VALUE); + + mockMvc.perform(requestBuilder).andExpect(status().isNoContent()); + + //Invalid chart + requestBuilder = MockMvcRequestBuilders.delete(UNINSTALL_CHART_URL + "invalidName" + + "/" + "invalidVersion").accept(MediaType.APPLICATION_JSON_VALUE) + .contentType(MediaType.APPLICATION_JSON_VALUE); + + mockMvc.perform(requestBuilder).andExpect(status().isNotFound()); + } + + /** + * Test endpoint for chart onboarding. + * @throws Exception incase of error. + */ + @Test + void onboardChart() throws Exception { + RequestBuilder requestBuilder; + MockMultipartFile chartFile = new MockMultipartFile("chart", "hello.tgz", + MediaType.TEXT_PLAIN_VALUE, "Dummy data".getBytes()); + + MockMultipartFile overrideFile = new MockMultipartFile("values", "values.yaml", + MediaType.TEXT_PLAIN_VALUE, "Dummy data".getBytes()); + + //Mocking successful scenario for void uninstall method + when(chartService.saveChart(charts.get(0), chartFile, null)).thenReturn(charts.get(0)); + + requestBuilder = MockMvcRequestBuilders.multipart(ONBOARD_CHART_URL) + .file(chartFile).file(overrideFile).param("info", getChartInfoJson()); + + mockMvc.perform(requestBuilder).andExpect(status().isOk()); + } + + /** + * Test endpoint for deleting a chart. + * @throws Exception incase of error. + */ + @Test + void deleteChart() throws Exception { + RequestBuilder requestBuilder; + + //Mocking successful scenario for void uninstall method + doNothing().when(chartService).deleteChart(charts.get(0)); + + requestBuilder = MockMvcRequestBuilders.delete(DELETE_CHART_URL + "/" + charts.get(0) + .getChartId().getName() + "/" + charts.get(0).getChartId().getVersion()) + .accept(MediaType.APPLICATION_JSON_VALUE) + .contentType(MediaType.APPLICATION_JSON_VALUE); + + mockMvc.perform(requestBuilder).andExpect(status().isNoContent()); + //Invalid chart + requestBuilder = MockMvcRequestBuilders.delete(UNINSTALL_CHART_URL + "invalidName" + + "/" + "invalidVersion").accept(MediaType.APPLICATION_JSON_VALUE) + .contentType(MediaType.APPLICATION_JSON_VALUE); + + mockMvc.perform(requestBuilder).andExpect(status().isNotFound()); + + } + + /** + * Test endpoint for configuring a helm repository. + * @throws Exception in case of error. + */ + @Test + void testConfigureRepo() throws Exception { + RequestBuilder requestBuilder; + + requestBuilder = MockMvcRequestBuilders.post(CONFIGURE_REPO_URL).accept(MediaType.APPLICATION_JSON_VALUE) + .content(getInstallationJson(charts.get(0).getChartId().getName(), charts.get(0).getChartId().getVersion())) + .contentType(MediaType.APPLICATION_JSON_VALUE); + + mockMvc.perform(requestBuilder).andExpect(status().isCreated()); + + } + + + private String getInstallationJson(String name, String version) { + JSONObject jsonObj = new JSONObject(); + jsonObj.put("name", name); + jsonObj.put("version", version); + return jsonObj.toString(); + } + + private String getChartInfoJson() throws IOException { + return FileUtils.readFileToString(new File(CHART_INFO_YAML), StandardCharsets.UTF_8); + } + +} diff --git a/participant/participant-impl/participant-impl-kubernetes/src/test/java/org/onap/policy/clamp/acm/participant/kubernetes/service/ChartServiceTest.java b/participant/participant-impl/participant-impl-kubernetes/src/test/java/org/onap/policy/clamp/acm/participant/kubernetes/service/ChartServiceTest.java new file mode 100644 index 000000000..f5b6093d3 --- /dev/null +++ b/participant/participant-impl/participant-impl-kubernetes/src/test/java/org/onap/policy/clamp/acm/participant/kubernetes/service/ChartServiceTest.java @@ -0,0 +1,148 @@ +/*- + * ============LICENSE_START======================================================= + * Copyright (C) 2021 Nordix Foundation. + * Modifications Copyright (C) 2021 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * SPDX-License-Identifier: Apache-2.0 + * ============LICENSE_END========================================================= + */ + +package org.onap.policy.clamp.acm.participant.kubernetes.service; + +import static org.assertj.core.api.Assertions.assertThat; +import static org.assertj.core.api.Assertions.assertThatThrownBy; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNotNull; +import static org.junit.Assert.assertNull; +import static org.junit.jupiter.api.Assertions.assertDoesNotThrow; +import static org.mockito.ArgumentMatchers.any; +import static org.mockito.Mockito.doNothing; +import static org.mockito.Mockito.doReturn; +import static org.mockito.Mockito.doThrow; + +import java.io.File; +import java.io.IOException; +import java.util.Collection; +import java.util.List; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.ExtendWith; +import org.mockito.InjectMocks; +import org.mockito.Mock; +import org.mockito.Spy; +import org.onap.policy.clamp.acm.participant.kubernetes.exception.ServiceException; +import org.onap.policy.clamp.acm.participant.kubernetes.helm.HelmClient; +import org.onap.policy.clamp.acm.participant.kubernetes.models.ChartInfo; +import org.onap.policy.clamp.acm.participant.kubernetes.models.ChartList; +import org.onap.policy.common.utils.coder.Coder; +import org.onap.policy.common.utils.coder.CoderException; +import org.onap.policy.common.utils.coder.StandardCoder; +import org.springframework.mock.web.MockMultipartFile; +import org.springframework.test.context.junit.jupiter.SpringExtension; + +@ExtendWith(SpringExtension.class) +class ChartServiceTest { + + private static final Coder CODER = new StandardCoder(); + private static final String CHART_INFO_YAML = "src/test/resources/ChartList.json"; + private static List charts; + + @InjectMocks + @Spy + private ChartService chartService = new ChartService(); + + @Mock + private ChartStore chartStore; + + @Mock + private HelmClient helmClient; + + @BeforeAll + static void init() throws CoderException { + charts = CODER.decode(new File(CHART_INFO_YAML), ChartList.class).getCharts(); + } + + @Test + void test_getAllCharts() { + assertThat(chartService.getAllCharts()).isEmpty(); + + doReturn(charts).when(chartStore).getAllCharts(); + Collection result = chartService.getAllCharts(); + assertNotNull(result); + assertThat(result).containsAll(charts); + } + + @Test + void test_getChart() { + assertNull(chartService.getChart("dummyName", "dummyversion")); + + doReturn(charts.get(0)).when(chartStore).getChart(any(), any()); + ChartInfo chart = chartService.getChart(charts.get(0).getChartId().getName(), + charts.get(0).getChartId().getVersion()); + assertNotNull(chart); + assertThat(chart.getNamespace()).isEqualTo(charts.get(0).getNamespace()); + } + + @Test + void test_saveChart() throws IOException, ServiceException { + doThrow(IOException.class).when(chartStore).saveChart(charts.get(0), null, null); + assertThatThrownBy(() -> chartService.saveChart(charts.get(0), null, null)) + .isInstanceOf(IOException.class); + + MockMultipartFile mockChartFile = new MockMultipartFile("chart", "dummy".getBytes()); + MockMultipartFile mockOverrideFile = new MockMultipartFile("override", "dummy".getBytes()); + + doReturn(charts.get(0)).when(chartStore).saveChart(any(), any(), any()); + + ChartInfo chart = chartService.saveChart(charts.get(0), mockChartFile, mockOverrideFile); + assertNotNull(chart); + assertThat(chart.getChartId().getName()).isEqualTo(charts.get(0).getChartId().getName()); + + } + + @Test + void test_installChart() throws IOException, ServiceException { + assertDoesNotThrow(() -> chartService.installChart(charts.get(0))); + doThrow(ServiceException.class).when(helmClient).installChart(any()); + assertThatThrownBy(() -> chartService.installChart(charts.get(0))).isInstanceOf(ServiceException.class); + + doReturn("dummyRepoName").when(chartService).findChartRepo(any()); + doNothing().when(helmClient).installChart(any()); + chartService.installChart(charts.get(1)); + assertEquals("dummyRepoName", charts.get(1).getRepository().getRepoName()); + + ChartInfo testChart = charts.get(1); + testChart.setRepository(null); + doReturn(null).when(chartService).findChartRepo(any()); + chartService.installChart(charts.get(1)); + } + + @Test + void test_UninstallChart() throws ServiceException { + assertDoesNotThrow(() -> chartService.uninstallChart(charts.get(0))); + doThrow(ServiceException.class).when(helmClient).uninstallChart(any()); + assertThatThrownBy(() -> chartService.uninstallChart(charts.get(0))).isInstanceOf(ServiceException.class); + } + + @Test + void test_findChartRepo() throws IOException, ServiceException { + assertDoesNotThrow(() -> chartService.findChartRepo(charts.get(0))); + doReturn("dummyRepoName").when(helmClient).findChartRepository(any()); + assertEquals("dummyRepoName", chartService.findChartRepo(charts.get(1))); + + doThrow(ServiceException.class).when(helmClient).findChartRepository(any()); + assertThatThrownBy(() -> chartService.findChartRepo(charts.get(0))).isInstanceOf(ServiceException.class); + } +} diff --git a/participant/participant-impl/participant-impl-kubernetes/src/test/java/org/onap/policy/clamp/acm/participant/kubernetes/service/ChartStoreTest.java b/participant/participant-impl/participant-impl-kubernetes/src/test/java/org/onap/policy/clamp/acm/participant/kubernetes/service/ChartStoreTest.java new file mode 100644 index 000000000..180861bae --- /dev/null +++ b/participant/participant-impl/participant-impl-kubernetes/src/test/java/org/onap/policy/clamp/acm/participant/kubernetes/service/ChartStoreTest.java @@ -0,0 +1,175 @@ +/*- + * ============LICENSE_START======================================================= + * Copyright (C) 2021 Nordix Foundation. + * Modifications Copyright (C) 2021 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * SPDX-License-Identifier: Apache-2.0 + * ============LICENSE_END========================================================= + */ + +package org.onap.policy.clamp.acm.participant.kubernetes.service; + +import static org.assertj.core.api.Assertions.assertThat; +import static org.assertj.core.api.Assertions.assertThatThrownBy; +import static org.junit.Assert.assertNull; +import static org.junit.jupiter.api.Assertions.assertNotNull; + +import java.io.File; +import java.io.IOException; +import java.nio.file.Path; +import java.util.List; +import org.junit.jupiter.api.AfterEach; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.ExtendWith; +import org.mockito.Mock; +import org.mockito.Mockito; +import org.mockito.junit.jupiter.MockitoExtension; +import org.mockito.junit.jupiter.MockitoSettings; +import org.mockito.quality.Strictness; +import org.onap.policy.clamp.acm.participant.kubernetes.exception.ServiceException; +import org.onap.policy.clamp.acm.participant.kubernetes.models.ChartInfo; +import org.onap.policy.clamp.acm.participant.kubernetes.models.ChartList; +import org.onap.policy.clamp.acm.participant.kubernetes.parameters.ParticipantK8sParameters; +import org.onap.policy.common.utils.coder.Coder; +import org.onap.policy.common.utils.coder.CoderException; +import org.onap.policy.common.utils.coder.StandardCoder; +import org.onap.policy.models.tosca.authorative.concepts.ToscaConceptIdentifier; +import org.springframework.mock.web.MockMultipartFile; +import org.springframework.util.FileSystemUtils; + + +@ExtendWith(MockitoExtension.class) +@MockitoSettings(strictness = Strictness.LENIENT) +class ChartStoreTest { + + private static final Coder CODER = new StandardCoder(); + private static final String CHART_INFO_YAML = "src/test/resources/ChartList.json"; + private static List charts; + + @Mock + private ParticipantK8sParameters parameters; + + private ChartStore chartStore; + + + @BeforeAll + static void init() throws CoderException { + charts = CODER.decode(new File(CHART_INFO_YAML), ChartList.class).getCharts(); + } + + //Overriding the local chart dir parameter to a temp folder under target for testing java FILE IO operations. + @BeforeEach + void setup() { + Mockito.doReturn("target/tmp/").when(parameters).getLocalChartDirectory(); + Mockito.doReturn("info.json").when(parameters).getInfoFileName(); + chartStore = new ChartStore(parameters); + } + + //Clean up the 'tmp' dir after each test case. + @AfterEach + void cleanUp() throws IOException { + FileSystemUtils.deleteRecursively(Path.of(parameters.getLocalChartDirectory())); + chartStore.getLocalChartMap().clear(); + } + + @Test + void test_getHelmChartFile() { + File file = chartStore.getHelmChartFile(charts.get(0)); + assertNotNull(file); + assertThat(file.getPath()).endsWith(charts.get(0).getChartId().getName()); + } + + @Test + void test_getOverrideFile() { + File file = chartStore.getOverrideFile(charts.get(0)); + assertNotNull(file); + assertThat(file.getPath()).endsWith("values.yaml"); + } + + @Test + void test_saveChart() throws IOException, ServiceException { + MockMultipartFile mockChartFile = new MockMultipartFile("chart", "dummy".getBytes()); + MockMultipartFile mockOverrideFile = new MockMultipartFile("override", "dummy".getBytes()); + ChartInfo testChart = charts.get(0); + testChart.setChartId(new ToscaConceptIdentifier("testChart", "1.0.0")); + ChartInfo result = chartStore.saveChart(charts.get(0), mockChartFile, mockOverrideFile); + + assertThat(result.getChartId().getName()).isEqualTo("testChart"); + assertThat(chartStore.getLocalChartMap()).hasSize(1); + + assertThatThrownBy(() -> chartStore.saveChart(charts.get(0), mockChartFile, mockOverrideFile)) + .isInstanceOf(ServiceException.class); + } + + + @Test + void test_getChart() { + assertNull(chartStore.getChart(charts.get(0).getChartId().getName(), charts.get(0).getChartId().getVersion())); + chartStore.getLocalChartMap().put(charts.get(0).getChartId().getName() + "_" + charts.get(0).getChartId() + .getVersion(), charts.get(0)); + ChartInfo chart = chartStore.getChart(charts.get(0).getChartId().getName(), + charts.get(0).getChartId().getVersion()); + assertThat(chart.getChartId().getName()).isEqualTo(charts.get(0).getChartId().getName()); + } + + @Test + void test_getAllChart() { + // When the chart store is empty before adding any charts + assertThat(chartStore.getAllCharts()).isEmpty(); + + for (ChartInfo chart : charts) { + chartStore.getLocalChartMap().put(chart.getChartId().getName() + "_" + chart.getChartId().getVersion(), + chart); + } + List retrievedChartList = chartStore.getAllCharts(); + assertThat(retrievedChartList).isNotEmpty(); + assertThat(retrievedChartList.size()).isEqualTo(charts.size()); + } + + @Test + void test_deleteChart() { + chartStore.getLocalChartMap().put(charts.get(0).getChartId().getName() + "_" + charts.get(0).getChartId() + .getVersion(), charts.get(0)); + assertThat(chartStore.getLocalChartMap()).hasSize(1); + chartStore.deleteChart(charts.get(0)); + assertThat(chartStore.getLocalChartMap()).isEmpty(); + } + + @Test + void test_getAppPath() { + Path path = chartStore.getAppPath(charts.get(0).getChartId()); + assertNotNull(path); + assertThat(path.toString()).endsWith(charts.get(0).getChartId().getVersion()); + assertThat(path.toString()).startsWith("target"); + } + + @Test + void test_chartSoreInstantiationWithExistingChartFiles() throws IOException, ServiceException { + MockMultipartFile mockChartFile = new MockMultipartFile("HelmChartFile", "dummyData".getBytes()); + MockMultipartFile mockOverrideFile = new MockMultipartFile("overrideFile.yaml", "dummyData".getBytes()); + ChartInfo testChart = charts.get(0); + testChart.setChartId(new ToscaConceptIdentifier("dummyChart", "1.0.0")); + + //Creating a dummy chart in local dir. + chartStore.saveChart(charts.get(0), mockChartFile, mockOverrideFile); + + //Instantiating a new chartStore object with pre available chart in local. + ChartStore chartStore2 = new ChartStore(parameters); + assertThat(chartStore2.getLocalChartMap()).hasSize(1).containsKey("dummyChart_" + charts.get(0).getChartId() + .getVersion()); + } +} diff --git a/participant/participant-impl/participant-impl-kubernetes/src/test/java/org/onap/policy/clamp/acm/participant/kubernetes/utils/CommonActuatorController.java b/participant/participant-impl/participant-impl-kubernetes/src/test/java/org/onap/policy/clamp/acm/participant/kubernetes/utils/CommonActuatorController.java new file mode 100644 index 000000000..e5a5be9fa --- /dev/null +++ b/participant/participant-impl/participant-impl-kubernetes/src/test/java/org/onap/policy/clamp/acm/participant/kubernetes/utils/CommonActuatorController.java @@ -0,0 +1,114 @@ +/*- + * ============LICENSE_START======================================================= + * Copyright (C) 2021 Nordix Foundation. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * SPDX-License-Identifier: Apache-2.0 + * ============LICENSE_END========================================================= + */ + +package org.onap.policy.clamp.acm.participant.kubernetes.utils; + +import static org.junit.Assert.assertEquals; + +import javax.ws.rs.client.Client; +import javax.ws.rs.client.ClientBuilder; +import javax.ws.rs.client.Invocation; +import javax.ws.rs.client.WebTarget; +import javax.ws.rs.core.MediaType; +import javax.ws.rs.core.Response; +import org.glassfish.jersey.client.ClientProperties; +import org.glassfish.jersey.client.authentication.HttpAuthenticationFeature; +import org.onap.policy.common.gson.GsonMessageBodyHandler; +import org.onap.policy.common.utils.network.NetworkUtil; + +/** + * Class to perform Rest unit tests. + * + */ +public class CommonActuatorController { + + public static final String SELF = NetworkUtil.getHostname(); + public static final String CONTEXT_PATH = "onap/policy/clamp/acm/k8sparticipant"; + public static final String ACTUATOR_ENDPOINT = CONTEXT_PATH + "/actuator/"; + + private static String httpPrefix; + + /** + * Sends a request to an actuator endpoint. + * + * @param endpoint the target endpoint + * @return a request builder + * @throws Exception if an error occurs + */ + protected Invocation.Builder sendActRequest(final String endpoint) throws Exception { + return sendFqeRequest(httpPrefix + ACTUATOR_ENDPOINT + endpoint, true); + } + + /** + * Sends a request to an actuator endpoint, without any authorization header. + * + * @param endpoint the target endpoint + * @return a request builder + * @throws Exception if an error occurs + */ + protected Invocation.Builder sendNoAuthActRequest(final String endpoint) throws Exception { + return sendFqeRequest(httpPrefix + ACTUATOR_ENDPOINT + endpoint, false); + } + + /** + * Sends a request to a fully qualified endpoint. + * + * @param fullyQualifiedEndpoint the fully qualified target endpoint + * @param includeAuth if authorization header should be included + * @return a request builder + * @throws Exception if an error occurs + */ + protected Invocation.Builder sendFqeRequest(final String fullyQualifiedEndpoint, boolean includeAuth) + throws Exception { + final Client client = ClientBuilder.newBuilder().build(); + + client.property(ClientProperties.METAINF_SERVICES_LOOKUP_DISABLE, "true"); + client.register(GsonMessageBodyHandler.class); + + if (includeAuth) { + client.register(HttpAuthenticationFeature.basic("participantUser", "zb!XztG34")); + } + + final WebTarget webTarget = client.target(fullyQualifiedEndpoint); + + return webTarget.request(MediaType.APPLICATION_JSON, MediaType.TEXT_PLAIN); + } + + /** + * Assert that GET call to actuator endpoint is Unauthorized. + * + * @param endPoint the endpoint + * @throws Exception if an error occurs + */ + protected void assertUnauthorizedActGet(final String endPoint) throws Exception { + Response rawresp = sendNoAuthActRequest(endPoint).buildGet().invoke(); + assertEquals(Response.Status.UNAUTHORIZED.getStatusCode(), rawresp.getStatus()); + } + + /** + * Set Up httpPrefix. + * + * @param port the port + */ + protected void setHttpPrefix(int port) { + httpPrefix = "http://" + SELF + ":" + port + "/"; + } + +} diff --git a/participant/participant-impl/participant-impl-kubernetes/src/test/java/org/onap/policy/clamp/acm/participant/kubernetes/utils/TestUtils.java b/participant/participant-impl/participant-impl-kubernetes/src/test/java/org/onap/policy/clamp/acm/participant/kubernetes/utils/TestUtils.java new file mode 100644 index 000000000..8f4969a9b --- /dev/null +++ b/participant/participant-impl/participant-impl-kubernetes/src/test/java/org/onap/policy/clamp/acm/participant/kubernetes/utils/TestUtils.java @@ -0,0 +1,47 @@ +/*- + * ============LICENSE_START======================================================= + * Copyright (C) 2021 Nordix Foundation. + * Modifications Copyright (C) 2021 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * SPDX-License-Identifier: Apache-2.0 + * ============LICENSE_END========================================================= + */ + +package org.onap.policy.clamp.acm.participant.kubernetes.utils; + +import lombok.AccessLevel; +import lombok.NoArgsConstructor; +import org.onap.policy.common.utils.coder.YamlJsonTranslator; +import org.onap.policy.common.utils.resources.ResourceUtils; +import org.onap.policy.models.tosca.authorative.concepts.ToscaServiceTemplate; + +@NoArgsConstructor(access = AccessLevel.PRIVATE) +public final class TestUtils { + + private static final YamlJsonTranslator yamlTranslator = new YamlJsonTranslator(); + private static final String TOSCA_TEMPLATE_YAML = "src/test/resources/servicetemplates/KubernetesHelm.yaml"; + + public static ToscaServiceTemplate testAutomationCompositionRead() { + return testAutomationCompositionYamlSerialization(TOSCA_TEMPLATE_YAML); + } + + private static ToscaServiceTemplate testAutomationCompositionYamlSerialization( + String automationCompositionFilePath) { + String automationCompositionString = ResourceUtils.getResourceAsString(automationCompositionFilePath); + ToscaServiceTemplate serviceTemplate = + yamlTranslator.fromYaml(automationCompositionString, ToscaServiceTemplate.class); + return serviceTemplate; + } +} diff --git a/participant/participant-impl/participant-impl-kubernetes/src/test/java/org/onap/policy/clamp/controlloop/participant/kubernetes/handler/ControlLoopElementHandlerTest.java b/participant/participant-impl/participant-impl-kubernetes/src/test/java/org/onap/policy/clamp/controlloop/participant/kubernetes/handler/ControlLoopElementHandlerTest.java deleted file mode 100644 index 805404b90..000000000 --- a/participant/participant-impl/participant-impl-kubernetes/src/test/java/org/onap/policy/clamp/controlloop/participant/kubernetes/handler/ControlLoopElementHandlerTest.java +++ /dev/null @@ -1,180 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * Copyright (C) 2021-2022 Nordix Foundation. - * Modifications Copyright (C) 2021 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - * SPDX-License-Identifier: Apache-2.0 - * ============LICENSE_END========================================================= - */ - -package org.onap.policy.clamp.controlloop.participant.kubernetes.handler; - -import static org.assertj.core.api.Assertions.assertThat; -import static org.junit.jupiter.api.Assertions.assertDoesNotThrow; -import static org.mockito.ArgumentMatchers.any; -import static org.mockito.ArgumentMatchers.anyInt; -import static org.mockito.Mockito.doNothing; -import static org.mockito.Mockito.doReturn; -import static org.mockito.Mockito.doThrow; -import static org.mockito.Mockito.when; - -import java.io.File; -import java.io.IOException; -import java.util.List; -import java.util.Map; -import java.util.UUID; -import java.util.concurrent.ExecutionException; -import java.util.concurrent.ExecutorService; -import java.util.concurrent.Future; -import org.junit.jupiter.api.BeforeAll; -import org.junit.jupiter.api.Test; -import org.junit.jupiter.api.extension.ExtendWith; -import org.mockito.InjectMocks; -import org.mockito.Mock; -import org.mockito.Mockito; -import org.mockito.Spy; -import org.onap.policy.clamp.controlloop.models.controlloop.concepts.ControlLoopElement; -import org.onap.policy.clamp.controlloop.models.controlloop.concepts.ControlLoopOrderedState; -import org.onap.policy.clamp.controlloop.models.controlloop.concepts.ControlLoopState; -import org.onap.policy.clamp.controlloop.participant.intermediary.api.ParticipantIntermediaryApi; -import org.onap.policy.clamp.controlloop.participant.kubernetes.exception.ServiceException; -import org.onap.policy.clamp.controlloop.participant.kubernetes.models.ChartInfo; -import org.onap.policy.clamp.controlloop.participant.kubernetes.models.ChartList; -import org.onap.policy.clamp.controlloop.participant.kubernetes.parameters.CommonTestData; -import org.onap.policy.clamp.controlloop.participant.kubernetes.service.ChartService; -import org.onap.policy.clamp.controlloop.participant.kubernetes.utils.TestUtils; -import org.onap.policy.common.utils.coder.Coder; -import org.onap.policy.common.utils.coder.CoderException; -import org.onap.policy.common.utils.coder.StandardCoder; -import org.onap.policy.models.base.PfModelException; -import org.onap.policy.models.tosca.authorative.concepts.ToscaConceptIdentifier; -import org.onap.policy.models.tosca.authorative.concepts.ToscaNodeTemplate; -import org.onap.policy.models.tosca.authorative.concepts.ToscaServiceTemplate; -import org.springframework.test.context.junit.jupiter.SpringExtension; - - -@ExtendWith(SpringExtension.class) -class ControlLoopElementHandlerTest { - - private static final Coder CODER = new StandardCoder(); - private static final String CHART_INFO_YAML = "src/test/resources/ChartList.json"; - private static final String KEY_NAME = "org.onap.domain.database.HelloWorld_K8SMicroserviceControlLoopElement"; - private static List charts; - private static ToscaServiceTemplate toscaServiceTemplate; - private static final String K8S_CONTROL_LOOP_ELEMENT = - "org.onap.domain.database.PMSH_K8SMicroserviceControlLoopElement"; - private CommonTestData commonTestData = new CommonTestData(); - - @InjectMocks - @Spy - private ControlLoopElementHandler controlLoopElementHandler = new ControlLoopElementHandler(); - - @Mock - private ChartService chartService; - - @Mock - private ParticipantIntermediaryApi participantIntermediaryApi; - - @Mock - private ExecutorService executor; - - @Mock - private Future result; - - @BeforeAll - static void init() throws CoderException { - charts = CODER.decode(new File(CHART_INFO_YAML), ChartList.class).getCharts(); - toscaServiceTemplate = TestUtils.testControlLoopRead(); - } - - - @Test - void test_ControlLoopElementStateChange() throws ServiceException { - UUID controlLoopElementId1 = UUID.randomUUID(); - UUID controlLoopElementId2 = UUID.randomUUID(); - - controlLoopElementHandler.getChartMap().put(controlLoopElementId1, charts.get(0)); - controlLoopElementHandler.getChartMap().put(controlLoopElementId2, charts.get(1)); - - doNothing().when(chartService).uninstallChart(charts.get(0)); - - controlLoopElementHandler.controlLoopElementStateChange(commonTestData.getControlLoopId(), - controlLoopElementId1, ControlLoopState.PASSIVE, ControlLoopOrderedState.UNINITIALISED); - - doThrow(new ServiceException("Error uninstalling the chart")).when(chartService) - .uninstallChart(charts.get(0)); - - assertDoesNotThrow(() -> controlLoopElementHandler - .controlLoopElementStateChange(commonTestData.getControlLoopId(), controlLoopElementId1, - ControlLoopState.PASSIVE, ControlLoopOrderedState.PASSIVE)); - - assertDoesNotThrow(() -> controlLoopElementHandler - .controlLoopElementStateChange(commonTestData.getControlLoopId(), controlLoopElementId1, - ControlLoopState.PASSIVE, ControlLoopOrderedState.UNINITIALISED)); - - assertDoesNotThrow(() -> controlLoopElementHandler - .controlLoopElementStateChange(commonTestData.getControlLoopId(), controlLoopElementId1, - ControlLoopState.PASSIVE, ControlLoopOrderedState.RUNNING)); - - } - - @Test - void test_ControlLoopElementUpdate() throws PfModelException, IOException, ServiceException, - ExecutionException, InterruptedException { - doNothing().when(controlLoopElementHandler).checkPodStatus(any(), any(), any(), anyInt(), anyInt()); - UUID elementId1 = UUID.randomUUID(); - ControlLoopElement element = new ControlLoopElement(); - element.setId(elementId1); - element.setDefinition(new ToscaConceptIdentifier(KEY_NAME, "1.0.1")); - element.setOrderedState(ControlLoopOrderedState.PASSIVE); - - Map nodeTemplatesMap = - toscaServiceTemplate.getToscaTopologyTemplate().getNodeTemplates(); - controlLoopElementHandler.controlLoopElementUpdate(commonTestData.getControlLoopId(), element, - nodeTemplatesMap.get(K8S_CONTROL_LOOP_ELEMENT)); - - assertThat(controlLoopElementHandler.getChartMap()).hasSize(1).containsKey(elementId1); - - doThrow(new ServiceException("Error installing the chart")).when(chartService) - .installChart(Mockito.any()); - - UUID elementId2 = UUID.randomUUID(); - element.setId(elementId2); - controlLoopElementHandler.controlLoopElementUpdate(commonTestData.getControlLoopId(), element, - nodeTemplatesMap.get(K8S_CONTROL_LOOP_ELEMENT)); - - assertThat(controlLoopElementHandler.getChartMap().containsKey(elementId2)).isFalse(); - } - - @Test - void test_handleStatistics() throws PfModelException { - UUID elementId1 = UUID.randomUUID(); - controlLoopElementHandler.getChartMap().put(elementId1, charts.get(0)); - when(participantIntermediaryApi.getControlLoopElement(elementId1)).thenReturn(new ControlLoopElement()); - assertDoesNotThrow(() -> controlLoopElementHandler.handleStatistics(elementId1)); - } - - @Test - void test_checkPodStatus() throws ExecutionException, InterruptedException { - doReturn(result).when(executor).submit(any(Runnable.class), any()); - doReturn("Done").when(result).get(); - doReturn(true).when(result).isDone(); - var chartInfo = charts.get(0); - ToscaConceptIdentifier controlLoopId = new ToscaConceptIdentifier(); - ControlLoopElement element = new ControlLoopElement(); - assertDoesNotThrow(() -> controlLoopElementHandler.checkPodStatus(controlLoopId, element.getId(), chartInfo, - 1, 1)); - } -} diff --git a/participant/participant-impl/participant-impl-kubernetes/src/test/java/org/onap/policy/clamp/controlloop/participant/kubernetes/helm/HelmClientTest.java b/participant/participant-impl/participant-impl-kubernetes/src/test/java/org/onap/policy/clamp/controlloop/participant/kubernetes/helm/HelmClientTest.java deleted file mode 100644 index 335dbcb21..000000000 --- a/participant/participant-impl/participant-impl-kubernetes/src/test/java/org/onap/policy/clamp/controlloop/participant/kubernetes/helm/HelmClientTest.java +++ /dev/null @@ -1,158 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * Copyright (C) 2021 Nordix Foundation. - * Modifications Copyright (C) 2021 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - * SPDX-License-Identifier: Apache-2.0 - * ============LICENSE_END========================================================= - */ - -package org.onap.policy.clamp.controlloop.participant.kubernetes.helm; - -import static org.assertj.core.api.Assertions.assertThat; -import static org.assertj.core.api.Assertions.assertThatThrownBy; -import static org.junit.Assert.assertNull; -import static org.junit.jupiter.api.Assertions.assertDoesNotThrow; -import static org.junit.jupiter.api.Assertions.assertNotNull; -import static org.mockito.ArgumentMatchers.any; -import static org.mockito.Mockito.doReturn; -import static org.mockito.Mockito.mockStatic; -import static org.mockito.Mockito.when; - -import java.io.File; -import java.io.IOException; -import java.nio.file.Path; -import java.util.List; -import org.junit.jupiter.api.AfterAll; -import org.junit.jupiter.api.BeforeAll; -import org.junit.jupiter.api.Test; -import org.junit.jupiter.api.extension.ExtendWith; -import org.mockito.InjectMocks; -import org.mockito.Mock; -import org.mockito.MockedStatic; -import org.mockito.Mockito; -import org.mockito.Spy; -import org.onap.policy.clamp.controlloop.participant.kubernetes.exception.ServiceException; -import org.onap.policy.clamp.controlloop.participant.kubernetes.models.ChartInfo; -import org.onap.policy.clamp.controlloop.participant.kubernetes.models.ChartList; -import org.onap.policy.clamp.controlloop.participant.kubernetes.models.HelmRepository; -import org.onap.policy.clamp.controlloop.participant.kubernetes.service.ChartStore; -import org.onap.policy.common.utils.coder.Coder; -import org.onap.policy.common.utils.coder.CoderException; -import org.onap.policy.common.utils.coder.StandardCoder; -import org.springframework.test.context.junit.jupiter.SpringExtension; -import org.springframework.util.FileSystemUtils; - - -@ExtendWith(SpringExtension.class) -class HelmClientTest { - - private static final Coder CODER = new StandardCoder(); - private static final String CHART_INFO_YAML = "src/test/resources/ChartList.json"; - private static List charts; - - @InjectMocks - @Spy - private HelmClient helmClient = new HelmClient(); - - @Mock - ChartStore chartStore; - - @Mock - HelmRepository repo; - - private static MockedStatic mockedClient; - - @BeforeAll - static void init() throws CoderException { - charts = CODER.decode(new File(CHART_INFO_YAML), ChartList.class).getCharts(); - //Mock static method for bash command execution - mockedClient = mockStatic(HelmClient.class); - } - - @AfterAll - public static void close() throws IOException { - mockedClient.close(); - FileSystemUtils.deleteRecursively(Path.of("target/tmp")); - } - - @Test - void test_installChart() throws IOException { - mockedClient.when(() -> HelmClient.executeCommand(any())) - .thenReturn("success"); - doReturn(new File("/target/tmp/override.yaml")).when(chartStore) - .getOverrideFile(any()); - var chartinfo = charts.get(0); - - assertDoesNotThrow(() -> helmClient.installChart(chartinfo)); - chartinfo.setNamespace(""); - assertDoesNotThrow(() -> helmClient.installChart(chartinfo)); - - mockedClient.when(() -> HelmClient.executeCommand(any())) - .thenReturn(new String()); - assertDoesNotThrow(() -> helmClient.installChart(chartinfo)); - - } - - @Test - void test_addRepository() throws IOException { - mockedClient.when(() -> HelmClient.executeCommand(any())) - .thenReturn(new String()); - when(repo.getRepoName()).thenReturn("RepoName"); - assertDoesNotThrow(() -> helmClient.addRepository(repo)); - - mockedClient.when(() -> HelmClient.executeCommand(any())) - .thenReturn("failed"); - assertDoesNotThrow(() -> helmClient.addRepository(repo)); - } - - @Test - void test_findChartRepository() throws IOException, ServiceException { - String tmpPath = "target/tmp/dummyChart/1.0/"; - mockedClient.when(() -> HelmClient.executeCommand(Mockito.any())) - .thenReturn("nginx-stable/nginx-ingress\t0.9.3\t1.11.3" - + " \tNGINX Ingress Controller"); - String configuredRepo = helmClient.findChartRepository(charts.get(1)); - assertThat(configuredRepo).isEqualTo("nginx-stable"); - - File tmpFile = new File(tmpPath + charts.get(1).getChartId().getName()); - tmpFile.mkdirs(); - doReturn(Path.of(tmpPath)).when(chartStore).getAppPath(charts.get(1).getChartId()); - - doReturn(null).when(helmClient).verifyConfiguredRepo(charts.get(1)); - - String localRepoName = helmClient.findChartRepository(charts.get(1)); - assertNotNull(localRepoName); - assertThat(localRepoName).endsWith(charts.get(0).getChartId().getVersion()); - } - - @Test - void test_uninstallChart() throws ServiceException { - helmClient.uninstallChart(charts.get(0)); - mockedClient.when(() -> HelmClient.executeCommand(any())).thenThrow(new ServiceException("error in execution")); - - assertThatThrownBy(() -> helmClient.uninstallChart(charts.get(0))) - .isInstanceOf(ServiceException.class); - } - - @Test - void test_verifyConfiguredRepoForInvalidChart() throws IOException, ServiceException { - mockedClient.when(() -> HelmClient.executeCommand(Mockito.any())) - .thenReturn(""); - String configuredRepo = helmClient.verifyConfiguredRepo(charts.get(1)); - assertNull(configuredRepo); - } - -} diff --git a/participant/participant-impl/participant-impl-kubernetes/src/test/java/org/onap/policy/clamp/controlloop/participant/kubernetes/helm/PodStatusValidatorTest.java b/participant/participant-impl/participant-impl-kubernetes/src/test/java/org/onap/policy/clamp/controlloop/participant/kubernetes/helm/PodStatusValidatorTest.java deleted file mode 100644 index 18c32d474..000000000 --- a/participant/participant-impl/participant-impl-kubernetes/src/test/java/org/onap/policy/clamp/controlloop/participant/kubernetes/helm/PodStatusValidatorTest.java +++ /dev/null @@ -1,109 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * Copyright (C) 2021 Nordix Foundation. - * Modifications Copyright (C) 2021 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - * SPDX-License-Identifier: Apache-2.0 - * ============LICENSE_END========================================================= - */ - -package org.onap.policy.clamp.controlloop.participant.kubernetes.helm; - - - -import static org.assertj.core.api.Assertions.assertThat; -import static org.assertj.core.api.Assertions.assertThatThrownBy; -import static org.junit.jupiter.api.Assertions.assertDoesNotThrow; -import static org.mockito.ArgumentMatchers.any; -import static org.mockito.Mockito.mockStatic; - -import java.io.File; -import java.util.List; -import java.util.Map; -import org.junit.jupiter.api.AfterAll; -import org.junit.jupiter.api.AfterEach; -import org.junit.jupiter.api.BeforeAll; -import org.junit.jupiter.api.Test; -import org.junit.jupiter.api.extension.ExtendWith; -import org.mockito.InjectMocks; -import org.mockito.MockedStatic; -import org.onap.policy.clamp.controlloop.participant.kubernetes.exception.ServiceException; -import org.onap.policy.clamp.controlloop.participant.kubernetes.handler.ControlLoopElementHandler; -import org.onap.policy.clamp.controlloop.participant.kubernetes.models.ChartInfo; -import org.onap.policy.clamp.controlloop.participant.kubernetes.models.ChartList; -import org.onap.policy.common.utils.coder.Coder; -import org.onap.policy.common.utils.coder.CoderException; -import org.onap.policy.common.utils.coder.StandardCoder; -import org.springframework.test.context.junit.jupiter.SpringExtension; - -@ExtendWith(SpringExtension.class) -class PodStatusValidatorTest { - - - private static final Coder CODER = new StandardCoder(); - private static final String CHART_INFO_YAML = "src/test/resources/ChartList.json"; - private static List charts; - private static int timeout = 60; - private static int statusCheckInterval = 30; - - - @InjectMocks - private static PodStatusValidator podStatusValidator; - - private static MockedStatic mockedClient; - - - @BeforeAll - static void init() throws CoderException { - charts = CODER.decode(new File(CHART_INFO_YAML), ChartList.class).getCharts(); - mockedClient = mockStatic(HelmClient.class); - podStatusValidator = new PodStatusValidator(charts.get(0), timeout, statusCheckInterval); - } - - @AfterEach - void clearPodStatusMap() { - ControlLoopElementHandler.getPodStatusMap().clear(); - } - - @AfterAll - public static void close() { - mockedClient.close(); - } - - - @Test - void test_RunningPodState() { - String runningPod = "NAME\tREADY\tSTATUS\tRESTARTS\tAGE\r\nHelloWorld-54777df9f8-qpzqr\t1/1\tRunning\t0\t9h"; - mockedClient.when(() -> HelmClient.executeCommand(any())) - .thenReturn(runningPod); - assertDoesNotThrow(() -> podStatusValidator.run()); - assertThat(ControlLoopElementHandler.getPodStatusMap()).hasSize(1); - assertThat(ControlLoopElementHandler.getPodStatusMap()).containsKey(charts.get(0).getReleaseName()); - assertThat(ControlLoopElementHandler.getPodStatusMap()) - .containsValue(Map.of("HelloWorld-54777df9f8-qpzqr", "Running")); - } - - - @Test - void test_InvalidPodState() { - String invalidPod = "NAME\tREADY\tSTATUS\tRESTARTS\tAGE\nhellofromdocker-54777df9f8-qpzqr\t1/1\tInit\t0\t9h"; - mockedClient.when(() -> HelmClient.executeCommand(any())) - .thenReturn(invalidPod); - assertThatThrownBy(() -> podStatusValidator.run()) - .isInstanceOf(ServiceException.class).hasMessage("Error verifying the status of the pod. Exiting"); - assertThat(ControlLoopElementHandler.getPodStatusMap()).isEmpty(); - } - -} diff --git a/participant/participant-impl/participant-impl-kubernetes/src/test/java/org/onap/policy/clamp/controlloop/participant/kubernetes/parameters/CommonTestData.java b/participant/participant-impl/participant-impl-kubernetes/src/test/java/org/onap/policy/clamp/controlloop/participant/kubernetes/parameters/CommonTestData.java deleted file mode 100644 index f6ec401b8..000000000 --- a/participant/participant-impl/participant-impl-kubernetes/src/test/java/org/onap/policy/clamp/controlloop/participant/kubernetes/parameters/CommonTestData.java +++ /dev/null @@ -1,161 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * Copyright (C) 2021 Nordix Foundation. - * Modifications Copyright (C) 2021 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - * SPDX-License-Identifier: Apache-2.0 - * ============LICENSE_END========================================================= - */ - -package org.onap.policy.clamp.controlloop.participant.kubernetes.parameters; - -import java.util.Arrays; -import java.util.List; -import java.util.Map; -import java.util.TreeMap; -import org.onap.policy.common.endpoints.parameters.TopicParameters; -import org.onap.policy.common.utils.coder.Coder; -import org.onap.policy.common.utils.coder.CoderException; -import org.onap.policy.common.utils.coder.StandardCoder; -import org.onap.policy.models.tosca.authorative.concepts.ToscaConceptIdentifier; - -public class CommonTestData { - - public static final String PARTICIPANT_GROUP_NAME = "ControlLoopParticipantGroup"; - public static final String DESCRIPTION = "Participant description"; - public static final long TIME_INTERVAL = 2000; - public static final List TOPIC_PARAMS = Arrays.asList(getTopicParams()); - public static final Coder CODER = new StandardCoder(); - - - /** - * Get ParticipantK8sParameters. - * - * @return ParticipantK8sParameters - */ - public ParticipantK8sParameters getParticipantK8sParameters() { - try { - return CODER.convert(getParticipantK8sParametersMap(PARTICIPANT_GROUP_NAME), - ParticipantK8sParameters.class); - } catch (final CoderException e) { - throw new RuntimeException("cannot create ParticipantK8sParameters from map", e); - } - } - - /** - * Returns a property map for a ParticipantK8sParameters map for test cases. - * - * @param name name of the parameters - * - * @return a property map suitable for constructing an object - */ - public Map getParticipantK8sParametersMap(final String name) { - final Map map = new TreeMap<>(); - - map.put("name", name); - map.put("intermediaryParameters", getIntermediaryParametersMap(false)); - map.put("localChartDirectory", getLocalChartDir()); - map.put("infoFileName", getInfoFileName()); - return map; - } - - - /** - * Returns string value of local chart Directory. - * @return a string value - */ - public String getLocalChartDir() { - return "/var/helm-manager/local-charts"; - } - - /** - * Returns string value of Info file name. - * @return string value - */ - public String getInfoFileName() { - return "CHART-INFO.json"; - } - - - - /** - * Returns a property map for a intermediaryParameters map for test cases. - * - * @param isEmpty boolean value to represent that object created should be empty or not - * @return a property map suitable for constructing an object - */ - public Map getIntermediaryParametersMap(final boolean isEmpty) { - final Map map = new TreeMap<>(); - if (!isEmpty) { - map.put("name", "Participant parameters"); - map.put("reportingTimeIntervalMs", TIME_INTERVAL); - map.put("description", DESCRIPTION); - map.put("participantId", getParticipantId()); - map.put("participantType", getParticipantId()); - map.put("clampControlLoopTopics", getTopicParametersMap(false)); - } - - return map; - } - - /** - * Returns participantId for test cases. - * - * @return participant Id - */ - public static ToscaConceptIdentifier getParticipantId() { - final ToscaConceptIdentifier participantId = new ToscaConceptIdentifier(); - participantId.setName("K8sParticipant0"); - participantId.setVersion("1.0.0"); - return participantId; - } - - - /** - * Returns a property map for a TopicParameters map for test cases. - * - * @param isEmpty boolean value to represent that object created should be empty or not - * @return a property map suitable for constructing an object - */ - public Map getTopicParametersMap(final boolean isEmpty) { - final Map map = new TreeMap<>(); - if (!isEmpty) { - map.put("topicSources", TOPIC_PARAMS); - map.put("topicSinks", TOPIC_PARAMS); - } - return map; - } - - /** - * Returns topic parameters for test cases. - * - * @return topic parameters - */ - public static TopicParameters getTopicParams() { - final TopicParameters topicParams = new TopicParameters(); - topicParams.setTopic("POLICY-CLRUNTIME-PARTICIPANT"); - topicParams.setTopicCommInfrastructure("dmaap"); - topicParams.setServers(Arrays.asList("localhost")); - return topicParams; - } - - /** - * Get controlloop id. - * @return ToscaConceptIdentifier controlLoopId - */ - public ToscaConceptIdentifier getControlLoopId() { - return new ToscaConceptIdentifier("PMSHInstance0", "1.0.0"); - } -} diff --git a/participant/participant-impl/participant-impl-kubernetes/src/test/java/org/onap/policy/clamp/controlloop/participant/kubernetes/parameters/ParticipantK8sParametersTest.java b/participant/participant-impl/participant-impl-kubernetes/src/test/java/org/onap/policy/clamp/controlloop/participant/kubernetes/parameters/ParticipantK8sParametersTest.java deleted file mode 100644 index f22fc711e..000000000 --- a/participant/participant-impl/participant-impl-kubernetes/src/test/java/org/onap/policy/clamp/controlloop/participant/kubernetes/parameters/ParticipantK8sParametersTest.java +++ /dev/null @@ -1,89 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * Copyright (C) 2021 Nordix Foundation. - * Modifications Copyright (C) 2021 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - * SPDX-License-Identifier: Apache-2.0 - * ============LICENSE_END========================================================= - */ - -package org.onap.policy.clamp.controlloop.participant.kubernetes.parameters; - -import static org.assertj.core.api.Assertions.assertThat; - -import java.util.Set; -import javax.validation.ConstraintViolation; -import javax.validation.Validation; -import javax.validation.ValidatorFactory; -import org.junit.jupiter.api.Test; - -class ParticipantK8sParametersTest { - - private CommonTestData commonTestData = new CommonTestData(); - private ValidatorFactory validatorFactory = Validation.buildDefaultValidatorFactory(); - - @Test - void testParticipantPolicyParameters() { - final ParticipantK8sParameters participantParameters = commonTestData.getParticipantK8sParameters(); - assertThat(validatorFactory.getValidator().validate(participantParameters)).isNullOrEmpty(); - } - - @Test - void testParticipantK8sParameters_NullTopicSinks() { - final ParticipantK8sParameters participantParameters = commonTestData.getParticipantK8sParameters(); - participantParameters.getIntermediaryParameters().getClampControlLoopTopics().setTopicSinks(null); - assertThat(validatorFactory.getValidator().validate(participantParameters)).isNotEmpty(); - } - - @Test - void testParticipantK8sParameters_NullTopicSources() { - final ParticipantK8sParameters participantParameters = commonTestData.getParticipantK8sParameters(); - participantParameters.getIntermediaryParameters().getClampControlLoopTopics().setTopicSources(null); - assertThat(validatorFactory.getValidator().validate(participantParameters)).isNotEmpty(); - } - - @Test - void testParticipantK8sParameters_BlankLocalChartDirParameter() { - final ParticipantK8sParameters participantParameters = commonTestData.getParticipantK8sParameters(); - participantParameters.setLocalChartDirectory(" "); - Set> violations = validatorFactory.getValidator() - .validate(participantParameters); - assertThat(violations.size()).isEqualTo(1); - } - - @Test - void testParticipantK8sParameters_BlankInfoFileParameter() { - final ParticipantK8sParameters participantParameters = commonTestData.getParticipantK8sParameters(); - participantParameters.setInfoFileName(""); - Set> violations = validatorFactory.getValidator() - .validate(participantParameters); - assertThat(violations.size()).isEqualTo(1); - } - - @Test - void testNoIntermediaryParameters() { - final ParticipantK8sParameters participantParameters = commonTestData.getParticipantK8sParameters(); - participantParameters.setIntermediaryParameters(null); - assertThat(validatorFactory.getValidator().validate(participantParameters)).isNotEmpty(); - } - - @Test - void testNoParticipantId() { - final ParticipantK8sParameters participantParameters = commonTestData.getParticipantK8sParameters(); - participantParameters.getIntermediaryParameters().setParticipantId(null); - assertThat(validatorFactory.getValidator().validate(participantParameters)).isNotEmpty(); - } - -} diff --git a/participant/participant-impl/participant-impl-kubernetes/src/test/java/org/onap/policy/clamp/controlloop/participant/kubernetes/rest/ActuatorControllerTest.java b/participant/participant-impl/participant-impl-kubernetes/src/test/java/org/onap/policy/clamp/controlloop/participant/kubernetes/rest/ActuatorControllerTest.java deleted file mode 100644 index 1442e9f1f..000000000 --- a/participant/participant-impl/participant-impl-kubernetes/src/test/java/org/onap/policy/clamp/controlloop/participant/kubernetes/rest/ActuatorControllerTest.java +++ /dev/null @@ -1,92 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * Copyright (C) 2021 Nordix Foundation. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - * SPDX-License-Identifier: Apache-2.0 - * ============LICENSE_END========================================================= - */ - -package org.onap.policy.clamp.controlloop.participant.kubernetes.rest; - -import static org.junit.jupiter.api.Assertions.assertEquals; - -import javax.ws.rs.client.Invocation; -import javax.ws.rs.core.Response; -import org.junit.jupiter.api.BeforeEach; -import org.junit.jupiter.api.Test; -import org.junit.jupiter.api.extension.ExtendWith; -import org.onap.policy.clamp.controlloop.participant.kubernetes.utils.CommonActuatorController; -import org.springframework.boot.test.autoconfigure.actuate.metrics.AutoConfigureMetrics; -import org.springframework.boot.test.context.SpringBootTest; -import org.springframework.boot.test.context.SpringBootTest.WebEnvironment; -import org.springframework.boot.web.server.LocalServerPort; -import org.springframework.test.context.TestPropertySource; -import org.springframework.test.context.junit.jupiter.SpringExtension; - -@AutoConfigureMetrics -@ExtendWith(SpringExtension.class) -@SpringBootTest(webEnvironment = WebEnvironment.RANDOM_PORT) -@TestPropertySource(locations = {"classpath:application_test.properties"}) -class ActuatorControllerTest extends CommonActuatorController { - - private static final String HEALTH_ENDPOINT = "health"; - private static final String METRICS_ENDPOINT = "metrics"; - private static final String PROMETHEUS_ENDPOINT = "prometheus"; - - @LocalServerPort - private int randomServerPort; - - @BeforeEach - public void setUpPort() { - super.setHttpPrefix(randomServerPort); - } - - @Test - void testGetHealth_Unauthorized() throws Exception { - assertUnauthorizedActGet(HEALTH_ENDPOINT); - } - - @Test - void testGetMetrics_Unauthorized() throws Exception { - assertUnauthorizedActGet(METRICS_ENDPOINT); - } - - @Test - void testGetPrometheus_Unauthorized() throws Exception { - assertUnauthorizedActGet(PROMETHEUS_ENDPOINT); - } - - @Test - void testGetHealth() throws Exception { - Invocation.Builder invocationBuilder = super.sendActRequest(HEALTH_ENDPOINT); - Response rawresp = invocationBuilder.buildGet().invoke(); - assertEquals(Response.Status.OK.getStatusCode(), rawresp.getStatus()); - } - - @Test - void testGetMetrics() throws Exception { - Invocation.Builder invocationBuilder = super.sendActRequest(METRICS_ENDPOINT); - Response rawresp = invocationBuilder.buildGet().invoke(); - assertEquals(Response.Status.OK.getStatusCode(), rawresp.getStatus()); - } - - @Test - void testGePrometheus() throws Exception { - Invocation.Builder invocationBuilder = super.sendActRequest(PROMETHEUS_ENDPOINT); - Response rawresp = invocationBuilder.buildGet().invoke(); - assertEquals(Response.Status.OK.getStatusCode(), rawresp.getStatus()); - } - -} diff --git a/participant/participant-impl/participant-impl-kubernetes/src/test/java/org/onap/policy/clamp/controlloop/participant/kubernetes/rest/ChartControllerTest.java b/participant/participant-impl/participant-impl-kubernetes/src/test/java/org/onap/policy/clamp/controlloop/participant/kubernetes/rest/ChartControllerTest.java deleted file mode 100644 index 8048b19ce..000000000 --- a/participant/participant-impl/participant-impl-kubernetes/src/test/java/org/onap/policy/clamp/controlloop/participant/kubernetes/rest/ChartControllerTest.java +++ /dev/null @@ -1,249 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * Copyright (C) 2021-2022 Nordix Foundation. - * Modifications Copyright (C) 2021 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - * SPDX-License-Identifier: Apache-2.0 - * ============LICENSE_END========================================================= - */ - -package org.onap.policy.clamp.controlloop.participant.kubernetes.rest; - -import static org.hamcrest.CoreMatchers.is; -import static org.mockito.Mockito.doNothing; -import static org.mockito.Mockito.when; -import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.content; -import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.jsonPath; -import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status; - -import java.io.File; -import java.io.IOException; -import java.nio.charset.StandardCharsets; -import java.util.List; -import org.apache.commons.io.FileUtils; -import org.json.JSONObject; -import org.junit.jupiter.api.BeforeAll; -import org.junit.jupiter.api.BeforeEach; -import org.junit.jupiter.api.Test; -import org.junit.jupiter.api.extension.ExtendWith; -import org.onap.policy.clamp.controlloop.participant.kubernetes.controller.ChartController; -import org.onap.policy.clamp.controlloop.participant.kubernetes.models.ChartInfo; -import org.onap.policy.clamp.controlloop.participant.kubernetes.models.ChartList; -import org.onap.policy.clamp.controlloop.participant.kubernetes.parameters.ParticipantK8sParameters; -import org.onap.policy.clamp.controlloop.participant.kubernetes.service.ChartService; -import org.onap.policy.common.utils.coder.Coder; -import org.onap.policy.common.utils.coder.CoderException; -import org.onap.policy.common.utils.coder.StandardCoder; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.boot.context.properties.EnableConfigurationProperties; -import org.springframework.boot.test.autoconfigure.web.servlet.WebMvcTest; -import org.springframework.boot.test.mock.mockito.MockBean; -import org.springframework.http.MediaType; -import org.springframework.mock.web.MockMultipartFile; -import org.springframework.test.context.junit.jupiter.SpringExtension; -import org.springframework.test.web.servlet.MockMvc; -import org.springframework.test.web.servlet.RequestBuilder; -import org.springframework.test.web.servlet.request.MockMvcRequestBuilders; -import org.springframework.test.web.servlet.setup.MockMvcBuilders; -import org.springframework.web.context.WebApplicationContext; - - -@ExtendWith(SpringExtension.class) -@WebMvcTest(value = ChartController.class, properties = "chart.api.enabled=true") -@EnableConfigurationProperties(value = ParticipantK8sParameters.class) -class ChartControllerTest { - - private static final Coder CODER = new StandardCoder(); - private static final String CHART_INFO_YAML = "src/test/resources/ChartList.json"; - private static List charts; - private static String RETRIEVE_CHART_URL = "/helm/charts"; - private static String INSTALL_CHART_URL = "/helm/install"; - private static String UNINSTALL_CHART_URL = "/helm/uninstall/"; - private static String ONBOARD_CHART_URL = "/helm/onboard/chart"; - private static String DELETE_CHART_URL = "/helm/chart"; - private static String CONFIGURE_REPO_URL = "/helm/repo"; - - @Autowired - private MockMvc mockMvc; - - @MockBean - private ChartService chartService; - - @Autowired - private WebApplicationContext context; - - /** - * Read input chart info json. - * @throws Exception incase of error. - */ - @BeforeAll - static void setupParams() throws CoderException { - charts = CODER.decode(new File(CHART_INFO_YAML), ChartList.class).getCharts(); - } - - /** - * Mock service layer in Controller. - * @throws Exception incase of error. - */ - @BeforeEach - void mockServiceClass() { - when(chartService.getAllCharts()).thenReturn(charts); - when(chartService.getChart(charts.get(0).getChartId().getName(), charts.get(0).getChartId().getVersion())) - .thenReturn(charts.get(0)); - - this.mockMvc = MockMvcBuilders.webAppContextSetup(this.context).build(); - } - - /** - * Test endpoint for retrieving all charts. - * @throws Exception incase of error. - */ - @Test - void retrieveAllCharts() throws Exception { - RequestBuilder requestBuilder; - requestBuilder = MockMvcRequestBuilders.get(RETRIEVE_CHART_URL).accept(MediaType.APPLICATION_JSON_VALUE); - - mockMvc.perform(requestBuilder).andExpect(status().isOk()) - .andExpect(content().contentTypeCompatibleWith(MediaType.APPLICATION_JSON)) - .andExpect(jsonPath("$.charts.[0].chartId.name", is("HelloWorld"))); - } - - /** - * Test endpoint for installing a chart. - * @throws Exception incase of error. - */ - @Test - void installChart() throws Exception { - RequestBuilder requestBuilder; - - //Mocking successful installation for void install method - doNothing().when(chartService).installChart(charts.get(0)); - - requestBuilder = MockMvcRequestBuilders.post(INSTALL_CHART_URL).accept(MediaType.APPLICATION_JSON_VALUE) - .content(getInstallationJson(charts.get(0).getChartId().getName(), charts.get(0).getChartId().getVersion())) - .contentType(MediaType.APPLICATION_JSON_VALUE); - - mockMvc.perform(requestBuilder).andExpect(status().isCreated()); - - //Install Invalid chart, expects HTTP status NOT_FOUND - requestBuilder = MockMvcRequestBuilders.post(INSTALL_CHART_URL).accept(MediaType.APPLICATION_JSON_VALUE) - .content(getInstallationJson("invalidName", "invalidVersion")) - .contentType(MediaType.APPLICATION_JSON_VALUE); - - mockMvc.perform(requestBuilder).andExpect(status().isNotFound()); - } - - /** - * Test endpoint for uninstalling a chart. - * @throws Exception incase of error. - */ - @Test - void uninstallChart() throws Exception { - RequestBuilder requestBuilder; - - //Mocking successful scenario for void uninstall method - doNothing().when(chartService).uninstallChart(charts.get(0)); - - requestBuilder = MockMvcRequestBuilders.delete(UNINSTALL_CHART_URL + charts.get(0) - .getChartId().getName() + "/" + charts.get(0).getChartId().getVersion()) - .accept(MediaType.APPLICATION_JSON_VALUE).contentType(MediaType.APPLICATION_JSON_VALUE); - - mockMvc.perform(requestBuilder).andExpect(status().isNoContent()); - - //Invalid chart - requestBuilder = MockMvcRequestBuilders.delete(UNINSTALL_CHART_URL + "invalidName" - + "/" + "invalidVersion").accept(MediaType.APPLICATION_JSON_VALUE) - .contentType(MediaType.APPLICATION_JSON_VALUE); - - mockMvc.perform(requestBuilder).andExpect(status().isNotFound()); - } - - /** - * Test endpoint for chart onboarding. - * @throws Exception incase of error. - */ - @Test - void onboardChart() throws Exception { - RequestBuilder requestBuilder; - MockMultipartFile chartFile = new MockMultipartFile("chart", "hello.tgz", - MediaType.TEXT_PLAIN_VALUE, "Dummy data".getBytes()); - - MockMultipartFile overrideFile = new MockMultipartFile("values", "values.yaml", - MediaType.TEXT_PLAIN_VALUE, "Dummy data".getBytes()); - - //Mocking successful scenario for void uninstall method - when(chartService.saveChart(charts.get(0), chartFile, null)).thenReturn(charts.get(0)); - - requestBuilder = MockMvcRequestBuilders.multipart(ONBOARD_CHART_URL) - .file(chartFile).file(overrideFile).param("info", getChartInfoJson()); - - mockMvc.perform(requestBuilder).andExpect(status().isOk()); - } - - /** - * Test endpoint for deleting a chart. - * @throws Exception incase of error. - */ - @Test - void deleteChart() throws Exception { - RequestBuilder requestBuilder; - - //Mocking successful scenario for void uninstall method - doNothing().when(chartService).deleteChart(charts.get(0)); - - requestBuilder = MockMvcRequestBuilders.delete(DELETE_CHART_URL + "/" + charts.get(0) - .getChartId().getName() + "/" + charts.get(0).getChartId().getVersion()) - .accept(MediaType.APPLICATION_JSON_VALUE) - .contentType(MediaType.APPLICATION_JSON_VALUE); - - mockMvc.perform(requestBuilder).andExpect(status().isNoContent()); - //Invalid chart - requestBuilder = MockMvcRequestBuilders.delete(UNINSTALL_CHART_URL + "invalidName" - + "/" + "invalidVersion").accept(MediaType.APPLICATION_JSON_VALUE) - .contentType(MediaType.APPLICATION_JSON_VALUE); - - mockMvc.perform(requestBuilder).andExpect(status().isNotFound()); - - } - - /** - * Test endpoint for configuring a helm repository. - * @throws Exception in case of error. - */ - @Test - void testConfigureRepo() throws Exception { - RequestBuilder requestBuilder; - - requestBuilder = MockMvcRequestBuilders.post(CONFIGURE_REPO_URL).accept(MediaType.APPLICATION_JSON_VALUE) - .content(getInstallationJson(charts.get(0).getChartId().getName(), charts.get(0).getChartId().getVersion())) - .contentType(MediaType.APPLICATION_JSON_VALUE); - - mockMvc.perform(requestBuilder).andExpect(status().isCreated()); - - } - - - private String getInstallationJson(String name, String version) { - JSONObject jsonObj = new JSONObject(); - jsonObj.put("name", name); - jsonObj.put("version", version); - return jsonObj.toString(); - } - - private String getChartInfoJson() throws IOException { - return FileUtils.readFileToString(new File(CHART_INFO_YAML), StandardCharsets.UTF_8); - } - -} diff --git a/participant/participant-impl/participant-impl-kubernetes/src/test/java/org/onap/policy/clamp/controlloop/participant/kubernetes/service/ChartServiceTest.java b/participant/participant-impl/participant-impl-kubernetes/src/test/java/org/onap/policy/clamp/controlloop/participant/kubernetes/service/ChartServiceTest.java deleted file mode 100644 index f1c8d19df..000000000 --- a/participant/participant-impl/participant-impl-kubernetes/src/test/java/org/onap/policy/clamp/controlloop/participant/kubernetes/service/ChartServiceTest.java +++ /dev/null @@ -1,148 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * Copyright (C) 2021 Nordix Foundation. - * Modifications Copyright (C) 2021 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - * SPDX-License-Identifier: Apache-2.0 - * ============LICENSE_END========================================================= - */ - -package org.onap.policy.clamp.controlloop.participant.kubernetes.service; - -import static org.assertj.core.api.Assertions.assertThat; -import static org.assertj.core.api.Assertions.assertThatThrownBy; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertNotNull; -import static org.junit.Assert.assertNull; -import static org.junit.jupiter.api.Assertions.assertDoesNotThrow; -import static org.mockito.ArgumentMatchers.any; -import static org.mockito.Mockito.doNothing; -import static org.mockito.Mockito.doReturn; -import static org.mockito.Mockito.doThrow; - -import java.io.File; -import java.io.IOException; -import java.util.Collection; -import java.util.List; -import org.junit.jupiter.api.BeforeAll; -import org.junit.jupiter.api.Test; -import org.junit.jupiter.api.extension.ExtendWith; -import org.mockito.InjectMocks; -import org.mockito.Mock; -import org.mockito.Spy; -import org.onap.policy.clamp.controlloop.participant.kubernetes.exception.ServiceException; -import org.onap.policy.clamp.controlloop.participant.kubernetes.helm.HelmClient; -import org.onap.policy.clamp.controlloop.participant.kubernetes.models.ChartInfo; -import org.onap.policy.clamp.controlloop.participant.kubernetes.models.ChartList; -import org.onap.policy.common.utils.coder.Coder; -import org.onap.policy.common.utils.coder.CoderException; -import org.onap.policy.common.utils.coder.StandardCoder; -import org.springframework.mock.web.MockMultipartFile; -import org.springframework.test.context.junit.jupiter.SpringExtension; - -@ExtendWith(SpringExtension.class) -class ChartServiceTest { - - private static final Coder CODER = new StandardCoder(); - private static final String CHART_INFO_YAML = "src/test/resources/ChartList.json"; - private static List charts; - - @InjectMocks - @Spy - private ChartService chartService = new ChartService(); - - @Mock - private ChartStore chartStore; - - @Mock - private HelmClient helmClient; - - @BeforeAll - static void init() throws CoderException { - charts = CODER.decode(new File(CHART_INFO_YAML), ChartList.class).getCharts(); - } - - @Test - void test_getAllCharts() { - assertThat(chartService.getAllCharts()).isEmpty(); - - doReturn(charts).when(chartStore).getAllCharts(); - Collection result = chartService.getAllCharts(); - assertNotNull(result); - assertThat(result).containsAll(charts); - } - - @Test - void test_getChart() { - assertNull(chartService.getChart("dummyName", "dummyversion")); - - doReturn(charts.get(0)).when(chartStore).getChart(any(), any()); - ChartInfo chart = chartService.getChart(charts.get(0).getChartId().getName(), - charts.get(0).getChartId().getVersion()); - assertNotNull(chart); - assertThat(chart.getNamespace()).isEqualTo(charts.get(0).getNamespace()); - } - - @Test - void test_saveChart() throws IOException, ServiceException { - doThrow(IOException.class).when(chartStore).saveChart(charts.get(0), null, null); - assertThatThrownBy(() -> chartService.saveChart(charts.get(0), null, null)) - .isInstanceOf(IOException.class); - - MockMultipartFile mockChartFile = new MockMultipartFile("chart", "dummy".getBytes()); - MockMultipartFile mockOverrideFile = new MockMultipartFile("override", "dummy".getBytes()); - - doReturn(charts.get(0)).when(chartStore).saveChart(any(), any(), any()); - - ChartInfo chart = chartService.saveChart(charts.get(0), mockChartFile, mockOverrideFile); - assertNotNull(chart); - assertThat(chart.getChartId().getName()).isEqualTo(charts.get(0).getChartId().getName()); - - } - - @Test - void test_installChart() throws IOException, ServiceException { - assertDoesNotThrow(() -> chartService.installChart(charts.get(0))); - doThrow(ServiceException.class).when(helmClient).installChart(any()); - assertThatThrownBy(() -> chartService.installChart(charts.get(0))).isInstanceOf(ServiceException.class); - - doReturn("dummyRepoName").when(chartService).findChartRepo(any()); - doNothing().when(helmClient).installChart(any()); - chartService.installChart(charts.get(1)); - assertEquals("dummyRepoName", charts.get(1).getRepository().getRepoName()); - - ChartInfo testChart = charts.get(1); - testChart.setRepository(null); - doReturn(null).when(chartService).findChartRepo(any()); - chartService.installChart(charts.get(1)); - } - - @Test - void test_UninstallChart() throws ServiceException { - assertDoesNotThrow(() -> chartService.uninstallChart(charts.get(0))); - doThrow(ServiceException.class).when(helmClient).uninstallChart(any()); - assertThatThrownBy(() -> chartService.uninstallChart(charts.get(0))).isInstanceOf(ServiceException.class); - } - - @Test - void test_findChartRepo() throws IOException, ServiceException { - assertDoesNotThrow(() -> chartService.findChartRepo(charts.get(0))); - doReturn("dummyRepoName").when(helmClient).findChartRepository(any()); - assertEquals("dummyRepoName", chartService.findChartRepo(charts.get(1))); - - doThrow(ServiceException.class).when(helmClient).findChartRepository(any()); - assertThatThrownBy(() -> chartService.findChartRepo(charts.get(0))).isInstanceOf(ServiceException.class); - } -} diff --git a/participant/participant-impl/participant-impl-kubernetes/src/test/java/org/onap/policy/clamp/controlloop/participant/kubernetes/service/ChartStoreTest.java b/participant/participant-impl/participant-impl-kubernetes/src/test/java/org/onap/policy/clamp/controlloop/participant/kubernetes/service/ChartStoreTest.java deleted file mode 100644 index 54f1cc528..000000000 --- a/participant/participant-impl/participant-impl-kubernetes/src/test/java/org/onap/policy/clamp/controlloop/participant/kubernetes/service/ChartStoreTest.java +++ /dev/null @@ -1,175 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * Copyright (C) 2021 Nordix Foundation. - * Modifications Copyright (C) 2021 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - * SPDX-License-Identifier: Apache-2.0 - * ============LICENSE_END========================================================= - */ - -package org.onap.policy.clamp.controlloop.participant.kubernetes.service; - -import static org.assertj.core.api.Assertions.assertThat; -import static org.assertj.core.api.Assertions.assertThatThrownBy; -import static org.junit.Assert.assertNull; -import static org.junit.jupiter.api.Assertions.assertNotNull; - -import java.io.File; -import java.io.IOException; -import java.nio.file.Path; -import java.util.List; -import org.junit.jupiter.api.AfterEach; -import org.junit.jupiter.api.BeforeAll; -import org.junit.jupiter.api.BeforeEach; -import org.junit.jupiter.api.Test; -import org.junit.jupiter.api.extension.ExtendWith; -import org.mockito.Mock; -import org.mockito.Mockito; -import org.mockito.junit.jupiter.MockitoExtension; -import org.mockito.junit.jupiter.MockitoSettings; -import org.mockito.quality.Strictness; -import org.onap.policy.clamp.controlloop.participant.kubernetes.exception.ServiceException; -import org.onap.policy.clamp.controlloop.participant.kubernetes.models.ChartInfo; -import org.onap.policy.clamp.controlloop.participant.kubernetes.models.ChartList; -import org.onap.policy.clamp.controlloop.participant.kubernetes.parameters.ParticipantK8sParameters; -import org.onap.policy.common.utils.coder.Coder; -import org.onap.policy.common.utils.coder.CoderException; -import org.onap.policy.common.utils.coder.StandardCoder; -import org.onap.policy.models.tosca.authorative.concepts.ToscaConceptIdentifier; -import org.springframework.mock.web.MockMultipartFile; -import org.springframework.util.FileSystemUtils; - - -@ExtendWith(MockitoExtension.class) -@MockitoSettings(strictness = Strictness.LENIENT) -class ChartStoreTest { - - private static final Coder CODER = new StandardCoder(); - private static final String CHART_INFO_YAML = "src/test/resources/ChartList.json"; - private static List charts; - - @Mock - private ParticipantK8sParameters parameters; - - private ChartStore chartStore; - - - @BeforeAll - static void init() throws CoderException { - charts = CODER.decode(new File(CHART_INFO_YAML), ChartList.class).getCharts(); - } - - //Overriding the local chart dir parameter to a temp folder under target for testing java FILE IO operations. - @BeforeEach - void setup() { - Mockito.doReturn("target/tmp/").when(parameters).getLocalChartDirectory(); - Mockito.doReturn("info.json").when(parameters).getInfoFileName(); - chartStore = new ChartStore(parameters); - } - - //Clean up the 'tmp' dir after each test case. - @AfterEach - void cleanUp() throws IOException { - FileSystemUtils.deleteRecursively(Path.of(parameters.getLocalChartDirectory())); - chartStore.getLocalChartMap().clear(); - } - - @Test - void test_getHelmChartFile() { - File file = chartStore.getHelmChartFile(charts.get(0)); - assertNotNull(file); - assertThat(file.getPath()).endsWith(charts.get(0).getChartId().getName()); - } - - @Test - void test_getOverrideFile() { - File file = chartStore.getOverrideFile(charts.get(0)); - assertNotNull(file); - assertThat(file.getPath()).endsWith("values.yaml"); - } - - @Test - void test_saveChart() throws IOException, ServiceException { - MockMultipartFile mockChartFile = new MockMultipartFile("chart", "dummy".getBytes()); - MockMultipartFile mockOverrideFile = new MockMultipartFile("override", "dummy".getBytes()); - ChartInfo testChart = charts.get(0); - testChart.setChartId(new ToscaConceptIdentifier("testChart", "1.0.0")); - ChartInfo result = chartStore.saveChart(charts.get(0), mockChartFile, mockOverrideFile); - - assertThat(result.getChartId().getName()).isEqualTo("testChart"); - assertThat(chartStore.getLocalChartMap()).hasSize(1); - - assertThatThrownBy(() -> chartStore.saveChart(charts.get(0), mockChartFile, mockOverrideFile)) - .isInstanceOf(ServiceException.class); - } - - - @Test - void test_getChart() { - assertNull(chartStore.getChart(charts.get(0).getChartId().getName(), charts.get(0).getChartId().getVersion())); - chartStore.getLocalChartMap().put(charts.get(0).getChartId().getName() + "_" + charts.get(0).getChartId() - .getVersion(), charts.get(0)); - ChartInfo chart = chartStore.getChart(charts.get(0).getChartId().getName(), - charts.get(0).getChartId().getVersion()); - assertThat(chart.getChartId().getName()).isEqualTo(charts.get(0).getChartId().getName()); - } - - @Test - void test_getAllChart() { - // When the chart store is empty before adding any charts - assertThat(chartStore.getAllCharts()).isEmpty(); - - for (ChartInfo chart : charts) { - chartStore.getLocalChartMap().put(chart.getChartId().getName() + "_" + chart.getChartId().getVersion(), - chart); - } - List retrievedChartList = chartStore.getAllCharts(); - assertThat(retrievedChartList).isNotEmpty(); - assertThat(retrievedChartList.size()).isEqualTo(charts.size()); - } - - @Test - void test_deleteChart() { - chartStore.getLocalChartMap().put(charts.get(0).getChartId().getName() + "_" + charts.get(0).getChartId() - .getVersion(), charts.get(0)); - assertThat(chartStore.getLocalChartMap()).hasSize(1); - chartStore.deleteChart(charts.get(0)); - assertThat(chartStore.getLocalChartMap()).isEmpty(); - } - - @Test - void test_getAppPath() { - Path path = chartStore.getAppPath(charts.get(0).getChartId()); - assertNotNull(path); - assertThat(path.toString()).endsWith(charts.get(0).getChartId().getVersion()); - assertThat(path.toString()).startsWith("target"); - } - - @Test - void test_chartSoreInstantiationWithExistingChartFiles() throws IOException, ServiceException { - MockMultipartFile mockChartFile = new MockMultipartFile("HelmChartFile", "dummyData".getBytes()); - MockMultipartFile mockOverrideFile = new MockMultipartFile("overrideFile.yaml", "dummyData".getBytes()); - ChartInfo testChart = charts.get(0); - testChart.setChartId(new ToscaConceptIdentifier("dummyChart", "1.0.0")); - - //Creating a dummy chart in local dir. - chartStore.saveChart(charts.get(0), mockChartFile, mockOverrideFile); - - //Instantiating a new chartStore object with pre available chart in local. - ChartStore chartStore2 = new ChartStore(parameters); - assertThat(chartStore2.getLocalChartMap()).hasSize(1).containsKey("dummyChart_" + charts.get(0).getChartId() - .getVersion()); - } -} diff --git a/participant/participant-impl/participant-impl-kubernetes/src/test/java/org/onap/policy/clamp/controlloop/participant/kubernetes/utils/CommonActuatorController.java b/participant/participant-impl/participant-impl-kubernetes/src/test/java/org/onap/policy/clamp/controlloop/participant/kubernetes/utils/CommonActuatorController.java deleted file mode 100644 index 35ffbb5e9..000000000 --- a/participant/participant-impl/participant-impl-kubernetes/src/test/java/org/onap/policy/clamp/controlloop/participant/kubernetes/utils/CommonActuatorController.java +++ /dev/null @@ -1,114 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * Copyright (C) 2021 Nordix Foundation. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - * SPDX-License-Identifier: Apache-2.0 - * ============LICENSE_END========================================================= - */ - -package org.onap.policy.clamp.controlloop.participant.kubernetes.utils; - -import static org.junit.Assert.assertEquals; - -import javax.ws.rs.client.Client; -import javax.ws.rs.client.ClientBuilder; -import javax.ws.rs.client.Invocation; -import javax.ws.rs.client.WebTarget; -import javax.ws.rs.core.MediaType; -import javax.ws.rs.core.Response; -import org.glassfish.jersey.client.ClientProperties; -import org.glassfish.jersey.client.authentication.HttpAuthenticationFeature; -import org.onap.policy.common.gson.GsonMessageBodyHandler; -import org.onap.policy.common.utils.network.NetworkUtil; - -/** - * Class to perform Rest unit tests. - * - */ -public class CommonActuatorController { - - public static final String SELF = NetworkUtil.getHostname(); - public static final String CONTEXT_PATH = "onap/k8sparticipant"; - public static final String ACTUATOR_ENDPOINT = CONTEXT_PATH + "/actuator/"; - - private static String httpPrefix; - - /** - * Sends a request to an actuator endpoint. - * - * @param endpoint the target endpoint - * @return a request builder - * @throws Exception if an error occurs - */ - protected Invocation.Builder sendActRequest(final String endpoint) throws Exception { - return sendFqeRequest(httpPrefix + ACTUATOR_ENDPOINT + endpoint, true); - } - - /** - * Sends a request to an actuator endpoint, without any authorization header. - * - * @param endpoint the target endpoint - * @return a request builder - * @throws Exception if an error occurs - */ - protected Invocation.Builder sendNoAuthActRequest(final String endpoint) throws Exception { - return sendFqeRequest(httpPrefix + ACTUATOR_ENDPOINT + endpoint, false); - } - - /** - * Sends a request to a fully qualified endpoint. - * - * @param fullyQualifiedEndpoint the fully qualified target endpoint - * @param includeAuth if authorization header should be included - * @return a request builder - * @throws Exception if an error occurs - */ - protected Invocation.Builder sendFqeRequest(final String fullyQualifiedEndpoint, boolean includeAuth) - throws Exception { - final Client client = ClientBuilder.newBuilder().build(); - - client.property(ClientProperties.METAINF_SERVICES_LOOKUP_DISABLE, "true"); - client.register(GsonMessageBodyHandler.class); - - if (includeAuth) { - client.register(HttpAuthenticationFeature.basic("participantUser", "zb!XztG34")); - } - - final WebTarget webTarget = client.target(fullyQualifiedEndpoint); - - return webTarget.request(MediaType.APPLICATION_JSON, MediaType.TEXT_PLAIN); - } - - /** - * Assert that GET call to actuator endpoint is Unauthorized. - * - * @param endPoint the endpoint - * @throws Exception if an error occurs - */ - protected void assertUnauthorizedActGet(final String endPoint) throws Exception { - Response rawresp = sendNoAuthActRequest(endPoint).buildGet().invoke(); - assertEquals(Response.Status.UNAUTHORIZED.getStatusCode(), rawresp.getStatus()); - } - - /** - * Set Up httpPrefix. - * - * @param port the port - */ - protected void setHttpPrefix(int port) { - httpPrefix = "http://" + SELF + ":" + port + "/"; - } - -} diff --git a/participant/participant-impl/participant-impl-kubernetes/src/test/java/org/onap/policy/clamp/controlloop/participant/kubernetes/utils/TestUtils.java b/participant/participant-impl/participant-impl-kubernetes/src/test/java/org/onap/policy/clamp/controlloop/participant/kubernetes/utils/TestUtils.java deleted file mode 100644 index af514f8aa..000000000 --- a/participant/participant-impl/participant-impl-kubernetes/src/test/java/org/onap/policy/clamp/controlloop/participant/kubernetes/utils/TestUtils.java +++ /dev/null @@ -1,47 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * Copyright (C) 2021 Nordix Foundation. - * Modifications Copyright (C) 2021 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - * SPDX-License-Identifier: Apache-2.0 - * ============LICENSE_END========================================================= - */ - -package org.onap.policy.clamp.controlloop.participant.kubernetes.utils; - -import lombok.AccessLevel; -import lombok.NoArgsConstructor; -import org.onap.policy.common.utils.coder.YamlJsonTranslator; -import org.onap.policy.common.utils.resources.ResourceUtils; -import org.onap.policy.models.tosca.authorative.concepts.ToscaServiceTemplate; - -@NoArgsConstructor(access = AccessLevel.PRIVATE) -public final class TestUtils { - - private static final YamlJsonTranslator yamlTranslator = new YamlJsonTranslator(); - private static final String TOSCA_TEMPLATE_YAML = "src/test/resources/servicetemplates/KubernetesHelm.yaml"; - - - public static ToscaServiceTemplate testControlLoopRead() { - return testControlLoopYamlSerialization(TOSCA_TEMPLATE_YAML); - } - - - private static ToscaServiceTemplate testControlLoopYamlSerialization(String controlLoopFilePath) { - String controlLoopString = ResourceUtils.getResourceAsString(controlLoopFilePath); - ToscaServiceTemplate serviceTemplate = yamlTranslator.fromYaml(controlLoopString, ToscaServiceTemplate.class); - return serviceTemplate; - } -} diff --git a/participant/participant-impl/participant-impl-kubernetes/src/test/resources/application_test.properties b/participant/participant-impl/participant-impl-kubernetes/src/test/resources/application_test.properties index b5b209fd1..243512166 100644 --- a/participant/participant-impl/participant-impl-kubernetes/src/test/resources/application_test.properties +++ b/participant/participant-impl/participant-impl-kubernetes/src/test/resources/application_test.properties @@ -1,24 +1,24 @@ spring.security.user.name=participantUser spring.security.user.password=zb!XztG34 -server.servlet.context-path=/onap/k8sparticipant +server.servlet.context-path=/onap/policy/clamp/acm/k8sparticipant server.error.path=/error server.http-port=8083 -participant.name=ControlLoopParticipant Kubernetes Test +participant.name=AutomationCompositionParticipant Kubernetes Test participant.intermediaryParameters.name=Participant parameters participant.intermediaryParameters.reportingTimeInterval=120000 participant.intermediaryParameters.description=Participant Description participant.intermediaryParameters.participantId.name=K8sParticipant0 participant.intermediaryParameters.participantId.version=1.0.0 -participant.intermediaryParameters.participantType.name=org.onap.k8s.controlloop.K8SControlLoopParticipant +participant.intermediaryParameters.participantType.name=org.onap.k8s.acm.K8SAutomationCompositionParticipant participant.intermediaryParameters.participantType.version=2.3.4 -participant.intermediaryParameters.clampControlLoopTopics.name=ControlLoop Topics -participant.intermediaryParameters.clampControlLoopTopics.topicSources[0].topic=POLICY-CLRUNTIME-PARTICIPANT -participant.intermediaryParameters.clampControlLoopTopics.topicSources[0].servers[0]=localhost -participant.intermediaryParameters.clampControlLoopTopics.topicSources[0].topicCommInfrastructure=dmaap -participant.intermediaryParameters.clampControlLoopTopics.topicSources[0].fetchTimeout=15000 -participant.intermediaryParameters.clampControlLoopTopics.topicSinks[0].topic=POLICY-CLRUNTIME-PARTICIPANT -participant.intermediaryParameters.clampControlLoopTopics.topicSinks[0].servers[0]=localhost -participant.intermediaryParameters.clampControlLoopTopics.topicSinks[0].topicCommInfrastructure=dmaap +participant.intermediaryParameters.clampAutomationCompositionTopics.name=AutomationComposition Topics +participant.intermediaryParameters.clampAutomationCompositionTopics.topicSources[0].topic=POLICY-ACRUNTIME-PARTICIPANT +participant.intermediaryParameters.clampAutomationCompositionTopics.topicSources[0].servers[0]=localhost +participant.intermediaryParameters.clampAutomationCompositionTopics.topicSources[0].topicCommInfrastructure=dmaap +participant.intermediaryParameters.clampAutomationCompositionTopics.topicSources[0].fetchTimeout=15000 +participant.intermediaryParameters.clampAutomationCompositionTopics.topicSinks[0].topic=POLICY-ACRUNTIME-PARTICIPANT +participant.intermediaryParameters.clampAutomationCompositionTopics.topicSinks[0].servers[0]=localhost +participant.intermediaryParameters.clampAutomationCompositionTopics.topicSinks[0].topicCommInfrastructure=dmaap management.endpoints.web.exposure.include=health,metrics,prometheus diff --git a/participant/participant-impl/participant-impl-kubernetes/src/test/resources/servicetemplates/KubernetesHelm.yaml b/participant/participant-impl/participant-impl-kubernetes/src/test/resources/servicetemplates/KubernetesHelm.yaml index 7d594019a..f5eb6233f 100644 --- a/participant/participant-impl/participant-impl-kubernetes/src/test/resources/servicetemplates/KubernetesHelm.yaml +++ b/participant/participant-impl/participant-impl-kubernetes/src/test/resources/servicetemplates/KubernetesHelm.yaml @@ -27,14 +27,14 @@ data_types: type: string required: true node_types: - org.onap.policy.clamp.controlloop.Participant: + org.onap.policy.clamp.acm.Participant: version: 1.0.1 derived_from: tosca.nodetypes.Root properties: provider: type: string requred: false - org.onap.policy.clamp.controlloop.ControlLoopElement: + org.onap.policy.clamp.acm.AutomationCompositionElement: version: 1.0.1 derived_from: tosca.nodetypes.Root properties: @@ -51,11 +51,11 @@ node_types: - greater-or-equal: 0 metadata: common: true - description: A value indicating the start phase in which this control loop element will be started, the - first start phase is zero. Control Loop Elements are started in their start_phase order and stopped - in reverse start phase order. Control Loop Elements with the same start phase are started and - stopped simultaneously - org.onap.policy.clamp.controlloop.ControlLoop: + description: A value indicating the start phase in which this automation composition element will be started, + the first start phase is zero. Automation Composition Elements are started in their start_phase + order and stopped in reverse start phase order. Automation Composition Elements with the same start + phase are started and stopped simultaneously + org.onap.policy.clamp.acm.AutomationComposition: version: 1.0.1 derived_from: tosca.nodetypes.Root properties: @@ -67,9 +67,9 @@ node_types: required: true entry_schema: type: onap.datatypes.ToscaConceptIdentifier - org.onap.policy.clamp.controlloop.K8SMicroserviceControlLoopElement: + org.onap.policy.clamp.acm.K8SMicroserviceAutomationCompositionElement: version: 1.0.1 - derived_from: org.onap.policy.clamp.controlloop.ControlLoopElement + derived_from: org.onap.policy.clamp.acm.AutomationCompositionElement properties: chart: type: string @@ -89,24 +89,24 @@ node_types: requred: true topology_template: node_templates: - org.onap.k8s.controlloop.K8SControlLoopParticipant: + org.onap.k8s.acm.K8SAutomationCompositionParticipant: version: 2.3.4 - type: org.onap.policy.clamp.controlloop.Participant + type: org.onap.policy.clamp.acm.Participant type_version: 1.0.1 description: Participant for K8S properties: provider: ONAP - org.onap.domain.database.HelloWorld_K8SMicroserviceControlLoopElement: + org.onap.domain.database.HelloWorld_K8SMicroserviceAutomationCompositionElement: # Chart from any chart repository configured on helm client. version: 1.2.3 - type: org.onap.policy.clamp.controlloop.K8SMicroserviceControlLoopElement + type: org.onap.policy.clamp.acm.K8SMicroserviceAutomationCompositionElement type_version: 1.0.0 - description: Control loop element for the K8S microservice for Hello World + description: Automation composition element for the K8S microservice for Hello World properties: provider: ONAP participantType: - name: org.onap.k8s.controlloop.K8SControlLoopParticipant + name: org.onap.k8s.acm.K8SAutomationCompositionParticipant version: 2.3.4 startPhase: 2 uninitializedToPassiveTimeout: 180 @@ -119,16 +119,16 @@ topology_template: namespace: onap repository: chartMuseum - org.onap.domain.database.PMSH_K8SMicroserviceControlLoopElement: + org.onap.domain.database.PMSH_K8SMicroserviceAutomationCompositionElement: # Chart from local file system version: 1.2.3 - type: org.onap.policy.clamp.controlloop.K8SMicroserviceControlLoopElement + type: org.onap.policy.clamp.acm.K8SMicroserviceAutomationCompositionElement type_version: 1.0.0 - description: Control loop element for the K8S microservice for PMSH + description: Automation composition element for the K8S microservice for PMSH properties: provider: ONAP participantType: - name: org.onap.k8s.controlloop.K8SControlLoopParticipant + name: org.onap.k8s.acm.K8SAutomationCompositionParticipant version: 2.3.4 startPhase: 2 uninitializedToPassiveTimeout: 180 @@ -142,16 +142,16 @@ topology_template: overrideParams: global.masterPassword: test - org.onap.domain.database.Local_K8SMicroserviceControlLoopElement: + org.onap.domain.database.Local_K8SMicroserviceAutomationCompositionElement: # Chart installation without passing repository name version: 1.2.3 - type: org.onap.policy.clamp.controlloop.K8SMicroserviceControlLoopElement + type: org.onap.policy.clamp.acm.K8SMicroserviceAutomationCompositionElement type_version: 1.0.0 - description: Control loop element for the K8S microservice for local chart + description: Automation composition element for the K8S microservice for local chart properties: provider: ONAP participantType: - name: org.onap.k8s.controlloop.K8SControlLoopParticipant + name: org.onap.k8s.acm.K8SAutomationCompositionParticipant version: 2.3.4 startPhase: 2 uninitializedToPassiveTimeout: 180 @@ -163,17 +163,17 @@ topology_template: releaseName: nginxms namespace: onap - org.onap.domain.sample.GenericK8s_ControlLoopDefinition: + org.onap.domain.sample.GenericK8s_AutomationCompositionDefinition: version: 1.2.3 - type: org.onap.policy.clamp.controlloop.ControlLoop + type: org.onap.policy.clamp.acm.AutomationComposition type_version: 1.0.0 - description: Control loop for Hello World + description: Automation composition for Hello World properties: provider: ONAP elements: - - name: org.onap.domain.database.HelloWorld_K8SMicroserviceControlLoopElement + - name: org.onap.domain.database.HelloWorld_K8SMicroserviceAutomationCompositionElement version: 1.2.3 - - name: org.onap.domain.database.PMSH_K8SMicroserviceControlLoopElement + - name: org.onap.domain.database.PMSH_K8SMicroserviceAutomationCompositionElement version: 1.2.3 - - name: org.onap.domain.database.Local_K8SMicroserviceControlLoopElement + - name: org.onap.domain.database.Local_K8SMicroserviceAutomationCompositionElement version: 1.2.3 diff --git a/participant/participant-impl/participant-impl-policy/pom.xml b/participant/participant-impl/participant-impl-policy/pom.xml index fce29acae..052e959dc 100644 --- a/participant/participant-impl/participant-impl-policy/pom.xml +++ b/participant/participant-impl/participant-impl-policy/pom.xml @@ -30,7 +30,7 @@ policy-clamp-participant-impl-policy ${project.artifactId} - Policy participant, that allows Policy to partake in control loops + Policy participant, that allows Policy to partake in automation compositions diff --git a/participant/participant-impl/participant-impl-policy/src/main/java/org/onap/policy/clamp/acm/participant/policy/PolicyParticipantApplication.java b/participant/participant-impl/participant-impl-policy/src/main/java/org/onap/policy/clamp/acm/participant/policy/PolicyParticipantApplication.java new file mode 100644 index 000000000..0ba2aa2ea --- /dev/null +++ b/participant/participant-impl/participant-impl-policy/src/main/java/org/onap/policy/clamp/acm/participant/policy/PolicyParticipantApplication.java @@ -0,0 +1,43 @@ +/*- + * ============LICENSE_START======================================================= + * Copyright (C) 2021 Nordix Foundation. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * SPDX-License-Identifier: Apache-2.0 + * ============LICENSE_END========================================================= + */ + +package org.onap.policy.clamp.acm.participant.policy; + +import org.springframework.boot.SpringApplication; +import org.springframework.boot.autoconfigure.SpringBootApplication; +import org.springframework.boot.context.properties.ConfigurationPropertiesScan; +import org.springframework.context.annotation.ComponentScan; + +/** + * Starter. + * + */ +@SpringBootApplication +@ComponentScan({ + "org.onap.policy.clamp.acm.participant.policy", + "org.onap.policy.clamp.acm.participant.intermediary" +}) +@ConfigurationPropertiesScan("org.onap.policy.clamp.acm.participant.policy.main.parameters") +public class PolicyParticipantApplication { + + public static void main(String[] args) { + SpringApplication.run(PolicyParticipantApplication.class, args); + } +} diff --git a/participant/participant-impl/participant-impl-policy/src/main/java/org/onap/policy/clamp/acm/participant/policy/client/AbstractHttpClient.java b/participant/participant-impl/participant-impl-policy/src/main/java/org/onap/policy/clamp/acm/participant/policy/client/AbstractHttpClient.java new file mode 100644 index 000000000..4920d6550 --- /dev/null +++ b/participant/participant-impl/participant-impl-policy/src/main/java/org/onap/policy/clamp/acm/participant/policy/client/AbstractHttpClient.java @@ -0,0 +1,76 @@ +/*- + * ============LICENSE_START======================================================= + * Copyright (C) 2021 Nordix Foundation. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * SPDX-License-Identifier: Apache-2.0 + * ============LICENSE_END========================================================= + */ + +package org.onap.policy.clamp.acm.participant.policy.client; + +import java.io.Closeable; +import java.io.IOException; +import java.util.Collections; +import java.util.Map; +import javax.ws.rs.client.Entity; +import javax.ws.rs.core.HttpHeaders; +import javax.ws.rs.core.MediaType; +import javax.ws.rs.core.Response; +import javax.ws.rs.core.Response.Status; +import org.onap.policy.clamp.common.acm.exception.AutomationCompositionRuntimeException; +import org.onap.policy.common.endpoints.event.comm.bus.internal.BusTopicParams; +import org.onap.policy.common.endpoints.http.client.HttpClient; +import org.onap.policy.common.endpoints.http.client.HttpClientFactoryInstance; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +public abstract class AbstractHttpClient implements Closeable { + + private static final Logger LOGGER = LoggerFactory.getLogger(AbstractHttpClient.class); + private final HttpClient httpclient; + + /** + * Constructor. + * + * @param policyParticipantParameters the parameters for the policy participant + * @throws AutomationCompositionRuntimeException on client start errors + */ + protected AbstractHttpClient(BusTopicParams policyParticipantParameters) { + try { + httpclient = HttpClientFactoryInstance.getClientFactory().build(policyParticipantParameters); + } catch (final Exception e) { + throw new AutomationCompositionRuntimeException(Status.INTERNAL_SERVER_ERROR, " Client failed to start", e); + } + } + + protected Response executePost(String path, final Entity entity) { + var response = httpclient.post(path, entity, Map.of(HttpHeaders.ACCEPT, MediaType.APPLICATION_JSON, + HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)); + if (response.getStatus() / 100 != 2) { + LOGGER.error("Invocation of path {} failed for entity {}. Response status: {}, Response status info: {}", + path, entity, response.getStatus(), response.getStatusInfo()); + } + return response; + } + + protected Response executeDelete(String path) { + return httpclient.delete(path, Collections.emptyMap()); + } + + @Override + public void close() throws IOException { + httpclient.shutdown(); + } +} diff --git a/participant/participant-impl/participant-impl-policy/src/main/java/org/onap/policy/clamp/acm/participant/policy/client/PolicyApiHttpClient.java b/participant/participant-impl/participant-impl-policy/src/main/java/org/onap/policy/clamp/acm/participant/policy/client/PolicyApiHttpClient.java new file mode 100644 index 000000000..a86576eed --- /dev/null +++ b/participant/participant-impl/participant-impl-policy/src/main/java/org/onap/policy/clamp/acm/participant/policy/client/PolicyApiHttpClient.java @@ -0,0 +1,87 @@ +/*- + * ============LICENSE_START======================================================= + * Copyright (C) 2021 Nordix Foundation. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * SPDX-License-Identifier: Apache-2.0 + * ============LICENSE_END========================================================= + */ + +package org.onap.policy.clamp.acm.participant.policy.client; + +import javax.ws.rs.client.Entity; +import javax.ws.rs.core.MediaType; +import javax.ws.rs.core.Response; +import org.onap.policy.clamp.acm.participant.policy.main.parameters.ParticipantPolicyParameters; +import org.onap.policy.models.base.PfModelException; +import org.onap.policy.models.tosca.authorative.concepts.ToscaServiceTemplate; +import org.springframework.stereotype.Component; + +@Component +public class PolicyApiHttpClient extends AbstractHttpClient { + + private static final String POLICY_URI = "/policy/api/v1/"; + + /** + * Constructor. + * + * @param parameters the policy participant parameters + */ + public PolicyApiHttpClient(ParticipantPolicyParameters parameters) { + super(parameters.getPolicyApiParameters()); + } + + /** + * Create Policy Types. + * + * @param toscaServiceTemplate the whole ToscaServiceTemplate + * @return Response + * @throws PfModelException on errors creating the policy type + */ + public Response createPolicyType(ToscaServiceTemplate toscaServiceTemplate) throws PfModelException { + return executePost(POLICY_URI + "policytypes", Entity.entity(toscaServiceTemplate, MediaType.APPLICATION_JSON)); + } + + /** + * Create Policies. + * + * @param toscaServiceTemplate the whole ToscaServiceTemplate + * @return Response + */ + public Response createPolicy(final ToscaServiceTemplate toscaServiceTemplate) { + return executePost(POLICY_URI + "policies", Entity.entity(toscaServiceTemplate, MediaType.APPLICATION_JSON)); + } + + /** + * Delete Policies. + * + * @param policyName the name of the policy to be deleted + * @param policyVersion the version of the policy to be deleted + * @return Response + */ + public Response deletePolicy(final String policyName, final String policyVersion) { + return executeDelete(POLICY_URI + "policies/" + policyName + "/versions/" + policyVersion); + } + + /** + * Delete Policy types. + * + * @param policyTypeName the name of the policy to be deleted + * @param policyTypeVersion the version of the policy to be deleted + * @return Response + */ + public Response deletePolicyType(final String policyTypeName, final String policyTypeVersion) { + return executeDelete(POLICY_URI + "policytypes/" + policyTypeName + "/versions/" + policyTypeVersion); + } +} diff --git a/participant/participant-impl/participant-impl-policy/src/main/java/org/onap/policy/clamp/acm/participant/policy/client/PolicyPapHttpClient.java b/participant/participant-impl/participant-impl-policy/src/main/java/org/onap/policy/clamp/acm/participant/policy/client/PolicyPapHttpClient.java new file mode 100644 index 000000000..584170ae4 --- /dev/null +++ b/participant/participant-impl/participant-impl-policy/src/main/java/org/onap/policy/clamp/acm/participant/policy/client/PolicyPapHttpClient.java @@ -0,0 +1,85 @@ +/*- + * ============LICENSE_START======================================================= + * Copyright (C) 2021 Nordix Foundation. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * SPDX-License-Identifier: Apache-2.0 + * ============LICENSE_END========================================================= + */ + +package org.onap.policy.clamp.acm.participant.policy.client; + +import java.util.LinkedList; +import java.util.List; +import javax.ws.rs.client.Entity; +import javax.ws.rs.core.MediaType; +import javax.ws.rs.core.Response; +import org.onap.policy.clamp.acm.participant.policy.main.parameters.ParticipantPolicyParameters; +import org.onap.policy.models.pdp.concepts.DeploymentGroup; +import org.onap.policy.models.pdp.concepts.DeploymentGroups; +import org.onap.policy.models.pdp.concepts.DeploymentSubGroup; +import org.onap.policy.models.tosca.authorative.concepts.ToscaConceptIdentifier; +import org.springframework.stereotype.Component; + +@Component +public class PolicyPapHttpClient extends AbstractHttpClient { + + private static final String PAP_URI = "/policy/pap/v1/"; + private final String pdpGroup; + private final String pdpType; + + /** + * Constructor. + * + * @param parameters the policy participant parameters + */ + public PolicyPapHttpClient(ParticipantPolicyParameters parameters) { + super(parameters.getPolicyPapParameters()); + this.pdpGroup = parameters.getPdpGroup(); + this.pdpType = parameters.getPdpType(); + } + + /** + * Deploy or undeploy Policies. + * + * @param policyName the name of the policy to be deployed/undeployed + * @param policyVersion the version of the policy to be deployed/undeployed + * @param action the action to deploy/undeploy policy + * @return Response + */ + public Response handlePolicyDeployOrUndeploy(final String policyName, final String policyVersion, + final DeploymentSubGroup.Action action) { + + List policies = new LinkedList(); + policies.add(new ToscaConceptIdentifier(policyName, policyVersion)); + + DeploymentSubGroup subGroup = new DeploymentSubGroup(); + subGroup.setPolicies(policies); + subGroup.setPdpType(pdpType); + subGroup.setAction(action); + + DeploymentGroup group = new DeploymentGroup(); + List subGroups = new LinkedList(); + subGroups.add(subGroup); + group.setDeploymentSubgroups(subGroups); + group.setName(pdpGroup); + + DeploymentGroups groups = new DeploymentGroups(); + List groupsArr = new LinkedList(); + groupsArr.add(group); + groups.setGroups(groupsArr); + + return executePost(PAP_URI + "pdps/deployments/batch", Entity.entity(groups, MediaType.APPLICATION_JSON)); + } +} diff --git a/participant/participant-impl/participant-impl-policy/src/main/java/org/onap/policy/clamp/acm/participant/policy/config/ParticipantConfig.java b/participant/participant-impl/participant-impl-policy/src/main/java/org/onap/policy/clamp/acm/participant/policy/config/ParticipantConfig.java new file mode 100644 index 000000000..7f9ad243d --- /dev/null +++ b/participant/participant-impl/participant-impl-policy/src/main/java/org/onap/policy/clamp/acm/participant/policy/config/ParticipantConfig.java @@ -0,0 +1,43 @@ +/*- + * ============LICENSE_START======================================================= + * Copyright (C) 2021 Nordix Foundation. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * SPDX-License-Identifier: Apache-2.0 + * ============LICENSE_END========================================================= + */ + +package org.onap.policy.clamp.acm.participant.policy.config; + +import org.onap.policy.clamp.acm.participant.intermediary.api.ParticipantIntermediaryApi; +import org.onap.policy.clamp.acm.participant.policy.main.handler.AutomationCompositionElementHandler; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.context.annotation.Configuration; + +@Configuration +public class ParticipantConfig { + + /** + * Register AutomationCompositionElementListener. + * + * @param intermediaryApi the ParticipantIntermediaryApi + * @param acElementHandler the Aotumation Composition Element Handler + */ + @Autowired + public void registerAutomationCompositionElementListener(ParticipantIntermediaryApi intermediaryApi, + AutomationCompositionElementHandler acElementHandler) { + intermediaryApi.registerAutomationCompositionElementListener(acElementHandler); + acElementHandler.setIntermediaryApi(intermediaryApi); + } +} diff --git a/participant/participant-impl/participant-impl-policy/src/main/java/org/onap/policy/clamp/acm/participant/policy/config/SecurityConfig.java b/participant/participant-impl/participant-impl-policy/src/main/java/org/onap/policy/clamp/acm/participant/policy/config/SecurityConfig.java new file mode 100644 index 000000000..d7ce925e2 --- /dev/null +++ b/participant/participant-impl/participant-impl-policy/src/main/java/org/onap/policy/clamp/acm/participant/policy/config/SecurityConfig.java @@ -0,0 +1,45 @@ +/*- + * ========================LICENSE_START================================= + * Copyright (C) 2021 Nordix Foundation. All rights reserved. + * ====================================================================== + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ========================LICENSE_END=================================== + */ + +package org.onap.policy.clamp.acm.participant.policy.config; + +import org.springframework.beans.factory.annotation.Value; +import org.springframework.context.annotation.Configuration; +import org.springframework.security.config.annotation.web.builders.HttpSecurity; +import org.springframework.security.config.annotation.web.configuration.WebSecurityConfigurerAdapter; + +@Configuration +public class SecurityConfig extends WebSecurityConfigurerAdapter { + + @Value("${security.enable-csrf:true}") + private boolean csrfEnabled = true; + + @Override + protected void configure(HttpSecurity http) throws Exception { + // @formatter:off + http.authorizeRequests() + .antMatchers().authenticated() + .anyRequest().authenticated() + .and().httpBasic(); + // @formatter:on + + if (!csrfEnabled) { + http.csrf().disable(); + } + } +} diff --git a/participant/participant-impl/participant-impl-policy/src/main/java/org/onap/policy/clamp/acm/participant/policy/main/handler/AutomationCompositionElementHandler.java b/participant/participant-impl/participant-impl-policy/src/main/java/org/onap/policy/clamp/acm/participant/policy/main/handler/AutomationCompositionElementHandler.java new file mode 100644 index 000000000..42d7526f8 --- /dev/null +++ b/participant/participant-impl/participant-impl-policy/src/main/java/org/onap/policy/clamp/acm/participant/policy/main/handler/AutomationCompositionElementHandler.java @@ -0,0 +1,227 @@ +/*- + * ============LICENSE_START======================================================= + * Copyright (C) 2021,2022 Nordix Foundation. + * ================================================================================ + * Modifications Copyright (C) 2021 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * SPDX-License-Identifier: Apache-2.0 + * ============LICENSE_END========================================================= + */ + +package org.onap.policy.clamp.acm.participant.policy.main.handler; + +import java.time.Instant; +import java.util.LinkedHashMap; +import java.util.Map; +import java.util.Map.Entry; +import java.util.UUID; +import lombok.Setter; +import org.onap.policy.clamp.acm.participant.intermediary.api.AutomationCompositionElementListener; +import org.onap.policy.clamp.acm.participant.intermediary.api.ParticipantIntermediaryApi; +import org.onap.policy.clamp.acm.participant.policy.client.PolicyApiHttpClient; +import org.onap.policy.clamp.acm.participant.policy.client.PolicyPapHttpClient; +import org.onap.policy.clamp.models.acm.concepts.AcElementStatistics; +import org.onap.policy.clamp.models.acm.concepts.AutomationCompositionElement; +import org.onap.policy.clamp.models.acm.concepts.AutomationCompositionOrderedState; +import org.onap.policy.clamp.models.acm.concepts.AutomationCompositionState; +import org.onap.policy.clamp.models.acm.messages.dmaap.participant.ParticipantMessageType; +import org.onap.policy.models.base.PfModelException; +import org.onap.policy.models.base.PfModelRuntimeException; +import org.onap.policy.models.pdp.concepts.DeploymentSubGroup; +import org.onap.policy.models.tosca.authorative.concepts.ToscaConceptIdentifier; +import org.onap.policy.models.tosca.authorative.concepts.ToscaNodeTemplate; +import org.onap.policy.models.tosca.authorative.concepts.ToscaPolicy; +import org.onap.policy.models.tosca.authorative.concepts.ToscaPolicyType; +import org.onap.policy.models.tosca.authorative.concepts.ToscaServiceTemplate; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.stereotype.Component; + +/** + * This class handles implementation of automationCompositionElement updates. + */ +@Component +public class AutomationCompositionElementHandler implements AutomationCompositionElementListener { + + private static final Logger LOGGER = LoggerFactory.getLogger(AutomationCompositionElementHandler.class); + private final Map policyTypeMap = new LinkedHashMap<>(); + private final Map policyMap = new LinkedHashMap<>(); + + private final PolicyApiHttpClient apiHttpClient; + private final PolicyPapHttpClient papHttpClient; + + @Setter + private ParticipantIntermediaryApi intermediaryApi; + + /** + * constructor. + * + * @param apiHttpClient the Policy Api Http Client + * @param papHttpClient the Policy Pap Http Client + */ + public AutomationCompositionElementHandler(PolicyApiHttpClient apiHttpClient, PolicyPapHttpClient papHttpClient) { + this.papHttpClient = papHttpClient; + this.apiHttpClient = apiHttpClient; + } + + /** + * Callback method to handle a automation composition element state change. + * + * @param automationCompositionId the ID of the automation composition + * @param automationCompositionElementId the ID of the automation composition element + * @param currentState the current state of the automation composition element + * @param orderedState the state to which the automation composition element is changing to + */ + @Override + public void automationCompositionElementStateChange(ToscaConceptIdentifier automationCompositionId, + UUID automationCompositionElementId, + AutomationCompositionState currentState, + AutomationCompositionOrderedState orderedState) { + switch (orderedState) { + case UNINITIALISED: + try { + undeployPolicies(automationCompositionElementId); + deletePolicyData(automationCompositionId, automationCompositionElementId, orderedState); + intermediaryApi.updateAutomationCompositionElementState(automationCompositionId, + automationCompositionElementId, orderedState, AutomationCompositionState.UNINITIALISED, + ParticipantMessageType.AUTOMATION_COMPOSITION_STATE_CHANGE); + } catch (PfModelRuntimeException e) { + LOGGER.debug("Undeploying/Deleting policy failed {}", automationCompositionElementId, e); + } + break; + case PASSIVE: + try { + undeployPolicies(automationCompositionElementId); + } catch (PfModelRuntimeException e) { + LOGGER.debug("Undeploying policies failed - no policies to undeploy {}", + automationCompositionElementId); + } + intermediaryApi.updateAutomationCompositionElementState(automationCompositionId, + automationCompositionElementId, orderedState, AutomationCompositionState.PASSIVE, + ParticipantMessageType.AUTOMATION_COMPOSITION_STATE_CHANGE); + break; + case RUNNING: + LOGGER.info("Running state is not supported"); + break; + default: + LOGGER.debug("Unknown orderedstate {}", orderedState); + break; + } + } + + private void deletePolicyData(ToscaConceptIdentifier automationCompositionId, + UUID automationCompositionElementId, AutomationCompositionOrderedState newState) { + // Delete all policies of this automationComposition from policy framework + for (Entry policy : policyMap.entrySet()) { + apiHttpClient.deletePolicy(policy.getKey(), policy.getValue()); + } + policyMap.clear(); + // Delete all policy types of this automation composition from policy framework + for (Entry policyType : policyTypeMap.entrySet()) { + apiHttpClient.deletePolicyType(policyType.getKey(), policyType.getValue()); + } + policyTypeMap.clear(); + intermediaryApi.updateAutomationCompositionElementState(automationCompositionId, + automationCompositionElementId, newState, AutomationCompositionState.UNINITIALISED, + ParticipantMessageType.AUTOMATION_COMPOSITION_STATE_CHANGE); + } + + private void deployPolicies(ToscaConceptIdentifier automationCompositionId, UUID automationCompositionElementId, + AutomationCompositionOrderedState newState) { + // Deploy all policies of this automationComposition from Policy Framework + if (!policyMap.entrySet().isEmpty()) { + for (Entry policy : policyMap.entrySet()) { + papHttpClient.handlePolicyDeployOrUndeploy(policy.getKey(), policy.getValue(), + DeploymentSubGroup.Action.POST); + } + LOGGER.debug("Policies deployed to {} successfully", automationCompositionElementId); + } else { + LOGGER.debug("No policies to deploy to {}", automationCompositionElementId); + } + intermediaryApi.updateAutomationCompositionElementState(automationCompositionId, + automationCompositionElementId, newState, AutomationCompositionState.PASSIVE, + ParticipantMessageType.AUTOMATION_COMPOSITION_STATE_CHANGE); + } + + private void undeployPolicies(UUID automationCompositionElementId) { + // Undeploy all policies of this automation composition from Policy Framework + if (!policyMap.entrySet().isEmpty()) { + for (Entry policy : policyMap.entrySet()) { + papHttpClient.handlePolicyDeployOrUndeploy(policy.getKey(), policy.getValue(), + DeploymentSubGroup.Action.DELETE); + } + LOGGER.debug("Undeployed policies from {} successfully", automationCompositionElementId); + } else { + LOGGER.debug("No policies are deployed to {}", automationCompositionElementId); + } + } + + /** + * Callback method to handle an update on a automation composition element. + * + * @param element the information on the automation composition element + * @param acElementDefinition toscaNodeTemplate + * @throws PfModelException in case of an exception + */ + @Override + public void automationCompositionElementUpdate(ToscaConceptIdentifier automationCompositionId, + AutomationCompositionElement element, + ToscaNodeTemplate acElementDefinition) + throws PfModelException { + intermediaryApi.updateAutomationCompositionElementState(automationCompositionId, element.getId(), + element.getOrderedState(), + AutomationCompositionState.PASSIVE, ParticipantMessageType.AUTOMATION_COMPOSITION_UPDATE); + ToscaServiceTemplate automationCompositionDefinition = element.getToscaServiceTemplateFragment(); + if (automationCompositionDefinition.getToscaTopologyTemplate() != null) { + if (automationCompositionDefinition.getPolicyTypes() != null) { + for (ToscaPolicyType policyType : automationCompositionDefinition.getPolicyTypes().values()) { + policyTypeMap.put(policyType.getName(), policyType.getVersion()); + } + LOGGER.debug("Found Policy Types in automation composition definition: {} , Creating Policy Types", + automationCompositionDefinition.getName()); + apiHttpClient.createPolicyType(automationCompositionDefinition); + } + if (automationCompositionDefinition.getToscaTopologyTemplate().getPolicies() != null) { + for (Map gotPolicyMap : automationCompositionDefinition.getToscaTopologyTemplate() + .getPolicies()) { + for (ToscaPolicy policy : gotPolicyMap.values()) { + policyMap.put(policy.getName(), policy.getVersion()); + } + } + LOGGER.debug("Found Policies in automation composition definition: {} , Creating Policies", + automationCompositionDefinition.getName()); + apiHttpClient.createPolicy(automationCompositionDefinition); + } + } + deployPolicies(automationCompositionId, element.getId(), element.getOrderedState()); + } + + /** + * Handle automationCompositionElement statistics. + * + * @param automationCompositionElementId automation composition element id + */ + @Override + public void handleStatistics(UUID automationCompositionElementId) { + var acElement = intermediaryApi.getAutomationCompositionElement(automationCompositionElementId); + if (acElement != null) { + var acElementStatistics = new AcElementStatistics(); + acElementStatistics.setState(acElement.getState()); + acElementStatistics.setTimeStamp(Instant.now()); + intermediaryApi.updateAutomationCompositionElementStatistics(automationCompositionElementId, + acElementStatistics); + } + } +} \ No newline at end of file diff --git a/participant/participant-impl/participant-impl-policy/src/main/java/org/onap/policy/clamp/acm/participant/policy/main/parameters/ParticipantPolicyParameters.java b/participant/participant-impl/participant-impl-policy/src/main/java/org/onap/policy/clamp/acm/participant/policy/main/parameters/ParticipantPolicyParameters.java new file mode 100644 index 000000000..a57198126 --- /dev/null +++ b/participant/participant-impl/participant-impl-policy/src/main/java/org/onap/policy/clamp/acm/participant/policy/main/parameters/ParticipantPolicyParameters.java @@ -0,0 +1,62 @@ +/*- + * ============LICENSE_START======================================================= + * Copyright (C) 2021 Nordix Foundation. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * SPDX-License-Identifier: Apache-2.0 + * ============LICENSE_END========================================================= + */ + +package org.onap.policy.clamp.acm.participant.policy.main.parameters; + +import javax.validation.Valid; +import javax.validation.constraints.NotBlank; +import javax.validation.constraints.NotNull; +import lombok.Getter; +import lombok.Setter; +import org.onap.policy.clamp.acm.participant.intermediary.parameters.ParticipantIntermediaryParameters; +import org.onap.policy.clamp.acm.participant.intermediary.parameters.ParticipantParameters; +import org.onap.policy.common.endpoints.parameters.RestClientParameters; +import org.onap.policy.common.parameters.validation.ParameterGroupConstraint; +import org.springframework.boot.context.properties.ConfigurationProperties; +import org.springframework.validation.annotation.Validated; + +/** + * Class to hold all parameters needed for the policy participant. + * + */ +@Validated +@Getter +@Setter +@ConfigurationProperties(prefix = "participant") +public class ParticipantPolicyParameters implements ParticipantParameters { + + @NotNull + @Valid + private ParticipantIntermediaryParameters intermediaryParameters; + + @NotNull + @ParameterGroupConstraint + private RestClientParameters policyApiParameters; + + @NotNull + @ParameterGroupConstraint + private RestClientParameters policyPapParameters; + + @NotBlank + private String pdpGroup; + + @NotBlank + private String pdpType; +} diff --git a/participant/participant-impl/participant-impl-policy/src/main/java/org/onap/policy/clamp/controlloop/participant/policy/PolicyParticipantApplication.java b/participant/participant-impl/participant-impl-policy/src/main/java/org/onap/policy/clamp/controlloop/participant/policy/PolicyParticipantApplication.java deleted file mode 100644 index 4869b7c2f..000000000 --- a/participant/participant-impl/participant-impl-policy/src/main/java/org/onap/policy/clamp/controlloop/participant/policy/PolicyParticipantApplication.java +++ /dev/null @@ -1,42 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * Copyright (C) 2021 Nordix Foundation. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - * SPDX-License-Identifier: Apache-2.0 - * ============LICENSE_END========================================================= - */ - -package org.onap.policy.clamp.controlloop.participant.policy; - -import org.springframework.boot.SpringApplication; -import org.springframework.boot.autoconfigure.SpringBootApplication; -import org.springframework.boot.context.properties.ConfigurationPropertiesScan; -import org.springframework.context.annotation.ComponentScan; - -/** - * Starter. - * - */ -@SpringBootApplication -@ComponentScan({ - "org.onap.policy.clamp.controlloop.participant.policy", - "org.onap.policy.clamp.controlloop.participant.intermediary"}) -@ConfigurationPropertiesScan("org.onap.policy.clamp.controlloop.participant.policy.main.parameters") -public class PolicyParticipantApplication { - - public static void main(String[] args) { - SpringApplication.run(PolicyParticipantApplication.class, args); - } -} diff --git a/participant/participant-impl/participant-impl-policy/src/main/java/org/onap/policy/clamp/controlloop/participant/policy/client/AbstractHttpClient.java b/participant/participant-impl/participant-impl-policy/src/main/java/org/onap/policy/clamp/controlloop/participant/policy/client/AbstractHttpClient.java deleted file mode 100644 index 2579585e5..000000000 --- a/participant/participant-impl/participant-impl-policy/src/main/java/org/onap/policy/clamp/controlloop/participant/policy/client/AbstractHttpClient.java +++ /dev/null @@ -1,76 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * Copyright (C) 2021 Nordix Foundation. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - * SPDX-License-Identifier: Apache-2.0 - * ============LICENSE_END========================================================= - */ - -package org.onap.policy.clamp.controlloop.participant.policy.client; - -import java.io.Closeable; -import java.io.IOException; -import java.util.Collections; -import java.util.Map; -import javax.ws.rs.client.Entity; -import javax.ws.rs.core.HttpHeaders; -import javax.ws.rs.core.MediaType; -import javax.ws.rs.core.Response; -import javax.ws.rs.core.Response.Status; -import org.onap.policy.clamp.controlloop.common.exception.ControlLoopRuntimeException; -import org.onap.policy.common.endpoints.event.comm.bus.internal.BusTopicParams; -import org.onap.policy.common.endpoints.http.client.HttpClient; -import org.onap.policy.common.endpoints.http.client.HttpClientFactoryInstance; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -public abstract class AbstractHttpClient implements Closeable { - - private static final Logger LOGGER = LoggerFactory.getLogger(AbstractHttpClient.class); - private final HttpClient httpclient; - - /** - * Constructor. - * - * @param policyParticipantParameters the parameters for the policy participant - * @throws ControlLoopRuntimeException on client start errors - */ - protected AbstractHttpClient(BusTopicParams policyParticipantParameters) { - try { - httpclient = HttpClientFactoryInstance.getClientFactory().build(policyParticipantParameters); - } catch (final Exception e) { - throw new ControlLoopRuntimeException(Status.INTERNAL_SERVER_ERROR, " Client failed to start", e); - } - } - - protected Response executePost(String path, final Entity entity) { - var response = httpclient.post(path, entity, Map.of(HttpHeaders.ACCEPT, MediaType.APPLICATION_JSON, - HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)); - if (response.getStatus() / 100 != 2) { - LOGGER.error("Invocation of path {} failed for entity {}. Response status: {}, Response status info: {}", - path, entity, response.getStatus(), response.getStatusInfo()); - } - return response; - } - - protected Response executeDelete(String path) { - return httpclient.delete(path, Collections.emptyMap()); - } - - @Override - public void close() throws IOException { - httpclient.shutdown(); - } -} diff --git a/participant/participant-impl/participant-impl-policy/src/main/java/org/onap/policy/clamp/controlloop/participant/policy/client/PolicyApiHttpClient.java b/participant/participant-impl/participant-impl-policy/src/main/java/org/onap/policy/clamp/controlloop/participant/policy/client/PolicyApiHttpClient.java deleted file mode 100644 index 38a79f7f6..000000000 --- a/participant/participant-impl/participant-impl-policy/src/main/java/org/onap/policy/clamp/controlloop/participant/policy/client/PolicyApiHttpClient.java +++ /dev/null @@ -1,87 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * Copyright (C) 2021 Nordix Foundation. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - * SPDX-License-Identifier: Apache-2.0 - * ============LICENSE_END========================================================= - */ - -package org.onap.policy.clamp.controlloop.participant.policy.client; - -import javax.ws.rs.client.Entity; -import javax.ws.rs.core.MediaType; -import javax.ws.rs.core.Response; -import org.onap.policy.clamp.controlloop.participant.policy.main.parameters.ParticipantPolicyParameters; -import org.onap.policy.models.base.PfModelException; -import org.onap.policy.models.tosca.authorative.concepts.ToscaServiceTemplate; -import org.springframework.stereotype.Component; - -@Component -public class PolicyApiHttpClient extends AbstractHttpClient { - - private static final String POLICY_URI = "/policy/api/v1/"; - - /** - * Constructor. - * - * @param parameters the policy participant parameters - */ - public PolicyApiHttpClient(ParticipantPolicyParameters parameters) { - super(parameters.getPolicyApiParameters()); - } - - /** - * Create Policy Types. - * - * @param toscaServiceTemplate the whole ToscaServiceTemplate - * @return Response - * @throws PfModelException on errors creating the policy type - */ - public Response createPolicyType(ToscaServiceTemplate toscaServiceTemplate) throws PfModelException { - return executePost(POLICY_URI + "policytypes", Entity.entity(toscaServiceTemplate, MediaType.APPLICATION_JSON)); - } - - /** - * Create Policies. - * - * @param toscaServiceTemplate the whole ToscaServiceTemplate - * @return Response - */ - public Response createPolicy(final ToscaServiceTemplate toscaServiceTemplate) { - return executePost(POLICY_URI + "policies", Entity.entity(toscaServiceTemplate, MediaType.APPLICATION_JSON)); - } - - /** - * Delete Policies. - * - * @param policyName the name of the policy to be deleted - * @param policyVersion the version of the policy to be deleted - * @return Response - */ - public Response deletePolicy(final String policyName, final String policyVersion) { - return executeDelete(POLICY_URI + "policies/" + policyName + "/versions/" + policyVersion); - } - - /** - * Delete Policy types. - * - * @param policyTypeName the name of the policy to be deleted - * @param policyTypeVersion the version of the policy to be deleted - * @return Response - */ - public Response deletePolicyType(final String policyTypeName, final String policyTypeVersion) { - return executeDelete(POLICY_URI + "policytypes/" + policyTypeName + "/versions/" + policyTypeVersion); - } -} diff --git a/participant/participant-impl/participant-impl-policy/src/main/java/org/onap/policy/clamp/controlloop/participant/policy/client/PolicyPapHttpClient.java b/participant/participant-impl/participant-impl-policy/src/main/java/org/onap/policy/clamp/controlloop/participant/policy/client/PolicyPapHttpClient.java deleted file mode 100644 index f835c6e04..000000000 --- a/participant/participant-impl/participant-impl-policy/src/main/java/org/onap/policy/clamp/controlloop/participant/policy/client/PolicyPapHttpClient.java +++ /dev/null @@ -1,85 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * Copyright (C) 2021 Nordix Foundation. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - * SPDX-License-Identifier: Apache-2.0 - * ============LICENSE_END========================================================= - */ - -package org.onap.policy.clamp.controlloop.participant.policy.client; - -import java.util.LinkedList; -import java.util.List; -import javax.ws.rs.client.Entity; -import javax.ws.rs.core.MediaType; -import javax.ws.rs.core.Response; -import org.onap.policy.clamp.controlloop.participant.policy.main.parameters.ParticipantPolicyParameters; -import org.onap.policy.models.pdp.concepts.DeploymentGroup; -import org.onap.policy.models.pdp.concepts.DeploymentGroups; -import org.onap.policy.models.pdp.concepts.DeploymentSubGroup; -import org.onap.policy.models.tosca.authorative.concepts.ToscaConceptIdentifier; -import org.springframework.stereotype.Component; - -@Component -public class PolicyPapHttpClient extends AbstractHttpClient { - - private static final String PAP_URI = "/policy/pap/v1/"; - private final String pdpGroup; - private final String pdpType; - - /** - * Constructor. - * - * @param parameters the policy participant parameters - */ - public PolicyPapHttpClient(ParticipantPolicyParameters parameters) { - super(parameters.getPolicyPapParameters()); - this.pdpGroup = parameters.getPdpGroup(); - this.pdpType = parameters.getPdpType(); - } - - /** - * Deploy or undeploy Policies. - * - * @param policyName the name of the policy to be deployed/undeployed - * @param policyVersion the version of the policy to be deployed/undeployed - * @param action the action to deploy/undeploy policy - * @return Response - */ - public Response handlePolicyDeployOrUndeploy(final String policyName, final String policyVersion, - final DeploymentSubGroup.Action action) { - - List policies = new LinkedList(); - policies.add(new ToscaConceptIdentifier(policyName, policyVersion)); - - DeploymentSubGroup subGroup = new DeploymentSubGroup(); - subGroup.setPolicies(policies); - subGroup.setPdpType(pdpType); - subGroup.setAction(action); - - DeploymentGroup group = new DeploymentGroup(); - List subGroups = new LinkedList(); - subGroups.add(subGroup); - group.setDeploymentSubgroups(subGroups); - group.setName(pdpGroup); - - DeploymentGroups groups = new DeploymentGroups(); - List groupsArr = new LinkedList(); - groupsArr.add(group); - groups.setGroups(groupsArr); - - return executePost(PAP_URI + "pdps/deployments/batch", Entity.entity(groups, MediaType.APPLICATION_JSON)); - } -} diff --git a/participant/participant-impl/participant-impl-policy/src/main/java/org/onap/policy/clamp/controlloop/participant/policy/config/ParticipantConfig.java b/participant/participant-impl/participant-impl-policy/src/main/java/org/onap/policy/clamp/controlloop/participant/policy/config/ParticipantConfig.java deleted file mode 100644 index 7b49a9a6b..000000000 --- a/participant/participant-impl/participant-impl-policy/src/main/java/org/onap/policy/clamp/controlloop/participant/policy/config/ParticipantConfig.java +++ /dev/null @@ -1,43 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * Copyright (C) 2021 Nordix Foundation. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - * SPDX-License-Identifier: Apache-2.0 - * ============LICENSE_END========================================================= - */ - -package org.onap.policy.clamp.controlloop.participant.policy.config; - -import org.onap.policy.clamp.controlloop.participant.intermediary.api.ParticipantIntermediaryApi; -import org.onap.policy.clamp.controlloop.participant.policy.main.handler.ControlLoopElementHandler; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.context.annotation.Configuration; - -@Configuration -public class ParticipantConfig { - - /** - * Register ControlLoopElementListener. - * - * @param intermediaryApi the ParticipantIntermediaryApi - * @param clElementHandler the ControlLoop Element Handler - */ - @Autowired - public void registerControlLoopElementListener(ParticipantIntermediaryApi intermediaryApi, - ControlLoopElementHandler clElementHandler) { - intermediaryApi.registerControlLoopElementListener(clElementHandler); - clElementHandler.setIntermediaryApi(intermediaryApi); - } -} diff --git a/participant/participant-impl/participant-impl-policy/src/main/java/org/onap/policy/clamp/controlloop/participant/policy/config/SecurityConfig.java b/participant/participant-impl/participant-impl-policy/src/main/java/org/onap/policy/clamp/controlloop/participant/policy/config/SecurityConfig.java deleted file mode 100644 index 4ee8c41b0..000000000 --- a/participant/participant-impl/participant-impl-policy/src/main/java/org/onap/policy/clamp/controlloop/participant/policy/config/SecurityConfig.java +++ /dev/null @@ -1,45 +0,0 @@ -/*- - * ========================LICENSE_START================================= - * Copyright (C) 2021 Nordix Foundation. All rights reserved. - * ====================================================================== - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ========================LICENSE_END=================================== - */ - -package org.onap.policy.clamp.controlloop.participant.policy.config; - -import org.springframework.beans.factory.annotation.Value; -import org.springframework.context.annotation.Configuration; -import org.springframework.security.config.annotation.web.builders.HttpSecurity; -import org.springframework.security.config.annotation.web.configuration.WebSecurityConfigurerAdapter; - -@Configuration -public class SecurityConfig extends WebSecurityConfigurerAdapter { - - @Value("${security.enable-csrf:true}") - private boolean csrfEnabled = true; - - @Override - protected void configure(HttpSecurity http) throws Exception { - // @formatter:off - http.authorizeRequests() - .antMatchers().authenticated() - .anyRequest().authenticated() - .and().httpBasic(); - // @formatter:on - - if (!csrfEnabled) { - http.csrf().disable(); - } - } -} diff --git a/participant/participant-impl/participant-impl-policy/src/main/java/org/onap/policy/clamp/controlloop/participant/policy/main/handler/ControlLoopElementHandler.java b/participant/participant-impl/participant-impl-policy/src/main/java/org/onap/policy/clamp/controlloop/participant/policy/main/handler/ControlLoopElementHandler.java deleted file mode 100644 index 663d6d5e9..000000000 --- a/participant/participant-impl/participant-impl-policy/src/main/java/org/onap/policy/clamp/controlloop/participant/policy/main/handler/ControlLoopElementHandler.java +++ /dev/null @@ -1,220 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * Copyright (C) 2021-2022 Nordix Foundation. - * ================================================================================ - * Modifications Copyright (C) 2021 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - * SPDX-License-Identifier: Apache-2.0 - * ============LICENSE_END========================================================= - */ - -package org.onap.policy.clamp.controlloop.participant.policy.main.handler; - -import java.time.Instant; -import java.util.LinkedHashMap; -import java.util.Map; -import java.util.Map.Entry; -import java.util.UUID; -import lombok.Setter; -import org.onap.policy.clamp.controlloop.models.controlloop.concepts.ClElementStatistics; -import org.onap.policy.clamp.controlloop.models.controlloop.concepts.ControlLoopElement; -import org.onap.policy.clamp.controlloop.models.controlloop.concepts.ControlLoopOrderedState; -import org.onap.policy.clamp.controlloop.models.controlloop.concepts.ControlLoopState; -import org.onap.policy.clamp.controlloop.models.messages.dmaap.participant.ParticipantMessageType; -import org.onap.policy.clamp.controlloop.participant.intermediary.api.ControlLoopElementListener; -import org.onap.policy.clamp.controlloop.participant.intermediary.api.ParticipantIntermediaryApi; -import org.onap.policy.clamp.controlloop.participant.policy.client.PolicyApiHttpClient; -import org.onap.policy.clamp.controlloop.participant.policy.client.PolicyPapHttpClient; -import org.onap.policy.models.base.PfModelException; -import org.onap.policy.models.base.PfModelRuntimeException; -import org.onap.policy.models.pdp.concepts.DeploymentSubGroup; -import org.onap.policy.models.tosca.authorative.concepts.ToscaConceptIdentifier; -import org.onap.policy.models.tosca.authorative.concepts.ToscaNodeTemplate; -import org.onap.policy.models.tosca.authorative.concepts.ToscaPolicy; -import org.onap.policy.models.tosca.authorative.concepts.ToscaPolicyType; -import org.onap.policy.models.tosca.authorative.concepts.ToscaServiceTemplate; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; -import org.springframework.stereotype.Component; - -/** - * This class handles implementation of controlLoopElement updates. - */ -@Component -public class ControlLoopElementHandler implements ControlLoopElementListener { - - private static final Logger LOGGER = LoggerFactory.getLogger(ControlLoopElementHandler.class); - private final Map policyTypeMap = new LinkedHashMap<>(); - private final Map policyMap = new LinkedHashMap<>(); - - private final PolicyApiHttpClient apiHttpClient; - private final PolicyPapHttpClient papHttpClient; - - @Setter - private ParticipantIntermediaryApi intermediaryApi; - - /** - * constructor. - * - * @param apiHttpClient the Policy Api Http Client - * @param papHttpClient the Policy Pap Http Client - */ - public ControlLoopElementHandler(PolicyApiHttpClient apiHttpClient, PolicyPapHttpClient papHttpClient) { - this.papHttpClient = papHttpClient; - this.apiHttpClient = apiHttpClient; - } - - /** - * Callback method to handle a control loop element state change. - * - * @param controlLoopId the ID of the control loop - * @param controlLoopElementId the ID of the control loop element - * @param currentState the current state of the control loop element - * @param orderedState the state to which the control loop element is changing to - */ - @Override - public void controlLoopElementStateChange(ToscaConceptIdentifier controlLoopId, - UUID controlLoopElementId, ControlLoopState currentState, - ControlLoopOrderedState orderedState) { - switch (orderedState) { - case UNINITIALISED: - try { - undeployPolicies(controlLoopElementId); - deletePolicyData(controlLoopId, controlLoopElementId, orderedState); - intermediaryApi.updateControlLoopElementState(controlLoopId, - controlLoopElementId, orderedState, ControlLoopState.UNINITIALISED, - ParticipantMessageType.CONTROL_LOOP_STATE_CHANGE); - } catch (PfModelRuntimeException e) { - LOGGER.debug("Undeploying/Deleting policy failed {}", controlLoopElementId, e); - } - break; - case PASSIVE: - try { - undeployPolicies(controlLoopElementId); - } catch (PfModelRuntimeException e) { - LOGGER.debug("Undeploying policies failed - no policies to undeploy {}", controlLoopElementId); - } - intermediaryApi.updateControlLoopElementState(controlLoopId, - controlLoopElementId, orderedState, ControlLoopState.PASSIVE, - ParticipantMessageType.CONTROL_LOOP_STATE_CHANGE); - break; - case RUNNING: - LOGGER.info("Running state is not supported"); - break; - default: - LOGGER.debug("Unknown orderedstate {}", orderedState); - break; - } - } - - private void deletePolicyData(ToscaConceptIdentifier controlLoopId, - UUID controlLoopElementId, ControlLoopOrderedState newState) { - // Delete all policies of this controlLoop from policy framework - for (Entry policy : policyMap.entrySet()) { - apiHttpClient.deletePolicy(policy.getKey(), policy.getValue()); - } - policyMap.clear(); - // Delete all policy types of this control loop from policy framework - for (Entry policyType : policyTypeMap.entrySet()) { - apiHttpClient.deletePolicyType(policyType.getKey(), policyType.getValue()); - } - policyTypeMap.clear(); - intermediaryApi.updateControlLoopElementState(controlLoopId, - controlLoopElementId, newState, ControlLoopState.UNINITIALISED, - ParticipantMessageType.CONTROL_LOOP_STATE_CHANGE); - } - - private void deployPolicies(ToscaConceptIdentifier controlLoopId, UUID controlLoopElementId, - ControlLoopOrderedState newState) { - // Deploy all policies of this controlLoop from Policy Framework - if (policyMap.entrySet() != null) { - for (Entry policy : policyMap.entrySet()) { - papHttpClient.handlePolicyDeployOrUndeploy(policy.getKey(), policy.getValue(), - DeploymentSubGroup.Action.POST); - } - LOGGER.debug("Policies deployed to {} successfully", controlLoopElementId); - } else { - LOGGER.debug("No policies to deploy to {}", controlLoopElementId); - } - intermediaryApi.updateControlLoopElementState(controlLoopId, - controlLoopElementId, newState, ControlLoopState.PASSIVE, - ParticipantMessageType.CONTROL_LOOP_STATE_CHANGE); - } - - private void undeployPolicies(UUID controlLoopElementId) { - // Undeploy all policies of this controlloop from Policy Framework - if (policyMap.entrySet() != null) { - for (Entry policy : policyMap.entrySet()) { - papHttpClient.handlePolicyDeployOrUndeploy(policy.getKey(), policy.getValue(), - DeploymentSubGroup.Action.DELETE); - } - LOGGER.debug("Undeployed policies from {} successfully", controlLoopElementId); - } else { - LOGGER.debug("No policies are deployed to {}", controlLoopElementId); - } - } - - /** - * Callback method to handle an update on a control loop element. - * - * @param element the information on the control loop element - * @param clElementDefinition toscaNodeTemplate - * @throws PfModelException in case of an exception - */ - @Override - public void controlLoopElementUpdate(ToscaConceptIdentifier controlLoopId, ControlLoopElement element, - ToscaNodeTemplate clElementDefinition) - throws PfModelException { - ToscaServiceTemplate controlLoopDefinition = element.getToscaServiceTemplateFragment(); - if (controlLoopDefinition.getToscaTopologyTemplate() != null) { - if (controlLoopDefinition.getPolicyTypes() != null) { - for (ToscaPolicyType policyType : controlLoopDefinition.getPolicyTypes().values()) { - policyTypeMap.put(policyType.getName(), policyType.getVersion()); - } - LOGGER.debug("Found Policy Types in control loop definition: {} , Creating Policy Types", - controlLoopDefinition.getName()); - apiHttpClient.createPolicyType(controlLoopDefinition); - } - if (controlLoopDefinition.getToscaTopologyTemplate().getPolicies() != null) { - for (Map foundPolicyMap : controlLoopDefinition.getToscaTopologyTemplate() - .getPolicies()) { - for (ToscaPolicy policy : foundPolicyMap.values()) { - policyMap.put(policy.getName(), policy.getVersion()); - } - } - LOGGER.debug("Found Policies in control loop definition: {} , Creating Policies", - controlLoopDefinition.getName()); - apiHttpClient.createPolicy(controlLoopDefinition); - } - } - deployPolicies(controlLoopId, element.getId(), element.getOrderedState()); - } - - /** - * Handle controlLoopElement statistics. - * - * @param controlLoopElementId controlloop element id - */ - @Override - public void handleStatistics(UUID controlLoopElementId) throws PfModelException { - var clElement = intermediaryApi.getControlLoopElement(controlLoopElementId); - if (clElement != null) { - var clElementStatistics = new ClElementStatistics(); - clElementStatistics.setControlLoopState(clElement.getState()); - clElementStatistics.setTimeStamp(Instant.now()); - intermediaryApi.updateControlLoopElementStatistics(controlLoopElementId, clElementStatistics); - } - } -} \ No newline at end of file diff --git a/participant/participant-impl/participant-impl-policy/src/main/java/org/onap/policy/clamp/controlloop/participant/policy/main/parameters/ParticipantPolicyParameters.java b/participant/participant-impl/participant-impl-policy/src/main/java/org/onap/policy/clamp/controlloop/participant/policy/main/parameters/ParticipantPolicyParameters.java deleted file mode 100644 index 8e1de36b9..000000000 --- a/participant/participant-impl/participant-impl-policy/src/main/java/org/onap/policy/clamp/controlloop/participant/policy/main/parameters/ParticipantPolicyParameters.java +++ /dev/null @@ -1,62 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * Copyright (C) 2021 Nordix Foundation. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - * SPDX-License-Identifier: Apache-2.0 - * ============LICENSE_END========================================================= - */ - -package org.onap.policy.clamp.controlloop.participant.policy.main.parameters; - -import javax.validation.Valid; -import javax.validation.constraints.NotBlank; -import javax.validation.constraints.NotNull; -import lombok.Getter; -import lombok.Setter; -import org.onap.policy.clamp.controlloop.participant.intermediary.parameters.ParticipantIntermediaryParameters; -import org.onap.policy.clamp.controlloop.participant.intermediary.parameters.ParticipantParameters; -import org.onap.policy.common.endpoints.parameters.RestClientParameters; -import org.onap.policy.common.parameters.validation.ParameterGroupConstraint; -import org.springframework.boot.context.properties.ConfigurationProperties; -import org.springframework.validation.annotation.Validated; - -/** - * Class to hold all parameters needed for the policy participant. - * - */ -@Validated -@Getter -@Setter -@ConfigurationProperties(prefix = "participant") -public class ParticipantPolicyParameters implements ParticipantParameters { - - @NotNull - @Valid - private ParticipantIntermediaryParameters intermediaryParameters; - - @NotNull - @ParameterGroupConstraint - private RestClientParameters policyApiParameters; - - @NotNull - @ParameterGroupConstraint - private RestClientParameters policyPapParameters; - - @NotBlank - private String pdpGroup; - - @NotBlank - private String pdpType; -} diff --git a/participant/participant-impl/participant-impl-policy/src/main/resources/META-INF/persistence.xml b/participant/participant-impl/participant-impl-policy/src/main/resources/META-INF/persistence.xml index 46db712b6..383bc7418 100644 --- a/participant/participant-impl/participant-impl-policy/src/main/resources/META-INF/persistence.xml +++ b/participant/participant-impl/participant-impl-policy/src/main/resources/META-INF/persistence.xml @@ -52,11 +52,11 @@ org.onap.policy.models.tosca.simple.concepts.JpaToscaServiceTemplate org.onap.policy.models.tosca.simple.concepts.JpaToscaTopologyTemplate org.onap.policy.models.tosca.simple.concepts.JpaToscaTrigger - org.onap.policy.clamp.controlloop.models.controlloop.persistence.concepts.JpaControlLoop - org.onap.policy.clamp.controlloop.models.controlloop.persistence.concepts.JpaControlLoopElement - org.onap.policy.clamp.controlloop.models.controlloop.persistence.concepts.JpaParticipant - org.onap.policy.clamp.controlloop.models.controlloop.persistence.concepts.JpaParticipantStatistics - org.onap.policy.clamp.controlloop.models.controlloop.persistence.concepts.JpaClElementStatistics + org.onap.policy.clamp.acm.models.acm.persistence.concepts.JpaAutomationComposition + org.onap.policy.clamp.acm.models.acm.persistence.concepts.JpaAutomationCompositionElement + org.onap.policy.clamp.acm.models.acm.persistence.concepts.JpaParticipant + org.onap.policy.clamp.acm.models.acm.persistence.concepts.JpaParticipantStatistics + org.onap.policy.clamp.acm.models.acm.persistence.concepts.JpaAcElementStatistics diff --git a/participant/participant-impl/participant-impl-policy/src/main/resources/config/application.yaml b/participant/participant-impl/participant-impl-policy/src/main/resources/config/application.yaml index 2aa33c1c4..c3338a993 100644 --- a/participant/participant-impl/participant-impl-policy/src/main/resources/config/application.yaml +++ b/participant/participant-impl/participant-impl-policy/src/main/resources/config/application.yaml @@ -30,19 +30,19 @@ participant: name: org.onap.PM_Policy version: 1.0.0 participantType: - name: org.onap.policy.controlloop.PolicyControlLoopParticipant + name: org.onap.policy.clamp.acm.PolicyParticipant version: 2.3.1 - clampControlLoopTopics: + clampAutomationCompositionTopics: topicSources: - - topic: POLICY-CLRUNTIME-PARTICIPANT + topic: POLICY-ACRUNTIME-PARTICIPANT servers: - ${topicServer:localhost} topicCommInfrastructure: dmaap fetchTimeout: 15000 topicSinks: - - topic: POLICY-CLRUNTIME-PARTICIPANT + topic: POLICY-ACRUNTIME-PARTICIPANT servers: - ${topicServer:localhost} topicCommInfrastructure: dmaap @@ -54,4 +54,4 @@ management: server: port: 8085 servlet: - context-path: /onap/policyparticipant + context-path: /onap/policy/clamp/acm/policyparticipant diff --git a/participant/participant-impl/participant-impl-policy/src/test/java/org/onap/policy/clamp/acm/participant/policy/endtoend/ParticipantMessagesTest.java b/participant/participant-impl/participant-impl-policy/src/test/java/org/onap/policy/clamp/acm/participant/policy/endtoend/ParticipantMessagesTest.java new file mode 100644 index 000000000..c17d2c53d --- /dev/null +++ b/participant/participant-impl/participant-impl-policy/src/test/java/org/onap/policy/clamp/acm/participant/policy/endtoend/ParticipantMessagesTest.java @@ -0,0 +1,174 @@ +/*- + * ============LICENSE_START======================================================= + * Copyright (C) 2021 Nordix Foundation. + * Modifications Copyright (C) 2021 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * SPDX-License-Identifier: Apache-2.0 + * ============LICENSE_END========================================================= + */ + +package org.onap.policy.clamp.acm.participant.policy.endtoend; + +import static org.assertj.core.api.Assertions.assertThatCode; +import static org.junit.Assert.assertEquals; + +import java.time.Instant; +import java.util.Collections; +import java.util.UUID; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.ExtendWith; +import org.mockito.Mockito; +import org.onap.policy.clamp.acm.participant.intermediary.comm.ParticipantDeregisterAckListener; +import org.onap.policy.clamp.acm.participant.intermediary.comm.ParticipantMessagePublisher; +import org.onap.policy.clamp.acm.participant.intermediary.comm.ParticipantRegisterAckListener; +import org.onap.policy.clamp.acm.participant.intermediary.comm.ParticipantUpdateListener; +import org.onap.policy.clamp.acm.participant.intermediary.handler.ParticipantHandler; +import org.onap.policy.clamp.acm.participant.policy.main.utils.TestListenerUtils; +import org.onap.policy.clamp.models.acm.messages.dmaap.participant.ParticipantDeregister; +import org.onap.policy.clamp.models.acm.messages.dmaap.participant.ParticipantDeregisterAck; +import org.onap.policy.clamp.models.acm.messages.dmaap.participant.ParticipantRegister; +import org.onap.policy.clamp.models.acm.messages.dmaap.participant.ParticipantRegisterAck; +import org.onap.policy.clamp.models.acm.messages.dmaap.participant.ParticipantStatus; +import org.onap.policy.clamp.models.acm.messages.dmaap.participant.ParticipantUpdate; +import org.onap.policy.clamp.models.acm.messages.dmaap.participant.ParticipantUpdateAck; +import org.onap.policy.common.endpoints.event.comm.Topic.CommInfrastructure; +import org.onap.policy.common.endpoints.event.comm.TopicSink; +import org.onap.policy.models.tosca.authorative.concepts.ToscaConceptIdentifier; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.boot.test.context.SpringBootTest; +import org.springframework.boot.test.context.SpringBootTest.WebEnvironment; +import org.springframework.test.context.TestPropertySource; +import org.springframework.test.context.junit.jupiter.SpringExtension; + +@ExtendWith(SpringExtension.class) +@SpringBootTest(webEnvironment = WebEnvironment.RANDOM_PORT) +@TestPropertySource(locations = {"classpath:application_test.properties"}) +class ParticipantMessagesTest { + + private static final Object lockit = new Object(); + private static final CommInfrastructure INFRA = CommInfrastructure.NOOP; + private static final String TOPIC = "my-topic"; + + @Autowired + private ParticipantHandler participantHandler; + + @Test + void testSendParticipantRegisterMessage() throws Exception { + final ParticipantRegister participantRegisterMsg = new ParticipantRegister(); + participantRegisterMsg.setParticipantId(getParticipantId()); + participantRegisterMsg.setTimestamp(Instant.now()); + participantRegisterMsg.setParticipantType(getParticipantType()); + + synchronized (lockit) { + ParticipantMessagePublisher participantMessagePublisher = + new ParticipantMessagePublisher(); + participantMessagePublisher.active(Collections.singletonList(Mockito.mock(TopicSink.class))); + assertThatCode(() -> participantMessagePublisher.sendParticipantRegister(participantRegisterMsg)) + .doesNotThrowAnyException(); + } + } + + @Test + void testReceiveParticipantRegisterAckMessage() throws Exception { + final ParticipantRegisterAck participantRegisterAckMsg = new ParticipantRegisterAck(); + participantRegisterAckMsg.setMessage("ParticipantRegisterAck message"); + participantRegisterAckMsg.setResponseTo(UUID.randomUUID()); + participantRegisterAckMsg.setResult(true); + + synchronized (lockit) { + ParticipantRegisterAckListener participantRegisterAckListener = + new ParticipantRegisterAckListener(participantHandler); + assertThatCode(() -> participantRegisterAckListener.onTopicEvent(INFRA, TOPIC, null, + participantRegisterAckMsg)).doesNotThrowAnyException(); + } + } + + @Test + void testSendParticipantDeregisterMessage() throws Exception { + final ParticipantDeregister participantDeregisterMsg = new ParticipantDeregister(); + participantDeregisterMsg.setParticipantId(getParticipantId()); + participantDeregisterMsg.setTimestamp(Instant.now()); + participantDeregisterMsg.setParticipantType(getParticipantType()); + + synchronized (lockit) { + ParticipantMessagePublisher participantMessagePublisher = + new ParticipantMessagePublisher(); + participantMessagePublisher.active(Collections.singletonList(Mockito.mock(TopicSink.class))); + assertThatCode(() -> participantMessagePublisher.sendParticipantDeregister(participantDeregisterMsg)) + .doesNotThrowAnyException(); + } + } + + @Test + void testReceiveParticipantDeregisterAckMessage() throws Exception { + final ParticipantDeregisterAck participantDeregisterAckMsg = new ParticipantDeregisterAck(); + participantDeregisterAckMsg.setMessage("ParticipantDeregisterAck message"); + participantDeregisterAckMsg.setResponseTo(UUID.randomUUID()); + participantDeregisterAckMsg.setResult(true); + + synchronized (lockit) { + ParticipantDeregisterAckListener participantDeregisterAckListener = + new ParticipantDeregisterAckListener(participantHandler); + assertThatCode(() -> participantDeregisterAckListener.onTopicEvent(INFRA, TOPIC, null, + participantDeregisterAckMsg)).doesNotThrowAnyException(); + } + } + + @Test + void testReceiveParticipantUpdateMessage() throws Exception { + ParticipantUpdate participantUpdateMsg = TestListenerUtils.createParticipantUpdateMsg(); + + synchronized (lockit) { + ParticipantUpdateListener participantUpdateListener = new ParticipantUpdateListener(participantHandler); + participantUpdateListener.onTopicEvent(INFRA, TOPIC, null, participantUpdateMsg); + } + + // Verify the result of GET participants with what is stored + assertEquals("org.onap.PM_Policy", participantHandler.getParticipantId().getName()); + } + + @Test + void testSendParticipantUpdateAckMessage() throws Exception { + final ParticipantUpdateAck participantUpdateAckMsg = new ParticipantUpdateAck(); + participantUpdateAckMsg.setMessage("ParticipantUpdateAck message"); + participantUpdateAckMsg.setResponseTo(UUID.randomUUID()); + participantUpdateAckMsg.setResult(true); + + synchronized (lockit) { + ParticipantMessagePublisher participantMessagePublisher = new ParticipantMessagePublisher(); + participantMessagePublisher.active(Collections.singletonList(Mockito.mock(TopicSink.class))); + assertThatCode(() -> participantMessagePublisher.sendParticipantUpdateAck(participantUpdateAckMsg)) + .doesNotThrowAnyException(); + } + } + + @Test + void testParticipantStatusHeartbeat() throws Exception { + final ParticipantStatus heartbeat = participantHandler.makeHeartbeat(true); + synchronized (lockit) { + ParticipantMessagePublisher publisher = new ParticipantMessagePublisher(); + publisher.active(Collections.singletonList(Mockito.mock(TopicSink.class))); + assertThatCode(() -> publisher.sendHeartbeat(heartbeat)).doesNotThrowAnyException(); + } + } + + private ToscaConceptIdentifier getParticipantId() { + return new ToscaConceptIdentifier("org.onap.PM_Policy", "1.0.0"); + } + + private ToscaConceptIdentifier getParticipantType() { + return new ToscaConceptIdentifier("org.onap.policy.acm.PolicyAutomationCompositionParticipant", "2.3.1"); + } +} diff --git a/participant/participant-impl/participant-impl-policy/src/test/java/org/onap/policy/clamp/acm/participant/policy/main/handler/AutomationCompositionElementHandlerTest.java b/participant/participant-impl/participant-impl-policy/src/test/java/org/onap/policy/clamp/acm/participant/policy/main/handler/AutomationCompositionElementHandlerTest.java new file mode 100644 index 000000000..0d114db8d --- /dev/null +++ b/participant/participant-impl/participant-impl-policy/src/test/java/org/onap/policy/clamp/acm/participant/policy/main/handler/AutomationCompositionElementHandlerTest.java @@ -0,0 +1,102 @@ +/*- + * ============LICENSE_START======================================================= + * Copyright (C) 2021 Nordix Foundation. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * SPDX-License-Identifier: Apache-2.0 + * ============LICENSE_END========================================================= + */ + +package org.onap.policy.clamp.acm.participant.policy.main.handler; + +import static org.junit.jupiter.api.Assertions.assertDoesNotThrow; +import static org.mockito.Mockito.when; + +import java.util.UUID; +import org.junit.jupiter.api.Test; +import org.mockito.Mockito; +import org.onap.policy.clamp.acm.participant.intermediary.api.ParticipantIntermediaryApi; +import org.onap.policy.clamp.acm.participant.policy.client.PolicyApiHttpClient; +import org.onap.policy.clamp.acm.participant.policy.client.PolicyPapHttpClient; +import org.onap.policy.clamp.models.acm.concepts.AutomationCompositionElement; +import org.onap.policy.clamp.models.acm.concepts.AutomationCompositionOrderedState; +import org.onap.policy.clamp.models.acm.concepts.AutomationCompositionState; +import org.onap.policy.models.base.PfModelException; +import org.onap.policy.models.tosca.authorative.concepts.ToscaConceptIdentifier; +import org.onap.policy.models.tosca.authorative.concepts.ToscaNodeTemplate; +import org.onap.policy.models.tosca.authorative.concepts.ToscaServiceTemplate; + +class AutomationCompositionElementHandlerTest { + + private static final String ID_NAME = "org.onap.PM_CDS_Blueprint"; + private static final String ID_VERSION = "1.0.1"; + private static final UUID automationCompositionElementId = UUID.randomUUID(); + private static final ToscaConceptIdentifier automationCompositionId = + new ToscaConceptIdentifier(ID_NAME, ID_VERSION); + + @Test + void testHandlerExceptions() { + AutomationCompositionElementHandler handler = getTestingHandler(); + + assertDoesNotThrow(() -> handler + .automationCompositionElementStateChange(automationCompositionId, + automationCompositionElementId, + AutomationCompositionState.UNINITIALISED, + AutomationCompositionOrderedState.PASSIVE)); + + assertDoesNotThrow(() -> handler + .automationCompositionElementStateChange(automationCompositionId, + automationCompositionElementId, + AutomationCompositionState.RUNNING, + AutomationCompositionOrderedState.UNINITIALISED)); + + assertDoesNotThrow(() -> handler + .automationCompositionElementStateChange(automationCompositionId, + automationCompositionElementId, + AutomationCompositionState.PASSIVE, + AutomationCompositionOrderedState.RUNNING)); + var element = getTestingAcElement(); + var acElementDefinition = Mockito.mock(ToscaNodeTemplate.class); + + assertDoesNotThrow(() -> handler + .automationCompositionElementUpdate(automationCompositionId, element, acElementDefinition)); + + assertDoesNotThrow(() -> handler + .handleStatistics(automationCompositionElementId)); + } + + AutomationCompositionElementHandler getTestingHandler() { + var api = Mockito.mock(PolicyApiHttpClient.class); + var pap = Mockito.mock(PolicyPapHttpClient.class); + var handler = new AutomationCompositionElementHandler(api, pap); + var intermediaryApi = Mockito.mock(ParticipantIntermediaryApi.class); + var element = getTestingAcElement(); + when(intermediaryApi.getAutomationCompositionElement(automationCompositionElementId)).thenReturn(element); + handler.setIntermediaryApi(intermediaryApi); + return handler; + } + + AutomationCompositionElement getTestingAcElement() { + var element = new AutomationCompositionElement(); + element.setDefinition(automationCompositionId); + element.setDescription("Description"); + element.setId(automationCompositionElementId); + element.setOrderedState(AutomationCompositionOrderedState.UNINITIALISED); + element.setParticipantId(automationCompositionId); + element.setState(AutomationCompositionState.UNINITIALISED); + var template = Mockito.mock(ToscaServiceTemplate.class); + element.setToscaServiceTemplateFragment(template); + return element; + } +} diff --git a/participant/participant-impl/participant-impl-policy/src/test/java/org/onap/policy/clamp/acm/participant/policy/main/parameters/CommonTestData.java b/participant/participant-impl/participant-impl-policy/src/test/java/org/onap/policy/clamp/acm/participant/policy/main/parameters/CommonTestData.java new file mode 100644 index 000000000..b5cd9d442 --- /dev/null +++ b/participant/participant-impl/participant-impl-policy/src/test/java/org/onap/policy/clamp/acm/participant/policy/main/parameters/CommonTestData.java @@ -0,0 +1,181 @@ +/*- + * ============LICENSE_START======================================================= + * Copyright (C) 2021 Nordix Foundation. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * SPDX-License-Identifier: Apache-2.0 + * ============LICENSE_END========================================================= + */ + +package org.onap.policy.clamp.acm.participant.policy.main.parameters; + +import java.util.Arrays; +import java.util.List; +import java.util.Map; +import java.util.TreeMap; +import org.onap.policy.clamp.acm.participant.policy.main.parameters.ParticipantPolicyParameters; +import org.onap.policy.common.endpoints.parameters.TopicParameters; +import org.onap.policy.common.utils.coder.Coder; +import org.onap.policy.common.utils.coder.CoderException; +import org.onap.policy.common.utils.coder.StandardCoder; +import org.onap.policy.models.tosca.authorative.concepts.ToscaConceptIdentifier; + +/** + * Class to hold/create all parameters for test cases. + */ +public class CommonTestData { + public static final String PARTICIPANT_GROUP_NAME = "AutomationCompositionParticipantGroup"; + public static final String DESCRIPTION = "Participant description"; + public static final long TIME_INTERVAL = 2000; + public static final List TOPIC_PARAMS = Arrays.asList(getTopicParams()); + + public static final Coder CODER = new StandardCoder(); + + /** + * Get ParticipantPolicyParameters. + * + * @return ParticipantPolicyParameters + */ + public ParticipantPolicyParameters getParticipantPolicyParameters() { + try { + return CODER.convert(getParticipantPolicyParametersMap(PARTICIPANT_GROUP_NAME), + ParticipantPolicyParameters.class); + } catch (final CoderException e) { + throw new RuntimeException("cannot create ParticipantPolicyParameters from map", e); + } + } + + /** + * Returns a property map for a ParticipantPolicyParameters map for test cases. + * + * @param name name of the parameters + * + * @return a property map suitable for constructing an object + */ + public Map getParticipantPolicyParametersMap(final String name) { + final Map map = new TreeMap<>(); + + map.put("name", name); + map.put("intermediaryParameters", getIntermediaryParametersMap(false)); + map.put("policyApiParameters", getPolicyApiParametersMap()); + map.put("policyPapParameters", getPolicyPapParametersMap()); + map.put("pdpGroup", "defaultGroup"); + map.put("pdpType", "apex"); + return map; + } + + /** + * Returns a property map for a policyPapParameters map for test cases. + * + * @return a property map suitable for constructing an object + */ + public Map getPolicyPapParametersMap() { + final Map map = new TreeMap<>(); + map.put("clientName", "pap"); + map.put("hostname", "localhost"); + map.put("port", 6968); + map.put("userName", "policyadmin"); + map.put("password", "zb!XztG34"); + map.put("https", false); + map.put("allowSelfSignedCerts", true); + return map; + } + + /** + * Returns a property map for a policyApiParameters map for test cases. + * + * @return a property map suitable for constructing an object + */ + public Map getPolicyApiParametersMap() { + final Map map = new TreeMap<>(); + map.put("clientName", "api"); + map.put("hostname", "localhost"); + map.put("port", 6969); + map.put("userName", "policyadmin"); + map.put("password", "zb!XztG34"); + map.put("https", false); + map.put("allowSelfSignedCerts", true); + + return map; + } + + /** + * Returns a property map for a intermediaryParameters map for test cases. + * + * @param isEmpty boolean value to represent that object created should be empty or not + * @return a property map suitable for constructing an object + */ + public Map getIntermediaryParametersMap(final boolean isEmpty) { + final Map map = new TreeMap<>(); + if (!isEmpty) { + map.put("name", "Participant parameters"); + map.put("reportingTimeIntervalMs", TIME_INTERVAL); + map.put("description", DESCRIPTION); + map.put("participantId", getParticipantId()); + map.put("participantType", getParticipantId()); + map.put("clampAutomationCompositionTopics", getTopicParametersMap(false)); + } + + return map; + } + + /** + * Returns a property map for a TopicParameters map for test cases. + * + * @param isEmpty boolean value to represent that object created should be empty or not + * @return a property map suitable for constructing an object + */ + public Map getTopicParametersMap(final boolean isEmpty) { + final Map map = new TreeMap<>(); + if (!isEmpty) { + map.put("topicSources", TOPIC_PARAMS); + map.put("topicSinks", TOPIC_PARAMS); + } + return map; + } + + /** + * Returns topic parameters for test cases. + * + * @return topic parameters + */ + public static TopicParameters getTopicParams() { + final TopicParameters topicParams = new TopicParameters(); + topicParams.setTopic("POLICY-ACRUNTIME-PARTICIPANT"); + topicParams.setTopicCommInfrastructure("dmaap"); + topicParams.setServers(Arrays.asList("localhost")); + return topicParams; + } + + /** + * Returns participantId for test cases. + * + * @return participant Id + */ + public static ToscaConceptIdentifier getParticipantId() { + final ToscaConceptIdentifier participantId = new ToscaConceptIdentifier("org.onap.PM_Policy", "0.0.0"); + return participantId; + } + + /** + * Nulls out a field within a JSON string. + * + * @param json JSON string + * @param field field to be nulled out + * @return a new JSON string with the field nulled out + */ + public String nullifyField(String json, String field) { + return json.replace(field + "\"", field + "\":null, \"" + field + "Xxx\""); + } +} diff --git a/participant/participant-impl/participant-impl-policy/src/test/java/org/onap/policy/clamp/acm/participant/policy/main/parameters/ParticipantPolicyParametersTest.java b/participant/participant-impl/participant-impl-policy/src/test/java/org/onap/policy/clamp/acm/participant/policy/main/parameters/ParticipantPolicyParametersTest.java new file mode 100644 index 000000000..89b2bce58 --- /dev/null +++ b/participant/participant-impl/participant-impl-policy/src/test/java/org/onap/policy/clamp/acm/participant/policy/main/parameters/ParticipantPolicyParametersTest.java @@ -0,0 +1,67 @@ +/*- + * ============LICENSE_START======================================================= + * Copyright (C) 2021 Nordix Foundation. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * SPDX-License-Identifier: Apache-2.0 + * ============LICENSE_END========================================================= + */ + +package org.onap.policy.clamp.acm.participant.policy.main.parameters; + +import static org.assertj.core.api.Assertions.assertThat; + +import javax.validation.Validation; +import javax.validation.ValidatorFactory; +import org.junit.jupiter.api.Test; +import org.onap.policy.clamp.acm.participant.policy.main.parameters.ParticipantPolicyParameters; + +class ParticipantPolicyParametersTest { + private final CommonTestData commonTestData = new CommonTestData(); + private final ValidatorFactory validatorFactory = Validation.buildDefaultValidatorFactory(); + + @Test + void testParticipantPolicyParameters() { + final ParticipantPolicyParameters participantParameters = commonTestData.getParticipantPolicyParameters(); + assertThat(validatorFactory.getValidator().validate(participantParameters)).isEmpty(); + } + + @Test + void testParticipantPolicyParameters_NullTopicSinks() { + final ParticipantPolicyParameters participantParameters = commonTestData.getParticipantPolicyParameters(); + participantParameters.getIntermediaryParameters().getClampAutomationCompositionTopics().setTopicSinks(null); + assertThat(validatorFactory.getValidator().validate(participantParameters)).isNotEmpty(); + } + + @Test + void testParticipantPolicyParameters_NullTopicSources() { + final ParticipantPolicyParameters participantParameters = commonTestData.getParticipantPolicyParameters(); + participantParameters.getIntermediaryParameters().getClampAutomationCompositionTopics().setTopicSources(null); + assertThat(validatorFactory.getValidator().validate(participantParameters)).isNotEmpty(); + } + + @Test + void testParticipantPolicyParameters_NullPolicyApiParameters() { + final ParticipantPolicyParameters participantParameters = commonTestData.getParticipantPolicyParameters(); + participantParameters.setPolicyApiParameters(null); + assertThat(validatorFactory.getValidator().validate(participantParameters)).isNotEmpty(); + } + + @Test + void testParticipantPolicyParameters_NullHostname() { + final ParticipantPolicyParameters participantParameters = commonTestData.getParticipantPolicyParameters(); + participantParameters.getPolicyApiParameters().setHostname(null); + assertThat(validatorFactory.getValidator().validate(participantParameters)).isNotEmpty(); + } +} diff --git a/participant/participant-impl/participant-impl-policy/src/test/java/org/onap/policy/clamp/acm/participant/policy/main/rest/ActuatorControllerTest.java b/participant/participant-impl/participant-impl-policy/src/test/java/org/onap/policy/clamp/acm/participant/policy/main/rest/ActuatorControllerTest.java new file mode 100644 index 000000000..8543bf98a --- /dev/null +++ b/participant/participant-impl/participant-impl-policy/src/test/java/org/onap/policy/clamp/acm/participant/policy/main/rest/ActuatorControllerTest.java @@ -0,0 +1,92 @@ +/*- + * ============LICENSE_START======================================================= + * Copyright (C) 2021 Nordix Foundation. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * SPDX-License-Identifier: Apache-2.0 + * ============LICENSE_END========================================================= + */ + +package org.onap.policy.clamp.acm.participant.policy.main.rest; + +import static org.junit.jupiter.api.Assertions.assertEquals; + +import javax.ws.rs.client.Invocation; +import javax.ws.rs.core.Response; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.ExtendWith; +import org.onap.policy.clamp.acm.participant.policy.main.utils.CommonActuatorController; +import org.springframework.boot.test.autoconfigure.actuate.metrics.AutoConfigureMetrics; +import org.springframework.boot.test.context.SpringBootTest; +import org.springframework.boot.test.context.SpringBootTest.WebEnvironment; +import org.springframework.boot.web.server.LocalServerPort; +import org.springframework.test.context.TestPropertySource; +import org.springframework.test.context.junit.jupiter.SpringExtension; + +@AutoConfigureMetrics +@ExtendWith(SpringExtension.class) +@SpringBootTest(webEnvironment = WebEnvironment.RANDOM_PORT) +@TestPropertySource(locations = {"classpath:application_test.properties"}) +class ActuatorControllerTest extends CommonActuatorController { + + private static final String HEALTH_ENDPOINT = "health"; + private static final String METRICS_ENDPOINT = "metrics"; + private static final String PROMETHEUS_ENDPOINT = "prometheus"; + + @LocalServerPort + private int randomServerPort; + + @BeforeEach + public void setUpPort() { + super.setHttpPrefix(randomServerPort); + } + + @Test + void testGetHealth_Unauthorized() throws Exception { + assertUnauthorizedActGet(HEALTH_ENDPOINT); + } + + @Test + void testGetMetrics_Unauthorized() throws Exception { + assertUnauthorizedActGet(METRICS_ENDPOINT); + } + + @Test + void testGetPrometheus_Unauthorized() throws Exception { + assertUnauthorizedActGet(PROMETHEUS_ENDPOINT); + } + + @Test + void testGetHealth() throws Exception { + Invocation.Builder invocationBuilder = super.sendActRequest(HEALTH_ENDPOINT); + Response rawresp = invocationBuilder.buildGet().invoke(); + assertEquals(Response.Status.OK.getStatusCode(), rawresp.getStatus()); + } + + @Test + void testGetMetrics() throws Exception { + Invocation.Builder invocationBuilder = super.sendActRequest(METRICS_ENDPOINT); + Response rawresp = invocationBuilder.buildGet().invoke(); + assertEquals(Response.Status.OK.getStatusCode(), rawresp.getStatus()); + } + + @Test + void testGePrometheus() throws Exception { + Invocation.Builder invocationBuilder = super.sendActRequest(PROMETHEUS_ENDPOINT); + Response rawresp = invocationBuilder.buildGet().invoke(); + assertEquals(Response.Status.OK.getStatusCode(), rawresp.getStatus()); + } + +} diff --git a/participant/participant-impl/participant-impl-policy/src/test/java/org/onap/policy/clamp/acm/participant/policy/main/utils/CommonActuatorController.java b/participant/participant-impl/participant-impl-policy/src/test/java/org/onap/policy/clamp/acm/participant/policy/main/utils/CommonActuatorController.java new file mode 100644 index 000000000..689977e3c --- /dev/null +++ b/participant/participant-impl/participant-impl-policy/src/test/java/org/onap/policy/clamp/acm/participant/policy/main/utils/CommonActuatorController.java @@ -0,0 +1,114 @@ +/*- + * ============LICENSE_START======================================================= + * Copyright (C) 2021 Nordix Foundation. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * SPDX-License-Identifier: Apache-2.0 + * ============LICENSE_END========================================================= + */ + +package org.onap.policy.clamp.acm.participant.policy.main.utils; + +import static org.junit.Assert.assertEquals; + +import javax.ws.rs.client.Client; +import javax.ws.rs.client.ClientBuilder; +import javax.ws.rs.client.Invocation; +import javax.ws.rs.client.WebTarget; +import javax.ws.rs.core.MediaType; +import javax.ws.rs.core.Response; +import org.glassfish.jersey.client.ClientProperties; +import org.glassfish.jersey.client.authentication.HttpAuthenticationFeature; +import org.onap.policy.common.gson.GsonMessageBodyHandler; +import org.onap.policy.common.utils.network.NetworkUtil; + +/** + * Class to perform Rest unit tests. + * + */ +public class CommonActuatorController { + + public static final String SELF = NetworkUtil.getHostname(); + public static final String CONTEXT_PATH = "onap/policy/clamp/acm/policyparticipant"; + public static final String ACTUATOR_ENDPOINT = CONTEXT_PATH + "/actuator/"; + + private static String httpPrefix; + + /** + * Sends a request to an actuator endpoint. + * + * @param endpoint the target endpoint + * @return a request builder + * @throws Exception if an error occurs + */ + protected Invocation.Builder sendActRequest(final String endpoint) throws Exception { + return sendFqeRequest(httpPrefix + ACTUATOR_ENDPOINT + endpoint, true); + } + + /** + * Sends a request to an actuator endpoint, without any authorization header. + * + * @param endpoint the target endpoint + * @return a request builder + * @throws Exception if an error occurs + */ + protected Invocation.Builder sendNoAuthActRequest(final String endpoint) throws Exception { + return sendFqeRequest(httpPrefix + ACTUATOR_ENDPOINT + endpoint, false); + } + + /** + * Sends a request to a fully qualified endpoint. + * + * @param fullyQualifiedEndpoint the fully qualified target endpoint + * @param includeAuth if authorization header should be included + * @return a request builder + * @throws Exception if an error occurs + */ + protected Invocation.Builder sendFqeRequest(final String fullyQualifiedEndpoint, boolean includeAuth) + throws Exception { + final Client client = ClientBuilder.newBuilder().build(); + + client.property(ClientProperties.METAINF_SERVICES_LOOKUP_DISABLE, "true"); + client.register(GsonMessageBodyHandler.class); + + if (includeAuth) { + client.register(HttpAuthenticationFeature.basic("participantUser", "zb!XztG34")); + } + + final WebTarget webTarget = client.target(fullyQualifiedEndpoint); + + return webTarget.request(MediaType.APPLICATION_JSON, MediaType.TEXT_PLAIN); + } + + /** + * Assert that GET call to actuator endpoint is Unauthorized. + * + * @param endPoint the endpoint + * @throws Exception if an error occurs + */ + protected void assertUnauthorizedActGet(final String endPoint) throws Exception { + Response rawresp = sendNoAuthActRequest(endPoint).buildGet().invoke(); + assertEquals(Response.Status.UNAUTHORIZED.getStatusCode(), rawresp.getStatus()); + } + + /** + * Set Up httpPrefix. + * + * @param port the port + */ + protected void setHttpPrefix(int port) { + httpPrefix = "http://" + SELF + ":" + port + "/"; + } + +} diff --git a/participant/participant-impl/participant-impl-policy/src/test/java/org/onap/policy/clamp/acm/participant/policy/main/utils/TestListenerUtils.java b/participant/participant-impl/participant-impl-policy/src/test/java/org/onap/policy/clamp/acm/participant/policy/main/utils/TestListenerUtils.java new file mode 100644 index 000000000..a29831d56 --- /dev/null +++ b/participant/participant-impl/participant-impl-policy/src/test/java/org/onap/policy/clamp/acm/participant/policy/main/utils/TestListenerUtils.java @@ -0,0 +1,321 @@ +/*- + * ============LICENSE_START======================================================= + * Copyright (C) 2021 Nordix Foundation. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * SPDX-License-Identifier: Apache-2.0 + * ============LICENSE_END========================================================= + */ + +package org.onap.policy.clamp.acm.participant.policy.main.utils; + +import static org.junit.Assert.assertTrue; + +import java.io.File; +import java.io.FileNotFoundException; +import java.time.Instant; +import java.util.ArrayList; +import java.util.LinkedHashMap; +import java.util.List; +import java.util.Map; +import java.util.Set; +import java.util.UUID; +import lombok.AccessLevel; +import lombok.NoArgsConstructor; +import org.onap.policy.clamp.models.acm.concepts.AutomationComposition; +import org.onap.policy.clamp.models.acm.concepts.AutomationCompositionElement; +import org.onap.policy.clamp.models.acm.concepts.AutomationCompositionOrderedState; +import org.onap.policy.clamp.models.acm.concepts.AutomationCompositionState; +import org.onap.policy.clamp.models.acm.concepts.ParticipantDefinition; +import org.onap.policy.clamp.models.acm.concepts.ParticipantUpdates; +import org.onap.policy.clamp.models.acm.concepts.ParticipantUtils; +import org.onap.policy.clamp.models.acm.messages.dmaap.participant.AutomationCompositionStateChange; +import org.onap.policy.clamp.models.acm.messages.dmaap.participant.AutomationCompositionUpdate; +import org.onap.policy.clamp.models.acm.messages.dmaap.participant.ParticipantUpdate; +import org.onap.policy.clamp.models.acm.utils.AcmUtils; +import org.onap.policy.common.utils.coder.Coder; +import org.onap.policy.common.utils.coder.CoderException; +import org.onap.policy.common.utils.coder.StandardCoder; +import org.onap.policy.common.utils.coder.YamlJsonTranslator; +import org.onap.policy.common.utils.resources.ResourceUtils; +import org.onap.policy.models.tosca.authorative.concepts.ToscaConceptIdentifier; +import org.onap.policy.models.tosca.authorative.concepts.ToscaNodeTemplate; +import org.onap.policy.models.tosca.authorative.concepts.ToscaServiceTemplate; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +@NoArgsConstructor(access = AccessLevel.PRIVATE) +public final class TestListenerUtils { + + private static final YamlJsonTranslator yamlTranslator = new YamlJsonTranslator(); + private static final Coder CODER = new StandardCoder(); + private static final Logger LOGGER = LoggerFactory.getLogger(TestListenerUtils.class); + + /** + * Method to create a automationComposition from a yaml file. + * + * @return AutomationComposition automation composition + */ + public static AutomationComposition createAutomationComposition() { + AutomationComposition automationComposition = new AutomationComposition(); + Map elements = new LinkedHashMap<>(); + ToscaServiceTemplate toscaServiceTemplate = testAutomationCompositionRead(); + Map nodeTemplatesMap = + toscaServiceTemplate.getToscaTopologyTemplate().getNodeTemplates(); + for (Map.Entry toscaInputEntry : nodeTemplatesMap.entrySet()) { + AutomationCompositionElement acElement = new AutomationCompositionElement(); + acElement.setId(UUID.randomUUID()); + + ToscaConceptIdentifier acElementParticipantId = new ToscaConceptIdentifier(); + acElementParticipantId.setName(toscaInputEntry.getKey()); + acElementParticipantId.setVersion(toscaInputEntry.getValue().getVersion()); + acElement.setParticipantId(acElementParticipantId); + + acElement.setDefinition(acElementParticipantId); + acElement.setState(AutomationCompositionState.UNINITIALISED); + acElement.setDescription(toscaInputEntry.getValue().getDescription()); + acElement.setOrderedState(AutomationCompositionOrderedState.UNINITIALISED); + elements.put(acElement.getId(), acElement); + } + automationComposition.setElements(elements); + automationComposition.setName("PMSHInstance0"); + automationComposition.setVersion("1.0.0"); + + ToscaConceptIdentifier definition = new ToscaConceptIdentifier(); + definition.setName("PMSHInstance0"); + definition.setVersion("1.0.0"); + automationComposition.setDefinition(definition); + + return automationComposition; + } + + /** + * Method to create AutomationCompositionStateChange message from the arguments passed. + * + * @param automationCompositionOrderedState automationCompositionOrderedState + * @return AutomationCompositionStateChange message + */ + public static AutomationCompositionStateChange createAutomationCompositionStateChangeMsg( + final AutomationCompositionOrderedState automationCompositionOrderedState) { + final AutomationCompositionStateChange acStateChangeMsg = new AutomationCompositionStateChange(); + + ToscaConceptIdentifier automationCompositionId = new ToscaConceptIdentifier(); + automationCompositionId.setName("PMSHInstance0"); + automationCompositionId.setVersion("1.0.0"); + + ToscaConceptIdentifier participantId = new ToscaConceptIdentifier(); + participantId.setName("org.onap.PM_Policy"); + participantId.setVersion("0.0.0"); + + acStateChangeMsg.setAutomationCompositionId(automationCompositionId); + acStateChangeMsg.setParticipantId(participantId); + acStateChangeMsg.setTimestamp(Instant.now()); + acStateChangeMsg.setOrderedState(automationCompositionOrderedState); + + return acStateChangeMsg; + } + + /** + * Method to create AutomationCompositionUpdateMsg. + * + * @return AutomationCompositionUpdate message + */ + public static AutomationCompositionUpdate createAutomationCompositionUpdateMsg() { + final AutomationCompositionUpdate acUpdateMsg = new AutomationCompositionUpdate(); + ToscaConceptIdentifier automationCompositionId = new ToscaConceptIdentifier("PMSHInstance0", "1.0.0"); + ToscaConceptIdentifier participantId = new ToscaConceptIdentifier("org.onap.PM_Policy", "0.0.0"); + + acUpdateMsg.setAutomationCompositionId(automationCompositionId); + acUpdateMsg.setParticipantId(participantId); + acUpdateMsg.setMessageId(UUID.randomUUID()); + acUpdateMsg.setTimestamp(Instant.now()); + + Map elements = new LinkedHashMap<>(); + ToscaServiceTemplate toscaServiceTemplate = testAutomationCompositionRead(); + TestListenerUtils.addPoliciesToToscaServiceTemplate(toscaServiceTemplate); + Map nodeTemplatesMap = + toscaServiceTemplate.getToscaTopologyTemplate().getNodeTemplates(); + for (Map.Entry toscaInputEntry : nodeTemplatesMap.entrySet()) { + if (ParticipantUtils.checkIfNodeTemplateIsAutomationCompositionElement(toscaInputEntry.getValue(), + toscaServiceTemplate)) { + AutomationCompositionElement acElement = new AutomationCompositionElement(); + acElement.setId(UUID.randomUUID()); + var acParticipantType = + ParticipantUtils.findParticipantType(toscaInputEntry.getValue().getProperties()); + + acElement.setParticipantId(acParticipantType); + acElement.setParticipantType(acParticipantType); + + acElement.setDefinition( + new ToscaConceptIdentifier(toscaInputEntry.getKey(), toscaInputEntry.getValue().getVersion())); + acElement.setState(AutomationCompositionState.UNINITIALISED); + acElement.setDescription(toscaInputEntry.getValue().getDescription()); + acElement.setOrderedState(AutomationCompositionOrderedState.PASSIVE); + elements.put(acElement.getId(), acElement); + } + } + + List participantUpdates = new ArrayList<>(); + for (AutomationCompositionElement element : elements.values()) { + AcmUtils.setServiceTemplatePolicyInfo(element, toscaServiceTemplate); + AcmUtils.prepareParticipantUpdate(element, participantUpdates); + } + acUpdateMsg.setParticipantUpdatesList(participantUpdates); + return acUpdateMsg; + } + + /** + * Method to create participantUpdateMsg. + * + * @return ParticipantUpdate message + */ + public static ParticipantUpdate createParticipantUpdateMsg() { + final ParticipantUpdate participantUpdateMsg = new ParticipantUpdate(); + ToscaConceptIdentifier participantId = new ToscaConceptIdentifier("org.onap.PM_Policy", "1.0.0"); + ToscaConceptIdentifier participantType = + new ToscaConceptIdentifier("org.onap.policy.acm.PolicyAutomationCompositionParticipant", "2.3.1"); + + participantUpdateMsg.setParticipantId(participantId); + participantUpdateMsg.setTimestamp(Instant.now()); + participantUpdateMsg.setParticipantType(participantType); + participantUpdateMsg.setTimestamp(Instant.ofEpochMilli(3000)); + participantUpdateMsg.setMessageId(UUID.randomUUID()); + + ToscaServiceTemplate toscaServiceTemplate = testAutomationCompositionRead(); + // Add policies to the toscaServiceTemplate + TestListenerUtils.addPoliciesToToscaServiceTemplate(toscaServiceTemplate); + + List participantDefinitionUpdates = new ArrayList<>(); + for (Map.Entry toscaInputEntry : toscaServiceTemplate.getToscaTopologyTemplate() + .getNodeTemplates().entrySet()) { + if (ParticipantUtils.checkIfNodeTemplateIsAutomationCompositionElement(toscaInputEntry.getValue(), + toscaServiceTemplate)) { + AcmUtils.prepareParticipantDefinitionUpdate( + ParticipantUtils.findParticipantType(toscaInputEntry.getValue().getProperties()), + toscaInputEntry.getKey(), toscaInputEntry.getValue(), + participantDefinitionUpdates, null); + } + } + + participantUpdateMsg.setParticipantDefinitionUpdates(participantDefinitionUpdates); + return participantUpdateMsg; + } + + /** + * Method to create AutomationCompositionUpdate using the arguments passed. + * + * @param jsonFilePath the path of the automation composition content + * @return AutomationCompositionUpdate message + * @throws CoderException exception while reading the file to object + */ + public static AutomationCompositionUpdate createParticipantAcUpdateMsgFromJson(String jsonFilePath) + throws CoderException { + AutomationCompositionUpdate automationCompositionUpdateMsg = + CODER.decode(new File(jsonFilePath), AutomationCompositionUpdate.class); + return automationCompositionUpdateMsg; + } + + private static ToscaServiceTemplate testAutomationCompositionRead() { + Set automationCompositionDirectoryContents = + ResourceUtils.getDirectoryContents("src/test/resources/utils/servicetemplates"); + + boolean atLeastOneAutomationCompositionTested = false; + ToscaServiceTemplate toscaServiceTemplate = null; + + for (String automationCompositionFilePath : automationCompositionDirectoryContents) { + if (!automationCompositionFilePath.endsWith(".yaml")) { + continue; + } + atLeastOneAutomationCompositionTested = true; + toscaServiceTemplate = testAutomationCompositionYamlSerialization(automationCompositionFilePath); + } + + // Add policy_types to the toscaServiceTemplate + addPolicyTypesToToscaServiceTemplate(toscaServiceTemplate); + + assertTrue(atLeastOneAutomationCompositionTested); + return toscaServiceTemplate; + } + + private static void addPolicyTypesToToscaServiceTemplate(ToscaServiceTemplate toscaServiceTemplate) { + Set policyTypeDirectoryContents = ResourceUtils.getDirectoryContents("policytypes"); + + for (String policyTypeFilePath : policyTypeDirectoryContents) { + String policyTypeString = ResourceUtils.getResourceAsString(policyTypeFilePath); + + ToscaServiceTemplate foundPolicyTypeSt = + yamlTranslator.fromYaml(policyTypeString, ToscaServiceTemplate.class); + + toscaServiceTemplate.setDerivedFrom(foundPolicyTypeSt.getDerivedFrom()); + toscaServiceTemplate.setDescription(foundPolicyTypeSt.getDescription()); + toscaServiceTemplate.setMetadata(foundPolicyTypeSt.getMetadata()); + toscaServiceTemplate.setName(foundPolicyTypeSt.getName()); + toscaServiceTemplate.setToscaDefinitionsVersion(foundPolicyTypeSt.getToscaDefinitionsVersion()); + toscaServiceTemplate.setVersion(foundPolicyTypeSt.getVersion()); + + if (foundPolicyTypeSt.getDataTypes() != null) { + if (toscaServiceTemplate.getDataTypes() == null) { + toscaServiceTemplate.setDataTypes(foundPolicyTypeSt.getDataTypes()); + } else { + toscaServiceTemplate.getDataTypes().putAll(foundPolicyTypeSt.getDataTypes()); + } + } + + if (toscaServiceTemplate.getPolicyTypes() == null) { + toscaServiceTemplate.setPolicyTypes(foundPolicyTypeSt.getPolicyTypes()); + } else { + toscaServiceTemplate.getPolicyTypes().putAll(foundPolicyTypeSt.getPolicyTypes()); + } + } + } + + /** + * Method to add polcies to the toscaServiceTemplate. + * + * @param toscaServiceTemplate to add policies + */ + public static void addPoliciesToToscaServiceTemplate(ToscaServiceTemplate toscaServiceTemplate) { + Set policiesDirectoryContents = ResourceUtils.getDirectoryContents("policies"); + + for (String policiesFilePath : policiesDirectoryContents) { + if (!policiesFilePath.endsWith("yaml")) { + continue; + } + + String policiesString = ResourceUtils.getResourceAsString(policiesFilePath); + + ToscaServiceTemplate foundPoliciesSt = + yamlTranslator.fromYaml(policiesString, ToscaServiceTemplate.class); + toscaServiceTemplate.getToscaTopologyTemplate() + .setPolicies(foundPoliciesSt.getToscaTopologyTemplate().getPolicies()); + } + } + + private static ToscaServiceTemplate testAutomationCompositionYamlSerialization( + String automationCompositionFilePath) { + try { + String automationCompositionString = ResourceUtils.getResourceAsString(automationCompositionFilePath); + if (automationCompositionString == null) { + throw new FileNotFoundException(automationCompositionFilePath); + } + + ToscaServiceTemplate serviceTemplate = + yamlTranslator.fromYaml(automationCompositionString, ToscaServiceTemplate.class); + return serviceTemplate; + } catch (FileNotFoundException e) { + LOGGER.error("cannot find YAML file", automationCompositionFilePath); + throw new IllegalArgumentException(e); + } + } +} diff --git a/participant/participant-impl/participant-impl-policy/src/test/java/org/onap/policy/clamp/controlloop/participant/policy/endtoend/ParticipantMessagesTest.java b/participant/participant-impl/participant-impl-policy/src/test/java/org/onap/policy/clamp/controlloop/participant/policy/endtoend/ParticipantMessagesTest.java deleted file mode 100644 index ce368eba1..000000000 --- a/participant/participant-impl/participant-impl-policy/src/test/java/org/onap/policy/clamp/controlloop/participant/policy/endtoend/ParticipantMessagesTest.java +++ /dev/null @@ -1,174 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * Copyright (C) 2021 Nordix Foundation. - * Modifications Copyright (C) 2021 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - * SPDX-License-Identifier: Apache-2.0 - * ============LICENSE_END========================================================= - */ - -package org.onap.policy.clamp.controlloop.participant.policy.endtoend; - -import static org.assertj.core.api.Assertions.assertThatCode; -import static org.junit.Assert.assertEquals; - -import java.time.Instant; -import java.util.Collections; -import java.util.UUID; -import org.junit.jupiter.api.Test; -import org.junit.jupiter.api.extension.ExtendWith; -import org.mockito.Mockito; -import org.onap.policy.clamp.controlloop.models.messages.dmaap.participant.ParticipantDeregister; -import org.onap.policy.clamp.controlloop.models.messages.dmaap.participant.ParticipantDeregisterAck; -import org.onap.policy.clamp.controlloop.models.messages.dmaap.participant.ParticipantRegister; -import org.onap.policy.clamp.controlloop.models.messages.dmaap.participant.ParticipantRegisterAck; -import org.onap.policy.clamp.controlloop.models.messages.dmaap.participant.ParticipantStatus; -import org.onap.policy.clamp.controlloop.models.messages.dmaap.participant.ParticipantUpdate; -import org.onap.policy.clamp.controlloop.models.messages.dmaap.participant.ParticipantUpdateAck; -import org.onap.policy.clamp.controlloop.participant.intermediary.comm.ParticipantDeregisterAckListener; -import org.onap.policy.clamp.controlloop.participant.intermediary.comm.ParticipantMessagePublisher; -import org.onap.policy.clamp.controlloop.participant.intermediary.comm.ParticipantRegisterAckListener; -import org.onap.policy.clamp.controlloop.participant.intermediary.comm.ParticipantUpdateListener; -import org.onap.policy.clamp.controlloop.participant.intermediary.handler.ParticipantHandler; -import org.onap.policy.clamp.controlloop.participant.policy.main.utils.TestListenerUtils; -import org.onap.policy.common.endpoints.event.comm.Topic.CommInfrastructure; -import org.onap.policy.common.endpoints.event.comm.TopicSink; -import org.onap.policy.models.tosca.authorative.concepts.ToscaConceptIdentifier; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.boot.test.context.SpringBootTest; -import org.springframework.boot.test.context.SpringBootTest.WebEnvironment; -import org.springframework.test.context.TestPropertySource; -import org.springframework.test.context.junit.jupiter.SpringExtension; - -@ExtendWith(SpringExtension.class) -@SpringBootTest(webEnvironment = WebEnvironment.RANDOM_PORT) -@TestPropertySource(locations = {"classpath:application_test.properties"}) -class ParticipantMessagesTest { - - private static final Object lockit = new Object(); - private static final CommInfrastructure INFRA = CommInfrastructure.NOOP; - private static final String TOPIC = "my-topic"; - - @Autowired - private ParticipantHandler participantHandler; - - @Test - void testSendParticipantRegisterMessage() throws Exception { - final ParticipantRegister participantRegisterMsg = new ParticipantRegister(); - participantRegisterMsg.setParticipantId(getParticipantId()); - participantRegisterMsg.setTimestamp(Instant.now()); - participantRegisterMsg.setParticipantType(getParticipantType()); - - synchronized (lockit) { - ParticipantMessagePublisher participantMessagePublisher = - new ParticipantMessagePublisher(); - participantMessagePublisher.active(Collections.singletonList(Mockito.mock(TopicSink.class))); - assertThatCode(() -> participantMessagePublisher.sendParticipantRegister(participantRegisterMsg)) - .doesNotThrowAnyException(); - } - } - - @Test - void testReceiveParticipantRegisterAckMessage() throws Exception { - final ParticipantRegisterAck participantRegisterAckMsg = new ParticipantRegisterAck(); - participantRegisterAckMsg.setMessage("ParticipantRegisterAck message"); - participantRegisterAckMsg.setResponseTo(UUID.randomUUID()); - participantRegisterAckMsg.setResult(true); - - synchronized (lockit) { - ParticipantRegisterAckListener participantRegisterAckListener = - new ParticipantRegisterAckListener(participantHandler); - assertThatCode(() -> participantRegisterAckListener.onTopicEvent(INFRA, TOPIC, null, - participantRegisterAckMsg)).doesNotThrowAnyException(); - } - } - - @Test - void testSendParticipantDeregisterMessage() throws Exception { - final ParticipantDeregister participantDeregisterMsg = new ParticipantDeregister(); - participantDeregisterMsg.setParticipantId(getParticipantId()); - participantDeregisterMsg.setTimestamp(Instant.now()); - participantDeregisterMsg.setParticipantType(getParticipantType()); - - synchronized (lockit) { - ParticipantMessagePublisher participantMessagePublisher = - new ParticipantMessagePublisher(); - participantMessagePublisher.active(Collections.singletonList(Mockito.mock(TopicSink.class))); - assertThatCode(() -> participantMessagePublisher.sendParticipantDeregister(participantDeregisterMsg)) - .doesNotThrowAnyException(); - } - } - - @Test - void testReceiveParticipantDeregisterAckMessage() throws Exception { - final ParticipantDeregisterAck participantDeregisterAckMsg = new ParticipantDeregisterAck(); - participantDeregisterAckMsg.setMessage("ParticipantDeregisterAck message"); - participantDeregisterAckMsg.setResponseTo(UUID.randomUUID()); - participantDeregisterAckMsg.setResult(true); - - synchronized (lockit) { - ParticipantDeregisterAckListener participantDeregisterAckListener = - new ParticipantDeregisterAckListener(participantHandler); - assertThatCode(() -> participantDeregisterAckListener.onTopicEvent(INFRA, TOPIC, null, - participantDeregisterAckMsg)).doesNotThrowAnyException(); - } - } - - @Test - void testReceiveParticipantUpdateMessage() throws Exception { - ParticipantUpdate participantUpdateMsg = TestListenerUtils.createParticipantUpdateMsg(); - - synchronized (lockit) { - ParticipantUpdateListener participantUpdateListener = new ParticipantUpdateListener(participantHandler); - participantUpdateListener.onTopicEvent(INFRA, TOPIC, null, participantUpdateMsg); - } - - // Verify the result of GET participants with what is stored - assertEquals("org.onap.PM_Policy", participantHandler.getParticipantId().getName()); - } - - @Test - void testSendParticipantUpdateAckMessage() throws Exception { - final ParticipantUpdateAck participantUpdateAckMsg = new ParticipantUpdateAck(); - participantUpdateAckMsg.setMessage("ParticipantUpdateAck message"); - participantUpdateAckMsg.setResponseTo(UUID.randomUUID()); - participantUpdateAckMsg.setResult(true); - - synchronized (lockit) { - ParticipantMessagePublisher participantMessagePublisher = new ParticipantMessagePublisher(); - participantMessagePublisher.active(Collections.singletonList(Mockito.mock(TopicSink.class))); - assertThatCode(() -> participantMessagePublisher.sendParticipantUpdateAck(participantUpdateAckMsg)) - .doesNotThrowAnyException(); - } - } - - @Test - void testParticipantStatusHeartbeat() throws Exception { - final ParticipantStatus heartbeat = participantHandler.makeHeartbeat(true); - synchronized (lockit) { - ParticipantMessagePublisher publisher = new ParticipantMessagePublisher(); - publisher.active(Collections.singletonList(Mockito.mock(TopicSink.class))); - assertThatCode(() -> publisher.sendHeartbeat(heartbeat)).doesNotThrowAnyException(); - } - } - - private ToscaConceptIdentifier getParticipantId() { - return new ToscaConceptIdentifier("org.onap.PM_Policy", "1.0.0"); - } - - private ToscaConceptIdentifier getParticipantType() { - return new ToscaConceptIdentifier("org.onap.policy.controlloop.PolicyControlLoopParticipant", "2.3.1"); - } -} diff --git a/participant/participant-impl/participant-impl-policy/src/test/java/org/onap/policy/clamp/controlloop/participant/policy/main/handler/ControlLoopElementHandlerTest.java b/participant/participant-impl/participant-impl-policy/src/test/java/org/onap/policy/clamp/controlloop/participant/policy/main/handler/ControlLoopElementHandlerTest.java deleted file mode 100644 index b5c5e19cb..000000000 --- a/participant/participant-impl/participant-impl-policy/src/test/java/org/onap/policy/clamp/controlloop/participant/policy/main/handler/ControlLoopElementHandlerTest.java +++ /dev/null @@ -1,102 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * Copyright (C) 2021 Nordix Foundation. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - * SPDX-License-Identifier: Apache-2.0 - * ============LICENSE_END========================================================= - */ - -package org.onap.policy.clamp.controlloop.participant.policy.main.handler; - -import static org.junit.jupiter.api.Assertions.assertDoesNotThrow; -import static org.mockito.Mockito.when; - -import java.util.UUID; -import org.junit.jupiter.api.Test; -import org.mockito.Mockito; -import org.onap.policy.clamp.controlloop.models.controlloop.concepts.ControlLoopElement; -import org.onap.policy.clamp.controlloop.models.controlloop.concepts.ControlLoopOrderedState; -import org.onap.policy.clamp.controlloop.models.controlloop.concepts.ControlLoopState; -import org.onap.policy.clamp.controlloop.participant.intermediary.api.ParticipantIntermediaryApi; -import org.onap.policy.clamp.controlloop.participant.policy.client.PolicyApiHttpClient; -import org.onap.policy.clamp.controlloop.participant.policy.client.PolicyPapHttpClient; -import org.onap.policy.models.base.PfModelException; -import org.onap.policy.models.tosca.authorative.concepts.ToscaConceptIdentifier; -import org.onap.policy.models.tosca.authorative.concepts.ToscaNodeTemplate; -import org.onap.policy.models.tosca.authorative.concepts.ToscaServiceTemplate; - -class ControlLoopElementHandlerTest { - - private static final String ID_NAME = "org.onap.PM_CDS_Blueprint"; - private static final String ID_VERSION = "1.0.1"; - private static final UUID controlLoopElementId = UUID.randomUUID(); - private static final ToscaConceptIdentifier controlLoopId = new ToscaConceptIdentifier(ID_NAME, ID_VERSION); - - @Test - void testHandlerExceptions() throws PfModelException { - ControlLoopElementHandler handler = getTestingHandler(); - - assertDoesNotThrow(() -> handler - .controlLoopElementStateChange(controlLoopId, - controlLoopElementId, - ControlLoopState.UNINITIALISED, - ControlLoopOrderedState.PASSIVE)); - - assertDoesNotThrow(() -> handler - .controlLoopElementStateChange(controlLoopId, - controlLoopElementId, - ControlLoopState.RUNNING, - ControlLoopOrderedState.UNINITIALISED)); - - assertDoesNotThrow(() -> handler - .controlLoopElementStateChange(controlLoopId, - controlLoopElementId, - ControlLoopState.PASSIVE, - ControlLoopOrderedState.RUNNING)); - var element = getTestingClElement(); - var clElementDefinition = Mockito.mock(ToscaNodeTemplate.class); - - assertDoesNotThrow(() -> handler - .controlLoopElementUpdate(controlLoopId, element, clElementDefinition)); - - assertDoesNotThrow(() -> handler - .handleStatistics(controlLoopElementId)); - } - - ControlLoopElementHandler getTestingHandler() { - var api = Mockito.mock(PolicyApiHttpClient.class); - var pap = Mockito.mock(PolicyPapHttpClient.class); - var handler = new ControlLoopElementHandler(api, pap); - var intermediaryApi = Mockito.mock(ParticipantIntermediaryApi.class); - var element = getTestingClElement(); - when(intermediaryApi.getControlLoopElement(controlLoopElementId)).thenReturn(element); - handler.setIntermediaryApi(intermediaryApi); - return handler; - } - - ControlLoopElement getTestingClElement() { - var element = new ControlLoopElement(); - element.setDefinition(controlLoopId); - element.setDescription("Description"); - element.setId(controlLoopElementId); - element.setOrderedState(ControlLoopOrderedState.UNINITIALISED); - element.setParticipantId(controlLoopId); - element.setState(ControlLoopState.UNINITIALISED); - var template = Mockito.mock(ToscaServiceTemplate.class); - element.setToscaServiceTemplateFragment(template); - return element; - } - -} diff --git a/participant/participant-impl/participant-impl-policy/src/test/java/org/onap/policy/clamp/controlloop/participant/policy/main/parameters/CommonTestData.java b/participant/participant-impl/participant-impl-policy/src/test/java/org/onap/policy/clamp/controlloop/participant/policy/main/parameters/CommonTestData.java deleted file mode 100644 index e965370cc..000000000 --- a/participant/participant-impl/participant-impl-policy/src/test/java/org/onap/policy/clamp/controlloop/participant/policy/main/parameters/CommonTestData.java +++ /dev/null @@ -1,180 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * Copyright (C) 2021 Nordix Foundation. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - * SPDX-License-Identifier: Apache-2.0 - * ============LICENSE_END========================================================= - */ - -package org.onap.policy.clamp.controlloop.participant.policy.main.parameters; - -import java.util.Arrays; -import java.util.List; -import java.util.Map; -import java.util.TreeMap; -import org.onap.policy.common.endpoints.parameters.TopicParameters; -import org.onap.policy.common.utils.coder.Coder; -import org.onap.policy.common.utils.coder.CoderException; -import org.onap.policy.common.utils.coder.StandardCoder; -import org.onap.policy.models.tosca.authorative.concepts.ToscaConceptIdentifier; - -/** - * Class to hold/create all parameters for test cases. - */ -public class CommonTestData { - public static final String PARTICIPANT_GROUP_NAME = "ControlLoopParticipantGroup"; - public static final String DESCRIPTION = "Participant description"; - public static final long TIME_INTERVAL = 2000; - public static final List TOPIC_PARAMS = Arrays.asList(getTopicParams()); - - public static final Coder CODER = new StandardCoder(); - - /** - * Get ParticipantPolicyParameters. - * - * @return ParticipantPolicyParameters - */ - public ParticipantPolicyParameters getParticipantPolicyParameters() { - try { - return CODER.convert(getParticipantPolicyParametersMap(PARTICIPANT_GROUP_NAME), - ParticipantPolicyParameters.class); - } catch (final CoderException e) { - throw new RuntimeException("cannot create ParticipantPolicyParameters from map", e); - } - } - - /** - * Returns a property map for a ParticipantPolicyParameters map for test cases. - * - * @param name name of the parameters - * - * @return a property map suitable for constructing an object - */ - public Map getParticipantPolicyParametersMap(final String name) { - final Map map = new TreeMap<>(); - - map.put("name", name); - map.put("intermediaryParameters", getIntermediaryParametersMap(false)); - map.put("policyApiParameters", getPolicyApiParametersMap()); - map.put("policyPapParameters", getPolicyPapParametersMap()); - map.put("pdpGroup", "defaultGroup"); - map.put("pdpType", "apex"); - return map; - } - - /** - * Returns a property map for a policyPapParameters map for test cases. - * - * @return a property map suitable for constructing an object - */ - public Map getPolicyPapParametersMap() { - final Map map = new TreeMap<>(); - map.put("clientName", "pap"); - map.put("hostname", "localhost"); - map.put("port", 6968); - map.put("userName", "policyadmin"); - map.put("password", "zb!XztG34"); - map.put("https", false); - map.put("allowSelfSignedCerts", true); - return map; - } - - /** - * Returns a property map for a policyApiParameters map for test cases. - * - * @return a property map suitable for constructing an object - */ - public Map getPolicyApiParametersMap() { - final Map map = new TreeMap<>(); - map.put("clientName", "api"); - map.put("hostname", "localhost"); - map.put("port", 6969); - map.put("userName", "policyadmin"); - map.put("password", "zb!XztG34"); - map.put("https", false); - map.put("allowSelfSignedCerts", true); - - return map; - } - - /** - * Returns a property map for a intermediaryParameters map for test cases. - * - * @param isEmpty boolean value to represent that object created should be empty or not - * @return a property map suitable for constructing an object - */ - public Map getIntermediaryParametersMap(final boolean isEmpty) { - final Map map = new TreeMap<>(); - if (!isEmpty) { - map.put("name", "Participant parameters"); - map.put("reportingTimeIntervalMs", TIME_INTERVAL); - map.put("description", DESCRIPTION); - map.put("participantId", getParticipantId()); - map.put("participantType", getParticipantId()); - map.put("clampControlLoopTopics", getTopicParametersMap(false)); - } - - return map; - } - - /** - * Returns a property map for a TopicParameters map for test cases. - * - * @param isEmpty boolean value to represent that object created should be empty or not - * @return a property map suitable for constructing an object - */ - public Map getTopicParametersMap(final boolean isEmpty) { - final Map map = new TreeMap<>(); - if (!isEmpty) { - map.put("topicSources", TOPIC_PARAMS); - map.put("topicSinks", TOPIC_PARAMS); - } - return map; - } - - /** - * Returns topic parameters for test cases. - * - * @return topic parameters - */ - public static TopicParameters getTopicParams() { - final TopicParameters topicParams = new TopicParameters(); - topicParams.setTopic("POLICY-CLRUNTIME-PARTICIPANT"); - topicParams.setTopicCommInfrastructure("dmaap"); - topicParams.setServers(Arrays.asList("localhost")); - return topicParams; - } - - /** - * Returns participantId for test cases. - * - * @return participant Id - */ - public static ToscaConceptIdentifier getParticipantId() { - final ToscaConceptIdentifier participantId = new ToscaConceptIdentifier("org.onap.PM_Policy", "0.0.0"); - return participantId; - } - - /** - * Nulls out a field within a JSON string. - * - * @param json JSON string - * @param field field to be nulled out - * @return a new JSON string with the field nulled out - */ - public String nullifyField(String json, String field) { - return json.replace(field + "\"", field + "\":null, \"" + field + "Xxx\""); - } -} diff --git a/participant/participant-impl/participant-impl-policy/src/test/java/org/onap/policy/clamp/controlloop/participant/policy/main/parameters/ParticipantPolicyParametersTest.java b/participant/participant-impl/participant-impl-policy/src/test/java/org/onap/policy/clamp/controlloop/participant/policy/main/parameters/ParticipantPolicyParametersTest.java deleted file mode 100644 index 74e7cb1bc..000000000 --- a/participant/participant-impl/participant-impl-policy/src/test/java/org/onap/policy/clamp/controlloop/participant/policy/main/parameters/ParticipantPolicyParametersTest.java +++ /dev/null @@ -1,66 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * Copyright (C) 2021 Nordix Foundation. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - * SPDX-License-Identifier: Apache-2.0 - * ============LICENSE_END========================================================= - */ - -package org.onap.policy.clamp.controlloop.participant.policy.main.parameters; - -import static org.assertj.core.api.Assertions.assertThat; - -import javax.validation.Validation; -import javax.validation.ValidatorFactory; -import org.junit.jupiter.api.Test; - -class ParticipantPolicyParametersTest { - private CommonTestData commonTestData = new CommonTestData(); - private ValidatorFactory validatorFactory = Validation.buildDefaultValidatorFactory(); - - @Test - void testParticipantPolicyParameters() { - final ParticipantPolicyParameters participantParameters = commonTestData.getParticipantPolicyParameters(); - assertThat(validatorFactory.getValidator().validate(participantParameters)).isEmpty(); - } - - @Test - void testParticipantPolicyParameters_NullTopicSinks() { - final ParticipantPolicyParameters participantParameters = commonTestData.getParticipantPolicyParameters(); - participantParameters.getIntermediaryParameters().getClampControlLoopTopics().setTopicSinks(null); - assertThat(validatorFactory.getValidator().validate(participantParameters)).isNotEmpty(); - } - - @Test - void testParticipantPolicyParameters_NullTopicSources() { - final ParticipantPolicyParameters participantParameters = commonTestData.getParticipantPolicyParameters(); - participantParameters.getIntermediaryParameters().getClampControlLoopTopics().setTopicSources(null); - assertThat(validatorFactory.getValidator().validate(participantParameters)).isNotEmpty(); - } - - @Test - void testParticipantPolicyParameters_NullPolicyApiParameters() { - final ParticipantPolicyParameters participantParameters = commonTestData.getParticipantPolicyParameters(); - participantParameters.setPolicyApiParameters(null); - assertThat(validatorFactory.getValidator().validate(participantParameters)).isNotEmpty(); - } - - @Test - void testParticipantPolicyParameters_NullHostname() { - final ParticipantPolicyParameters participantParameters = commonTestData.getParticipantPolicyParameters(); - participantParameters.getPolicyApiParameters().setHostname(null); - assertThat(validatorFactory.getValidator().validate(participantParameters)).isNotEmpty(); - } -} diff --git a/participant/participant-impl/participant-impl-policy/src/test/java/org/onap/policy/clamp/controlloop/participant/policy/main/rest/ActuatorControllerTest.java b/participant/participant-impl/participant-impl-policy/src/test/java/org/onap/policy/clamp/controlloop/participant/policy/main/rest/ActuatorControllerTest.java deleted file mode 100644 index 9cc16e287..000000000 --- a/participant/participant-impl/participant-impl-policy/src/test/java/org/onap/policy/clamp/controlloop/participant/policy/main/rest/ActuatorControllerTest.java +++ /dev/null @@ -1,92 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * Copyright (C) 2021 Nordix Foundation. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - * SPDX-License-Identifier: Apache-2.0 - * ============LICENSE_END========================================================= - */ - -package org.onap.policy.clamp.controlloop.participant.policy.main.rest; - -import static org.junit.jupiter.api.Assertions.assertEquals; - -import javax.ws.rs.client.Invocation; -import javax.ws.rs.core.Response; -import org.junit.jupiter.api.BeforeEach; -import org.junit.jupiter.api.Test; -import org.junit.jupiter.api.extension.ExtendWith; -import org.onap.policy.clamp.controlloop.participant.policy.main.utils.CommonActuatorController; -import org.springframework.boot.test.autoconfigure.actuate.metrics.AutoConfigureMetrics; -import org.springframework.boot.test.context.SpringBootTest; -import org.springframework.boot.test.context.SpringBootTest.WebEnvironment; -import org.springframework.boot.web.server.LocalServerPort; -import org.springframework.test.context.TestPropertySource; -import org.springframework.test.context.junit.jupiter.SpringExtension; - -@AutoConfigureMetrics -@ExtendWith(SpringExtension.class) -@SpringBootTest(webEnvironment = WebEnvironment.RANDOM_PORT) -@TestPropertySource(locations = {"classpath:application_test.properties"}) -class ActuatorControllerTest extends CommonActuatorController { - - private static final String HEALTH_ENDPOINT = "health"; - private static final String METRICS_ENDPOINT = "metrics"; - private static final String PROMETHEUS_ENDPOINT = "prometheus"; - - @LocalServerPort - private int randomServerPort; - - @BeforeEach - public void setUpPort() { - super.setHttpPrefix(randomServerPort); - } - - @Test - void testGetHealth_Unauthorized() throws Exception { - assertUnauthorizedActGet(HEALTH_ENDPOINT); - } - - @Test - void testGetMetrics_Unauthorized() throws Exception { - assertUnauthorizedActGet(METRICS_ENDPOINT); - } - - @Test - void testGetPrometheus_Unauthorized() throws Exception { - assertUnauthorizedActGet(PROMETHEUS_ENDPOINT); - } - - @Test - void testGetHealth() throws Exception { - Invocation.Builder invocationBuilder = super.sendActRequest(HEALTH_ENDPOINT); - Response rawresp = invocationBuilder.buildGet().invoke(); - assertEquals(Response.Status.OK.getStatusCode(), rawresp.getStatus()); - } - - @Test - void testGetMetrics() throws Exception { - Invocation.Builder invocationBuilder = super.sendActRequest(METRICS_ENDPOINT); - Response rawresp = invocationBuilder.buildGet().invoke(); - assertEquals(Response.Status.OK.getStatusCode(), rawresp.getStatus()); - } - - @Test - void testGePrometheus() throws Exception { - Invocation.Builder invocationBuilder = super.sendActRequest(PROMETHEUS_ENDPOINT); - Response rawresp = invocationBuilder.buildGet().invoke(); - assertEquals(Response.Status.OK.getStatusCode(), rawresp.getStatus()); - } - -} diff --git a/participant/participant-impl/participant-impl-policy/src/test/java/org/onap/policy/clamp/controlloop/participant/policy/main/utils/CommonActuatorController.java b/participant/participant-impl/participant-impl-policy/src/test/java/org/onap/policy/clamp/controlloop/participant/policy/main/utils/CommonActuatorController.java deleted file mode 100644 index ec6e30918..000000000 --- a/participant/participant-impl/participant-impl-policy/src/test/java/org/onap/policy/clamp/controlloop/participant/policy/main/utils/CommonActuatorController.java +++ /dev/null @@ -1,114 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * Copyright (C) 2021 Nordix Foundation. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - * SPDX-License-Identifier: Apache-2.0 - * ============LICENSE_END========================================================= - */ - -package org.onap.policy.clamp.controlloop.participant.policy.main.utils; - -import static org.junit.Assert.assertEquals; - -import javax.ws.rs.client.Client; -import javax.ws.rs.client.ClientBuilder; -import javax.ws.rs.client.Invocation; -import javax.ws.rs.client.WebTarget; -import javax.ws.rs.core.MediaType; -import javax.ws.rs.core.Response; -import org.glassfish.jersey.client.ClientProperties; -import org.glassfish.jersey.client.authentication.HttpAuthenticationFeature; -import org.onap.policy.common.gson.GsonMessageBodyHandler; -import org.onap.policy.common.utils.network.NetworkUtil; - -/** - * Class to perform Rest unit tests. - * - */ -public class CommonActuatorController { - - public static final String SELF = NetworkUtil.getHostname(); - public static final String CONTEXT_PATH = "onap/policyparticipant"; - public static final String ACTUATOR_ENDPOINT = CONTEXT_PATH + "/actuator/"; - - private static String httpPrefix; - - /** - * Sends a request to an actuator endpoint. - * - * @param endpoint the target endpoint - * @return a request builder - * @throws Exception if an error occurs - */ - protected Invocation.Builder sendActRequest(final String endpoint) throws Exception { - return sendFqeRequest(httpPrefix + ACTUATOR_ENDPOINT + endpoint, true); - } - - /** - * Sends a request to an actuator endpoint, without any authorization header. - * - * @param endpoint the target endpoint - * @return a request builder - * @throws Exception if an error occurs - */ - protected Invocation.Builder sendNoAuthActRequest(final String endpoint) throws Exception { - return sendFqeRequest(httpPrefix + ACTUATOR_ENDPOINT + endpoint, false); - } - - /** - * Sends a request to a fully qualified endpoint. - * - * @param fullyQualifiedEndpoint the fully qualified target endpoint - * @param includeAuth if authorization header should be included - * @return a request builder - * @throws Exception if an error occurs - */ - protected Invocation.Builder sendFqeRequest(final String fullyQualifiedEndpoint, boolean includeAuth) - throws Exception { - final Client client = ClientBuilder.newBuilder().build(); - - client.property(ClientProperties.METAINF_SERVICES_LOOKUP_DISABLE, "true"); - client.register(GsonMessageBodyHandler.class); - - if (includeAuth) { - client.register(HttpAuthenticationFeature.basic("participantUser", "zb!XztG34")); - } - - final WebTarget webTarget = client.target(fullyQualifiedEndpoint); - - return webTarget.request(MediaType.APPLICATION_JSON, MediaType.TEXT_PLAIN); - } - - /** - * Assert that GET call to actuator endpoint is Unauthorized. - * - * @param endPoint the endpoint - * @throws Exception if an error occurs - */ - protected void assertUnauthorizedActGet(final String endPoint) throws Exception { - Response rawresp = sendNoAuthActRequest(endPoint).buildGet().invoke(); - assertEquals(Response.Status.UNAUTHORIZED.getStatusCode(), rawresp.getStatus()); - } - - /** - * Set Up httpPrefix. - * - * @param port the port - */ - protected void setHttpPrefix(int port) { - httpPrefix = "http://" + SELF + ":" + port + "/"; - } - -} diff --git a/participant/participant-impl/participant-impl-policy/src/test/java/org/onap/policy/clamp/controlloop/participant/policy/main/utils/TestListenerUtils.java b/participant/participant-impl/participant-impl-policy/src/test/java/org/onap/policy/clamp/controlloop/participant/policy/main/utils/TestListenerUtils.java deleted file mode 100644 index d517ef61e..000000000 --- a/participant/participant-impl/participant-impl-policy/src/test/java/org/onap/policy/clamp/controlloop/participant/policy/main/utils/TestListenerUtils.java +++ /dev/null @@ -1,317 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * Copyright (C) 2021 Nordix Foundation. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - * SPDX-License-Identifier: Apache-2.0 - * ============LICENSE_END========================================================= - */ - -package org.onap.policy.clamp.controlloop.participant.policy.main.utils; - -import static org.junit.Assert.assertTrue; - -import java.io.File; -import java.io.FileNotFoundException; -import java.time.Instant; -import java.util.ArrayList; -import java.util.LinkedHashMap; -import java.util.List; -import java.util.Map; -import java.util.Set; -import java.util.UUID; -import lombok.AccessLevel; -import lombok.NoArgsConstructor; -import org.onap.policy.clamp.controlloop.common.utils.CommonUtils; -import org.onap.policy.clamp.controlloop.models.controlloop.concepts.ControlLoop; -import org.onap.policy.clamp.controlloop.models.controlloop.concepts.ControlLoopElement; -import org.onap.policy.clamp.controlloop.models.controlloop.concepts.ControlLoopOrderedState; -import org.onap.policy.clamp.controlloop.models.controlloop.concepts.ControlLoopState; -import org.onap.policy.clamp.controlloop.models.controlloop.concepts.ParticipantDefinition; -import org.onap.policy.clamp.controlloop.models.controlloop.concepts.ParticipantUpdates; -import org.onap.policy.clamp.controlloop.models.controlloop.concepts.ParticipantUtils; -import org.onap.policy.clamp.controlloop.models.messages.dmaap.participant.ControlLoopStateChange; -import org.onap.policy.clamp.controlloop.models.messages.dmaap.participant.ControlLoopUpdate; -import org.onap.policy.clamp.controlloop.models.messages.dmaap.participant.ParticipantUpdate; -import org.onap.policy.clamp.controlloop.participant.policy.main.parameters.CommonTestData; -import org.onap.policy.common.utils.coder.Coder; -import org.onap.policy.common.utils.coder.CoderException; -import org.onap.policy.common.utils.coder.StandardCoder; -import org.onap.policy.common.utils.coder.YamlJsonTranslator; -import org.onap.policy.common.utils.resources.ResourceUtils; -import org.onap.policy.models.tosca.authorative.concepts.ToscaConceptIdentifier; -import org.onap.policy.models.tosca.authorative.concepts.ToscaNodeTemplate; -import org.onap.policy.models.tosca.authorative.concepts.ToscaServiceTemplate; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -@NoArgsConstructor(access = AccessLevel.PRIVATE) -public final class TestListenerUtils { - - private static final YamlJsonTranslator yamlTranslator = new YamlJsonTranslator(); - private static final Coder CODER = new StandardCoder(); - static CommonTestData commonTestData = new CommonTestData(); - private static final Logger LOGGER = LoggerFactory.getLogger(TestListenerUtils.class); - - /** - * Method to create a controlLoop from a yaml file. - * - * @return ControlLoop controlloop - */ - public static ControlLoop createControlLoop() { - ControlLoop controlLoop = new ControlLoop(); - Map elements = new LinkedHashMap<>(); - ToscaServiceTemplate toscaServiceTemplate = testControlLoopRead(); - Map nodeTemplatesMap = - toscaServiceTemplate.getToscaTopologyTemplate().getNodeTemplates(); - for (Map.Entry toscaInputEntry : nodeTemplatesMap.entrySet()) { - ControlLoopElement clElement = new ControlLoopElement(); - clElement.setId(UUID.randomUUID()); - - ToscaConceptIdentifier clElementParticipantId = new ToscaConceptIdentifier(); - clElementParticipantId.setName(toscaInputEntry.getKey()); - clElementParticipantId.setVersion(toscaInputEntry.getValue().getVersion()); - clElement.setParticipantId(clElementParticipantId); - - clElement.setDefinition(clElementParticipantId); - clElement.setState(ControlLoopState.UNINITIALISED); - clElement.setDescription(toscaInputEntry.getValue().getDescription()); - clElement.setOrderedState(ControlLoopOrderedState.UNINITIALISED); - elements.put(clElement.getId(), clElement); - } - controlLoop.setElements(elements); - controlLoop.setName("PMSHInstance0"); - controlLoop.setVersion("1.0.0"); - - ToscaConceptIdentifier definition = new ToscaConceptIdentifier(); - definition.setName("PMSHInstance0"); - definition.setVersion("1.0.0"); - controlLoop.setDefinition(definition); - - return controlLoop; - } - - /** - * Method to create ControlLoopStateChange message from the arguments passed. - * - * @param controlLoopOrderedState controlLoopOrderedState - * - * @return ControlLoopStateChange message - */ - public static ControlLoopStateChange createControlLoopStateChangeMsg( - final ControlLoopOrderedState controlLoopOrderedState) { - final ControlLoopStateChange clStateChangeMsg = new ControlLoopStateChange(); - - ToscaConceptIdentifier controlLoopId = new ToscaConceptIdentifier(); - controlLoopId.setName("PMSHInstance0"); - controlLoopId.setVersion("1.0.0"); - - ToscaConceptIdentifier participantId = new ToscaConceptIdentifier(); - participantId.setName("org.onap.PM_Policy"); - participantId.setVersion("0.0.0"); - - clStateChangeMsg.setControlLoopId(controlLoopId); - clStateChangeMsg.setParticipantId(participantId); - clStateChangeMsg.setTimestamp(Instant.now()); - clStateChangeMsg.setOrderedState(controlLoopOrderedState); - - return clStateChangeMsg; - } - - /** - * Method to create ControlLoopUpdateMsg. - * - * @return ControlLoopUpdate message - */ - public static ControlLoopUpdate createControlLoopUpdateMsg() { - final ControlLoopUpdate clUpdateMsg = new ControlLoopUpdate(); - ToscaConceptIdentifier controlLoopId = new ToscaConceptIdentifier("PMSHInstance0", "1.0.0"); - ToscaConceptIdentifier participantId = new ToscaConceptIdentifier("org.onap.PM_Policy", "0.0.0"); - - clUpdateMsg.setControlLoopId(controlLoopId); - clUpdateMsg.setParticipantId(participantId); - clUpdateMsg.setMessageId(UUID.randomUUID()); - clUpdateMsg.setTimestamp(Instant.now()); - - Map elements = new LinkedHashMap<>(); - ToscaServiceTemplate toscaServiceTemplate = testControlLoopRead(); - TestListenerUtils.addPoliciesToToscaServiceTemplate(toscaServiceTemplate); - Map nodeTemplatesMap = - toscaServiceTemplate.getToscaTopologyTemplate().getNodeTemplates(); - for (Map.Entry toscaInputEntry : nodeTemplatesMap.entrySet()) { - if (ParticipantUtils.checkIfNodeTemplateIsControlLoopElement(toscaInputEntry.getValue(), - toscaServiceTemplate)) { - ControlLoopElement clElement = new ControlLoopElement(); - clElement.setId(UUID.randomUUID()); - var clParticipantType = - ParticipantUtils.findParticipantType(toscaInputEntry.getValue().getProperties()); - - clElement.setParticipantId(clParticipantType); - clElement.setParticipantType(clParticipantType); - - clElement.setDefinition( - new ToscaConceptIdentifier(toscaInputEntry.getKey(), toscaInputEntry.getValue().getVersion())); - clElement.setState(ControlLoopState.UNINITIALISED); - clElement.setDescription(toscaInputEntry.getValue().getDescription()); - clElement.setOrderedState(ControlLoopOrderedState.PASSIVE); - elements.put(clElement.getId(), clElement); - } - } - - List participantUpdates = new ArrayList<>(); - for (ControlLoopElement element : elements.values()) { - CommonUtils.setServiceTemplatePolicyInfo(element, toscaServiceTemplate); - CommonUtils.prepareParticipantUpdate(element, participantUpdates); - } - clUpdateMsg.setParticipantUpdatesList(participantUpdates); - return clUpdateMsg; - } - - /** - * Method to create participantUpdateMsg. - * - * @return ParticipantUpdate message - */ - public static ParticipantUpdate createParticipantUpdateMsg() { - final ParticipantUpdate participantUpdateMsg = new ParticipantUpdate(); - ToscaConceptIdentifier participantId = new ToscaConceptIdentifier("org.onap.PM_Policy", "1.0.0"); - ToscaConceptIdentifier participantType = - new ToscaConceptIdentifier("org.onap.policy.controlloop.PolicyControlLoopParticipant", "2.3.1"); - - participantUpdateMsg.setParticipantId(participantId); - participantUpdateMsg.setTimestamp(Instant.now()); - participantUpdateMsg.setParticipantType(participantType); - participantUpdateMsg.setTimestamp(Instant.ofEpochMilli(3000)); - participantUpdateMsg.setMessageId(UUID.randomUUID()); - - ToscaServiceTemplate toscaServiceTemplate = testControlLoopRead(); - // Add policies to the toscaServiceTemplate - TestListenerUtils.addPoliciesToToscaServiceTemplate(toscaServiceTemplate); - - List participantDefinitionUpdates = new ArrayList<>(); - for (Map.Entry toscaInputEntry : toscaServiceTemplate.getToscaTopologyTemplate() - .getNodeTemplates().entrySet()) { - if (ParticipantUtils.checkIfNodeTemplateIsControlLoopElement(toscaInputEntry.getValue(), - toscaServiceTemplate)) { - CommonUtils.prepareParticipantDefinitionUpdate( - ParticipantUtils.findParticipantType(toscaInputEntry.getValue().getProperties()), - toscaInputEntry.getKey(), toscaInputEntry.getValue(), - participantDefinitionUpdates, null); - } - } - - participantUpdateMsg.setParticipantDefinitionUpdates(participantDefinitionUpdates); - return participantUpdateMsg; - } - - /** - * Method to create ControlLoopUpdate using the arguments passed. - * - * @param jsonFilePath the path of the controlloop content - * - * @return ControlLoopUpdate message - * @throws CoderException exception while reading the file to object - */ - public static ControlLoopUpdate createParticipantClUpdateMsgFromJson(String jsonFilePath) throws CoderException { - ControlLoopUpdate controlLoopUpdateMsg = CODER.decode(new File(jsonFilePath), ControlLoopUpdate.class); - return controlLoopUpdateMsg; - } - - private static ToscaServiceTemplate testControlLoopRead() { - Set controlLoopDirectoryContents = - ResourceUtils.getDirectoryContents("src/test/resources/utils/servicetemplates"); - - boolean atLeastOneControlLoopTested = false; - ToscaServiceTemplate toscaServiceTemplate = null; - - for (String controlLoopFilePath : controlLoopDirectoryContents) { - if (!controlLoopFilePath.endsWith(".yaml")) { - continue; - } - atLeastOneControlLoopTested = true; - toscaServiceTemplate = testControlLoopYamlSerialization(controlLoopFilePath); - } - - // Add policy_types to the toscaServiceTemplate - addPolicyTypesToToscaServiceTemplate(toscaServiceTemplate); - - assertTrue(atLeastOneControlLoopTested); - return toscaServiceTemplate; - } - - private static void addPolicyTypesToToscaServiceTemplate(ToscaServiceTemplate toscaServiceTemplate) { - Set policyTypeDirectoryContents = ResourceUtils.getDirectoryContents("policytypes"); - - for (String policyTypeFilePath : policyTypeDirectoryContents) { - String policyTypeString = ResourceUtils.getResourceAsString(policyTypeFilePath); - - ToscaServiceTemplate foundPolicyTypeSt = - yamlTranslator.fromYaml(policyTypeString, ToscaServiceTemplate.class); - - toscaServiceTemplate.setDerivedFrom(foundPolicyTypeSt.getDerivedFrom()); - toscaServiceTemplate.setDescription(foundPolicyTypeSt.getDescription()); - toscaServiceTemplate.setMetadata(foundPolicyTypeSt.getMetadata()); - toscaServiceTemplate.setName(foundPolicyTypeSt.getName()); - toscaServiceTemplate.setToscaDefinitionsVersion(foundPolicyTypeSt.getToscaDefinitionsVersion()); - toscaServiceTemplate.setVersion(foundPolicyTypeSt.getVersion()); - - if (foundPolicyTypeSt.getDataTypes() != null) { - if (toscaServiceTemplate.getDataTypes() == null) { - toscaServiceTemplate.setDataTypes(foundPolicyTypeSt.getDataTypes()); - } else { - toscaServiceTemplate.getDataTypes().putAll(foundPolicyTypeSt.getDataTypes()); - } - } - - if (toscaServiceTemplate.getPolicyTypes() == null) { - toscaServiceTemplate.setPolicyTypes(foundPolicyTypeSt.getPolicyTypes()); - } else { - toscaServiceTemplate.getPolicyTypes().putAll(foundPolicyTypeSt.getPolicyTypes()); - } - } - } - - /** - * Method to add polcies to the toscaServiceTemplate. - * - * @param toscaServiceTemplate to add policies - */ - public static void addPoliciesToToscaServiceTemplate(ToscaServiceTemplate toscaServiceTemplate) { - Set policiesDirectoryContents = ResourceUtils.getDirectoryContents("policies"); - - for (String policiesFilePath : policiesDirectoryContents) { - String policiesString = ResourceUtils.getResourceAsString(policiesFilePath); - - ToscaServiceTemplate foundPoliciesSt = yamlTranslator.fromYaml(policiesString, ToscaServiceTemplate.class); - toscaServiceTemplate.getToscaTopologyTemplate() - .setPolicies(foundPoliciesSt.getToscaTopologyTemplate().getPolicies()); - } - } - - private static ToscaServiceTemplate testControlLoopYamlSerialization(String controlLoopFilePath) { - try { - String controlLoopString = ResourceUtils.getResourceAsString(controlLoopFilePath); - if (controlLoopString == null) { - throw new FileNotFoundException(controlLoopFilePath); - } - - ToscaServiceTemplate serviceTemplate = - yamlTranslator.fromYaml(controlLoopString, ToscaServiceTemplate.class); - return serviceTemplate; - } catch (FileNotFoundException e) { - LOGGER.error("cannot find YAML file", controlLoopFilePath); - throw new IllegalArgumentException(e); - } - } -} diff --git a/participant/participant-impl/participant-impl-policy/src/test/resources/application_test.properties b/participant/participant-impl/participant-impl-policy/src/test/resources/application_test.properties index 49781407d..932d9f2c3 100644 --- a/participant/participant-impl/participant-impl-policy/src/test/resources/application_test.properties +++ b/participant/participant-impl/participant-impl-policy/src/test/resources/application_test.properties @@ -1,6 +1,6 @@ spring.security.user.name=participantUser spring.security.user.password=zb!XztG34 -server.servlet.context-path=/onap/policyparticipant +server.servlet.context-path=/onap/policy/clamp/acm/policyparticipant server.error.path=/error server.http-port=8085 @@ -15,14 +15,14 @@ participant.intermediaryParameters.reportingTimeInterval: 120000 participant.intermediaryParameters.description: Participant Description participant.intermediaryParameters.participantId.name: org.onap.PM_Policy participant.intermediaryParameters.participantId.version: 1.0.0 -participant.intermediaryParameters.participantType.name: org.onap.policy.controlloop.PolicyControlLoopParticipant +participant.intermediaryParameters.participantType.name: org.onap.policy.acm.PolicyAutomationCompositionParticipant participant.intermediaryParameters.participantType.version: 2.3.1 -participant.intermediaryParameters.clampControlLoopTopics.name=ControlLoop Topics -participant.intermediaryParameters.clampControlLoopTopics.topicSources[0].topic=POLICY-CLRUNTIME-PARTICIPANT -participant.intermediaryParameters.clampControlLoopTopics.topicSources[0].servers[0]=localhost -participant.intermediaryParameters.clampControlLoopTopics.topicSources[0].topicCommInfrastructure=dmaap -participant.intermediaryParameters.clampControlLoopTopics.topicSources[0].fetchTimeout=15000 -participant.intermediaryParameters.clampControlLoopTopics.topicSinks[0].topic=POLICY-CLRUNTIME-PARTICIPANT -participant.intermediaryParameters.clampControlLoopTopics.topicSinks[0].servers[0]=localhost -participant.intermediaryParameters.clampControlLoopTopics.topicSinks[0].topicCommInfrastructure=dmaap +participant.intermediaryParameters.clampAutomationCompositionTopics.name=Automation Composition Topics +participant.intermediaryParameters.clampAutomationCompositionTopics.topicSources[0].topic=POLICY-ACRUNTIME-PARTICIPANT +participant.intermediaryParameters.clampAutomationCompositionTopics.topicSources[0].servers[0]=localhost +participant.intermediaryParameters.clampAutomationCompositionTopics.topicSources[0].topicCommInfrastructure=dmaap +participant.intermediaryParameters.clampAutomationCompositionTopics.topicSources[0].fetchTimeout=15000 +participant.intermediaryParameters.clampAutomationCompositionTopics.topicSinks[0].topic=POLICY-ACRUNTIME-PARTICIPANT +participant.intermediaryParameters.clampAutomationCompositionTopics.topicSinks[0].servers[0]=localhost +participant.intermediaryParameters.clampAutomationCompositionTopics.topicSinks[0].topicCommInfrastructure=dmaap management.endpoints.web.exposure.include=health,metrics,prometheus diff --git a/participant/participant-impl/participant-impl-policy/src/test/resources/parameters/TestACParams.yaml b/participant/participant-impl/participant-impl-policy/src/test/resources/parameters/TestACParams.yaml new file mode 100644 index 000000000..3e5782cdc --- /dev/null +++ b/participant/participant-impl/participant-impl-policy/src/test/resources/parameters/TestACParams.yaml @@ -0,0 +1,172 @@ +tosca_definitions_version: "tosca_simple_yaml_1_3" +data_types: + onap.datatypes.ToscaConceptIdentifier: + derived_from: tosca.datatypes.Root + properties: + name: + type: string + required: true + version: + type: string + required: true +node_types: + org.onap.policy.clamp.acm.Participant: + version: 1.0.1 + derived_from: tosca.nodetypes.Root + properties: + provider: + type: string + requred: false + org.onap.policy.clamp.acm.AutomationCompositionElement: + version: 1.0.1 + derived_from: tosca.nodetypes.Root + properties: + provider: + type: string + requred: false + participantType: + type: onap.datatypes.ToscaConceptIdentifier + requred: true + startPhase: + type: integer + required: false + constraints: + - greater-or-equal: 0 + metadata: + common: true + description: A value indicating the start phase in which this automation composition element will be started, + the first start phase is zero. Automation Composition Elements are started in their start_phase + order and stopped in reverse start phase order. Automation Composition Elements with the same start phase are + started and stopped simultaneously + org.onap.policy.clamp.acm.AutomationComposition: + version: 1.0.1 + derived_from: tosca.nodetypes.Root + properties: + provider: + type: string + requred: false + elements: + type: list + required: true + entry_schema: + type: onap.datatypes.ToscaConceptIdentifier + org.onap.policy.clamp.acm.DCAEMicroserviceAutomationCompositionElement: + version: 1.0.1 + derived_from: org.onap.policy.clamp.acm.AutomationCompositionElement + properties: + dcae_blueprint_id: + type: onap.datatypes.ToscaConceptIdentifier + requred: true + org.onap.policy.clamp.acm.PolicyTypeAutomationCompositionElement: + version: 1.0.1 + derived_from: org.onap.policy.clamp.acm.AutomationCompositionElement + properties: + policy_type_id: + type: onap.datatypes.ToscaConceptIdentifier + requred: true + org.onap.policy.clamp.acm.CDSAutomationCompositionElement: + version: 1.0.1 + derived_from: org.onap.policy.clamp.acm.AutomationCompositionElement + properties: + cds_blueprint_id: + type: onap.datatypes.ToscaConceptIdentifier + requred: true +topology_template: + node_templates: + org.onap.dcae.acm.DCAEMicroserviceAutomationCompositionParticipant: + version: 2.3.4 + type: org.onap.policy.clamp.acm.Participant + type_version: 1.0.1 + description: Participant for DCAE microservices + properties: + provider: ONAP + org.onap.policy.acm.MonitoringPolicyAutomationCompositionParticipant: + version: 2.3.1 + type: org.onap.policy.clamp.acm.Participant + type_version: 1.0.1 + description: Participant for DCAE microservices + properties: + provider: ONAP + org.onap.policy.acm.OperationalPolicyAutomationCompositionParticipant: + version: 3.2.1 + type: org.onap.policy.clamp.acm.Participant + type_version: 1.0.1 + description: Participant for DCAE microservices + properties: + provider: ONAP + org.onap.ccsdk.cds.acm.CdsAutomationCompositionParticipant: + version: 2.2.1 + type: org.onap.policy.clamp.acm.Participant + type_version: 1.0.1 + description: Participant for DCAE microservices + properties: + provider: ONAP + org.onap.domain.pmsh.PMSH_DCAEMicroservice: + version: 1.2.3 + type: org.onap.policy.clamp.acm.DCAEMicroserviceAutomationCompositionElement + type_version: 1.0.0 + description: Automation composition element, DCAE microservice for Performance Management Subscription Handling + properties: + provider: Ericsson + participantType: + name: org.onap.dcae.acm.DCAEMicroserviceAutomationCompositionParticipant + version: 2.3.4 + dcae_blueprint_id: + name: org.onap.dcae.blueprints.PMSHBlueprint + version: 1.0.0 + org.onap.domain.pmsh.PMSH_MonitoringPolicyAutomationCompositionElement: + version: 1.2.3 + type: org.onap.policy.clamp.acm.PolicyTypeAutomationCompositionElement + type_version: 1.0.0 + description: Automation composition element, monitoring policy for Performance Management Subscription Handling + properties: + provider: Ericsson + participantType: + name: org.onap.policy.acm.MonitoringPolicyAutomationCompositionParticipant + version: 2.3.1 + policy_type_id: + name: onap.policies.monitoring.pm-subscription-handler + version: 1.0.0 + org.onap.domain.pmsh.PMSH_OperationalPolicyAutomationCompositionElement: + version: 1.2.3 + type: org.onap.policy.clamp.acm.PolicyTypeAutomationCompositionElement + type_version: 1.0.0 + description: Automation composition element, operational policy for Performance Management Subscription Handling + properties: + provider: Ericsson + participantType: + name: org.onap.policy.acm.OperationalPolicyAutomationCompositionParticipant + version: 2.2.1 + policy_type_id: + name: onap.policies.operational.pm-subscription-handler + version: 1.0.0 + org.onap.domain.pmsh.PMSH_CDS_AutomationCompositionElement: + version: 1.2.3 + type: org.onap.policy.clamp.acm.AutomationCompositionElement + type_version: 1.0.0 + description: Automation composition element for CDS for Performance Management Subscription Handling + properties: + provider: Ericsson + participantType: + name: org.onap.ccsdk.cds.acm.CdsAutomationCompositionParticipant + version: 3.2.1 + cds_blueprint_id: + name: org.onap.ccsdk.cds.PMSHCdsBlueprint + version: 1.0.0 + org.onap.domain.pmsh.PMSHAutomationCompositionDefinition: + version: 1.2.3 + type: org.onap.policy.clamp.acm.AutomationComposition + type_version: 1.0.0 + description: Automation composition for Performance Management Subscription Handling + properties: + provider: Ericsson + elements: + - name: org.onap.domain.pmsh.PMSH_DCAEMicroservice + version: 1.2.3 + - name: org.onap.domain.pmsh.PMSH_MonitoringPolicyAutomationCompositionElement + version: 1.2.3 + - name: org.onap.domain.pmsh.PMSH_OperationalPolicyAutomationCompositionElement + version: 1.2.3 + - name: org.onap.domain.pmsh.PMSH_CDS_AutomationCompositionElement + version: 1.2.3 + diff --git a/participant/participant-impl/participant-impl-policy/src/test/resources/parameters/TestCLParams.yaml b/participant/participant-impl/participant-impl-policy/src/test/resources/parameters/TestCLParams.yaml deleted file mode 100644 index 2ef3c6da0..000000000 --- a/participant/participant-impl/participant-impl-policy/src/test/resources/parameters/TestCLParams.yaml +++ /dev/null @@ -1,172 +0,0 @@ -tosca_definitions_version: "tosca_simple_yaml_1_3" -data_types: - onap.datatypes.ToscaConceptIdentifier: - derived_from: tosca.datatypes.Root - properties: - name: - type: string - required: true - version: - type: string - required: true -node_types: - org.onap.policy.clamp.controlloop.Participant: - version: 1.0.1 - derived_from: tosca.nodetypes.Root - properties: - provider: - type: string - requred: false - org.onap.policy.clamp.controlloop.ControlLoopElement: - version: 1.0.1 - derived_from: tosca.nodetypes.Root - properties: - provider: - type: string - requred: false - participantType: - type: onap.datatypes.ToscaConceptIdentifier - requred: true - startPhase: - type: integer - required: false - constraints: - - greater-or-equal: 0 - metadata: - common: true - description: A value indicating the start phase in which this control loop element will be started, the - first start phase is zero. Control Loop Elements are started in their start_phase order and stopped - in reverse start phase order. Control Loop Elements with the same start phase are started and - stopped simultaneously - org.onap.policy.clamp.controlloop.ControlLoop: - version: 1.0.1 - derived_from: tosca.nodetypes.Root - properties: - provider: - type: string - requred: false - elements: - type: list - required: true - entry_schema: - type: onap.datatypes.ToscaConceptIdentifier - org.onap.policy.clamp.controlloop.DCAEMicroserviceControlLoopElement: - version: 1.0.1 - derived_from: org.onap.policy.clamp.controlloop.ControlLoopElement - properties: - dcae_blueprint_id: - type: onap.datatypes.ToscaConceptIdentifier - requred: true - org.onap.policy.clamp.controlloop.PolicyTypeControlLoopElement: - version: 1.0.1 - derived_from: org.onap.policy.clamp.controlloop.ControlLoopElement - properties: - policy_type_id: - type: onap.datatypes.ToscaConceptIdentifier - requred: true - org.onap.policy.clamp.controlloop.CDSControlLoopElement: - version: 1.0.1 - derived_from: org.onap.policy.clamp.controlloop.ControlLoopElement - properties: - cds_blueprint_id: - type: onap.datatypes.ToscaConceptIdentifier - requred: true -topology_template: - node_templates: - org.onap.dcae.controlloop.DCAEMicroserviceControlLoopParticipant: - version: 2.3.4 - type: org.onap.policy.clamp.controlloop.Participant - type_version: 1.0.1 - description: Participant for DCAE microservices - properties: - provider: ONAP - org.onap.policy.controlloop.MonitoringPolicyControlLoopParticipant: - version: 2.3.1 - type: org.onap.policy.clamp.controlloop.Participant - type_version: 1.0.1 - description: Participant for DCAE microservices - properties: - provider: ONAP - org.onap.policy.controlloop.OperationalPolicyControlLoopParticipant: - version: 3.2.1 - type: org.onap.policy.clamp.controlloop.Participant - type_version: 1.0.1 - description: Participant for DCAE microservices - properties: - provider: ONAP - org.onap.ccsdk.cds.controlloop.CdsControlLoopParticipant: - version: 2.2.1 - type: org.onap.policy.clamp.controlloop.Participant - type_version: 1.0.1 - description: Participant for DCAE microservices - properties: - provider: ONAP - org.onap.domain.pmsh.PMSH_DCAEMicroservice: - version: 1.2.3 - type: org.onap.policy.clamp.controlloop.DCAEMicroserviceControlLoopElement - type_version: 1.0.0 - description: Control loop element for the DCAE microservice for Performance Management Subscription Handling - properties: - provider: Ericsson - participantType: - name: org.onap.dcae.controlloop.DCAEMicroserviceControlLoopParticipant - version: 2.3.4 - dcae_blueprint_id: - name: org.onap.dcae.blueprints.PMSHBlueprint - version: 1.0.0 - org.onap.domain.pmsh.PMSH_MonitoringPolicyControlLoopElement: - version: 1.2.3 - type: org.onap.policy.clamp.controlloop.PolicyTypeControlLoopElement - type_version: 1.0.0 - description: Control loop element for the monitoring policy for Performance Management Subscription Handling - properties: - provider: Ericsson - participantType: - name: org.onap.policy.controlloop.MonitoringPolicyControlLoopParticipant - version: 2.3.1 - policy_type_id: - name: onap.policies.monitoring.pm-subscription-handler - version: 1.0.0 - org.onap.domain.pmsh.PMSH_OperationalPolicyControlLoopElement: - version: 1.2.3 - type: org.onap.policy.clamp.controlloop.PolicyTypeControlLoopElement - type_version: 1.0.0 - description: Control loop element for the operational policy for Performance Management Subscription Handling - properties: - provider: Ericsson - participantType: - name: org.onap.policy.controlloop.OperationalPolicyControlLoopParticipant - version: 2.2.1 - policy_type_id: - name: onap.policies.operational.pm-subscription-handler - version: 1.0.0 - org.onap.domain.pmsh.PMSH_CDS_ControlLoopElement: - version: 1.2.3 - type: org.onap.policy.clamp.controlloop.ControlLoopElement - type_version: 1.0.0 - description: Control loop element for CDS for Performance Management Subscription Handling - properties: - provider: Ericsson - participantType: - name: org.onap.ccsdk.cds.controlloop.CdsControlLoopParticipant - version: 3.2.1 - cds_blueprint_id: - name: org.onap.ccsdk.cds.PMSHCdsBlueprint - version: 1.0.0 - org.onap.domain.pmsh.PMSHControlLoopDefinition: - version: 1.2.3 - type: org.onap.policy.clamp.controlloop.ControlLoop - type_version: 1.0.0 - description: Control loop for Performance Management Subscription Handling - properties: - provider: Ericsson - elements: - - name: org.onap.domain.pmsh.PMSH_DCAEMicroservice - version: 1.2.3 - - name: org.onap.domain.pmsh.PMSH_MonitoringPolicyControlLoopElement - version: 1.2.3 - - name: org.onap.domain.pmsh.PMSH_OperationalPolicyControlLoopElement - version: 1.2.3 - - name: org.onap.domain.pmsh.PMSH_CDS_ControlLoopElement - version: 1.2.3 - diff --git a/participant/participant-impl/participant-impl-policy/src/test/resources/parameters/logback-test.xml b/participant/participant-impl/participant-impl-policy/src/test/resources/parameters/logback-test.xml index cf6b89eb9..0f1d28be7 100644 --- a/participant/participant-impl/participant-impl-policy/src/test/resources/parameters/logback-test.xml +++ b/participant/participant-impl/participant-impl-policy/src/test/resources/parameters/logback-test.xml @@ -36,7 +36,7 @@ - + diff --git a/participant/participant-impl/participant-impl-policy/src/test/resources/policies/vCPE.policies.optimization.input.tosca.yaml b/participant/participant-impl/participant-impl-policy/src/test/resources/policies/vCPE.policies.optimization.input.tosca.yaml deleted file mode 100644 index 126e8e6e2..000000000 --- a/participant/participant-impl/participant-impl-policy/src/test/resources/policies/vCPE.policies.optimization.input.tosca.yaml +++ /dev/null @@ -1,348 +0,0 @@ -tosca_definitions_version: tosca_simple_yaml_1_1_0 -topology_template: - policies: - - - OSDF_CASABLANCA.Affinity_Default: - type: onap.policies.optimization.resource.AffinityPolicy - version: 1.0.0 - type_version: 1.0.0 - name: OSDF_CASABLANCA.Affinity_Default - metadata: - policy-id: OSDF_CASABLANCA.Affinity_Default - policy-version: 1 - properties: - scope: [] - services: [] - resources: [] - geography: [] - identity: affinity_vCPE - applicableResources: any - affinityProperties: - qualifier: same - category: complex - - - OSDF_CASABLANCA.Affinity_Default_US: - type: onap.policies.optimization.resource.AffinityPolicy - version: 1.0.0 - type_version: 1.0.0 - name: OSDF_CASABLANCA.Affinity_Default_US - metadata: - policy-id: OSDF_CASABLANCA.Affinity_Default_US - policy-version: 1 - properties: - scope: [] - services: [] - resources: [] - geography: [US] - identity: affinity_vCPE - applicableResources: any - affinityProperties: - qualifier: same - category: complex - - - OSDF_CASABLANCA.Affinity_Default_vCPE_US_0: - type: onap.policies.optimization.resource.AffinityPolicy - version: 1.0.0 - type_version: 1.0.0 - name: OSDF_CASABLANCA.Affinity_Default_vCPE_US_0 - metadata: - policy-id: OSDF_CASABLANCA.Affinity_Default_vCPE_US_0 - policy-version: 1 - properties: - scope: [] - services: [vCPE] - resources: [] - geography: [US] - identity: affinity_vCPE - applicableResources: any - affinityProperties: - qualifier: different - category: complex - - - OSDF_CASABLANCA.Affinity_vCPE_US_Gold_1: - type: onap.policies.optimization.resource.AffinityPolicy - version: 1.0.0 - type_version: 1.0.0 - name: OSDF_CASABLANCA.Affinity_vCPE_US_Gold_1 - metadata: - policy-id: OSDF_CASABLANCA.Affinity_vCPE_1 - policy-version: 1 - properties: - scope: [gold] - services: [vCPE] - resources: [vGMuxInfra, vG] - geography: [US, INTERNATIONAL] - identity: affinity_vCPE - applicableResources: any - affinityProperties: - qualifier: same - category: availabilityZone - - - OSDF_CASABLANCA.Affinity_vCPE_US_Platinum_1: - type: onap.policies.optimization.resource.AffinityPolicy - version: 1.0.0 - type_version: 1.0.0 - name: OSDF_CASABLANCA.Affinity_vCPE_US_Platinum_1 - metadata: - policy-id: OSDF_CASABLANCA.Affinity_vCPE_1 - policy-version: 1 - properties: - scope: [platinum] - services: [vCPE] - resources: [vGMuxInfra, vG] - geography: [US, INTERNATIONAL] - identity: affinity_vCPE - applicableResources: any - affinityProperties: - qualifier: different - category: availabilityZone - - - OSDF_CASABLANCA.Capacity_vG_1: - type: onap.policies.optimization.resource.Vim_fit - version: 1.0.0 - type_version: 1.0.0 - name: OSDF_CASABLANCA.Capacity_vG_1 - metadata: - policy-id: OSDF_CASABLANCA.Capacity_vG_1 - policy-version: 1 - properties: - scope: [] - services: [vCPE] - resources: [vG] - geography: [US, INTERNATIONAL] - identity: capacity_vG - applicableResources: any - capacityProperty: - controller: multicloud - request: "{\"vCPU\": 10, \"Memory\": {\"quantity\": {\"get_param\": \"REQUIRED_MEM\"}, \"unit\": \"GB\"}, \"Storage\": {\"quantity\": {\"get_param\": \"REQUIRED_DISK\"}, \"unit\": \"GB\"}}" - - - OSDF_CASABLANCA.Capacity_vG_2: - type: onap.policies.optimization.resource.Vim_fit - version: 1.0.0 - type_version: 1.0.0 - name: OSDF_CASABLANCA.Capacity_vG_2 - metadata: - policy-id: OSDF_CASABLANCA.Capacity_vG_2 - policy-version: 1 - properties: - scope: [] - services: [vCPE] - resources: [vG] - geography: [US, INTERNATIONAL] - identity: capacity_vG - applicableResources: any - capacityProperty: - controller: multicloud - request: "{\"vCPU\": 15, \"Memory\": {\"quantity\": {\"get_param\": \"REQUIRED_MEM\"}, \"unit\": \"MB\"}, \"Storage\": {\"quantity\": {\"get_param\": \"REQUIRED_DISK\"}, \"unit\": \"GB\"}}" - - - OSDF_CASABLANCA.Distance_vG_1: - type: onap.policies.optimization.resource.DistancePolicy - version: 1.0.0 - type_version: 1.0.0 - name: OSDF_CASABLANCA.Distance_vG_1 - metadata: - policy-id: OSDF_CASABLANCA.Distance_vG_1 - policy-version: 1 - properties: - scope: [platinum] - services: [vCPE] - resources: [vG] - geography: [US, INTERNATIONAL] - identity: distance-vG - applicableResources: any - distanceProperties: - locationInfo: customer_loc - distance: - value: 1500 - operator: "<" - unit: km - - - OSDF_CASABLANCA.hpa_policy_Default: - type: onap.policies.optimization.resource.HpaPolicy - version: 1.0.0 - type_version: 1.0.0 - name: OSDF_CASABLANCA.hpa_policy_Default - metadata: - policy-id: OSDF_CASABLANCA.hpa_policy_Default - policy-version: 1 - properties: - scope: [] - services: [] - resources: [] - geography: [] - identity: hpa-vG - flavorFeatures: - - - id: vg_1 - type: vnfc - directives: - - type: flavor_directives - attributes: - - attribute_name: flavor_label_vm_01 - attribute_value: "" - flavorProperties: - - - hpa-feature: basicCapabilities - mandatory: True - architecture: generic - directives: [] - hpa-feature-attributes: - - hpa-attribute-key: numVirtualCpu - hpa-attribute-value: 8 - operator: ['>='] - unit: "" - - hpa-attribute-key: virtualMemSize - hpa-attribute-value: 6 - operator: ['<='] - unit: "" - - - hpa-feature: ovsDpdk - mandatory: False - architecture: generic - directives: [] - hpa-feature-attributes: - - hpa-attribute-key: dataProcessingAccelerationLibrary - hpa-attribute-value: ovsDpdk_version - operator: [=] - unit: "" - - - OSDF_CASABLANCA.hpa_policy_vG_1: - type: onap.policies.optimization.resource.HpaPolicy - version: 1.0.0 - type_version: 1.0.0 - name: OSDF_CASABLANCA.hpa_policy_vG_1 - metadata: - policy-id: OSDF_CASABLANCA.hpa_policy_vG_1 - policy-version: 1 - properties: - scope: [] - services: [vCPE, vOtherService] - resources: [vG] - geography: [] - identity: hpa-vG - flavorFeatures: - - - id: vg_1 - type: vnfc - directives: - - type: flavor_directives - attributes: - - attribute_name: flavor_label_vm_01 - attribute_value: "" - flavorProperties: - - - hpa-feature: basicCapabilities - mandatory: True - architecture: generic - directives: [] - hpa-feature-attributes: - - hpa-attribute-key: numVirtualCpu - hpa-attribute-value: 6 - operator: ['>='] - unit: "" - - hpa-attribute-key: virtualMemSize - hpa-attribute-value: 4 - operator: ['<='] - unit: "" - - - hpa-feature: ovsDpdk - mandatory: False - architecture: generic - directives: [] - hpa-feature-attributes: - - hpa-attribute-key: dataProcessingAccelerationLibrary - hpa-attribute-value: ovsDpdk_version - operator: [=] - unit: "" - - - OSDF_CASABLANCA.queryPolicy_vCPE: - type: onap.policies.optimization.service.QueryPolicy - version: 1.0.0 - type_version: 1.0.0 - name: OSDF_CASABLANCA.queryPolicy_vCPE - metadata: - policy-id: OSDF_CASABLANCA.queryPolicy_vCPE - policy-version: 1 - properties: - scope: [] - services: [vCPE] - geography: [US, INTERNATIONAL] - identity: vCPE_Query_Policy - queryProperties: - - - attribute: locationId - attribute_location: customerLocation - value: "" - - - attribute: id - attribute_location: "vpnInfo.vpnId" - value: "" - - - attribute: upstreamBW - attribute_location: "vpnInfo.upstreamBW" - value: "" - - - attribute: customerLatitude - attribute_location: customerLatitude - value: 1.1 - - - attribute: customerLongitude - attribute_location: customerLongitude - value: 2.2 - - - OSDF_CASABLANCA.SubscriberPolicy_v1: - type: onap.policies.optimization.service.SubscriberPolicy - version: 1.0.0 - type_version: 1.0.0 - name: OSDF_CASABLANCA.SubscriberPolicy_v1 - metadata: - policy-id: OSDF_CASABLANCA.SubscriberPolicy_v1 - policy-version: 1 - properties: - scope: [] - services: [vCPE] - identity: subscriber_vCPE - subscriberProperties: - subscriberName: [subscriber_x, subscriber_y] - subscriberRole: [platinum] - provStatus: [CAPPED] - - - OSDF_CASABLANCA.SubscriberPolicy_v2: - type: onap.policies.optimization.service.SubscriberPolicy - version: 1.0.0 - type_version: 1.0.0 - name: OSDF_CASABLANCA.SubscriberPolicy_v2 - metadata: - policy-id: OSDF_CASABLANCA.SubscriberPolicy_v2 - policy-version: 1 - properties: - scope: [] - services: [vCPE] - identity: subscriber_vCPE - subscriberProperties: - subscriberName: [subscriber_a, subscriber_b] - subscriberRole: [gold] - provStatus: [CAPPED] - - - OSDF_CASABLANCA.vnfPolicy_vG: - type: onap.policies.optimization.resource.VnfPolicy - version: 1.0.0 - type_version: 1.0.0 - name: OSDF_CASABLANCA.vnfPolicy_vG - metadata: - policy-id: OSDF_CASABLANCA.vnfPolicy_vG - policy-version: 1 - properties: - scope: [] - services: [vCPE] - resources: [vG] - geography: [US, INTERNATIONAL] - identity: vnf_vG - applicableResources: any - vnfProperties: - - - inventoryProvider: aai - serviceType: "" - inventoryType: cloudRegionId - customerId: "" - diff --git a/participant/participant-impl/participant-impl-policy/src/test/resources/policytypes/onap.policies.Match.yaml b/participant/participant-impl/participant-impl-policy/src/test/resources/policytypes/onap.policies.Match.yaml deleted file mode 100644 index 88b870580..000000000 --- a/participant/participant-impl/participant-impl-policy/src/test/resources/policytypes/onap.policies.Match.yaml +++ /dev/null @@ -1,8 +0,0 @@ -tosca_definitions_version: tosca_simple_yaml_1_1_0 -policy_types: - onap.policies.Match: - derived_from: tosca.policies.Root - version: 1.0.0 - name: onap.policies.Match - description: Base Policy Type for matchable Policies - diff --git a/participant/participant-impl/participant-impl-policy/src/test/resources/policytypes/onap.policies.Naming.yaml b/participant/participant-impl/participant-impl-policy/src/test/resources/policytypes/onap.policies.Naming.yaml deleted file mode 100644 index bde730cd7..000000000 --- a/participant/participant-impl/participant-impl-policy/src/test/resources/policytypes/onap.policies.Naming.yaml +++ /dev/null @@ -1,102 +0,0 @@ -tosca_definitions_version: tosca_simple_yaml_1_1_0 -policy_types: - onap.policies.Naming: - derived_from: tosca.policies.Root - version: 1.0.0 - name: onap.policies.Naming - description: Virtual policy node for naming - properties: - policy-instance-name: - type: string - naming-models: - type: list - entry_schema: - type: policy.data.naming-model-entity -data_types: - policy.data.naming-model-entity: - derived_from: tosca.datatypes.Root - properties: - nfRole: - type: string - required: false - metadata: - matchable: true - naming-type: - type: string - required: true - metadata: - matchable: true - naming-recipe: - type: string - required: true - name-operation: - type: string - required: false - naming-properties: - type: list - required: true - entry_schema: - type: policy.data.naming-property - policy.data.naming-property: - derived_from: tosca.datatypes.Root - properties: - property-name: - type: string - required: true - metadata: - matchable: true - property-value: - type: string - required: false - property-operation: - type: string - required: false - source-system: - type: string - required: false - source-endpoint: - type: string - required: false - increment-sequence: - type: policy.data.increment-sequence - required: false - policy.data.increment-sequence: - derived_from: tosca.datatypes.Root - properties: - scope: - type: list - required: true - entry_schema: - type: string - constraints: - - valid_values: - - CLOUD_REGION_ID - - LOCATION_CLLI - - VNF - - VM - - VFMODULE - - PRECEEDING - - TRAILING - - ENTIRETY - sequence-type: - type: string - require: true - entry_schema: - type: string - constraints: - - valid_values: - - numeric - - alpha-numeric - start-value: - type: string - required: true - max: - type: string - required: false - increment: - type: string - required: true - length: - type: string - required: true - diff --git a/participant/participant-impl/participant-impl-policy/src/test/resources/policytypes/onap.policies.Optimization.yaml b/participant/participant-impl/participant-impl-policy/src/test/resources/policytypes/onap.policies.Optimization.yaml deleted file mode 100644 index 7fe0e59de..000000000 --- a/participant/participant-impl/participant-impl-policy/src/test/resources/policytypes/onap.policies.Optimization.yaml +++ /dev/null @@ -1,33 +0,0 @@ -tosca_definitions_version: tosca_simple_yaml_1_1_0 -policy_types: - onap.policies.Optimization: - derived_from: tosca.policies.Root - version: 1.0.0 - name: onap.policies.Optimization - description: The base policy type for all policies that govern optimization - properties: - scope: - description: Scope for the policy - could be for a specific release. - type: list - metadata: - matchable: true - required: true - entry_schema: - type: string - geography: - description: One or more geographic regions - type: list - metadata: - matchable: true - required: true - entry_schema: - type: string - constraints: - - valid_values: - - US - - International - identity: - description: Used internally for identification - type: string - required: true - diff --git a/participant/participant-impl/participant-impl-policy/src/test/resources/policytypes/onap.policies.controlloop.guard.Common.yaml b/participant/participant-impl/participant-impl-policy/src/test/resources/policytypes/onap.policies.controlloop.guard.Common.yaml deleted file mode 100644 index 3dc979220..000000000 --- a/participant/participant-impl/participant-impl-policy/src/test/resources/policytypes/onap.policies.controlloop.guard.Common.yaml +++ /dev/null @@ -1,28 +0,0 @@ -tosca_definitions_version: tosca_simple_yaml_1_1_0 -policy_types: - onap.policies.controlloop.guard.Common: - derived_from: tosca.policies.Root - version: 1.0.0 - name: onap.policies.controlloop.guard.Common - description: | - This is the base Policy Type for Guard policies that guard the execution of Operational - Policies. - properties: - actor: - type: string - description: Specifies the Actor the guard applies to. - required: true - operation: - type: string - description: Specified the operation that the actor is performing the guard applies to. - required: true - timeRange: - type: tosca.datatypes.TimeInterval - description: | - An optional range of time during the day the guard policy is valid for. - required: false - id: - type: string - description: The Control Loop id this applies to. - required: false - diff --git a/participant/participant-impl/participant-impl-policy/src/test/resources/policytypes/onap.policies.controlloop.guard.common.Blacklist.yaml b/participant/participant-impl/participant-impl-policy/src/test/resources/policytypes/onap.policies.controlloop.guard.common.Blacklist.yaml deleted file mode 100644 index f2b67e18f..000000000 --- a/participant/participant-impl/participant-impl-policy/src/test/resources/policytypes/onap.policies.controlloop.guard.common.Blacklist.yaml +++ /dev/null @@ -1,16 +0,0 @@ -tosca_definitions_version: tosca_simple_yaml_1_1_0 -policy_types: - onap.policies.controlloop.guard.common.Blacklist: - derived_from: onap.policies.controlloop.guard.Common - type_version: 1.0.0 - version: 1.0.0 - name: onap.policies.controlloop.guard.common.Blacklist - description: Supports blacklist of entity id's from performing control loop actions on. - properties: - blacklist: - type: list - description: List of entity id's not allowed to have control loop operations on. - required: true - entry_schema: - type: string - diff --git a/participant/participant-impl/participant-impl-policy/src/test/resources/policytypes/onap.policies.controlloop.guard.common.Filter.yaml b/participant/participant-impl/participant-impl-policy/src/test/resources/policytypes/onap.policies.controlloop.guard.common.Filter.yaml deleted file mode 100644 index ea8e92aaf..000000000 --- a/participant/participant-impl/participant-impl-policy/src/test/resources/policytypes/onap.policies.controlloop.guard.common.Filter.yaml +++ /dev/null @@ -1,66 +0,0 @@ -tosca_definitions_version: tosca_simple_yaml_1_1_0 -policy_types: - onap.policies.controlloop.guard.common.Filter: - derived_from: onap.policies.controlloop.guard.Common - type_version: 1.0.0 - version: 1.0.0 - name: onap.policies.controlloop.guard.common.Filter - description: Supports filtering of A&AI entities such as vnf-id, type, service, geographic region, etc. - properties: - algorithm: - type: string - description: Designates the precendence of blacklist vs whitelist - required: true - default: blacklist-overrides - constraints: - - valid_values: ["blacklist-overrides", "whitelist-overrides"] - filters: - type: list - description: List of filters to be applied. - required: true - entry_schema: - type: onap.datatypes.guard.filter -data_types: - onap.datatypes.guard.filter: - derived_from: tosca.nodes.Root - properties: - field: - type: string - description: Name of the field to perform the filter on using the A&AI . syntax. - required: true - constraints: - - valid_values: - - generic-vnf.vnf-name - - generic-vnf.vnf-id - - generic-vnf.vnf-type - - generic-vnf.nf-naming-code - - vserver.vserver-id - - cloud-region.cloud-region-id - filter: - type: string - description: The filter value itself. For example, "RegionOne" "vFWCL*" - required: true - function: - type: string - description: The function applied to the filter. - required: true - constraints: - - valid_values: - - string-equal - - string-equal-ignore-case - - string-regexp-match - - string-contains - - string-greater-than - - string-greater-than-or-equal - - string-less-than - - string-less-than-or-equal - - string-starts-with - - string-ends-with - blacklist: - type: boolean - description: | - Indicates if the filter should be treated as a blacklist (true) - or whitelist (false). - required: true - default: true - diff --git a/participant/participant-impl/participant-impl-policy/src/test/resources/policytypes/onap.policies.controlloop.guard.common.FrequencyLimiter.yaml b/participant/participant-impl/participant-impl-policy/src/test/resources/policytypes/onap.policies.controlloop.guard.common.FrequencyLimiter.yaml deleted file mode 100644 index 3e31ec218..000000000 --- a/participant/participant-impl/participant-impl-policy/src/test/resources/policytypes/onap.policies.controlloop.guard.common.FrequencyLimiter.yaml +++ /dev/null @@ -1,26 +0,0 @@ -tosca_definitions_version: tosca_simple_yaml_1_1_0 -policy_types: - onap.policies.controlloop.guard.common.FrequencyLimiter: - derived_from: onap.policies.controlloop.guard.Common - type_version: 1.0.0 - version: 1.0.0 - name: onap.policies.controlloop.guard.common.FrequencyLimiter - description: Supports limiting the frequency of actions being taken by a Actor. - properties: - timeWindow: - type: integer - description: The time window to count the actions against. - required: true - timeUnits: - type: string - description: The units of time the window is counting. - required: true - constraints: - - valid_values: ["second", "minute", "hour", "day", "week", "month", "year"] - limit: - type: integer - description: The limit - required: true - constraints: - - greater_than: 0 - diff --git a/participant/participant-impl/participant-impl-policy/src/test/resources/policytypes/onap.policies.controlloop.guard.common.MinMax.yaml b/participant/participant-impl/participant-impl-policy/src/test/resources/policytypes/onap.policies.controlloop.guard.common.MinMax.yaml deleted file mode 100644 index 8f93572bf..000000000 --- a/participant/participant-impl/participant-impl-policy/src/test/resources/policytypes/onap.policies.controlloop.guard.common.MinMax.yaml +++ /dev/null @@ -1,24 +0,0 @@ -tosca_definitions_version: tosca_simple_yaml_1_1_0 -policy_types: - onap.policies.controlloop.guard.common.MinMax: - derived_from: onap.policies.controlloop.guard.Common - type_version: 1.0.0 - version: 1.0.0 - name: onap.policies.controlloop.guard.common.MinMax - description: | - Supports Min/Max number of entity for scaling operations. Although min and max fields are marked as not - required, you need to have at least one or the other. - properties: - target: - type: string - required: true - description: The target entity that has scaling restricted - min: - type: integer - required: false - description: The minimum instances of this entity - max: - type: integer - required: false - description: The maximum instances of this entity - diff --git a/participant/participant-impl/participant-impl-policy/src/test/resources/policytypes/onap.policies.controlloop.guard.coordination.FirstBlocksSecond.yaml b/participant/participant-impl/participant-impl-policy/src/test/resources/policytypes/onap.policies.controlloop.guard.coordination.FirstBlocksSecond.yaml deleted file mode 100644 index eaeee605d..000000000 --- a/participant/participant-impl/participant-impl-policy/src/test/resources/policytypes/onap.policies.controlloop.guard.coordination.FirstBlocksSecond.yaml +++ /dev/null @@ -1,27 +0,0 @@ -tosca_definitions_version: tosca_simple_yaml_1_1_0 -policy_types: - onap.policies.controlloop.Guard: - derived_from: tosca.policies.Root - version: 1.0.0 - name: onap.policies.controlloop.Guard - description: Guard Policies for Control Loop Operational Policies - onap.policies.controlloop.guard.Coordination: - derived_from: onap.policies.controlloop.Guard - version: 1.0.0 - name: onap.policies.controlloop.guard.Coordination - description: Guard Policies for Control Loop Coordination - onap.policies.controlloop.guard.coordination.FirstBlocksSecond: - derived_from: onap.policies.controlloop.guard.Coordination - version: 1.0.0 - name: onap.policies.controlloop.guard.coordination.FirstBlocksSecond - description: Supports one Control Loop blocking another - properties: - controlLoop: - type: list - description: Specific Control Loops to which to apply this guard - required: true - constraint: - length: 2 - entry_schema: - type: string - diff --git a/participant/participant-impl/participant-impl-policy/src/test/resources/policytypes/onap.policies.controlloop.operational.Common.yaml b/participant/participant-impl/participant-impl-policy/src/test/resources/policytypes/onap.policies.controlloop.operational.Common.yaml deleted file mode 100644 index 9b3b057b8..000000000 --- a/participant/participant-impl/participant-impl-policy/src/test/resources/policytypes/onap.policies.controlloop.operational.Common.yaml +++ /dev/null @@ -1,143 +0,0 @@ -tosca_definitions_version: tosca_simple_yaml_1_1_0 -policy_types: - onap.policies.controlloop.operational.Common: - derived_from: tosca.policies.Root - version: 1.0.0 - name: onap.policies.controlloop.operational.Common - description: | - Operational Policy for Control Loop execution. Originated in Frankfurt to support TOSCA Compliant - Policy Types. This does NOT support the legacy Policy YAML policy type. - properties: - id: - type: string - description: The unique control loop id. - required: true - timeout: - type: integer - description: | - Overall timeout for executing all the operations. This timeout should equal or exceed the total - timeout for each operation listed. - required: true - abatement: - type: boolean - description: Whether an abatement event message will be expected for the control loop from DCAE. - required: true - default: false - trigger: - type: string - description: Initial operation to execute upon receiving an Onset event message for the Control Loop. - required: true - operations: - type: list - description: List of operations to be performed when Control Loop is triggered. - required: true - entry_schema: - type: onap.datatype.controlloop.Operation - -data_types: - onap.datatype.controlloop.Target: - derived_from: tosca.datatypes.Root - description: Definition for a entity in A&AI to perform a control loop operation on - properties: - targetType: - type: string - description: Category for the target type - required: true - constraints: - - valid_values: [VNF, VM, VFMODULE, PNF] - entityIds: - type: map - description: | - Map of values that identify the resource. If none are provided, it is assumed that the - entity that generated the ONSET event will be the target. - required: false - metadata: - clamp_possible_values: ClampExecution:CSAR_RESOURCES - entry_schema: - type: string - - onap.datatype.controlloop.Actor: - derived_from: tosca.datatypes.Root - description: An actor/operation/target definition - properties: - actor: - type: string - description: The actor performing the operation. - required: true - metadata: - clamp_possible_values: Dictionary:DefaultActors,ClampExecution:CDS/actor - operation: - type: string - description: The operation the actor is performing. - metadata: - clamp_possible_values: Dictionary:DefaultOperations,ClampExecution:CDS/operation - required: true - target: - type: onap.datatype.controlloop.Target - description: The resource the operation should be performed on. - required: true - payload: - type: map - description: Name/value pairs of payload information passed by Policy to the actor - required: false - metadata: - clamp_possible_values: ClampExecution:CDS/payload - entry_schema: - type: string - - onap.datatype.controlloop.Operation: - derived_from: tosca.datatypes.Root - description: An operation supported by an actor - properties: - id: - type: string - description: Unique identifier for the operation - required: true - description: - type: string - description: A user-friendly description of the intent for the operation - required: false - operation: - type: onap.datatype.controlloop.Actor - description: The definition of the operation to be performed. - required: true - timeout: - type: integer - description: The amount of time for the actor to perform the operation. - required: true - retries: - type: integer - description: The number of retries the actor should attempt to perform the operation. - required: true - default: 0 - success: - type: string - description: Points to the operation to invoke on success. A value of "final_success" indicates and end to the operation. - required: false - default: final_success - failure: - type: string - description: Points to the operation to invoke on Actor operation failure. - required: false - default: final_failure - failure_timeout: - type: string - description: Points to the operation to invoke when the time out for the operation occurs. - required: false - default: final_failure_timeout - failure_retries: - type: string - description: Points to the operation to invoke when the current operation has exceeded its max retries. - required: false - default: final_failure_retries - failure_exception: - type: string - description: Points to the operation to invoke when the current operation causes an exception. - required: false - default: final_failure_exception - failure_guard: - type: string - description: Points to the operation to invoke when the current operation is blocked due to guard policy enforcement. - required: false - default: final_failure_guard - diff --git a/participant/participant-impl/participant-impl-policy/src/test/resources/policytypes/onap.policies.controlloop.operational.common.Apex.yaml b/participant/participant-impl/participant-impl-policy/src/test/resources/policytypes/onap.policies.controlloop.operational.common.Apex.yaml deleted file mode 100644 index a0c5b2456..000000000 --- a/participant/participant-impl/participant-impl-policy/src/test/resources/policytypes/onap.policies.controlloop.operational.common.Apex.yaml +++ /dev/null @@ -1,26 +0,0 @@ -tosca_definitions_version: tosca_simple_yaml_1_1_0 -policy_types: - onap.policies.controlloop.operational.common.Apex: - derived_from: onap.policies.controlloop.operational.Common - type_version: 1.0.0 - version: 1.0.0 - name: onap.policies.controlloop.operational.common.Apex - description: Operational policies for Apex PDP - properties: - engineServiceParameters: - type: string - description: The engine parameters like name, instanceCount, policy implementation, parameters etc. - required: true - eventInputParameters: - type: string - description: The event input parameters. - required: true - eventOutputParameters: - type: string - description: The event output parameters. - required: true - javaProperties: - type: string - description: Name/value pairs of properties to be set for APEX if needed. - required: false - diff --git a/participant/participant-impl/participant-impl-policy/src/test/resources/policytypes/onap.policies.controlloop.operational.common.Drools.yaml b/participant/participant-impl/participant-impl-policy/src/test/resources/policytypes/onap.policies.controlloop.operational.common.Drools.yaml deleted file mode 100644 index 69d73db58..000000000 --- a/participant/participant-impl/participant-impl-policy/src/test/resources/policytypes/onap.policies.controlloop.operational.common.Drools.yaml +++ /dev/null @@ -1,14 +0,0 @@ -tosca_definitions_version: tosca_simple_yaml_1_1_0 -policy_types: - onap.policies.controlloop.operational.common.Drools: - derived_from: onap.policies.controlloop.operational.Common - type_version: 1.0.0 - version: 1.0.0 - name: onap.policies.controlloop.operational.common.Drools - description: Operational policies for Drools PDP - properties: - controllerName: - type: string - description: Drools controller properties - required: false - diff --git a/participant/participant-impl/participant-impl-policy/src/test/resources/policytypes/onap.policies.monitoring.dcae-pm-mapper.yaml b/participant/participant-impl/participant-impl-policy/src/test/resources/policytypes/onap.policies.monitoring.dcae-pm-mapper.yaml deleted file mode 100644 index c50392eca..000000000 --- a/participant/participant-impl/participant-impl-policy/src/test/resources/policytypes/onap.policies.monitoring.dcae-pm-mapper.yaml +++ /dev/null @@ -1,50 +0,0 @@ -tosca_definitions_version: tosca_simple_yaml_1_1_0 -policy_types: - onap.policies.Monitoring: - derived_from: tosca.policies.Root - version: 1.0.0 - name: onap.policies.Monitoring - description: a base policy type for all policies that govern monitoring provisioning - onap.policies.monitoring.dcae-pm-mapper: - derived_from: onap.policies.Monitoring - version: 1.0.0 - properties: - pm-mapper-filter: - type: map - description: PM mapper filter on measInfo, measInfoId, measType, instanceId - entry_schema: - type: onap.datatypes.monitoring.pm-mapper-filter -data_types: - onap.datatypes.monitoring.pm-mapper-filter: - derived_from: tosca.datatypes.Root - properties: - filters: - type: list - description: Filter configuration - #default: [] - required: true - entry_schema: - type: onap.datatypes.monitoring.filters - onap.datatypes.monitoring.filters: - derived_from: tosca.datatypes.Root - properties: - pmDefVsn: - type: string - description: PM Dictionary version - required: true - nfType: - type: string - description: NF type - required: true - vendor: - type: string - description: Vendor name - required: true - measTypes: - type: list - description: Measurement types to collect - #default: [] - required: true - entry_schema: - type: string - diff --git a/participant/participant-impl/participant-impl-policy/src/test/resources/policytypes/onap.policies.monitoring.dcae-pm-subscription-handler.yaml b/participant/participant-impl/participant-impl-policy/src/test/resources/policytypes/onap.policies.monitoring.dcae-pm-subscription-handler.yaml deleted file mode 100644 index 8ac9b7484..000000000 --- a/participant/participant-impl/participant-impl-policy/src/test/resources/policytypes/onap.policies.monitoring.dcae-pm-subscription-handler.yaml +++ /dev/null @@ -1,132 +0,0 @@ -tosca_definitions_version: tosca_simple_yaml_1_1_0 -policy_types: - onap.policies.Monitoring: - derived_from: tosca.policies.Root - version: 1.0.0 - name: onap.policies.Monitoring - description: a base policy type for all policies that govern monitoring provisioning - onap.policies.monitoring.dcae-pm-subscription-handler: - derived_from: onap.policies.Monitoring - version: 1.0.0 - properties: - subscription: - type: map - description: PM Subscription Handler Subscription - entry_schema: - type: onap.datatypes.monitoring.subscription -data_types: - onap.datatypes.monitoring.subscription: - derived_from: tosca.datatypes.Root - properties: - subscriptionName: - type: string - description: Name of the subscription - required: true - administrativeState: - type: string - description: State of the subscription - required: true - constraints: - - valid_values: - - LOCKED - - UNLOCKED - fileBasedGP: - type: integer - description: File based granularity period - required: true - fileLocation: - type: string - description: ROP file location - required: true - nfTypeModelInvariantId: - type: string - description: Network function invariant ID - required: true - nfFilter: - type: map - description: Network function filter - required: true - entry_schema: - type: onap.datatypes.monitoring.nfFilter - measurementGroups: - type: list - description: Measurement Groups - required: true - entry_schema: - type: onap.datatypes.monitoring.measurementGroups - onap.datatypes.monitoring.nfFilter: - derived_from: tosca.datatypes.Root - properties: - nfNames: - type: list - description: List of network functions - required: true - #default: [] - entry_schema: - type: string - swVersions: - type: list - description: List of software versions - required: true - #default: [] - entry_schema: - type: string - onap.datatypes.monitoring.measurementGroups: - derived_from: tosca.datatypes.Root - properties: - measurementGroup: - type: map - description: Measurement Group - required: true - entry_schema: - type: onap.datatypes.monitoring.measurementGroup - onap.datatypes.monitoring.measurementGroup: - derived_from: tosca.datatypes.Root - properties: - measurementTypes: - type: list - description: List of measurement types - required: true - #default: [] - entry_schema: - type: onap.datatypes.monitoring.measurementTypes - managedObjectDNsBasic: - type: list - description: List of managed object distinguished names - required: true - #default: [] - entry_schema: - type: onap.datatypes.monitoring.managedObjectDNsBasics - onap.datatypes.monitoring.measurementTypes: - derived_from: tosca.datatypes.Root - properties: - measurementType: - type: map - description: Measurement type object - required: true - entry_schema: - type: onap.datatypes.monitoring.measurementType - onap.datatypes.monitoring.measurementType: - derived_from: tosca.datatypes.Root - properties: - measurementType: - type: string - description: Measurement type - required: true - onap.datatypes.monitoring.managedObjectDNsBasics: - derived_from: tosca.datatypes.Root - properties: - managedObjectDNsBasic: - type: map - description: Managed object distinguished name object - required: true - entry_schema: - type: onap.datatypes.monitoring.managedObjectDNsBasic - onap.datatypes.monitoring.managedObjectDNsBasic: - derived_from: tosca.datatypes.Root - properties: - DN: - type: string - description: Managed object distinguished name - required: true - diff --git a/participant/participant-impl/participant-impl-policy/src/test/resources/policytypes/onap.policies.monitoring.dcae-restconfcollector.yaml b/participant/participant-impl/participant-impl-policy/src/test/resources/policytypes/onap.policies.monitoring.dcae-restconfcollector.yaml deleted file mode 100644 index 58e60e98d..000000000 --- a/participant/participant-impl/participant-impl-policy/src/test/resources/policytypes/onap.policies.monitoring.dcae-restconfcollector.yaml +++ /dev/null @@ -1,128 +0,0 @@ -tosca_definitions_version: tosca_simple_yaml_1_1_0 -policy_types: - onap.policies.Monitoring: - derived_from: tosca.policies.Root - version: 1.0.0 - name: onap.policies.Monitoring - description: a base policy type for all policies that govern monitoring provisioning - onap.policies.monitoring.dcae-restconfcollector: - derived_from: onap.policies.Monitoring - version: 1.0.0 - properties: - rcc_policy: - type: list - description: RCC Policy JSON - entry_schema: - type: onap.datatypes.monitoring.rcc_policy -data_types: - onap.datatypes.monitoring.rcc_policy: - derived_from: tosca.datatypes.Root - properties: - controller_name: - type: string - description: Name of controller - required: true - controller_restapiUrl: - type: string - description: Controller's ip and port - required: true - controller_restapiUser: - type: string - description: Controller's username - required: true - controller_restapiPassword: - type: string - description: Controller's password - required: true - controller_accessTokenUrl: - type: string - description: URL to get access token - required: true - controller_accessTokenFile: - type: string - description: Access token file path - required: true - controller_accessTokenMethod: - type: string - description: Access token method POST/GET/PUT etc - required: true - constraints: - - valid_values: - - post - - get - - put - controller_subsMethod: - type: string - description: Subscription method POST/GET/PUT etc - required: true - default: post - constraints: - - valid_values: - - post - - get - - put - controller_subscriptionUrl: - type: string - description: URL to establish subscription - required: true - controller_disableSsl: - type: boolean - description: Option to disable ssl - required: true - default: true - event_details: - type: list - description: event details - required: true - entry_schema: - type: onap.datatypes.monitoring.rcc_event_details - onap.datatypes.monitoring.rcc_event_details: - derived_from: tosca.datatypes.Root - properties: - event_name: - type: string - description: event name - required: true - event_description: - type: string - description: description of event - required: false - event_sseventUrlEmbed: - type: boolean - description: Whether SSE url is embedded in subscription response - required: true - default: true - event_sseventsField: - type: string - description: Field name to access SSE url in subscription response - required: true - event_sseventsUrl: - type: string - description: Explicit SSE url - required: true - event_subscriptionTemplate: - type: string - description: Subscription template file path - required: true - event_unSubscriptionTemplate: - type: string - description: Unsubscription template file path - required: false - event_ruleId: - type: integer - description: Rule Id - required: false - modifyData: - type: boolean - description: Whether to modify the received SSE event - required: true - default: false - modifyMethod: - type: string - description: The java method name to modify data - required: false - userData: - type: string - description: The user specific data - required: false - diff --git a/participant/participant-impl/participant-impl-policy/src/test/resources/policytypes/onap.policies.monitoring.dcaegen2.collectors.datafile.datafile-app-server.yaml b/participant/participant-impl/participant-impl-policy/src/test/resources/policytypes/onap.policies.monitoring.dcaegen2.collectors.datafile.datafile-app-server.yaml deleted file mode 100644 index 408e8cd00..000000000 --- a/participant/participant-impl/participant-impl-policy/src/test/resources/policytypes/onap.policies.monitoring.dcaegen2.collectors.datafile.datafile-app-server.yaml +++ /dev/null @@ -1,19 +0,0 @@ -tosca_definitions_version: tosca_simple_yaml_1_1_0 -policy_types: - onap.policies.Monitoring: - derived_from: tosca.policies.Root - description: a base policy type for all policies that govern monitoring provisioning - version: 1.0.0 - name: onap.policies.Monitoring - onap.policies.monitoring.dcaegen2.collectors.datafile.datafile-app-server: - derived_from: onap.policies.Monitoring - version: 1.0.0 - name: onap.policies.monitoring.dcaegen2.collectors.datafile.datafile-app-server - properties: - buscontroller_feed_publishing_endpoint: - type: string - description: DMAAP Bus Controller feed endpoint - datafile.policy: - type: string - description: datafile Policy JSON as string - diff --git a/participant/participant-impl/participant-impl-policy/src/test/resources/policytypes/onap.policies.monitoring.tcagen2.yaml b/participant/participant-impl/participant-impl-policy/src/test/resources/policytypes/onap.policies.monitoring.tcagen2.yaml deleted file mode 100644 index 04026b323..000000000 --- a/participant/participant-impl/participant-impl-policy/src/test/resources/policytypes/onap.policies.monitoring.tcagen2.yaml +++ /dev/null @@ -1,161 +0,0 @@ -tosca_definitions_version: tosca_simple_yaml_1_1_0 -policy_types: - onap.policies.Monitoring: - derived_from: tosca.policies.Root - version: 1.0.0 - name: onap.policies.Monitoring - description: a base policy type for all policies that govern monitoring provisioning - onap.policies.monitoring.tcagen2: - derived_from: onap.policies.Monitoring - version: 1.0.0 - name: onap.policies.monitoring.tcagen2 - properties: - tca.policy: - type: onap.datatypes.monitoring.tca_policy - description: TCA Policy JSON - required: true -data_types: - onap.datatypes.monitoring.metricsPerEventName: - derived_from: tosca.datatypes.Root - properties: - controlLoopSchemaType: - type: string - required: true - description: Specifies Control Loop Schema Type for the event Name e.g. VNF, VM - constraints: - - valid_values: - - VM - - VNF - eventName: - type: string - required: true - description: Event name to which thresholds need to be applied - policyName: - type: string - required: true - description: TCA Policy Scope Name - policyScope: - type: string - required: true - description: TCA Policy Scope - policyVersion: - type: string - required: true - description: TCA Policy Scope Version - thresholds: - type: list - required: true - description: Thresholds associated with eventName - entry_schema: - type: onap.datatypes.monitoring.thresholds - onap.datatypes.monitoring.tca_policy: - derived_from: tosca.datatypes.Root - properties: - domain: - type: string - required: true - description: Domain name to which TCA needs to be applied - default: measurementsForVfScaling - constraints: - - equal: measurementsForVfScaling - metricsPerEventName: - type: list - required: true - description: Contains eventName and threshold details that need to be applied to given eventName - entry_schema: - type: onap.datatypes.monitoring.metricsPerEventName - onap.datatypes.monitoring.thresholds: - derived_from: tosca.datatypes.Root - properties: - closedLoopControlName: - type: string - required: true - description: Closed Loop Control Name associated with the threshold - closedLoopEventStatus: - type: string - required: true - description: Closed Loop Event Status of the threshold - constraints: - - valid_values: - - ONSET - - ABATED - direction: - type: string - required: true - description: Direction of the threshold - constraints: - - valid_values: - - LESS - - LESS_OR_EQUAL - - GREATER - - GREATER_OR_EQUAL - - EQUAL - fieldPath: - type: string - required: true - description: Json field Path as per CEF message which needs to be analyzed for TCA - constraints: - - valid_values: - - $.event.measurementsForVfScalingFields.vNicPerformanceArray[*].receivedTotalPacketsDelta - - $.event.measurementsForVfScalingFields.vNicPerformanceArray[*].receivedOctetsDelta - - $.event.measurementsForVfScalingFields.vNicPerformanceArray[*].receivedUnicastPacketsDelta - - $.event.measurementsForVfScalingFields.vNicPerformanceArray[*].receivedMulticastPacketsDelta - - $.event.measurementsForVfScalingFields.vNicPerformanceArray[*].receivedBroadcastPacketsDelta - - $.event.measurementsForVfScalingFields.vNicPerformanceArray[*].receivedDiscardedPacketsDelta - - $.event.measurementsForVfScalingFields.vNicPerformanceArray[*].receivedErrorPacketsDelta - - $.event.measurementsForVfScalingFields.vNicPerformanceArray[*].receivedTotalPacketsAccumulated - - $.event.measurementsForVfScalingFields.vNicPerformanceArray[*].receivedOctetsAccumulated - - $.event.measurementsForVfScalingFields.vNicPerformanceArray[*].receivedUnicastPacketsAccumulated - - $.event.measurementsForVfScalingFields.vNicPerformanceArray[*].receivedMulticastPacketsAccumulated - - $.event.measurementsForVfScalingFields.vNicPerformanceArray[*].receivedBroadcastPacketsAccumulated - - $.event.measurementsForVfScalingFields.vNicPerformanceArray[*].receivedDiscardedPacketsAccumulated - - $.event.measurementsForVfScalingFields.vNicPerformanceArray[*].receivedErrorPacketsAccumulated - - $.event.measurementsForVfScalingFields.vNicPerformanceArray[*].transmittedTotalPacketsDelta - - $.event.measurementsForVfScalingFields.vNicPerformanceArray[*].transmittedOctetsDelta - - $.event.measurementsForVfScalingFields.vNicPerformanceArray[*].transmittedUnicastPacketsDelta - - $.event.measurementsForVfScalingFields.vNicPerformanceArray[*].transmittedMulticastPacketsDelta - - $.event.measurementsForVfScalingFields.vNicPerformanceArray[*].transmittedBroadcastPacketsDelta - - $.event.measurementsForVfScalingFields.vNicPerformanceArray[*].transmittedDiscardedPacketsDelta - - $.event.measurementsForVfScalingFields.vNicPerformanceArray[*].transmittedErrorPacketsDelta - - $.event.measurementsForVfScalingFields.vNicPerformanceArray[*].transmittedTotalPacketsAccumulated - - $.event.measurementsForVfScalingFields.vNicPerformanceArray[*].transmittedOctetsAccumulated - - $.event.measurementsForVfScalingFields.vNicPerformanceArray[*].transmittedUnicastPacketsAccumulated - - $.event.measurementsForVfScalingFields.vNicPerformanceArray[*].transmittedMulticastPacketsAccumulated - - $.event.measurementsForVfScalingFields.vNicPerformanceArray[*].transmittedBroadcastPacketsAccumulated - - $.event.measurementsForVfScalingFields.vNicPerformanceArray[*].transmittedDiscardedPacketsAccumulated - - $.event.measurementsForVfScalingFields.vNicPerformanceArray[*].transmittedErrorPacketsAccumulated - - $.event.measurementsForVfScalingFields.cpuUsageArray[*].cpuIdle - - $.event.measurementsForVfScalingFields.cpuUsageArray[*].cpuUsageInterrupt - - $.event.measurementsForVfScalingFields.cpuUsageArray[*].cpuUsageNice - - $.event.measurementsForVfScalingFields.cpuUsageArray[*].cpuUsageSoftIrq - - $.event.measurementsForVfScalingFields.cpuUsageArray[*].cpuUsageSteal - - $.event.measurementsForVfScalingFields.cpuUsageArray[*].cpuUsageSystem - - $.event.measurementsForVfScalingFields.cpuUsageArray[*].cpuWait - - $.event.measurementsForVfScalingFields.cpuUsageArray[*].percentUsage - - $.event.measurementsForVfScalingFields.meanRequestLatency - - $.event.measurementsForVfScalingFields.memoryUsageArray[*].memoryBuffered - - $.event.measurementsForVfScalingFields.memoryUsageArray[*].memoryCached - - $.event.measurementsForVfScalingFields.memoryUsageArray[*].memoryConfigured - - $.event.measurementsForVfScalingFields.memoryUsageArray[*].memoryFree - - $.event.measurementsForVfScalingFields.memoryUsageArray[*].memoryUsed - - $.event.measurementsForVfScalingFields.additionalMeasurements[*].arrayOfFields[0].value - severity: - type: string - required: true - description: Threshold Event Severity - constraints: - - valid_values: - - CRITICAL - - MAJOR - - MINOR - - WARNING - - NORMAL - thresholdValue: - type: integer - required: true - description: Threshold value for the field Path inside CEF message - version: - type: string - required: true - description: Version number associated with the threshold - diff --git a/participant/participant-impl/participant-impl-policy/src/test/resources/policytypes/onap.policies.native.Apex.yaml b/participant/participant-impl/participant-impl-policy/src/test/resources/policytypes/onap.policies.native.Apex.yaml deleted file mode 100644 index d2a7632f3..000000000 --- a/participant/participant-impl/participant-impl-policy/src/test/resources/policytypes/onap.policies.native.Apex.yaml +++ /dev/null @@ -1,203 +0,0 @@ -tosca_definitions_version: tosca_simple_yaml_1_1_0 -policy_types: - onap.policies.Native: - derived_from: tosca.policies.Root - description: a base policy type for all native PDP policies - version: 1.0.0 - name: onap.policies.Native - onap.policies.native.Apex: - derived_from: onap.policies.Native - description: a policy type for native apex policies - version: 1.0.0 - name: onap.policies.native.Apex - properties: - engine_service: - type: onap.datatypes.native.apex.EngineService - description: APEX Engine Service Parameters - inputs: - type: map - description: Inputs for handling events coming into the APEX engine - entry_schema: - type: onap.datatypes.native.apex.EventHandler - outputs: - type: map - description: Outputs for handling events going out of the APEX engine - entry_schema: - type: onap.datatypes.native.apex.EventHandler - environment: - type: list - description: Envioronmental parameters for the APEX engine - entry_schema: - type: onap.datatypes.native.apex.Environment - -data_types: - onap.datatypes.native.apex.EngineService: - derived_from: tosca.datatypes.Root - properties: - name: - type: string - description: Specifies the engine name - required: false - default: "ApexEngineService" - version: - type: string - description: Specifies the engine version in double dotted format - required: false - default: "1.0.0" - id: - type: integer - description: Specifies the engine id - required: true - instance_count: - type: integer - description: Specifies the number of engine threads that should be run - required: true - deployment_port: - type: integer - description: Specifies the port to connect to for engine administration - required: false - default: 1 - policy_model_file_name: - type: string - description: The name of the file from which to read the APEX policy model - required: false - policy_type_impl: - type: string - description: The policy type implementation from which to read the APEX policy model - required: false - periodic_event_period: - type: string - description: The time interval in milliseconds for the periodic scanning event, 0 means don't scan - required: false - engine: - type: onap.datatypes.native.apex.engineservice.Engine - description: The parameters for all engines in the APEX engine service - required: true - onap.datatypes.native.apex.EventHandler: - derived_from: tosca.datatypes.Root - properties: - name: - type: string - description: Specifies the event handler name, if not specified this is set to the key name - required: false - carrier_technology: - type: onap.datatypes.native.apex.CarrierTechnology - description: Specifies the carrier technology of the event handler (such as REST/Web Socket/Kafka) - required: true - event_protocol: - type: onap.datatypes.native.apex.EventProtocol - description: Specifies the event protocol of events for the event handler (such as Yaml/JSON/XML/POJO) - required: true - event_name: - type: string - description: Specifies the event name for events on this event handler, if not specified, the event name is read from or written to the event being received or sent - required: false - event_name_filter: - type: string - description: Specifies a filter as a regular expression, events that do not match the filter are dropped, the default is to let all events through - required: false - synchronous_mode: - type: boolean - description: Specifies the event handler is syncronous (receive event and send response) - required: false - default: false - synchronous_peer: - type: string - description: The peer event handler (output for input or input for output) of this event handler in synchronous mode, this parameter is mandatory if the event handler is in synchronous mode - required: false - synchronous_timeout: - type: integer - description: The timeout in milliseconds for responses to be issued by APEX torequests, this parameter is mandatory if the event handler is in synchronous mode - required: false - requestor_mode: - type: boolean - description: Specifies the event handler is in requestor mode (send event and wait for response mode) - required: false - default: false - requestor_peer: - type: string - description: The peer event handler (output for input or input for output) of this event handler in requestor mode, this parameter is mandatory if the event handler is in requestor mode - required: false - requestor_timeout: - type: integer - description: The timeout in milliseconds for wait for responses to requests, this parameter is mandatory if the event handler is in requestor mode - required: false - onap.datatypes.native.apex.CarrierTechnology: - derived_from: tosca.datatypes.Root - properties: - label: - type: string - description: The label (name) of the carrier technology (such as REST, Kafka, WebSocket) - required: true - plugin_parameter_class_name: - type: string - description: The class name of the class that overrides default handling of event input or output for this carrier technology, defaults to the supplied input or output class - required: false - onap.datatypes.native.apex.EventProtocol: - derived_from: tosca.datatypes.Root - properties: - label: - type: string - description: The label (name) of the event protocol (such as Yaml, JSON, XML, or POJO) - required: true - event_protocol_plugin_class: - type: string - description: The class name of the class that overrides default handling of the event protocol for this carrier technology, defaults to the supplied event protocol class - required: false - onap.datatypes.native.apex.Environment: - derived_from: tosca.datatypes.Root - properties: - name: - type: string - description: The name of the environment variable - required: true - value: - type: string - description: The value of the environment variable - required: true - onap.datatypes.native.apex.engineservice.Engine: - derived_from: tosca.datatypes.Root - properties: - context: - type: onap.datatypes.native.apex.engineservice.engine.Context - description: The properties for handling context in APEX engines, defaults to using Java maps for context - required: false - executors: - type: map - description: The plugins for policy executors used in engines such as javascript, MVEL, Jython - required: true - entry_schema: - description: The plugin class path for this policy executor - type: string - onap.datatypes.native.apex.engineservice.engine.Context: - derived_from: tosca.datatypes.Root - properties: - distributor: - type: onap.datatypes.native.apex.Plugin - description: The plugin to be used for distributing context between APEX PDPs at runtime - required: false - schemas: - type: map - description: The plugins for context schemas available in APEX PDPs such as Java and Avro - required: false - entry_schema: - type: onap.datatypes.native.apex.Plugin - locking: - type: onap.datatypes.native.apex.Plugin - description: The plugin to be used for locking context in and between APEX PDPs at runtime - required: false - persistence: - type: onap.datatypes.native.apex.Plugin - description: The plugin to be used for persisting context for APEX PDPs at runtime - required: false - onap.datatypes.native.apex.Plugin: - derived_from: tosca.datatypes.Root - properties: - name: - type: string - description: The name of the executor such as Javascript, Jython or MVEL - required: true - plugin_class_name: - type: string - description: The class path of the plugin class for this executor - diff --git a/participant/participant-impl/participant-impl-policy/src/test/resources/policytypes/onap.policies.native.Drools.yaml b/participant/participant-impl/participant-impl-policy/src/test/resources/policytypes/onap.policies.native.Drools.yaml deleted file mode 100644 index 0ae96dbc2..000000000 --- a/participant/participant-impl/participant-impl-policy/src/test/resources/policytypes/onap.policies.native.Drools.yaml +++ /dev/null @@ -1,118 +0,0 @@ -tosca_definitions_version: tosca_simple_yaml_1_1_0 -policy_types: - onap.policies.Native: - derived_from: tosca.policies.Root - description: a base policy type for all native PDP policies - version: 1.0.0 - name: onap.policies.Native - onap.policies.native.Drools: - derived_from: onap.policies.Native - description: a base policy type for all native PDP policies - version: 1.0.0 - name: onap.policies.native.Drools - onap.policies.native.drools.Controller: - derived_from: onap.policies.native.Drools - description: a policy type for a drools controller configuration - version: 1.0.0 - name: onap.policies.native.drools.Controller - properties: - controllerName: - type: string - required: true - description: the drools controller name - sourceTopics: - type: list - required: false - description: source topics and applicable events - entry_schema: - type: onap.datatypes.dmaap.topic - sinkTopics: - type: list - required: false - description: sink topics and applicable events - entry_schema: - type: onap.datatypes.dmaap.topic - customConfig: - type: map - required: false - description: any use case specific configurations relevant to the drools controller - entry_schema: - type: string - onap.policies.native.drools.Artifact: - derived_from: onap.policies.native.Drools - description: a policy type for native drools artifact policies - version: 1.0.0 - name: onap.policies.native.drools.Artifact - properties: - rulesArtifact: - type: onap.datatypes.native.rules_artifact - required: true - description: the GAV information of the maven artifact - controller: - type: onap.datatypes.drools.controller.relation - required: true - description: the drools controller to which the current native policy is assigned - -data_types: - onap.datatypes.dmaap.topic: - derived_from: tosca.datatypes.Root - properties: - topicName: - type: string - required: true - description: the dmaap topic name - events: - type: list - required: true - description: events used by this topic - entry_schema: - type: onap.datatypes.dmaap.events - onap.datatypes.dmaap.events: - derived_from: tosca.datatypes.Root - properties: - eventClass: - type: string - required: true - description: the event canonical class for serialization - eventFilter: - type: string - required: false - description: the JSONPath based condition to filter out the events to serialize - customSerialization: - type: onap.datatypes.dmaap.custom_serialization - required: false - description: overrides the default serialization/deserialization mechanisms with custom ones - onap.datatypes.dmaap.custom_serialization: - derived_from: tosca.datatypes.Root - properties: - customSerializerClass: - type: string - required: true - description: the class that contains the JSON parser serializer/deserializer. - jsonParser: - type: string - required: true - description: static field in customSerialized class with the json parser (currently only gson supported) - onap.datatypes.native.rules_artifact: - derived_from: tosca.datatypes.Root - properties: - groupId: - type: string - required: true - description: the groupId of the maven artifact - artifactId: - type: string - required: true - description: the artifactId of the maven artifact - version: - type: string - required: true - description: the version of the maven artifact - onap.datatypes.drools.controller.relation: - derived_from: tosca.datatypes.Root - properties: - name: - type: string - required: true - description: the name of drools controller policy - diff --git a/participant/participant-impl/participant-impl-policy/src/test/resources/policytypes/onap.policies.native.Xacml.yaml b/participant/participant-impl/participant-impl-policy/src/test/resources/policytypes/onap.policies.native.Xacml.yaml deleted file mode 100644 index eb25cdb91..000000000 --- a/participant/participant-impl/participant-impl-policy/src/test/resources/policytypes/onap.policies.native.Xacml.yaml +++ /dev/null @@ -1,20 +0,0 @@ -tosca_definitions_version: tosca_simple_yaml_1_1_0 -policy_types: - onap.policies.Native: - derived_from: tosca.policies.Root - description: a base policy type for all native PDP policies - version: 1.0.0 - name: onap.policies.Native - onap.policies.native.Xacml: - derived_from: onap.policies.Native - description: a policy type for native xacml policies - version: 1.0.0 - name: onap.policies.native.Xacml - properties: - policy: - type: string - required: true - description: The XML XACML 3.0 PolicySet or Policy - metadata: - encoding: Base64 - diff --git a/participant/participant-impl/participant-impl-policy/src/test/resources/policytypes/onap.policies.optimization.Resource.yaml b/participant/participant-impl/participant-impl-policy/src/test/resources/policytypes/onap.policies.optimization.Resource.yaml deleted file mode 100644 index 6b3a2460d..000000000 --- a/participant/participant-impl/participant-impl-policy/src/test/resources/policytypes/onap.policies.optimization.Resource.yaml +++ /dev/null @@ -1,25 +0,0 @@ -tosca_definitions_version: tosca_simple_yaml_1_1_0 -policy_types: - onap.policies.optimization.Resource: - derived_from: onap.policies.Optimization - version: 1.0.0 - name: onap.policies.optimization.Resource - description: The base policy type for all policies that govern optimization for a Resource in a Service. - properties: - services: - description: One or more services that the policy applies to. - type: list - metadata: - matchable: true - required: true - entry_schema: - type: string - resources: - description: One or more VNF resources that the policy applies to. - type: list - metadata: - matchable: true - required: true - entry_schema: - type: string - diff --git a/participant/participant-impl/participant-impl-policy/src/test/resources/policytypes/onap.policies.optimization.Service.yaml b/participant/participant-impl/participant-impl-policy/src/test/resources/policytypes/onap.policies.optimization.Service.yaml deleted file mode 100644 index 8b37a67e7..000000000 --- a/participant/participant-impl/participant-impl-policy/src/test/resources/policytypes/onap.policies.optimization.Service.yaml +++ /dev/null @@ -1,17 +0,0 @@ -tosca_definitions_version: tosca_simple_yaml_1_1_0 -policy_types: - onap.policies.optimization.Service: - derived_from: onap.policies.Optimization - version: 1.0.0 - name: onap.policies.optimization.Service - description: The base policy type for all policies that govern optimization for a Service. - properties: - services: - description: One or more services that the policy applies to. - type: list - metadata: - matchable: true - required: true - entry_schema: - type: string - diff --git a/participant/participant-impl/participant-impl-policy/src/test/resources/policytypes/onap.policies.optimization.resource.AffinityPolicy.yaml b/participant/participant-impl/participant-impl-policy/src/test/resources/policytypes/onap.policies.optimization.resource.AffinityPolicy.yaml deleted file mode 100644 index bb6adb0aa..000000000 --- a/participant/participant-impl/participant-impl-policy/src/test/resources/policytypes/onap.policies.optimization.resource.AffinityPolicy.yaml +++ /dev/null @@ -1,33 +0,0 @@ -tosca_definitions_version: tosca_simple_yaml_1_1_0 -policy_types: - onap.policies.optimization.resource.AffinityPolicy: - derived_from: onap.policies.optimization.Resource - version: 1.0.0 - name: onap.policies.optimization.resource.AffinityPolicy - properties: - applicableResources: - type: list - required: true - entry_schema: - type: string - constraints: - - valid_values: - - any - - all - affinityProperties: - type: policy.data.affinityProperties_properties - required: true -data_types: - policy.data.affinityProperties_properties: - derived_from: tosca.nodes.Root - properties: - qualifier: - type: string - constraints: - - valid_values: - - same - - different - category: - type: string - required: true - diff --git a/participant/participant-impl/participant-impl-policy/src/test/resources/policytypes/onap.policies.optimization.resource.DistancePolicy.yaml b/participant/participant-impl/participant-impl-policy/src/test/resources/policytypes/onap.policies.optimization.resource.DistancePolicy.yaml deleted file mode 100644 index f41dcfd6f..000000000 --- a/participant/participant-impl/participant-impl-policy/src/test/resources/policytypes/onap.policies.optimization.resource.DistancePolicy.yaml +++ /dev/null @@ -1,58 +0,0 @@ -tosca_definitions_version: tosca_simple_yaml_1_1_0 -policy_types: - onap.policies.optimization.resource.DistancePolicy: - derived_from: onap.policies.optimization.Resource - version: 1.0.0 - name: onap.policies.optimization.resource.DistancePolicy - properties: - applicableResources: - type: list - required: true - entry_schema: - type: string - constraints: - - valid_values: - - any - - all - distanceProperties: - type: policy.data.distanceProperties_properties - required: true -data_types: - policy.data.distanceProperties_properties: - derived_from: tosca.nodes.Root - properties: - locationInfo: - type: string - required: true - distance: - type: policy.data.distance_properties - required: true - entry_schema: - type: policy.data.distance_properties - policy.data.distance_properties: - derived_from: tosca.nodes.Root - properties: - value: - type: string - required: true - operator: - type: list - required: true - entry_schema: - type: string - constraints: - - valid_values: - - < - - <= - - '>' - - '>=' - - = - unit: - type: list - required: true - entry_schema: - type: string - constraints: - - valid_values: - - km - diff --git a/participant/participant-impl/participant-impl-policy/src/test/resources/policytypes/onap.policies.optimization.resource.HpaPolicy.yaml b/participant/participant-impl/participant-impl-policy/src/test/resources/policytypes/onap.policies.optimization.resource.HpaPolicy.yaml deleted file mode 100644 index dfe30774b..000000000 --- a/participant/participant-impl/participant-impl-policy/src/test/resources/policytypes/onap.policies.optimization.resource.HpaPolicy.yaml +++ /dev/null @@ -1,105 +0,0 @@ -tosca_definitions_version: tosca_simple_yaml_1_1_0 -policy_types: - onap.policies.optimization.resource.HpaPolicy: - derived_from: onap.policies.optimization.Resource - version: 1.0.0 - name: onap.policies.optimization.resource.HpaPolicy - properties: - flavorFeatures: - type: list - required: true - entry_schema: - type: policy.data.flavorFeatures_properties -data_types: - policy.data.flavorFeatures_properties: - derived_from: tosca.nodes.Root - properties: - id: - type: string - required: true - type: - type: string - required: true - directives: - type: list - required: true - entry_schema: - type: policy.data.directives_properties - flavorProperties: - type: list - required: true - entry_schema: - type: policy.data.flavorProperties_properties - policy.data.directives_properties: - derived_from: tosca.nodes.Root - properties: - type: - type: string - attributes: - type: list - entry_schema: - type: policy.data.directives_attributes_properties - policy.data.directives_attributes_properties: - derived_from: tosca.nodes.Root - properties: - attribute_name: - type: string - attribute_value: - type: string - policy.data.flavorProperties_properties: - derived_from: tosca.nodes.Root - properties: - hpa-feature: - type: string - required: true - mandatory: - type: string - required: true - score: - type: string - required: false - architecture: - type: string - required: true - hpa-version: - type: string - required: true - directives: - type: list - required: true - entry_schema: - type: policy.data.directives_properties - hpa-feature-attributes: - type: list - required: true - entry_schema: - type: policy.data.hpa-feature-attributes_properties - policy.data.hpa-feature-attributes_properties: - derived_from: tosca.nodes.Root - properties: - hpa-attribute-key: - type: string - required: true - hpa-attribute-value: - type: string - required: true - operator: - type: list - required: true - entry_schema: - type: string - constraints: - - valid_values: - - < - - <= - - '>' - - '>=' - - = - - '!=' - - any - - all - - subset - unit: - type: string - required: false - diff --git a/participant/participant-impl/participant-impl-policy/src/test/resources/policytypes/onap.policies.optimization.resource.OptimizationPolicy.yaml b/participant/participant-impl/participant-impl-policy/src/test/resources/policytypes/onap.policies.optimization.resource.OptimizationPolicy.yaml deleted file mode 100644 index b0f77d67e..000000000 --- a/participant/participant-impl/participant-impl-policy/src/test/resources/policytypes/onap.policies.optimization.resource.OptimizationPolicy.yaml +++ /dev/null @@ -1,68 +0,0 @@ -tosca_definitions_version: tosca_simple_yaml_1_1_0 -policy_types: - onap.policies.optimization.resource.OptimizationPolicy: - derived_from: onap.policies.optimization.Resource - version: 1.0.0 - name: onap.policies.optimization.resource.OptimizationPolicy - properties: - objective: - type: list - required: true - entry_schema: - type: string - constraints: - - valid_values: - - minimize - - maximize - objectiveParameter: - type: policy.data.objectiveParameter_properties - required: true -data_types: - policy.data.objectiveParameter_properties: - derived_from: tosca.nodes.Root - properties: - parameterAttributes: - type: list - required: true - entry_schema: - type: policy.data.parameterAttributes_properties - operator: - type: list - required: true - entry_schema: - type: string - constraints: - - valid_values: - - '*' - - + - - '-' - - / - - '%' - policy.data.parameterAttributes_properties: - derived_from: tosca.nodes.Root - properties: - resources: - type: string - required: true - customerLocationInfo: - type: string - required: true - parameter: - type: string - required: true - weight: - type: string - required: true - operator: - type: list - required: true - entry_schema: - type: string - constraints: - - valid_values: - - '*' - - + - - '-' - - / - - '%' - diff --git a/participant/participant-impl/participant-impl-policy/src/test/resources/policytypes/onap.policies.optimization.resource.PciPolicy.yaml b/participant/participant-impl/participant-impl-policy/src/test/resources/policytypes/onap.policies.optimization.resource.PciPolicy.yaml deleted file mode 100644 index e636582df..000000000 --- a/participant/participant-impl/participant-impl-policy/src/test/resources/policytypes/onap.policies.optimization.resource.PciPolicy.yaml +++ /dev/null @@ -1,32 +0,0 @@ -tosca_definitions_version: tosca_simple_yaml_1_1_0 -policy_types: - onap.policies.optimization.resource.PciPolicy: - derived_from: onap.policies.optimization.Resource - version: 1.0.0 - name: onap.policies.optimization.resource.PciPolicy - properties: - pciProperties: - type: list - required: false - entry_schema: - type: policy.data.pciProperties_properties -data_types: - policy.data.pciProperties_properties: - derived_from: tosca.nodes.Root - properties: - algoCategory: - type: string - required: false - pciOptmizationAlgoName: - type: string - required: false - pciOptimizationNwConstraint: - type: string - required: false - pciOptimizationPriority: - type: string - required: false - pciOptimizationTimeConstraint: - type: string - required: false - diff --git a/participant/participant-impl/participant-impl-policy/src/test/resources/policytypes/onap.policies.optimization.resource.Vim_fit.yaml b/participant/participant-impl/participant-impl-policy/src/test/resources/policytypes/onap.policies.optimization.resource.Vim_fit.yaml deleted file mode 100644 index cb387dda1..000000000 --- a/participant/participant-impl/participant-impl-policy/src/test/resources/policytypes/onap.policies.optimization.resource.Vim_fit.yaml +++ /dev/null @@ -1,30 +0,0 @@ -tosca_definitions_version: tosca_simple_yaml_1_1_0 -policy_types: - onap.policies.optimization.resource.Vim_fit: - derived_from: onap.policies.optimization.Resource - version: 1.0.0 - name: onap.policies.optimization.resource.Vim_fit - properties: - applicableResources: - type: list - required: true - entry_schema: - type: string - constraints: - - valid_values: - - any - - all - capacityProperties: - type: policy.data.capacityProperties_properties - required: true -data_types: - policy.data.capacityProperties_properties: - derived_from: tosca.nodes.Root - properties: - controller: - type: string - required: true - request: - type: string - required: true - diff --git a/participant/participant-impl/participant-impl-policy/src/test/resources/policytypes/onap.policies.optimization.resource.VnfPolicy.yaml b/participant/participant-impl/participant-impl-policy/src/test/resources/policytypes/onap.policies.optimization.resource.VnfPolicy.yaml deleted file mode 100644 index 30b8b7212..000000000 --- a/participant/participant-impl/participant-impl-policy/src/test/resources/policytypes/onap.policies.optimization.resource.VnfPolicy.yaml +++ /dev/null @@ -1,46 +0,0 @@ -tosca_definitions_version: tosca_simple_yaml_1_1_0 -policy_types: - onap.policies.optimization.resource.VnfPolicy: - derived_from: onap.policies.optimization.Resource - version: 1.0.0 - name: onap.policies.optimization.resource.VnfPolicy - properties: - applicableResources: - type: list - required: true - entry_schema: - type: string - constraints: - - valid_values: - - any - - all - vnfProperties: - type: list - required: true - entry_schema: - type: policy.data.vnfProperties_properties -data_types: - policy.data.vnfProperties_properties: - derived_from: tosca.nodes.Root - properties: - inventoryProvider: - type: string - required: true - serviceType: - type: string - required: true - inventoryType: - type: list - required: true - entry_schema: - type: string - constraints: - - valid_values: - - serviceInstanceId - - vnfName - - cloudRegionId - - vimId - customerId: - type: string - required: true - diff --git a/participant/participant-impl/participant-impl-policy/src/test/resources/policytypes/onap.policies.optimization.service.QueryPolicy.yaml b/participant/participant-impl/participant-impl-policy/src/test/resources/policytypes/onap.policies.optimization.service.QueryPolicy.yaml deleted file mode 100644 index 2ff263b24..000000000 --- a/participant/participant-impl/participant-impl-policy/src/test/resources/policytypes/onap.policies.optimization.service.QueryPolicy.yaml +++ /dev/null @@ -1,26 +0,0 @@ -tosca_definitions_version: tosca_simple_yaml_1_1_0 -policy_types: - onap.policies.optimization.service.QueryPolicy: - derived_from: onap.policies.optimization.Service - version: 1.0.0 - name: onap.policies.optimization.service.QueryPolicy - properties: - queryProperties: - type: list - required: true - entry_schema: - type: policy.data.queryProperties_properties -data_types: - policy.data.queryProperties_properties: - derived_from: tosca.nodes.Root - properties: - attribute: - type: string - required: true - value: - type: string - required: true - attribute_location: - type: string - required: true - diff --git a/participant/participant-impl/participant-impl-policy/src/test/resources/policytypes/onap.policies.optimization.service.SubscriberPolicy.yaml b/participant/participant-impl/participant-impl-policy/src/test/resources/policytypes/onap.policies.optimization.service.SubscriberPolicy.yaml deleted file mode 100644 index 81dea2c3c..000000000 --- a/participant/participant-impl/participant-impl-policy/src/test/resources/policytypes/onap.policies.optimization.service.SubscriberPolicy.yaml +++ /dev/null @@ -1,36 +0,0 @@ -tosca_definitions_version: tosca_simple_yaml_1_1_0 -policy_types: - onap.policies.optimization.service.SubscriberPolicy: - derived_from: onap.policies.optimization.Service - version: 1.0.0 - name: onap.policies.optimization.service.SubscriberPolicy - properties: - subscriberProperties: - type: policy.data.subscriberProperties_properties - required: true -data_types: - policy.data.subscriberProperties_properties: - derived_from: tosca.nodes.Root - properties: - subscriberName: - type: list - required: true - metadata: - contextProvider: true - entry_schema: - type: string - subscriberRole: - type: list - required: true - metadata: - contextMatchable: scope - entry_schema: - type: string - provStatus: - type: list - required: true - metadata: - contextAttribute: true - entry_schema: - type: string - diff --git a/participant/participant-impl/participant-impl-policy/src/test/resources/utils/servicetemplates/pm_automation_composition_tosca.yaml b/participant/participant-impl/participant-impl-policy/src/test/resources/utils/servicetemplates/pm_automation_composition_tosca.yaml new file mode 100644 index 000000000..3d14cf572 --- /dev/null +++ b/participant/participant-impl/participant-impl-policy/src/test/resources/utils/servicetemplates/pm_automation_composition_tosca.yaml @@ -0,0 +1,164 @@ +tosca_definitions_version: tosca_simple_yaml_1_3 +data_types: + onap.datatypes.ToscaConceptIdentifier: + derived_from: tosca.datatypes.Root + properties: + name: + type: string + required: true + version: + type: string + required: true +node_types: + org.onap.policy.clamp.acmParticipant: + version: 1.0.1 + derived_from: tosca.nodetypes.Root + properties: + provider: + type: string + requred: false + org.onap.policy.clamp.acmAutomationCompositionElement: + version: 1.0.1 + derived_from: tosca.nodetypes.Root + properties: + provider: + type: string + requred: false + participantType: + type: onap.datatypes.ToscaConceptIdentifier + requred: true + startPhase: + type: integer + required: false + constraints: + - greater-or-equal: 0 + metadata: + common: true + description: A value indicating the start phase in which this automation composition element will be started, + the first start phase is zero. Automation Composition Elements are started in their start_phase + order and stopped in reverse start phase order. Automation Composition Elements with the same start + phase are started and stopped simultaneously + org.onap.policy.clamp.acmAutomationComposition: + version: 1.0.1 + derived_from: tosca.nodetypes.Root + properties: + provider: + type: string + requred: false + elements: + type: list + required: true + entry_schema: + type: onap.datatypes.ToscaConceptIdentifier + org.onap.policy.clamp.acmDCAEMicroserviceAutomationCompositionElement: + version: 1.0.1 + derived_from: org.onap.policy.clamp.acmAutomationCompositionElement + properties: + dcae_blueprint_id: + type: onap.datatypes.ToscaConceptIdentifier + requred: true + org.onap.policy.clamp.acmPolicyTypeAutomationCompositionElement: + version: 1.0.1 + derived_from: org.onap.policy.clamp.acmAutomationCompositionElement + properties: + policy_type_id: + type: onap.datatypes.ToscaConceptIdentifier + requred: true + org.onap.policy.clamp.acmCDSAutomationCompositionElement: + version: 1.0.1 + derived_from: org.onap.policy.clamp.acmAutomationCompositionElement + properties: + cds_blueprint_id: + type: onap.datatypes.ToscaConceptIdentifier + requred: true +topology_template: + node_templates: + org.onap.dcae.acmDCAEMicroserviceAutomationCompositionParticipant: + version: 2.3.4 + type: org.onap.policy.clamp.acmParticipant + type_version: 1.0.1 + description: Participant for DCAE microservices + properties: + provider: ONAP + org.onap.policy.acmPolicyAutomationCompositionParticipant: + version: 2.3.1 + type: org.onap.policy.clamp.acmParticipant + type_version: 1.0.1 + description: Participant for DCAE microservices + properties: + provider: ONAP + org.onap.ccsdk.cds.acmCdsAutomationCompositionParticipant: + version: 2.2.1 + type: org.onap.policy.clamp.acmParticipant + type_version: 1.0.1 + description: Participant for DCAE microservices + properties: + provider: ONAP + org.onap.domain.pmsh.PMSH_DCAEMicroservice: + version: 1.2.3 + type: org.onap.policy.clamp.acmDCAEMicroserviceAutomationCompositionElement + type_version: 1.0.0 + description: Automation composition element for DCAE microservice for Performance Management Subscription Handling + properties: + provider: Ericsson + participantType: + name: org.onap.dcae.acmDCAEMicroserviceAutomationCompositionParticipant + version: 2.3.4 + dcae_blueprint_id: + name: org.onap.dcae.blueprints.PMSHBlueprint + version: 1.0.0 + org.onap.domain.pmsh.PMSH_MonitoringPolicyAutomationCompositionElement: + version: 1.2.3 + type: org.onap.policy.clamp.acmPolicyTypeAutomationCompositionElement + type_version: 1.0.0 + description: Automation composition element for monitoring policy for Performance Management Subscription Handling + properties: + provider: Ericsson + participantType: + name: org.onap.policy.acmPolicyAutomationCompositionParticipant + version: 2.3.1 + policy_type_id: + name: onap.policies.monitoring.pm-subscription-handler + version: 1.0.0 + org.onap.domain.pmsh.PMSH_OperationalPolicyAutomationCompositionElement: + version: 1.2.3 + type: org.onap.policy.clamp.acmPolicyTypeAutomationCompositionElement + type_version: 1.0.0 + description: Automation composition element, operational policy for Performance Management Subscription Handling + properties: + provider: Ericsson + participantType: + name: org.onap.policy.acmPolicyAutomationCompositionParticipant + version: 2.3.1 + policy_type_id: + name: onap.policies.operational.pm-subscription-handler + version: 1.0.0 + org.onap.domain.pmsh.PMSH_CDS_AutomationCompositionElement: + version: 1.2.3 + type: org.onap.policy.clamp.acmAutomationCompositionElement + type_version: 1.0.0 + description: Automation composition element for CDS for Performance Management Subscription Handling + properties: + provider: Ericsson + participantType: + name: org.onap.ccsdk.cds.acmCdsAutomationCompositionParticipant + version: 3.2.1 + cds_blueprint_id: + name: org.onap.ccsdk.cds.PMSHCdsBlueprint + version: 1.0.0 + org.onap.domain.pmsh.PMSHAutomationCompositionDefinition: + version: 1.2.3 + type: org.onap.policy.clamp.acmAutomationComposition + type_version: 1.0.0 + description: Automation composition for Performance Management Subscription Handling + properties: + provider: Ericsson + elements: + - name: org.onap.domain.pmsh.PMSH_DCAEMicroservice + version: 1.2.3 + - name: org.onap.domain.pmsh.PMSH_MonitoringPolicyAutomationCompositionElement + version: 1.2.3 + - name: org.onap.domain.pmsh.PMSH_OperationalPolicyAutomationCompositionElement + version: 1.2.3 + - name: org.onap.domain.pmsh.PMSH_CDS_AutomationCompositionElement + version: 1.2.3 diff --git a/participant/participant-impl/participant-impl-policy/src/test/resources/utils/servicetemplates/pm_control_loop_tosca.yaml b/participant/participant-impl/participant-impl-policy/src/test/resources/utils/servicetemplates/pm_control_loop_tosca.yaml deleted file mode 100644 index 33b42b7bc..000000000 --- a/participant/participant-impl/participant-impl-policy/src/test/resources/utils/servicetemplates/pm_control_loop_tosca.yaml +++ /dev/null @@ -1,164 +0,0 @@ -tosca_definitions_version: tosca_simple_yaml_1_3 -data_types: - onap.datatypes.ToscaConceptIdentifier: - derived_from: tosca.datatypes.Root - properties: - name: - type: string - required: true - version: - type: string - required: true -node_types: - org.onap.policy.clamp.controlloop.Participant: - version: 1.0.1 - derived_from: tosca.nodetypes.Root - properties: - provider: - type: string - requred: false - org.onap.policy.clamp.controlloop.ControlLoopElement: - version: 1.0.1 - derived_from: tosca.nodetypes.Root - properties: - provider: - type: string - requred: false - participantType: - type: onap.datatypes.ToscaConceptIdentifier - requred: true - startPhase: - type: integer - required: false - constraints: - - greater-or-equal: 0 - metadata: - common: true - description: A value indicating the start phase in which this control loop element will be started, the - first start phase is zero. Control Loop Elements are started in their start_phase order and stopped - in reverse start phase order. Control Loop Elements with the same start phase are started and - stopped simultaneously - org.onap.policy.clamp.controlloop.ControlLoop: - version: 1.0.1 - derived_from: tosca.nodetypes.Root - properties: - provider: - type: string - requred: false - elements: - type: list - required: true - entry_schema: - type: onap.datatypes.ToscaConceptIdentifier - org.onap.policy.clamp.controlloop.DCAEMicroserviceControlLoopElement: - version: 1.0.1 - derived_from: org.onap.policy.clamp.controlloop.ControlLoopElement - properties: - dcae_blueprint_id: - type: onap.datatypes.ToscaConceptIdentifier - requred: true - org.onap.policy.clamp.controlloop.PolicyTypeControlLoopElement: - version: 1.0.1 - derived_from: org.onap.policy.clamp.controlloop.ControlLoopElement - properties: - policy_type_id: - type: onap.datatypes.ToscaConceptIdentifier - requred: true - org.onap.policy.clamp.controlloop.CDSControlLoopElement: - version: 1.0.1 - derived_from: org.onap.policy.clamp.controlloop.ControlLoopElement - properties: - cds_blueprint_id: - type: onap.datatypes.ToscaConceptIdentifier - requred: true -topology_template: - node_templates: - org.onap.dcae.controlloop.DCAEMicroserviceControlLoopParticipant: - version: 2.3.4 - type: org.onap.policy.clamp.controlloop.Participant - type_version: 1.0.1 - description: Participant for DCAE microservices - properties: - provider: ONAP - org.onap.policy.controlloop.PolicyControlLoopParticipant: - version: 2.3.1 - type: org.onap.policy.clamp.controlloop.Participant - type_version: 1.0.1 - description: Participant for DCAE microservices - properties: - provider: ONAP - org.onap.ccsdk.cds.controlloop.CdsControlLoopParticipant: - version: 2.2.1 - type: org.onap.policy.clamp.controlloop.Participant - type_version: 1.0.1 - description: Participant for DCAE microservices - properties: - provider: ONAP - org.onap.domain.pmsh.PMSH_DCAEMicroservice: - version: 1.2.3 - type: org.onap.policy.clamp.controlloop.DCAEMicroserviceControlLoopElement - type_version: 1.0.0 - description: Control loop element for the DCAE microservice for Performance Management Subscription Handling - properties: - provider: Ericsson - participantType: - name: org.onap.dcae.controlloop.DCAEMicroserviceControlLoopParticipant - version: 2.3.4 - dcae_blueprint_id: - name: org.onap.dcae.blueprints.PMSHBlueprint - version: 1.0.0 - org.onap.domain.pmsh.PMSH_MonitoringPolicyControlLoopElement: - version: 1.2.3 - type: org.onap.policy.clamp.controlloop.PolicyTypeControlLoopElement - type_version: 1.0.0 - description: Control loop element for the monitoring policy for Performance Management Subscription Handling - properties: - provider: Ericsson - participantType: - name: org.onap.policy.controlloop.PolicyControlLoopParticipant - version: 2.3.1 - policy_type_id: - name: onap.policies.monitoring.pm-subscription-handler - version: 1.0.0 - org.onap.domain.pmsh.PMSH_OperationalPolicyControlLoopElement: - version: 1.2.3 - type: org.onap.policy.clamp.controlloop.PolicyTypeControlLoopElement - type_version: 1.0.0 - description: Control loop element for the operational policy for Performance Management Subscription Handling - properties: - provider: Ericsson - participantType: - name: org.onap.policy.controlloop.PolicyControlLoopParticipant - version: 2.3.1 - policy_type_id: - name: onap.policies.operational.pm-subscription-handler - version: 1.0.0 - org.onap.domain.pmsh.PMSH_CDS_ControlLoopElement: - version: 1.2.3 - type: org.onap.policy.clamp.controlloop.ControlLoopElement - type_version: 1.0.0 - description: Control loop element for CDS for Performance Management Subscription Handling - properties: - provider: Ericsson - participantType: - name: org.onap.ccsdk.cds.controlloop.CdsControlLoopParticipant - version: 3.2.1 - cds_blueprint_id: - name: org.onap.ccsdk.cds.PMSHCdsBlueprint - version: 1.0.0 - org.onap.domain.pmsh.PMSHControlLoopDefinition: - version: 1.2.3 - type: org.onap.policy.clamp.controlloop.ControlLoop - type_version: 1.0.0 - description: Control loop for Performance Management Subscription Handling - properties: - provider: Ericsson - elements: - - name: org.onap.domain.pmsh.PMSH_DCAEMicroservice - version: 1.2.3 - - name: org.onap.domain.pmsh.PMSH_MonitoringPolicyControlLoopElement - version: 1.2.3 - - name: org.onap.domain.pmsh.PMSH_OperationalPolicyControlLoopElement - version: 1.2.3 - - name: org.onap.domain.pmsh.PMSH_CDS_ControlLoopElement - version: 1.2.3 diff --git a/participant/participant-impl/participant-impl-simulator/pom.xml b/participant/participant-impl/participant-impl-simulator/pom.xml index c19e45ee0..5673cb7c8 100644 --- a/participant/participant-impl/participant-impl-simulator/pom.xml +++ b/participant/participant-impl/participant-impl-simulator/pom.xml @@ -31,7 +31,7 @@ policy-clamp-participant-impl-simulator ${project.artifactId} - Participant simulator, used to test control loops + Participant simulator, used to test automation compositions diff --git a/participant/participant-impl/participant-impl-simulator/src/main/java/org/onap/policy/clamp/acm/participant/simulator/ParticipantSimulatorApplication.java b/participant/participant-impl/participant-impl-simulator/src/main/java/org/onap/policy/clamp/acm/participant/simulator/ParticipantSimulatorApplication.java new file mode 100644 index 000000000..ea94795fb --- /dev/null +++ b/participant/participant-impl/participant-impl-simulator/src/main/java/org/onap/policy/clamp/acm/participant/simulator/ParticipantSimulatorApplication.java @@ -0,0 +1,46 @@ +/*- + * ============LICENSE_START======================================================= + * Copyright (C) 2021 Nordix Foundation. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * SPDX-License-Identifier: Apache-2.0 + * ============LICENSE_END========================================================= + */ + +package org.onap.policy.clamp.acm.participant.simulator; + +import org.springframework.boot.SpringApplication; +import org.springframework.boot.autoconfigure.SpringBootApplication; +import org.springframework.boot.context.properties.ConfigurationPropertiesScan; +import org.springframework.context.annotation.ComponentScan; + +/** + * Starter. + * + */ +// @formatter:off +@SpringBootApplication +@ConfigurationPropertiesScan("org.onap.policy.clamp.acm.participant.simulator.main.parameters") +@ComponentScan({ + "org.onap.policy.clamp.acm.participant.simulator", + "org.onap.policy.clamp.acm.participant.intermediary", + "org.onap.policy.clamp.acm.common.rest" +}) +//@formatter:on +public class ParticipantSimulatorApplication { + + public static void main(String[] args) { + SpringApplication.run(ParticipantSimulatorApplication.class, args); + } +} diff --git a/participant/participant-impl/participant-impl-simulator/src/main/java/org/onap/policy/clamp/acm/participant/simulator/config/AafConfiguration.java b/participant/participant-impl/participant-impl-simulator/src/main/java/org/onap/policy/clamp/acm/participant/simulator/config/AafConfiguration.java new file mode 100644 index 000000000..101e7fac2 --- /dev/null +++ b/participant/participant-impl/participant-impl-simulator/src/main/java/org/onap/policy/clamp/acm/participant/simulator/config/AafConfiguration.java @@ -0,0 +1,46 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP CLAMP + * ================================================================================ + * Copyright (C) 2017-2018 AT&T Intellectual Property. All rights + * reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END============================================ + * =================================================================== + * + */ + +package org.onap.policy.clamp.acm.participant.simulator.config; + +import javax.servlet.Filter; +import org.onap.policy.clamp.acm.participant.simulator.main.rest.ParticipantSimulatorAafFilter; +import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.Configuration; +import org.springframework.context.annotation.Profile; + +@Configuration +@Profile("clamp-aaf-authentication") +public class AafConfiguration { + + /** + * Method to return Aaf filter. + * + * @return Filter + */ + @Bean + public Filter aafFilter() { + return new ParticipantSimulatorAafFilter(); + } + +} diff --git a/participant/participant-impl/participant-impl-simulator/src/main/java/org/onap/policy/clamp/acm/participant/simulator/config/ParticipantConfig.java b/participant/participant-impl/participant-impl-simulator/src/main/java/org/onap/policy/clamp/acm/participant/simulator/config/ParticipantConfig.java new file mode 100644 index 000000000..92ced99d7 --- /dev/null +++ b/participant/participant-impl/participant-impl-simulator/src/main/java/org/onap/policy/clamp/acm/participant/simulator/config/ParticipantConfig.java @@ -0,0 +1,61 @@ +/*- + * ============LICENSE_START======================================================= + * Copyright (C) 2021 Nordix Foundation. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * SPDX-License-Identifier: Apache-2.0 + * ============LICENSE_END========================================================= + */ + +package org.onap.policy.clamp.acm.participant.simulator.config; + +import org.onap.policy.clamp.acm.participant.intermediary.api.ParticipantIntermediaryApi; +import org.onap.policy.clamp.acm.participant.simulator.main.handler.AutomationCompositionElementHandler; +import org.onap.policy.clamp.common.acm.rest.RequestResponseLoggingFilter; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.boot.web.servlet.FilterRegistrationBean; +import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.Configuration; + +@Configuration +public class ParticipantConfig { + + /** + * logging Filter configuration. + * + * @return FilterRegistrationBean + */ + @Bean + public FilterRegistrationBean loggingFilter() { + FilterRegistrationBean registrationBean = new FilterRegistrationBean<>(); + + registrationBean.setFilter(new RequestResponseLoggingFilter()); + registrationBean.addUrlPatterns("/onap/participantsim/v2/*"); + + return registrationBean; + } + + /** + * Register AutomationCompositionElementListener. + * + * @param intermediaryApi the ParticipantIntermediaryApi + * @param acElementHandler the AutomationComposition Element Handler + */ + @Autowired + public void registerAutomationCompositionElementListener(ParticipantIntermediaryApi intermediaryApi, + AutomationCompositionElementHandler acElementHandler) { + intermediaryApi.registerAutomationCompositionElementListener(acElementHandler); + acElementHandler.setIntermediaryApi(intermediaryApi); + } +} diff --git a/participant/participant-impl/participant-impl-simulator/src/main/java/org/onap/policy/clamp/acm/participant/simulator/config/SecurityConfig.java b/participant/participant-impl/participant-impl-simulator/src/main/java/org/onap/policy/clamp/acm/participant/simulator/config/SecurityConfig.java new file mode 100644 index 000000000..c41c6e1b3 --- /dev/null +++ b/participant/participant-impl/participant-impl-simulator/src/main/java/org/onap/policy/clamp/acm/participant/simulator/config/SecurityConfig.java @@ -0,0 +1,39 @@ +/*- + * ============LICENSE_START======================================================= + * Copyright (C) 2021 Nordix Foundation. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * SPDX-License-Identifier: Apache-2.0 + * ============LICENSE_END========================================================= + */ + +package org.onap.policy.clamp.acm.participant.simulator.config; + +import org.springframework.context.annotation.Configuration; +import org.springframework.security.config.annotation.web.builders.HttpSecurity; +import org.springframework.security.config.annotation.web.configuration.WebSecurityConfigurerAdapter; + +@Configuration +public class SecurityConfig extends WebSecurityConfigurerAdapter { + + @Override + protected void configure(HttpSecurity http) throws Exception { + // @formatter:off + http.authorizeRequests() + .antMatchers().authenticated() + .anyRequest().authenticated() + .and().httpBasic().and().csrf().disable(); + // @formatter:on + } +} diff --git a/participant/participant-impl/participant-impl-simulator/src/main/java/org/onap/policy/clamp/acm/participant/simulator/config/SpringFoxConfig.java b/participant/participant-impl/participant-impl-simulator/src/main/java/org/onap/policy/clamp/acm/participant/simulator/config/SpringFoxConfig.java new file mode 100644 index 000000000..d9909818f --- /dev/null +++ b/participant/participant-impl/participant-impl-simulator/src/main/java/org/onap/policy/clamp/acm/participant/simulator/config/SpringFoxConfig.java @@ -0,0 +1,45 @@ +/*- + * ============LICENSE_START======================================================= + * Copyright (C) 2021 Nordix Foundation. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * SPDX-License-Identifier: Apache-2.0 + * ============LICENSE_END========================================================= + */ + +package org.onap.policy.clamp.acm.participant.simulator.config; + +import org.onap.policy.clamp.acm.participant.simulator.simulation.rest.SimulationElementController; +import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.Configuration; +import springfox.documentation.builders.PathSelectors; +import springfox.documentation.builders.RequestHandlerSelectors; +import springfox.documentation.spi.DocumentationType; +import springfox.documentation.spring.web.plugins.Docket; + +@Configuration +public class SpringFoxConfig { + + /** + * Docket Spring Fox Config. + * + * @return Docket + */ + @Bean + public Docket api() { + return new Docket(DocumentationType.SWAGGER_2).select() + .apis(RequestHandlerSelectors.basePackage(SimulationElementController.class.getPackageName())) + .paths(PathSelectors.any()).build(); + } +} diff --git a/participant/participant-impl/participant-impl-simulator/src/main/java/org/onap/policy/clamp/acm/participant/simulator/config/YamlConfiguration.java b/participant/participant-impl/participant-impl-simulator/src/main/java/org/onap/policy/clamp/acm/participant/simulator/config/YamlConfiguration.java new file mode 100644 index 000000000..718697786 --- /dev/null +++ b/participant/participant-impl/participant-impl-simulator/src/main/java/org/onap/policy/clamp/acm/participant/simulator/config/YamlConfiguration.java @@ -0,0 +1,43 @@ +/*- + * ============LICENSE_START======================================================= + * Copyright (C) 2021 Nordix Foundation. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * SPDX-License-Identifier: Apache-2.0 + * ============LICENSE_END========================================================= + */ + +package org.onap.policy.clamp.acm.participant.simulator.config; + +import java.util.List; +import org.onap.policy.clamp.common.acm.rest.CoderHttpMesageConverter; +import org.springframework.context.annotation.Configuration; +import org.springframework.http.MediaType; +import org.springframework.http.converter.HttpMessageConverter; +import org.springframework.http.converter.StringHttpMessageConverter; +import org.springframework.web.servlet.config.annotation.WebMvcConfigurer; + +@Configuration +public class YamlConfiguration implements WebMvcConfigurer { + + @Override + public void extendMessageConverters(List> converters) { + converters.add(new CoderHttpMesageConverter<>("yaml")); + converters.add(new CoderHttpMesageConverter<>("json")); + + StringHttpMessageConverter converter = new StringHttpMessageConverter(); + converter.setSupportedMediaTypes(List.of(MediaType.TEXT_PLAIN)); + converters.add(converter); + } +} diff --git a/participant/participant-impl/participant-impl-simulator/src/main/java/org/onap/policy/clamp/acm/participant/simulator/main/handler/AutomationCompositionElementHandler.java b/participant/participant-impl/participant-impl-simulator/src/main/java/org/onap/policy/clamp/acm/participant/simulator/main/handler/AutomationCompositionElementHandler.java new file mode 100644 index 000000000..9e30c8809 --- /dev/null +++ b/participant/participant-impl/participant-impl-simulator/src/main/java/org/onap/policy/clamp/acm/participant/simulator/main/handler/AutomationCompositionElementHandler.java @@ -0,0 +1,112 @@ +/*- + * ============LICENSE_START======================================================= + * Copyright (C) 2021 Nordix Foundation. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * SPDX-License-Identifier: Apache-2.0 + * ============LICENSE_END========================================================= + */ + +package org.onap.policy.clamp.acm.participant.simulator.main.handler; + +import java.time.Instant; +import java.util.UUID; +import lombok.Setter; +import org.onap.policy.clamp.acm.participant.intermediary.api.AutomationCompositionElementListener; +import org.onap.policy.clamp.acm.participant.intermediary.api.ParticipantIntermediaryApi; +import org.onap.policy.clamp.models.acm.concepts.AcElementStatistics; +import org.onap.policy.clamp.models.acm.concepts.AutomationCompositionElement; +import org.onap.policy.clamp.models.acm.concepts.AutomationCompositionOrderedState; +import org.onap.policy.clamp.models.acm.concepts.AutomationCompositionState; +import org.onap.policy.clamp.models.acm.messages.dmaap.participant.ParticipantMessageType; +import org.onap.policy.models.base.PfModelException; +import org.onap.policy.models.tosca.authorative.concepts.ToscaConceptIdentifier; +import org.onap.policy.models.tosca.authorative.concepts.ToscaNodeTemplate; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.stereotype.Component; + +/** + * This class handles implementation of automationCompositionElement updates. + */ +@Component +public class AutomationCompositionElementHandler implements AutomationCompositionElementListener { + + private static final Logger LOGGER = LoggerFactory.getLogger(AutomationCompositionElementHandler.class); + + @Setter + private ParticipantIntermediaryApi intermediaryApi; + + /** + * Callback method to handle a automation composition element state change. + * + * @param automationCompositionElementId the ID of the automation composition element + * @param currentState the current state of the automation composition element + * @param newState the state to which the automation composition element is changing to + * @throws PfModelException in case of an exception + */ + @Override + public void automationCompositionElementStateChange(ToscaConceptIdentifier automationCompositionId, + UUID automationCompositionElementId, AutomationCompositionState currentState, + AutomationCompositionOrderedState newState) throws PfModelException { + switch (newState) { + case UNINITIALISED: + intermediaryApi.updateAutomationCompositionElementState(automationCompositionId, + automationCompositionElementId, newState, AutomationCompositionState.UNINITIALISED, + ParticipantMessageType.AUTOMATION_COMPOSITION_STATE_CHANGE); + break; + case PASSIVE: + intermediaryApi.updateAutomationCompositionElementState(automationCompositionId, + automationCompositionElementId, newState, AutomationCompositionState.PASSIVE, + ParticipantMessageType.AUTOMATION_COMPOSITION_STATE_CHANGE); + break; + case RUNNING: + intermediaryApi.updateAutomationCompositionElementState(automationCompositionId, + automationCompositionElementId, newState, AutomationCompositionState.RUNNING, + ParticipantMessageType.AUTOMATION_COMPOSITION_STATE_CHANGE); + break; + default: + LOGGER.debug("Unknown orderedstate {}", newState); + break; + } + } + + /** + * Callback method to handle an update on a automation composition element. + * + * @param element the information on the automation composition element + * @param acElementDefinition toscaNodeTemplate + * @throws PfModelException in case of an exception + */ + @Override + public void automationCompositionElementUpdate(ToscaConceptIdentifier automationCompositionId, + AutomationCompositionElement element, ToscaNodeTemplate acElementDefinition) throws PfModelException { + intermediaryApi.updateAutomationCompositionElementState(automationCompositionId, element.getId(), + element.getOrderedState(), AutomationCompositionState.PASSIVE, + ParticipantMessageType.AUTOMATION_COMPOSITION_UPDATE); + } + + @Override + public void handleStatistics(UUID automationCompositionElementId) throws PfModelException { + var acElement = intermediaryApi.getAutomationCompositionElement(automationCompositionElementId); + if (acElement != null) { + var acElementStatistics = new AcElementStatistics(); + acElementStatistics.setState(acElement.getState()); + acElementStatistics.setTimeStamp(Instant.now()); + intermediaryApi.updateAutomationCompositionElementStatistics(automationCompositionElementId, + acElementStatistics); + } + } + +} diff --git a/participant/participant-impl/participant-impl-simulator/src/main/java/org/onap/policy/clamp/acm/participant/simulator/main/parameters/ParticipantSimulatorParameters.java b/participant/participant-impl/participant-impl-simulator/src/main/java/org/onap/policy/clamp/acm/participant/simulator/main/parameters/ParticipantSimulatorParameters.java new file mode 100644 index 000000000..8549e4c7b --- /dev/null +++ b/participant/participant-impl/participant-impl-simulator/src/main/java/org/onap/policy/clamp/acm/participant/simulator/main/parameters/ParticipantSimulatorParameters.java @@ -0,0 +1,45 @@ +/*- + * ============LICENSE_START======================================================= + * Copyright (C) 2021 Nordix Foundation. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * SPDX-License-Identifier: Apache-2.0 + * ============LICENSE_END========================================================= + */ + +package org.onap.policy.clamp.acm.participant.simulator.main.parameters; + +import javax.validation.Valid; +import javax.validation.constraints.NotNull; +import lombok.Getter; +import lombok.Setter; +import org.onap.policy.clamp.acm.participant.intermediary.parameters.ParticipantIntermediaryParameters; +import org.onap.policy.clamp.acm.participant.intermediary.parameters.ParticipantParameters; +import org.springframework.boot.context.properties.ConfigurationProperties; +import org.springframework.validation.annotation.Validated; + +/** + * Class to hold all parameters needed for the participant simulator. + * + */ +@Validated +@Getter +@Setter +@ConfigurationProperties(prefix = "participant") +public class ParticipantSimulatorParameters implements ParticipantParameters { + + @Valid + @NotNull + private ParticipantIntermediaryParameters intermediaryParameters; +} diff --git a/participant/participant-impl/participant-impl-simulator/src/main/java/org/onap/policy/clamp/acm/participant/simulator/main/rest/AbstractRestController.java b/participant/participant-impl/participant-impl-simulator/src/main/java/org/onap/policy/clamp/acm/participant/simulator/main/rest/AbstractRestController.java new file mode 100644 index 000000000..4db07c953 --- /dev/null +++ b/participant/participant-impl/participant-impl-simulator/src/main/java/org/onap/policy/clamp/acm/participant/simulator/main/rest/AbstractRestController.java @@ -0,0 +1,130 @@ +/*- + * ============LICENSE_START======================================================= + * Copyright (C) 2021 Nordix Foundation. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * SPDX-License-Identifier: Apache-2.0 + * ============LICENSE_END========================================================= + */ + +package org.onap.policy.clamp.acm.participant.simulator.main.rest; + +import io.swagger.annotations.Api; +import io.swagger.annotations.BasicAuthDefinition; +import io.swagger.annotations.Info; +import io.swagger.annotations.SecurityDefinition; +import io.swagger.annotations.SwaggerDefinition; +import io.swagger.annotations.Tag; +import java.net.HttpURLConnection; +import java.util.UUID; +import javax.ws.rs.core.MediaType; +import lombok.AccessLevel; +import lombok.Getter; +import org.onap.policy.clamp.acm.participant.simulator.simulation.SimulationProvider; +import org.springframework.http.HttpHeaders; +import org.springframework.web.bind.annotation.RequestMapping; + +/** + * Common superclass to provide REST endpoints for the participant simulator. + */ +// @formatter:off +@RequestMapping( + value = "/v2", + produces = { + MediaType.APPLICATION_JSON, + AbstractRestController.APPLICATION_YAML + } +) +@Api(value = "Participant Simulator API") +@SwaggerDefinition( + info = @Info( + description = "Participant Simulator", + version = "v1.0", + title = "Participant Simulator" + ), + consumes = {MediaType.APPLICATION_JSON, AbstractRestController.APPLICATION_YAML}, + produces = {MediaType.APPLICATION_JSON, AbstractRestController.APPLICATION_YAML}, + schemes = {SwaggerDefinition.Scheme.HTTP, SwaggerDefinition.Scheme.HTTPS}, + tags = { + @Tag(name = "participantsim", description = "Participant Simulator") + }, + securityDefinition = @SecurityDefinition(basicAuthDefinitions = {@BasicAuthDefinition(key = "basicAuth")})) +// @formatter:on +public abstract class AbstractRestController { + public static final String APPLICATION_YAML = "application/yaml"; + + public static final String EXTENSION_NAME = "interface info"; + + public static final String API_VERSION_NAME = "api-version"; + public static final String API_VERSION = "1.0.0"; + + public static final String LAST_MOD_NAME = "last-mod-release"; + public static final String LAST_MOD_RELEASE = "Dublin"; + + public static final String VERSION_MINOR_NAME = "X-MinorVersion"; + public static final String VERSION_MINOR_DESCRIPTION = + "Used to request or communicate a MINOR version back from the client" + + " to the server, and from the server back to the client"; + + public static final String VERSION_PATCH_NAME = "X-PatchVersion"; + public static final String VERSION_PATCH_DESCRIPTION = "Used only to communicate a PATCH version in a response for" + + " troubleshooting purposes only, and will not be provided by" + " the client on request"; + + public static final String VERSION_LATEST_NAME = "X-LatestVersion"; + public static final String VERSION_LATEST_DESCRIPTION = "Used only to communicate an API's latest version"; + + public static final String REQUEST_ID_NAME = "X-ONAP-RequestID"; + public static final String REQUEST_ID_HDR_DESCRIPTION = "Used to track REST transactions for logging purpose"; + public static final String REQUEST_ID_PARAM_DESCRIPTION = "RequestID for http transaction"; + + public static final String AUTHORIZATION_TYPE = "basicAuth"; + + public static final int AUTHENTICATION_ERROR_CODE = HttpURLConnection.HTTP_UNAUTHORIZED; + public static final int AUTHORIZATION_ERROR_CODE = HttpURLConnection.HTTP_FORBIDDEN; + public static final int SERVER_ERROR_CODE = HttpURLConnection.HTTP_INTERNAL_ERROR; + + public static final String AUTHENTICATION_ERROR_MESSAGE = "Authentication Error"; + public static final String AUTHORIZATION_ERROR_MESSAGE = "Authorization Error"; + public static final String SERVER_ERROR_MESSAGE = "Internal Server Error"; + + // The provider for simulation requests + @Getter(AccessLevel.PROTECTED) + private SimulationProvider simulationProvider; + + /** + * create a Rest Controller. + * + * @param simulationProvider the provider for the simulation participant + */ + protected AbstractRestController(SimulationProvider simulationProvider) { + this.simulationProvider = simulationProvider; + } + + /** + * Get the common headers for responses. + * + * @param requestId the request ID + * + * @return the headers + */ + protected HttpHeaders getCommonHeaders(UUID requestId) { + HttpHeaders commonHeaders = new HttpHeaders(); + commonHeaders.add(VERSION_MINOR_NAME, API_VERSION.split("\\.")[1]); + commonHeaders.add(VERSION_PATCH_NAME, API_VERSION.split("\\.")[2]); + commonHeaders.add(VERSION_LATEST_NAME, API_VERSION); + commonHeaders.add(REQUEST_ID_NAME, (requestId != null ? requestId.toString() : null)); + + return commonHeaders; + } +} diff --git a/participant/participant-impl/participant-impl-simulator/src/main/java/org/onap/policy/clamp/acm/participant/simulator/main/rest/GlobalControllerExceptionHandler.java b/participant/participant-impl/participant-impl-simulator/src/main/java/org/onap/policy/clamp/acm/participant/simulator/main/rest/GlobalControllerExceptionHandler.java new file mode 100644 index 000000000..69714137f --- /dev/null +++ b/participant/participant-impl/participant-impl-simulator/src/main/java/org/onap/policy/clamp/acm/participant/simulator/main/rest/GlobalControllerExceptionHandler.java @@ -0,0 +1,45 @@ +/*- + * ============LICENSE_START======================================================= + * Copyright (C) 2021 Nordix Foundation. + * ================================================================================ + * Modifications Copyright (C) 2021 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * SPDX-License-Identifier: Apache-2.0 + * ============LICENSE_END========================================================= + */ + +package org.onap.policy.clamp.acm.participant.simulator.main.rest; + +import org.onap.policy.clamp.common.acm.exception.AutomationCompositionException; +import org.onap.policy.clamp.models.acm.messages.rest.SimpleResponse; +import org.onap.policy.clamp.models.acm.rest.RestUtils; +import org.springframework.http.ResponseEntity; +import org.springframework.web.bind.annotation.ExceptionHandler; +import org.springframework.web.bind.annotation.RestControllerAdvice; + +@RestControllerAdvice +public class GlobalControllerExceptionHandler { + + /** + * Handle AutomationCompositionException. + * + * @param ex AutomationCompositionException + * @return ResponseEntity + */ + @ExceptionHandler(AutomationCompositionException.class) + public ResponseEntity handleBadRequest(AutomationCompositionException ex) { + return RestUtils.toSimpleResponse(ex); + } +} diff --git a/participant/participant-impl/participant-impl-simulator/src/main/java/org/onap/policy/clamp/acm/participant/simulator/main/rest/ParticipantErrorController.java b/participant/participant-impl/participant-impl-simulator/src/main/java/org/onap/policy/clamp/acm/participant/simulator/main/rest/ParticipantErrorController.java new file mode 100644 index 000000000..e32c57254 --- /dev/null +++ b/participant/participant-impl/participant-impl-simulator/src/main/java/org/onap/policy/clamp/acm/participant/simulator/main/rest/ParticipantErrorController.java @@ -0,0 +1,97 @@ +/*- + * ============LICENSE_START======================================================= + * Copyright (C) 2021 Nordix Foundation. + * ================================================================================ + * Modifications Copyright (C) 2021 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * SPDX-License-Identifier: Apache-2.0 + * ============LICENSE_END========================================================= + */ + +package org.onap.policy.clamp.acm.participant.simulator.main.rest; + +import java.util.Map; +import javax.servlet.RequestDispatcher; +import javax.servlet.http.HttpServletRequest; +import org.onap.policy.clamp.models.acm.messages.rest.SimpleResponse; +import org.onap.policy.clamp.models.acm.messages.rest.TypedSimpleResponse; +import org.springframework.beans.factory.annotation.Value; +import org.springframework.boot.web.error.ErrorAttributeOptions; +import org.springframework.boot.web.servlet.error.ErrorAttributes; +import org.springframework.boot.web.servlet.error.ErrorController; +import org.springframework.http.HttpStatus; +import org.springframework.http.MediaType; +import org.springframework.http.ResponseEntity; +import org.springframework.stereotype.Controller; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.context.request.ServletWebRequest; + +@Controller +public class ParticipantErrorController implements ErrorController { + + private final ErrorAttributes errorAttributes; + + @Value("${server.error.path}") + private String path; + + /** + * Constructor. + * + * @param errorAttributes ErrorAttributes + */ + public ParticipantErrorController(ErrorAttributes errorAttributes) { + this.errorAttributes = errorAttributes; + } + + protected HttpStatus getStatus(HttpServletRequest request) { + Integer statusCode = (Integer) request.getAttribute(RequestDispatcher.ERROR_STATUS_CODE); + if (statusCode == null) { + return HttpStatus.INTERNAL_SERVER_ERROR; + } + try { + return HttpStatus.valueOf(statusCode); + } catch (Exception ex) { + return HttpStatus.INTERNAL_SERVER_ERROR; + } + } + + /** + * Handle Errors not handled to GlobalControllerExceptionHandler. + * + * @param request HttpServletRequest + * @return ResponseEntity + */ + @RequestMapping(value = "${server.error.path}", produces = MediaType.APPLICATION_JSON_VALUE) + public ResponseEntity> handleError(HttpServletRequest request) { + Map map = this.errorAttributes.getErrorAttributes(new ServletWebRequest(request), + ErrorAttributeOptions.defaults()); + + var sb = new StringBuilder(); + final Object error = map.get("error"); + if (error != null) { + sb.append(error.toString() + " "); + } + final Object message = map.get("message"); + if (message != null) { + sb.append(message.toString()); + } + + TypedSimpleResponse resp = new TypedSimpleResponse<>(); + resp.setErrorDetails(sb.toString()); + + return ResponseEntity.status(getStatus(request)).body(resp); + + } +} diff --git a/participant/participant-impl/participant-impl-simulator/src/main/java/org/onap/policy/clamp/acm/participant/simulator/main/rest/ParticipantSimulatorAafFilter.java b/participant/participant-impl/participant-impl-simulator/src/main/java/org/onap/policy/clamp/acm/participant/simulator/main/rest/ParticipantSimulatorAafFilter.java new file mode 100644 index 000000000..3008d2d17 --- /dev/null +++ b/participant/participant-impl/participant-impl-simulator/src/main/java/org/onap/policy/clamp/acm/participant/simulator/main/rest/ParticipantSimulatorAafFilter.java @@ -0,0 +1,38 @@ +/*- + * ============LICENSE_START======================================================= + * Copyright (C) 2021 Nordix Foundation. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * SPDX-License-Identifier: Apache-2.0 + * ============LICENSE_END========================================================= + */ + +package org.onap.policy.clamp.acm.participant.simulator.main.rest; + +import org.onap.policy.common.endpoints.http.server.aaf.AafGranularAuthFilter; +import org.onap.policy.common.utils.resources.MessageConstants; + +/** + * Class to manage AAF filters for the participant simulator component. + */ +public class ParticipantSimulatorAafFilter extends AafGranularAuthFilter { + + public static final String AAF_NODETYPE = MessageConstants.POLICY_CLAMP + "-participant-simulator"; + public static final String AAF_ROOT_PERMISSION = DEFAULT_NAMESPACE + "." + AAF_NODETYPE; + + @Override + public String getPermissionTypeRoot() { + return AAF_ROOT_PERMISSION; + } +} diff --git a/participant/participant-impl/participant-impl-simulator/src/main/java/org/onap/policy/clamp/acm/participant/simulator/simulation/SimulationProvider.java b/participant/participant-impl/participant-impl-simulator/src/main/java/org/onap/policy/clamp/acm/participant/simulator/simulation/SimulationProvider.java new file mode 100644 index 000000000..73ae80e29 --- /dev/null +++ b/participant/participant-impl/participant-impl-simulator/src/main/java/org/onap/policy/clamp/acm/participant/simulator/simulation/SimulationProvider.java @@ -0,0 +1,113 @@ +/*- + * ============LICENSE_START======================================================= + * Copyright (C) 2021 Nordix Foundation. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * SPDX-License-Identifier: Apache-2.0 + * ============LICENSE_END========================================================= + */ + +package org.onap.policy.clamp.acm.participant.simulator.simulation; + +import java.util.List; +import java.util.Map; +import java.util.UUID; +import org.onap.policy.clamp.acm.participant.intermediary.api.ParticipantIntermediaryApi; +import org.onap.policy.clamp.common.acm.exception.AutomationCompositionException; +import org.onap.policy.clamp.models.acm.concepts.AutomationCompositionElement; +import org.onap.policy.clamp.models.acm.concepts.AutomationCompositions; +import org.onap.policy.clamp.models.acm.concepts.Participant; +import org.onap.policy.clamp.models.acm.messages.dmaap.participant.ParticipantMessageType; +import org.onap.policy.clamp.models.acm.messages.rest.TypedSimpleResponse; +import org.springframework.stereotype.Service; + +/** + * This provider class simulation of participants and automation composition elements. + */ +@Service +public class SimulationProvider { + + private final ParticipantIntermediaryApi intermediaryApi; + + /** + * Create a participant simulation provider. + * + * @param intermediaryApi the intermediary to use for talking to the CLAMP runtime + */ + public SimulationProvider(ParticipantIntermediaryApi intermediaryApi) { + this.intermediaryApi = intermediaryApi; + } + + /** + * Get the automation compositions. + * + * @param name the automationComposition, null to get all + * @param version the automationComposition, null to get all + * @return the automation compositions + * @throws AutomationCompositionException on errors getting the automation compositions + */ + public AutomationCompositions getAutomationCompositions(String name, String version) + throws AutomationCompositionException { + return intermediaryApi.getAutomationCompositions(name, version); + } + + /** + * Get the simulated automation composition elements. + * + * @param name the automationCompositionElement, null to get all + * @param version the automationCompositionElement, null to get all + * @return the automation composition elements + */ + public Map getAutomationCompositionElements(String name, String version) { + return intermediaryApi.getAutomationCompositionElements(name, version); + } + + /** + * Update the given automation composition element in the simulator. + * + * @param element the automation composition element to update + * @return response simple response returned + */ + public TypedSimpleResponse updateAutomationCompositionElement( + AutomationCompositionElement element) { + TypedSimpleResponse response = new TypedSimpleResponse<>(); + response.setResponse(intermediaryApi.updateAutomationCompositionElementState(null, element.getId(), + element.getOrderedState(), element.getState(), ParticipantMessageType.AUTOMATION_COMPOSITION_STATE_CHANGE)); + return response; + } + + /** + * Get the current simulated participants. + * + * @param name the participant, null to get all + * @param version the participant, null to get all + * @return the list of participants + */ + public List getParticipants(String name, String version) { + return intermediaryApi.getParticipants(name, version); + } + + /** + * Update a simulated participant. + * + * @param participant the participant to update + * @return TypedSimpleResponse simple response + */ + public TypedSimpleResponse updateParticipant(Participant participant) { + TypedSimpleResponse response = new TypedSimpleResponse<>(); + response.setResponse( + intermediaryApi.updateParticipantState(participant.getDefinition(), participant.getParticipantState())); + return response; + } +} diff --git a/participant/participant-impl/participant-impl-simulator/src/main/java/org/onap/policy/clamp/acm/participant/simulator/simulation/rest/SimulationElementController.java b/participant/participant-impl/participant-impl-simulator/src/main/java/org/onap/policy/clamp/acm/participant/simulator/simulation/rest/SimulationElementController.java new file mode 100644 index 000000000..277638220 --- /dev/null +++ b/participant/participant-impl/participant-impl-simulator/src/main/java/org/onap/policy/clamp/acm/participant/simulator/simulation/rest/SimulationElementController.java @@ -0,0 +1,188 @@ +/*- + * ============LICENSE_START======================================================= + * Copyright (C) 2021 Nordix Foundation. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * SPDX-License-Identifier: Apache-2.0 + * ============LICENSE_END========================================================= + */ + +package org.onap.policy.clamp.acm.participant.simulator.simulation.rest; + +import io.swagger.annotations.ApiOperation; +import io.swagger.annotations.ApiParam; +import io.swagger.annotations.ApiResponse; +import io.swagger.annotations.ApiResponses; +import io.swagger.annotations.Authorization; +import io.swagger.annotations.Extension; +import io.swagger.annotations.ExtensionProperty; +import io.swagger.annotations.ResponseHeader; +import java.util.Map; +import java.util.UUID; +import org.onap.policy.clamp.acm.participant.simulator.main.rest.AbstractRestController; +import org.onap.policy.clamp.acm.participant.simulator.simulation.SimulationProvider; +import org.onap.policy.clamp.models.acm.concepts.AutomationCompositionElement; +import org.onap.policy.clamp.models.acm.concepts.AutomationCompositions; +import org.onap.policy.clamp.models.acm.messages.rest.TypedSimpleResponse; +import org.springframework.http.ResponseEntity; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.PathVariable; +import org.springframework.web.bind.annotation.PutMapping; +import org.springframework.web.bind.annotation.RequestBody; +import org.springframework.web.bind.annotation.RequestHeader; +import org.springframework.web.bind.annotation.RestController; + +/** + * Class to provide REST end points for participant simulator to query/update details of automationCompositionElements. + */ +@RestController +public class SimulationElementController extends AbstractRestController { + + /** + * Constructor. + * + * @param simulationProvider the Simulation Provider + */ + public SimulationElementController(SimulationProvider simulationProvider) { + super(simulationProvider); + } + + /** + * Queries details of all automation composition element within the simulator. + * + * @param requestId request ID used in ONAP logging + * @param name the name of the Automation Composition element to get, null to get all + * @param version the version of the Automation Composition element to get, null to get all + * @return the automation composition elements + */ + // @formatter:off + @GetMapping("/elements/{name}/{version}") + @ApiOperation( + value = "Query details of the requested simulated automation composition elements", + notes = "Queries details of the requested simulated automation composition elements, " + + "returning all automation composition element details", + response = AutomationCompositions.class, + tags = { + "Clamp Automation Composition Participant Simulator API" + }, + authorizations = @Authorization(value = AUTHORIZATION_TYPE), + responseHeaders = { + @ResponseHeader( + name = VERSION_MINOR_NAME, description = VERSION_MINOR_DESCRIPTION, + response = String.class), + @ResponseHeader(name = VERSION_PATCH_NAME, description = VERSION_PATCH_DESCRIPTION, + response = String.class), + @ResponseHeader(name = VERSION_LATEST_NAME, description = VERSION_LATEST_DESCRIPTION, + response = String.class), + @ResponseHeader(name = REQUEST_ID_NAME, description = REQUEST_ID_HDR_DESCRIPTION, + response = UUID.class)}, + extensions = { + @Extension + ( + name = EXTENSION_NAME, + properties = { + @ExtensionProperty(name = API_VERSION_NAME, value = API_VERSION), + @ExtensionProperty(name = LAST_MOD_NAME, value = LAST_MOD_RELEASE) + } + ) + } + ) + @ApiResponses( + value = { + @ApiResponse(code = AUTHENTICATION_ERROR_CODE, message = AUTHENTICATION_ERROR_MESSAGE), + @ApiResponse(code = AUTHORIZATION_ERROR_CODE, message = AUTHORIZATION_ERROR_MESSAGE), + @ApiResponse(code = SERVER_ERROR_CODE, message = SERVER_ERROR_MESSAGE) + } + ) + // @formatter:on + public ResponseEntity> elements( + @RequestHeader(name = REQUEST_ID_NAME, required = false) @ApiParam(REQUEST_ID_PARAM_DESCRIPTION) UUID requestId, + @ApiParam(value = "Automation composition element name", required = true) @PathVariable("name") String name, + @ApiParam( + value = "Automation composition element version", + required = true) @PathVariable("version") String version) { + + return ResponseEntity + .ok() + .headers(super.getCommonHeaders(requestId)) + .body(getSimulationProvider().getAutomationCompositionElements(name, version)); + } + + /** + * Updates a automation composition element in the simulator. + * + * @param requestId request ID used in ONAP logging + * @param body the body of a automation composition element + * @return a response + */ + // @formatter:off + @PutMapping("/elements") + @ApiOperation( + value = "Updates simulated automation composition elements", + notes = "Updates simulated automation composition elements, " + + "returning the updated automation composition definition IDs", + response = TypedSimpleResponse.class, + tags = { + "Clamp Automation Composition Participant Simulator API" + }, + authorizations = @Authorization(value = AUTHORIZATION_TYPE), + responseHeaders = { + @ResponseHeader( + name = VERSION_MINOR_NAME, + description = VERSION_MINOR_DESCRIPTION, + response = String.class), + @ResponseHeader( + name = VERSION_PATCH_NAME, + description = VERSION_PATCH_DESCRIPTION, + response = String.class), + @ResponseHeader( + name = VERSION_LATEST_NAME, + description = VERSION_LATEST_DESCRIPTION, + response = String.class), + @ResponseHeader( + name = REQUEST_ID_NAME, + description = REQUEST_ID_HDR_DESCRIPTION, + response = UUID.class) + }, + extensions = { + @Extension + ( + name = EXTENSION_NAME, + properties = { + @ExtensionProperty(name = API_VERSION_NAME, value = API_VERSION), + @ExtensionProperty(name = LAST_MOD_NAME, value = LAST_MOD_RELEASE) + } + ) + } + ) + @ApiResponses( + value = { + @ApiResponse(code = AUTHENTICATION_ERROR_CODE, message = AUTHENTICATION_ERROR_MESSAGE), + @ApiResponse(code = AUTHORIZATION_ERROR_CODE, message = AUTHORIZATION_ERROR_MESSAGE), + @ApiResponse(code = SERVER_ERROR_CODE, message = SERVER_ERROR_MESSAGE) + } + ) + // @formatter:on + public ResponseEntity> update( + @RequestHeader(name = REQUEST_ID_NAME, required = false) @ApiParam(REQUEST_ID_PARAM_DESCRIPTION) UUID requestId, + @ApiParam( + value = "Body of a automation composition element", + required = true) @RequestBody AutomationCompositionElement body) { + + return ResponseEntity + .ok() + .headers(super.getCommonHeaders(requestId)) + .body(getSimulationProvider().updateAutomationCompositionElement(body)); + } +} diff --git a/participant/participant-impl/participant-impl-simulator/src/main/java/org/onap/policy/clamp/acm/participant/simulator/simulation/rest/SimulationParticipantController.java b/participant/participant-impl/participant-impl-simulator/src/main/java/org/onap/policy/clamp/acm/participant/simulator/simulation/rest/SimulationParticipantController.java new file mode 100644 index 000000000..02e56aa6e --- /dev/null +++ b/participant/participant-impl/participant-impl-simulator/src/main/java/org/onap/policy/clamp/acm/participant/simulator/simulation/rest/SimulationParticipantController.java @@ -0,0 +1,181 @@ +/*- + * ============LICENSE_START======================================================= + * Copyright (C) 2021 Nordix Foundation. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * SPDX-License-Identifier: Apache-2.0 + * ============LICENSE_END========================================================= + */ + +package org.onap.policy.clamp.acm.participant.simulator.simulation.rest; + +import io.swagger.annotations.ApiOperation; +import io.swagger.annotations.ApiParam; +import io.swagger.annotations.ApiResponse; +import io.swagger.annotations.ApiResponses; +import io.swagger.annotations.Authorization; +import io.swagger.annotations.Extension; +import io.swagger.annotations.ExtensionProperty; +import io.swagger.annotations.ResponseHeader; +import java.util.List; +import java.util.UUID; +import org.onap.policy.clamp.acm.participant.simulator.main.rest.AbstractRestController; +import org.onap.policy.clamp.acm.participant.simulator.simulation.SimulationProvider; +import org.onap.policy.clamp.models.acm.concepts.Participant; +import org.onap.policy.clamp.models.acm.messages.rest.TypedSimpleResponse; +import org.springframework.http.ResponseEntity; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.PathVariable; +import org.springframework.web.bind.annotation.PutMapping; +import org.springframework.web.bind.annotation.RequestBody; +import org.springframework.web.bind.annotation.RequestHeader; +import org.springframework.web.bind.annotation.RestController; + +/** + * Class to provide REST end points for participant simulator to query/update details of all participants. + */ +@RestController +public class SimulationParticipantController extends AbstractRestController { + + /** + * Constructor. + * + * @param simulationProvider the Simulation Provider + */ + public SimulationParticipantController(SimulationProvider simulationProvider) { + super(simulationProvider); + } + + /** + * Queries details of all participants within the simulator. + * + * @param requestId request ID used in ONAP logging + * @param name the name of the participant to get, null to get all + * @param version the version of the participant to get, null to get all + * @return the participants + */ + // @formatter:off + @GetMapping("/participants/{name}/{version}") + @ApiOperation(value = "Query details of the requested simulated participants", + notes = "Queries details of the requested simulated participants, " + + "returning all participant details", + response = List.class, + tags = { + "Clamp Automation Composition Participant Simulator API" + }, + authorizations = @Authorization(value = AUTHORIZATION_TYPE), + responseHeaders = { + @ResponseHeader( + name = VERSION_MINOR_NAME, description = VERSION_MINOR_DESCRIPTION, + response = String.class), + @ResponseHeader(name = VERSION_PATCH_NAME, description = VERSION_PATCH_DESCRIPTION, + response = String.class), + @ResponseHeader(name = VERSION_LATEST_NAME, description = VERSION_LATEST_DESCRIPTION, + response = String.class), + @ResponseHeader(name = REQUEST_ID_NAME, description = REQUEST_ID_HDR_DESCRIPTION, + response = UUID.class)}, + extensions = { + @Extension + ( + name = EXTENSION_NAME, + properties = { + @ExtensionProperty(name = API_VERSION_NAME, value = API_VERSION), + @ExtensionProperty(name = LAST_MOD_NAME, value = LAST_MOD_RELEASE) + } + ) + } + ) + @ApiResponses( + value = { + @ApiResponse(code = AUTHENTICATION_ERROR_CODE, message = AUTHENTICATION_ERROR_MESSAGE), + @ApiResponse(code = AUTHORIZATION_ERROR_CODE, message = AUTHORIZATION_ERROR_MESSAGE), + @ApiResponse(code = SERVER_ERROR_CODE, message = SERVER_ERROR_MESSAGE) + } + ) + // @formatter:on + public ResponseEntity> participants( + @RequestHeader(name = REQUEST_ID_NAME, required = false) @ApiParam(REQUEST_ID_PARAM_DESCRIPTION) UUID requestId, + @ApiParam(value = "Participant name", required = true) @PathVariable("name") String name, + @ApiParam(value = "Participant version", required = true) @PathVariable("version") String version) { + + return ResponseEntity + .ok() + .headers(super.getCommonHeaders(requestId)) + .body(getSimulationProvider().getParticipants(name, version)); + } + + /** + * Updates a participant in the simulator. + * + * @param requestId request ID used in ONAP logging + * @param body the body of a participant + * @return a response + */ + // @formatter:off + @PutMapping("/participants") + @ApiOperation( + value = "Updates simulated participants", + notes = "Updates simulated participants, returning the updated automation composition definition IDs", + response = TypedSimpleResponse.class, + tags = { + "Clamp Automation Composition Participant Simulator API" + }, + authorizations = @Authorization(value = AUTHORIZATION_TYPE), + responseHeaders = { + @ResponseHeader( + name = VERSION_MINOR_NAME, + description = VERSION_MINOR_DESCRIPTION, + response = String.class), + @ResponseHeader( + name = VERSION_PATCH_NAME, + description = VERSION_PATCH_DESCRIPTION, + response = String.class), + @ResponseHeader( + name = VERSION_LATEST_NAME, + description = VERSION_LATEST_DESCRIPTION, + response = String.class), + @ResponseHeader( + name = REQUEST_ID_NAME, + description = REQUEST_ID_HDR_DESCRIPTION, + response = UUID.class) + }, + extensions = { + @Extension + ( + name = EXTENSION_NAME, + properties = { + @ExtensionProperty(name = API_VERSION_NAME, value = API_VERSION), + @ExtensionProperty(name = LAST_MOD_NAME, value = LAST_MOD_RELEASE) + } + ) + } + ) + @ApiResponses( + value = { + @ApiResponse(code = AUTHENTICATION_ERROR_CODE, message = AUTHENTICATION_ERROR_MESSAGE), + @ApiResponse(code = AUTHORIZATION_ERROR_CODE, message = AUTHORIZATION_ERROR_MESSAGE), + @ApiResponse(code = SERVER_ERROR_CODE, message = SERVER_ERROR_MESSAGE) + } + ) + // @formatter:on + public ResponseEntity> update( + @RequestHeader(name = REQUEST_ID_NAME, required = false) @ApiParam(REQUEST_ID_PARAM_DESCRIPTION) UUID requestId, + @ApiParam(value = "Body of a participant", required = true) @RequestBody Participant body) { + + return ResponseEntity + .ok() + .headers(super.getCommonHeaders(requestId)) + .body(getSimulationProvider().updateParticipant(body)); + } +} diff --git a/participant/participant-impl/participant-impl-simulator/src/main/java/org/onap/policy/clamp/controlloop/participant/simulator/ParticipantSimulatorApplication.java b/participant/participant-impl/participant-impl-simulator/src/main/java/org/onap/policy/clamp/controlloop/participant/simulator/ParticipantSimulatorApplication.java deleted file mode 100644 index 5e72d9479..000000000 --- a/participant/participant-impl/participant-impl-simulator/src/main/java/org/onap/policy/clamp/controlloop/participant/simulator/ParticipantSimulatorApplication.java +++ /dev/null @@ -1,46 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * Copyright (C) 2021 Nordix Foundation. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - * SPDX-License-Identifier: Apache-2.0 - * ============LICENSE_END========================================================= - */ - -package org.onap.policy.clamp.controlloop.participant.simulator; - -import org.springframework.boot.SpringApplication; -import org.springframework.boot.autoconfigure.SpringBootApplication; -import org.springframework.boot.context.properties.ConfigurationPropertiesScan; -import org.springframework.context.annotation.ComponentScan; - -/** - * Starter. - * - */ -// @formatter:off -@SpringBootApplication -@ConfigurationPropertiesScan("org.onap.policy.clamp.controlloop.participant.simulator.main.parameters") -@ComponentScan({ - "org.onap.policy.clamp.controlloop.participant.simulator", - "org.onap.policy.clamp.controlloop.participant.intermediary", - "org.onap.policy.clamp.controlloop.common.rest" -}) -//@formatter:on -public class ParticipantSimulatorApplication { - - public static void main(String[] args) { - SpringApplication.run(ParticipantSimulatorApplication.class, args); - } -} diff --git a/participant/participant-impl/participant-impl-simulator/src/main/java/org/onap/policy/clamp/controlloop/participant/simulator/config/AafConfiguration.java b/participant/participant-impl/participant-impl-simulator/src/main/java/org/onap/policy/clamp/controlloop/participant/simulator/config/AafConfiguration.java deleted file mode 100644 index c8922a1f5..000000000 --- a/participant/participant-impl/participant-impl-simulator/src/main/java/org/onap/policy/clamp/controlloop/participant/simulator/config/AafConfiguration.java +++ /dev/null @@ -1,46 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * ONAP CLAMP - * ================================================================================ - * Copyright (C) 2017-2018 AT&T Intellectual Property. All rights - * reserved. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============LICENSE_END============================================ - * =================================================================== - * - */ - -package org.onap.policy.clamp.controlloop.participant.simulator.config; - -import javax.servlet.Filter; -import org.onap.policy.clamp.controlloop.participant.simulator.main.rest.ParticipantSimulatorAafFilter; -import org.springframework.context.annotation.Bean; -import org.springframework.context.annotation.Configuration; -import org.springframework.context.annotation.Profile; - -@Configuration -@Profile("clamp-aaf-authentication") -public class AafConfiguration { - - /** - * Method to return Aaf filter. - * - * @return Filter - */ - @Bean - public Filter aafFilter() { - return new ParticipantSimulatorAafFilter(); - } - -} diff --git a/participant/participant-impl/participant-impl-simulator/src/main/java/org/onap/policy/clamp/controlloop/participant/simulator/config/ParticipantConfig.java b/participant/participant-impl/participant-impl-simulator/src/main/java/org/onap/policy/clamp/controlloop/participant/simulator/config/ParticipantConfig.java deleted file mode 100644 index f2079edf5..000000000 --- a/participant/participant-impl/participant-impl-simulator/src/main/java/org/onap/policy/clamp/controlloop/participant/simulator/config/ParticipantConfig.java +++ /dev/null @@ -1,61 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * Copyright (C) 2021 Nordix Foundation. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - * SPDX-License-Identifier: Apache-2.0 - * ============LICENSE_END========================================================= - */ - -package org.onap.policy.clamp.controlloop.participant.simulator.config; - -import org.onap.policy.clamp.controlloop.common.rest.RequestResponseLoggingFilter; -import org.onap.policy.clamp.controlloop.participant.intermediary.api.ParticipantIntermediaryApi; -import org.onap.policy.clamp.controlloop.participant.simulator.main.handler.ControlLoopElementHandler; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.boot.web.servlet.FilterRegistrationBean; -import org.springframework.context.annotation.Bean; -import org.springframework.context.annotation.Configuration; - -@Configuration -public class ParticipantConfig { - - /** - * logging Filter configuration. - * - * @return FilterRegistrationBean - */ - @Bean - public FilterRegistrationBean loggingFilter() { - FilterRegistrationBean registrationBean = new FilterRegistrationBean<>(); - - registrationBean.setFilter(new RequestResponseLoggingFilter()); - registrationBean.addUrlPatterns("/onap/participantsim/v2/*"); - - return registrationBean; - } - - /** - * Register ControlLoopElementListener. - * - * @param intermediaryApi the ParticipantIntermediaryApi - * @param clElementHandler the ControlLoop Element Handler - */ - @Autowired - public void registerControlLoopElementListener(ParticipantIntermediaryApi intermediaryApi, - ControlLoopElementHandler clElementHandler) { - intermediaryApi.registerControlLoopElementListener(clElementHandler); - clElementHandler.setIntermediaryApi(intermediaryApi); - } -} diff --git a/participant/participant-impl/participant-impl-simulator/src/main/java/org/onap/policy/clamp/controlloop/participant/simulator/config/SecurityConfig.java b/participant/participant-impl/participant-impl-simulator/src/main/java/org/onap/policy/clamp/controlloop/participant/simulator/config/SecurityConfig.java deleted file mode 100644 index cdfd5eac3..000000000 --- a/participant/participant-impl/participant-impl-simulator/src/main/java/org/onap/policy/clamp/controlloop/participant/simulator/config/SecurityConfig.java +++ /dev/null @@ -1,39 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * Copyright (C) 2021 Nordix Foundation. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - * SPDX-License-Identifier: Apache-2.0 - * ============LICENSE_END========================================================= - */ - -package org.onap.policy.clamp.controlloop.participant.simulator.config; - -import org.springframework.context.annotation.Configuration; -import org.springframework.security.config.annotation.web.builders.HttpSecurity; -import org.springframework.security.config.annotation.web.configuration.WebSecurityConfigurerAdapter; - -@Configuration -public class SecurityConfig extends WebSecurityConfigurerAdapter { - - @Override - protected void configure(HttpSecurity http) throws Exception { - // @formatter:off - http.authorizeRequests() - .antMatchers().authenticated() - .anyRequest().authenticated() - .and().httpBasic().and().csrf().disable(); - // @formatter:on - } -} diff --git a/participant/participant-impl/participant-impl-simulator/src/main/java/org/onap/policy/clamp/controlloop/participant/simulator/config/SpringFoxConfig.java b/participant/participant-impl/participant-impl-simulator/src/main/java/org/onap/policy/clamp/controlloop/participant/simulator/config/SpringFoxConfig.java deleted file mode 100644 index bf776140b..000000000 --- a/participant/participant-impl/participant-impl-simulator/src/main/java/org/onap/policy/clamp/controlloop/participant/simulator/config/SpringFoxConfig.java +++ /dev/null @@ -1,45 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * Copyright (C) 2021 Nordix Foundation. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - * SPDX-License-Identifier: Apache-2.0 - * ============LICENSE_END========================================================= - */ - -package org.onap.policy.clamp.controlloop.participant.simulator.config; - -import org.onap.policy.clamp.controlloop.participant.simulator.simulation.rest.SimulationElementController; -import org.springframework.context.annotation.Bean; -import org.springframework.context.annotation.Configuration; -import springfox.documentation.builders.PathSelectors; -import springfox.documentation.builders.RequestHandlerSelectors; -import springfox.documentation.spi.DocumentationType; -import springfox.documentation.spring.web.plugins.Docket; - -@Configuration -public class SpringFoxConfig { - - /** - * Docket Spring Fox Config. - * - * @return Docket - */ - @Bean - public Docket api() { - return new Docket(DocumentationType.SWAGGER_2).select() - .apis(RequestHandlerSelectors.basePackage(SimulationElementController.class.getPackageName())) - .paths(PathSelectors.any()).build(); - } -} diff --git a/participant/participant-impl/participant-impl-simulator/src/main/java/org/onap/policy/clamp/controlloop/participant/simulator/config/YamlConfiguration.java b/participant/participant-impl/participant-impl-simulator/src/main/java/org/onap/policy/clamp/controlloop/participant/simulator/config/YamlConfiguration.java deleted file mode 100644 index 28dd2f9bc..000000000 --- a/participant/participant-impl/participant-impl-simulator/src/main/java/org/onap/policy/clamp/controlloop/participant/simulator/config/YamlConfiguration.java +++ /dev/null @@ -1,43 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * Copyright (C) 2021 Nordix Foundation. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - * SPDX-License-Identifier: Apache-2.0 - * ============LICENSE_END========================================================= - */ - -package org.onap.policy.clamp.controlloop.participant.simulator.config; - -import java.util.List; -import org.onap.policy.clamp.controlloop.common.rest.CoderHttpMesageConverter; -import org.springframework.context.annotation.Configuration; -import org.springframework.http.MediaType; -import org.springframework.http.converter.HttpMessageConverter; -import org.springframework.http.converter.StringHttpMessageConverter; -import org.springframework.web.servlet.config.annotation.WebMvcConfigurer; - -@Configuration -public class YamlConfiguration implements WebMvcConfigurer { - - @Override - public void extendMessageConverters(List> converters) { - converters.add(new CoderHttpMesageConverter<>("yaml")); - converters.add(new CoderHttpMesageConverter<>("json")); - - StringHttpMessageConverter converter = new StringHttpMessageConverter(); - converter.setSupportedMediaTypes(List.of(MediaType.TEXT_PLAIN)); - converters.add(converter); - } -} diff --git a/participant/participant-impl/participant-impl-simulator/src/main/java/org/onap/policy/clamp/controlloop/participant/simulator/main/handler/ControlLoopElementHandler.java b/participant/participant-impl/participant-impl-simulator/src/main/java/org/onap/policy/clamp/controlloop/participant/simulator/main/handler/ControlLoopElementHandler.java deleted file mode 100644 index fd46faf97..000000000 --- a/participant/participant-impl/participant-impl-simulator/src/main/java/org/onap/policy/clamp/controlloop/participant/simulator/main/handler/ControlLoopElementHandler.java +++ /dev/null @@ -1,111 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * Copyright (C) 2021 Nordix Foundation. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - * SPDX-License-Identifier: Apache-2.0 - * ============LICENSE_END========================================================= - */ - -package org.onap.policy.clamp.controlloop.participant.simulator.main.handler; - -import java.time.Instant; -import java.util.UUID; -import lombok.Setter; -import org.onap.policy.clamp.controlloop.models.controlloop.concepts.ClElementStatistics; -import org.onap.policy.clamp.controlloop.models.controlloop.concepts.ControlLoopElement; -import org.onap.policy.clamp.controlloop.models.controlloop.concepts.ControlLoopOrderedState; -import org.onap.policy.clamp.controlloop.models.controlloop.concepts.ControlLoopState; -import org.onap.policy.clamp.controlloop.models.messages.dmaap.participant.ParticipantMessageType; -import org.onap.policy.clamp.controlloop.participant.intermediary.api.ControlLoopElementListener; -import org.onap.policy.clamp.controlloop.participant.intermediary.api.ParticipantIntermediaryApi; -import org.onap.policy.models.base.PfModelException; -import org.onap.policy.models.tosca.authorative.concepts.ToscaConceptIdentifier; -import org.onap.policy.models.tosca.authorative.concepts.ToscaNodeTemplate; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; -import org.springframework.stereotype.Component; - -/** - * This class handles implementation of controlLoopElement updates. - */ -@Component -public class ControlLoopElementHandler implements ControlLoopElementListener { - - private static final Logger LOGGER = LoggerFactory.getLogger(ControlLoopElementHandler.class); - - @Setter - private ParticipantIntermediaryApi intermediaryApi; - - /** - * Callback method to handle a control loop element state change. - * - * @param controlLoopElementId the ID of the control loop element - * @param currentState the current state of the control loop element - * @param newState the state to which the control loop element is changing to - * @throws PfModelException in case of an exception - */ - @Override - public void controlLoopElementStateChange(ToscaConceptIdentifier controlLoopId, - UUID controlLoopElementId, ControlLoopState currentState, - ControlLoopOrderedState newState) throws PfModelException { - switch (newState) { - case UNINITIALISED: - intermediaryApi.updateControlLoopElementState(controlLoopId, - controlLoopElementId, newState, ControlLoopState.UNINITIALISED, - ParticipantMessageType.CONTROL_LOOP_STATE_CHANGE); - break; - case PASSIVE: - intermediaryApi.updateControlLoopElementState(controlLoopId, - controlLoopElementId, newState, ControlLoopState.PASSIVE, - ParticipantMessageType.CONTROL_LOOP_STATE_CHANGE); - break; - case RUNNING: - intermediaryApi.updateControlLoopElementState(controlLoopId, - controlLoopElementId, newState, ControlLoopState.RUNNING, - ParticipantMessageType.CONTROL_LOOP_STATE_CHANGE); - break; - default: - LOGGER.debug("Unknown orderedstate {}", newState); - break; - } - } - - /** - * Callback method to handle an update on a control loop element. - * - * @param element the information on the control loop element - * @param clElementDefinition toscaNodeTemplate - * @throws PfModelException in case of an exception - */ - @Override - public void controlLoopElementUpdate(ToscaConceptIdentifier controlLoopId, ControlLoopElement element, - ToscaNodeTemplate clElementDefinition) - throws PfModelException { - intermediaryApi.updateControlLoopElementState(controlLoopId, element.getId(), element.getOrderedState(), - ControlLoopState.PASSIVE, ParticipantMessageType.CONTROL_LOOP_UPDATE); - } - - @Override - public void handleStatistics(UUID controlLoopElementId) throws PfModelException { - var clElement = intermediaryApi.getControlLoopElement(controlLoopElementId); - if (clElement != null) { - var clElementStatistics = new ClElementStatistics(); - clElementStatistics.setControlLoopState(clElement.getState()); - clElementStatistics.setTimeStamp(Instant.now()); - intermediaryApi.updateControlLoopElementStatistics(controlLoopElementId, clElementStatistics); - } - } - -} diff --git a/participant/participant-impl/participant-impl-simulator/src/main/java/org/onap/policy/clamp/controlloop/participant/simulator/main/parameters/ParticipantSimulatorParameters.java b/participant/participant-impl/participant-impl-simulator/src/main/java/org/onap/policy/clamp/controlloop/participant/simulator/main/parameters/ParticipantSimulatorParameters.java deleted file mode 100644 index 99579006c..000000000 --- a/participant/participant-impl/participant-impl-simulator/src/main/java/org/onap/policy/clamp/controlloop/participant/simulator/main/parameters/ParticipantSimulatorParameters.java +++ /dev/null @@ -1,45 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * Copyright (C) 2021 Nordix Foundation. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - * SPDX-License-Identifier: Apache-2.0 - * ============LICENSE_END========================================================= - */ - -package org.onap.policy.clamp.controlloop.participant.simulator.main.parameters; - -import javax.validation.Valid; -import javax.validation.constraints.NotNull; -import lombok.Getter; -import lombok.Setter; -import org.onap.policy.clamp.controlloop.participant.intermediary.parameters.ParticipantIntermediaryParameters; -import org.onap.policy.clamp.controlloop.participant.intermediary.parameters.ParticipantParameters; -import org.springframework.boot.context.properties.ConfigurationProperties; -import org.springframework.validation.annotation.Validated; - -/** - * Class to hold all parameters needed for the participant simulator. - * - */ -@Validated -@Getter -@Setter -@ConfigurationProperties(prefix = "participant") -public class ParticipantSimulatorParameters implements ParticipantParameters { - - @Valid - @NotNull - private ParticipantIntermediaryParameters intermediaryParameters; -} diff --git a/participant/participant-impl/participant-impl-simulator/src/main/java/org/onap/policy/clamp/controlloop/participant/simulator/main/rest/AbstractRestController.java b/participant/participant-impl/participant-impl-simulator/src/main/java/org/onap/policy/clamp/controlloop/participant/simulator/main/rest/AbstractRestController.java deleted file mode 100644 index 5a6dbfa81..000000000 --- a/participant/participant-impl/participant-impl-simulator/src/main/java/org/onap/policy/clamp/controlloop/participant/simulator/main/rest/AbstractRestController.java +++ /dev/null @@ -1,102 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * Copyright (C) 2021 Nordix Foundation. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - * SPDX-License-Identifier: Apache-2.0 - * ============LICENSE_END========================================================= - */ - -package org.onap.policy.clamp.controlloop.participant.simulator.main.rest; - -import io.swagger.annotations.Api; -import io.swagger.annotations.BasicAuthDefinition; -import io.swagger.annotations.Info; -import io.swagger.annotations.SecurityDefinition; -import io.swagger.annotations.SwaggerDefinition; -import io.swagger.annotations.Tag; -import java.net.HttpURLConnection; -import javax.ws.rs.core.MediaType; -import lombok.AccessLevel; -import lombok.Getter; -import org.onap.policy.clamp.controlloop.participant.simulator.simulation.SimulationProvider; -import org.springframework.web.bind.annotation.RequestMapping; - -/** - * Common superclass to provide REST endpoints for the participant simulator. - */ -// @formatter:off -@RequestMapping(value = "/v2", produces = {MediaType.APPLICATION_JSON, AbstractRestController.APPLICATION_YAML}) -@Api(value = "Participant Simulator API") -@SwaggerDefinition( - info = @Info(description = - "Participant Simulator", version = "v1.0", - title = "Participant Simulator"), - consumes = {MediaType.APPLICATION_JSON, AbstractRestController.APPLICATION_YAML}, - produces = {MediaType.APPLICATION_JSON, AbstractRestController.APPLICATION_YAML}, - schemes = {SwaggerDefinition.Scheme.HTTP, SwaggerDefinition.Scheme.HTTPS}, - tags = {@Tag(name = "participantsim", description = "Participant Simulator")}, - securityDefinition = @SecurityDefinition(basicAuthDefinitions = {@BasicAuthDefinition(key = "basicAuth")})) -// @formatter:on -public abstract class AbstractRestController { - public static final String APPLICATION_YAML = "application/yaml"; - - public static final String EXTENSION_NAME = "interface info"; - - public static final String API_VERSION_NAME = "api-version"; - public static final String API_VERSION = "1.0.0"; - - public static final String LAST_MOD_NAME = "last-mod-release"; - public static final String LAST_MOD_RELEASE = "Dublin"; - - public static final String VERSION_MINOR_NAME = "X-MinorVersion"; - public static final String VERSION_MINOR_DESCRIPTION = - "Used to request or communicate a MINOR version back from the client" - + " to the server, and from the server back to the client"; - - public static final String VERSION_PATCH_NAME = "X-PatchVersion"; - public static final String VERSION_PATCH_DESCRIPTION = "Used only to communicate a PATCH version in a response for" - + " troubleshooting purposes only, and will not be provided by" + " the client on request"; - - public static final String VERSION_LATEST_NAME = "X-LatestVersion"; - public static final String VERSION_LATEST_DESCRIPTION = "Used only to communicate an API's latest version"; - - public static final String REQUEST_ID_NAME = "X-ONAP-RequestID"; - public static final String REQUEST_ID_HDR_DESCRIPTION = "Used to track REST transactions for logging purpose"; - public static final String REQUEST_ID_PARAM_DESCRIPTION = "RequestID for http transaction"; - - public static final String AUTHORIZATION_TYPE = "basicAuth"; - - public static final int AUTHENTICATION_ERROR_CODE = HttpURLConnection.HTTP_UNAUTHORIZED; - public static final int AUTHORIZATION_ERROR_CODE = HttpURLConnection.HTTP_FORBIDDEN; - public static final int SERVER_ERROR_CODE = HttpURLConnection.HTTP_INTERNAL_ERROR; - - public static final String AUTHENTICATION_ERROR_MESSAGE = "Authentication Error"; - public static final String AUTHORIZATION_ERROR_MESSAGE = "Authorization Error"; - public static final String SERVER_ERROR_MESSAGE = "Internal Server Error"; - - @Getter(AccessLevel.PROTECTED) - // The provider for simulation requests - private SimulationProvider simulationProvider; - - /** - * create a Rest Controller. - * - * @param simulationProvider the provider for the simulation participant - */ - protected AbstractRestController(SimulationProvider simulationProvider) { - this.simulationProvider = simulationProvider; - } - -} diff --git a/participant/participant-impl/participant-impl-simulator/src/main/java/org/onap/policy/clamp/controlloop/participant/simulator/main/rest/GlobalControllerExceptionHandler.java b/participant/participant-impl/participant-impl-simulator/src/main/java/org/onap/policy/clamp/controlloop/participant/simulator/main/rest/GlobalControllerExceptionHandler.java deleted file mode 100644 index 8648c253e..000000000 --- a/participant/participant-impl/participant-impl-simulator/src/main/java/org/onap/policy/clamp/controlloop/participant/simulator/main/rest/GlobalControllerExceptionHandler.java +++ /dev/null @@ -1,45 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * Copyright (C) 2021 Nordix Foundation. - * ================================================================================ - * Modifications Copyright (C) 2021 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - * SPDX-License-Identifier: Apache-2.0 - * ============LICENSE_END========================================================= - */ - -package org.onap.policy.clamp.controlloop.participant.simulator.main.rest; - -import org.onap.policy.clamp.controlloop.common.exception.ControlLoopException; -import org.onap.policy.clamp.controlloop.models.messages.rest.SimpleResponse; -import org.onap.policy.clamp.controlloop.models.rest.RestUtils; -import org.springframework.http.ResponseEntity; -import org.springframework.web.bind.annotation.ExceptionHandler; -import org.springframework.web.bind.annotation.RestControllerAdvice; - -@RestControllerAdvice -public class GlobalControllerExceptionHandler { - - /** - * Handle ControlLoopException. - * - * @param ex ControlLoopException - * @return ResponseEntity - */ - @ExceptionHandler(ControlLoopException.class) - public ResponseEntity handleBadRequest(ControlLoopException ex) { - return RestUtils.toSimpleResponse(ex); - } -} diff --git a/participant/participant-impl/participant-impl-simulator/src/main/java/org/onap/policy/clamp/controlloop/participant/simulator/main/rest/ParticipantErrorController.java b/participant/participant-impl/participant-impl-simulator/src/main/java/org/onap/policy/clamp/controlloop/participant/simulator/main/rest/ParticipantErrorController.java deleted file mode 100644 index 75546196a..000000000 --- a/participant/participant-impl/participant-impl-simulator/src/main/java/org/onap/policy/clamp/controlloop/participant/simulator/main/rest/ParticipantErrorController.java +++ /dev/null @@ -1,97 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * Copyright (C) 2021 Nordix Foundation. - * ================================================================================ - * Modifications Copyright (C) 2021 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - * SPDX-License-Identifier: Apache-2.0 - * ============LICENSE_END========================================================= - */ - -package org.onap.policy.clamp.controlloop.participant.simulator.main.rest; - -import java.util.Map; -import javax.servlet.RequestDispatcher; -import javax.servlet.http.HttpServletRequest; -import org.onap.policy.clamp.controlloop.models.messages.rest.SimpleResponse; -import org.onap.policy.clamp.controlloop.models.messages.rest.TypedSimpleResponse; -import org.springframework.beans.factory.annotation.Value; -import org.springframework.boot.web.error.ErrorAttributeOptions; -import org.springframework.boot.web.servlet.error.ErrorAttributes; -import org.springframework.boot.web.servlet.error.ErrorController; -import org.springframework.http.HttpStatus; -import org.springframework.http.MediaType; -import org.springframework.http.ResponseEntity; -import org.springframework.stereotype.Controller; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.context.request.ServletWebRequest; - -@Controller -public class ParticipantErrorController implements ErrorController { - - private final ErrorAttributes errorAttributes; - - @Value("${server.error.path}") - private String path; - - /** - * Constructor. - * - * @param errorAttributes ErrorAttributes - */ - public ParticipantErrorController(ErrorAttributes errorAttributes) { - this.errorAttributes = errorAttributes; - } - - protected HttpStatus getStatus(HttpServletRequest request) { - Integer statusCode = (Integer) request.getAttribute(RequestDispatcher.ERROR_STATUS_CODE); - if (statusCode == null) { - return HttpStatus.INTERNAL_SERVER_ERROR; - } - try { - return HttpStatus.valueOf(statusCode); - } catch (Exception ex) { - return HttpStatus.INTERNAL_SERVER_ERROR; - } - } - - /** - * Handle Errors not handled to GlobalControllerExceptionHandler. - * - * @param request HttpServletRequest - * @return ResponseEntity - */ - @RequestMapping(value = "${server.error.path}", produces = MediaType.APPLICATION_JSON_VALUE) - public ResponseEntity> handleError(HttpServletRequest request) { - Map map = this.errorAttributes.getErrorAttributes(new ServletWebRequest(request), - ErrorAttributeOptions.defaults()); - - var sb = new StringBuilder(); - final Object error = map.get("error"); - if (error != null) { - sb.append(error.toString() + " "); - } - final Object message = map.get("message"); - if (message != null) { - sb.append(message.toString()); - } - - TypedSimpleResponse resp = new TypedSimpleResponse<>(); - resp.setErrorDetails(sb.toString()); - - return ResponseEntity.status(getStatus(request)).body(resp); - - } -} diff --git a/participant/participant-impl/participant-impl-simulator/src/main/java/org/onap/policy/clamp/controlloop/participant/simulator/main/rest/ParticipantSimulatorAafFilter.java b/participant/participant-impl/participant-impl-simulator/src/main/java/org/onap/policy/clamp/controlloop/participant/simulator/main/rest/ParticipantSimulatorAafFilter.java deleted file mode 100644 index f200f975a..000000000 --- a/participant/participant-impl/participant-impl-simulator/src/main/java/org/onap/policy/clamp/controlloop/participant/simulator/main/rest/ParticipantSimulatorAafFilter.java +++ /dev/null @@ -1,38 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * Copyright (C) 2021 Nordix Foundation. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - * SPDX-License-Identifier: Apache-2.0 - * ============LICENSE_END========================================================= - */ - -package org.onap.policy.clamp.controlloop.participant.simulator.main.rest; - -import org.onap.policy.common.endpoints.http.server.aaf.AafGranularAuthFilter; -import org.onap.policy.common.utils.resources.MessageConstants; - -/** - * Class to manage AAF filters for the participant simulator component. - */ -public class ParticipantSimulatorAafFilter extends AafGranularAuthFilter { - - public static final String AAF_NODETYPE = MessageConstants.POLICY_CLAMP + "-participant-simulator"; - public static final String AAF_ROOT_PERMISSION = DEFAULT_NAMESPACE + "." + AAF_NODETYPE; - - @Override - public String getPermissionTypeRoot() { - return AAF_ROOT_PERMISSION; - } -} diff --git a/participant/participant-impl/participant-impl-simulator/src/main/java/org/onap/policy/clamp/controlloop/participant/simulator/simulation/SimulationProvider.java b/participant/participant-impl/participant-impl-simulator/src/main/java/org/onap/policy/clamp/controlloop/participant/simulator/simulation/SimulationProvider.java deleted file mode 100644 index 688f7df6b..000000000 --- a/participant/participant-impl/participant-impl-simulator/src/main/java/org/onap/policy/clamp/controlloop/participant/simulator/simulation/SimulationProvider.java +++ /dev/null @@ -1,110 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * Copyright (C) 2021 Nordix Foundation. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - * SPDX-License-Identifier: Apache-2.0 - * ============LICENSE_END========================================================= - */ - -package org.onap.policy.clamp.controlloop.participant.simulator.simulation; - -import java.util.List; -import java.util.Map; -import java.util.UUID; -import org.onap.policy.clamp.controlloop.common.exception.ControlLoopException; -import org.onap.policy.clamp.controlloop.models.controlloop.concepts.ControlLoopElement; -import org.onap.policy.clamp.controlloop.models.controlloop.concepts.ControlLoops; -import org.onap.policy.clamp.controlloop.models.controlloop.concepts.Participant; -import org.onap.policy.clamp.controlloop.models.messages.dmaap.participant.ParticipantMessageType; -import org.onap.policy.clamp.controlloop.models.messages.rest.TypedSimpleResponse; -import org.onap.policy.clamp.controlloop.participant.intermediary.api.ParticipantIntermediaryApi; -import org.springframework.stereotype.Service; - -/** - * This provider class simulation of participants and control loop elements. - */ -@Service -public class SimulationProvider { - - private final ParticipantIntermediaryApi intermediaryApi; - - /** - * Create a participant simulation provider. - * @param intermediaryApi the intermediary to use for talking to the CLAMP runtime - */ - public SimulationProvider(ParticipantIntermediaryApi intermediaryApi) { - this.intermediaryApi = intermediaryApi; - } - - /** - * Get the control loops. - * - * @param name the controlLoop, null to get all - * @param version the controlLoop, null to get all - * @return the control loops - * @throws ControlLoopException on errors getting the control loops - */ - public ControlLoops getControlLoops(String name, String version) throws ControlLoopException { - return intermediaryApi.getControlLoops(name, version); - } - - /** - * Get the simulated control loop elements. - * - * @param name the controlLoopElement, null to get all - * @param version the controlLoopElement, null to get all - * @return the control loop elements - */ - public Map getControlLoopElements(String name, String version) { - return intermediaryApi.getControlLoopElements(name, version); - } - - /** - * Update the given control loop element in the simulator. - * - * @param element the control loop element to update - * @return response simple response returned - */ - public TypedSimpleResponse updateControlLoopElement(ControlLoopElement element) { - TypedSimpleResponse response = new TypedSimpleResponse<>(); - response.setResponse(intermediaryApi.updateControlLoopElementState(null, element.getId(), - element.getOrderedState(), element.getState(), ParticipantMessageType.CONTROL_LOOP_STATE_CHANGE)); - return response; - } - - /** - * Get the current simulated participants. - * - * @param name the participant, null to get all - * @param version the participant, null to get all - * @return the list of participants - */ - public List getParticipants(String name, String version) { - return intermediaryApi.getParticipants(name, version); - } - - /** - * Update a simulated participant. - * - * @param participant the participant to update - * @return TypedSimpleResponse simple response - */ - public TypedSimpleResponse updateParticipant(Participant participant) { - TypedSimpleResponse response = new TypedSimpleResponse<>(); - response.setResponse( - intermediaryApi.updateParticipantState(participant.getDefinition(), participant.getParticipantState())); - return response; - } -} diff --git a/participant/participant-impl/participant-impl-simulator/src/main/java/org/onap/policy/clamp/controlloop/participant/simulator/simulation/rest/SimulationElementController.java b/participant/participant-impl/participant-impl-simulator/src/main/java/org/onap/policy/clamp/controlloop/participant/simulator/simulation/rest/SimulationElementController.java deleted file mode 100644 index e0569cf0f..000000000 --- a/participant/participant-impl/participant-impl-simulator/src/main/java/org/onap/policy/clamp/controlloop/participant/simulator/simulation/rest/SimulationElementController.java +++ /dev/null @@ -1,183 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * Copyright (C) 2021 Nordix Foundation. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - * SPDX-License-Identifier: Apache-2.0 - * ============LICENSE_END========================================================= - */ - -package org.onap.policy.clamp.controlloop.participant.simulator.simulation.rest; - -import io.swagger.annotations.ApiOperation; -import io.swagger.annotations.ApiParam; -import io.swagger.annotations.ApiResponse; -import io.swagger.annotations.ApiResponses; -import io.swagger.annotations.Authorization; -import io.swagger.annotations.Extension; -import io.swagger.annotations.ExtensionProperty; -import io.swagger.annotations.ResponseHeader; -import java.util.Map; -import java.util.UUID; -import org.onap.policy.clamp.controlloop.models.controlloop.concepts.ControlLoopElement; -import org.onap.policy.clamp.controlloop.models.controlloop.concepts.ControlLoops; -import org.onap.policy.clamp.controlloop.models.messages.rest.TypedSimpleResponse; -import org.onap.policy.clamp.controlloop.participant.simulator.main.rest.AbstractRestController; -import org.onap.policy.clamp.controlloop.participant.simulator.simulation.SimulationProvider; -import org.springframework.http.ResponseEntity; -import org.springframework.web.bind.annotation.GetMapping; -import org.springframework.web.bind.annotation.PathVariable; -import org.springframework.web.bind.annotation.PutMapping; -import org.springframework.web.bind.annotation.RequestBody; -import org.springframework.web.bind.annotation.RequestHeader; -import org.springframework.web.bind.annotation.RestController; - -/** - * Class to provide REST end points for participant simulator to query/update details of controlLoopElements. - */ -@RestController -public class SimulationElementController extends AbstractRestController { - - /** - * Constructor. - * - * @param simulationProvider the Simulation Provider - */ - public SimulationElementController(SimulationProvider simulationProvider) { - super(simulationProvider); - } - - /** - * Queries details of all control loop element within the simulator. - * - * @param requestId request ID used in ONAP logging - * @param name the name of the Control Loop element to get, null to get all - * @param version the version of the Control Loop element to get, null to get all - * @return the control loop elements - */ - // @formatter:off - @GetMapping("/elements/{name}/{version}") - @ApiOperation( - value = "Query details of the requested simulated control loop elements", - notes = "Queries details of the requested simulated control loop elements, " - + "returning all control loop element details", - response = ControlLoops.class, - tags = { - "Clamp Control Loop Participant Simulator API" - }, - authorizations = @Authorization(value = AUTHORIZATION_TYPE), - responseHeaders = { - @ResponseHeader( - name = VERSION_MINOR_NAME, description = VERSION_MINOR_DESCRIPTION, - response = String.class), - @ResponseHeader(name = VERSION_PATCH_NAME, description = VERSION_PATCH_DESCRIPTION, - response = String.class), - @ResponseHeader(name = VERSION_LATEST_NAME, description = VERSION_LATEST_DESCRIPTION, - response = String.class), - @ResponseHeader(name = REQUEST_ID_NAME, description = REQUEST_ID_HDR_DESCRIPTION, - response = UUID.class)}, - extensions = { - @Extension - ( - name = EXTENSION_NAME, - properties = { - @ExtensionProperty(name = API_VERSION_NAME, value = API_VERSION), - @ExtensionProperty(name = LAST_MOD_NAME, value = LAST_MOD_RELEASE) - } - ) - } - ) - @ApiResponses( - value = { - @ApiResponse(code = AUTHENTICATION_ERROR_CODE, message = AUTHENTICATION_ERROR_MESSAGE), - @ApiResponse(code = AUTHORIZATION_ERROR_CODE, message = AUTHORIZATION_ERROR_MESSAGE), - @ApiResponse(code = SERVER_ERROR_CODE, message = SERVER_ERROR_MESSAGE) - } - ) - // @formatter:on - public ResponseEntity> elements( - @RequestHeader( - name = REQUEST_ID_NAME, - required = false) @ApiParam(REQUEST_ID_PARAM_DESCRIPTION) UUID requestId, - @ApiParam(value = "Control loop element name", required = true) @PathVariable("name") String name, - @ApiParam( - value = "Control loop element version", - required = true) @PathVariable("version") String version) { - - return ResponseEntity.ok().body(getSimulationProvider().getControlLoopElements(name, version)); - } - - /** - * Updates a control loop element in the simulator. - * - * @param requestId request ID used in ONAP logging - * @param body the body of a control loop element - * @return a response - */ - // @formatter:off - @PutMapping("/elements") - @ApiOperation( - value = "Updates simulated control loop elements", - notes = "Updates simulated control loop elements, returning the updated control loop definition IDs", - response = TypedSimpleResponse.class, - tags = { - "Clamp Control Loop Participant Simulator API" - }, - authorizations = @Authorization(value = AUTHORIZATION_TYPE), - responseHeaders = { - @ResponseHeader( - name = VERSION_MINOR_NAME, - description = VERSION_MINOR_DESCRIPTION, - response = String.class), - @ResponseHeader( - name = VERSION_PATCH_NAME, - description = VERSION_PATCH_DESCRIPTION, - response = String.class), - @ResponseHeader( - name = VERSION_LATEST_NAME, - description = VERSION_LATEST_DESCRIPTION, - response = String.class), - @ResponseHeader( - name = REQUEST_ID_NAME, - description = REQUEST_ID_HDR_DESCRIPTION, - response = UUID.class) - }, - extensions = { - @Extension - ( - name = EXTENSION_NAME, - properties = { - @ExtensionProperty(name = API_VERSION_NAME, value = API_VERSION), - @ExtensionProperty(name = LAST_MOD_NAME, value = LAST_MOD_RELEASE) - } - ) - } - ) - @ApiResponses( - value = { - @ApiResponse(code = AUTHENTICATION_ERROR_CODE, message = AUTHENTICATION_ERROR_MESSAGE), - @ApiResponse(code = AUTHORIZATION_ERROR_CODE, message = AUTHORIZATION_ERROR_MESSAGE), - @ApiResponse(code = SERVER_ERROR_CODE, message = SERVER_ERROR_MESSAGE) - } - ) - // @formatter:on - public ResponseEntity> update( - @RequestHeader( - name = REQUEST_ID_NAME, - required = false) @ApiParam(REQUEST_ID_PARAM_DESCRIPTION) UUID requestId, - @ApiParam(value = "Body of a control loop element", required = true) @RequestBody ControlLoopElement body) { - - return ResponseEntity.ok().body(getSimulationProvider().updateControlLoopElement(body)); - } -} diff --git a/participant/participant-impl/participant-impl-simulator/src/main/java/org/onap/policy/clamp/controlloop/participant/simulator/simulation/rest/SimulationParticipantController.java b/participant/participant-impl/participant-impl-simulator/src/main/java/org/onap/policy/clamp/controlloop/participant/simulator/simulation/rest/SimulationParticipantController.java deleted file mode 100644 index 25ae4ac22..000000000 --- a/participant/participant-impl/participant-impl-simulator/src/main/java/org/onap/policy/clamp/controlloop/participant/simulator/simulation/rest/SimulationParticipantController.java +++ /dev/null @@ -1,175 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * Copyright (C) 2021 Nordix Foundation. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - * SPDX-License-Identifier: Apache-2.0 - * ============LICENSE_END========================================================= - */ - -package org.onap.policy.clamp.controlloop.participant.simulator.simulation.rest; - -import io.swagger.annotations.ApiOperation; -import io.swagger.annotations.ApiParam; -import io.swagger.annotations.ApiResponse; -import io.swagger.annotations.ApiResponses; -import io.swagger.annotations.Authorization; -import io.swagger.annotations.Extension; -import io.swagger.annotations.ExtensionProperty; -import io.swagger.annotations.ResponseHeader; -import java.util.List; -import java.util.UUID; -import org.onap.policy.clamp.controlloop.models.controlloop.concepts.Participant; -import org.onap.policy.clamp.controlloop.models.messages.rest.TypedSimpleResponse; -import org.onap.policy.clamp.controlloop.participant.simulator.main.rest.AbstractRestController; -import org.onap.policy.clamp.controlloop.participant.simulator.simulation.SimulationProvider; -import org.springframework.http.ResponseEntity; -import org.springframework.web.bind.annotation.GetMapping; -import org.springframework.web.bind.annotation.PathVariable; -import org.springframework.web.bind.annotation.PutMapping; -import org.springframework.web.bind.annotation.RequestBody; -import org.springframework.web.bind.annotation.RequestHeader; -import org.springframework.web.bind.annotation.RestController; - -/** - * Class to provide REST end points for participant simulator to query/update details of all participants. - */ -@RestController -public class SimulationParticipantController extends AbstractRestController { - - /** - * Constructor. - * - * @param simulationProvider the Simulation Provider - */ - public SimulationParticipantController(SimulationProvider simulationProvider) { - super(simulationProvider); - } - - /** - * Queries details of all participants within the simulator. - * - * @param requestId request ID used in ONAP logging - * @param name the name of the participant to get, null to get all - * @param version the version of the participant to get, null to get all - * @return the participants - */ - // @formatter:off - @GetMapping("/participants/{name}/{version}") - @ApiOperation(value = "Query details of the requested simulated participants", - notes = "Queries details of the requested simulated participants, " - + "returning all participant details", - response = List.class, - tags = { - "Clamp Control Loop Participant Simulator API" - }, - authorizations = @Authorization(value = AUTHORIZATION_TYPE), - responseHeaders = { - @ResponseHeader( - name = VERSION_MINOR_NAME, description = VERSION_MINOR_DESCRIPTION, - response = String.class), - @ResponseHeader(name = VERSION_PATCH_NAME, description = VERSION_PATCH_DESCRIPTION, - response = String.class), - @ResponseHeader(name = VERSION_LATEST_NAME, description = VERSION_LATEST_DESCRIPTION, - response = String.class), - @ResponseHeader(name = REQUEST_ID_NAME, description = REQUEST_ID_HDR_DESCRIPTION, - response = UUID.class)}, - extensions = { - @Extension - ( - name = EXTENSION_NAME, - properties = { - @ExtensionProperty(name = API_VERSION_NAME, value = API_VERSION), - @ExtensionProperty(name = LAST_MOD_NAME, value = LAST_MOD_RELEASE) - } - ) - } - ) - @ApiResponses( - value = { - @ApiResponse(code = AUTHENTICATION_ERROR_CODE, message = AUTHENTICATION_ERROR_MESSAGE), - @ApiResponse(code = AUTHORIZATION_ERROR_CODE, message = AUTHORIZATION_ERROR_MESSAGE), - @ApiResponse(code = SERVER_ERROR_CODE, message = SERVER_ERROR_MESSAGE) - } - ) - // @formatter:on - public ResponseEntity> participants( - @RequestHeader(name = REQUEST_ID_NAME, required = false) @ApiParam(REQUEST_ID_PARAM_DESCRIPTION) UUID requestId, - @ApiParam(value = "Participant name", required = true) @PathVariable("name") String name, - @ApiParam(value = "Participant version", required = true) @PathVariable("version") String version) { - - return ResponseEntity.ok().body(getSimulationProvider().getParticipants(name, version)); - } - - /** - * Updates a participant in the simulator. - * - * @param requestId request ID used in ONAP logging - * @param body the body of a participant - * @return a response - */ - // @formatter:off - @PutMapping("/participants") - @ApiOperation( - value = "Updates simulated participants", - notes = "Updates simulated participants, returning the updated control loop definition IDs", - response = TypedSimpleResponse.class, - tags = { - "Clamp Control Loop Participant Simulator API" - }, - authorizations = @Authorization(value = AUTHORIZATION_TYPE), - responseHeaders = { - @ResponseHeader( - name = VERSION_MINOR_NAME, - description = VERSION_MINOR_DESCRIPTION, - response = String.class), - @ResponseHeader( - name = VERSION_PATCH_NAME, - description = VERSION_PATCH_DESCRIPTION, - response = String.class), - @ResponseHeader( - name = VERSION_LATEST_NAME, - description = VERSION_LATEST_DESCRIPTION, - response = String.class), - @ResponseHeader( - name = REQUEST_ID_NAME, - description = REQUEST_ID_HDR_DESCRIPTION, - response = UUID.class) - }, - extensions = { - @Extension - ( - name = EXTENSION_NAME, - properties = { - @ExtensionProperty(name = API_VERSION_NAME, value = API_VERSION), - @ExtensionProperty(name = LAST_MOD_NAME, value = LAST_MOD_RELEASE) - } - ) - } - ) - @ApiResponses( - value = { - @ApiResponse(code = AUTHENTICATION_ERROR_CODE, message = AUTHENTICATION_ERROR_MESSAGE), - @ApiResponse(code = AUTHORIZATION_ERROR_CODE, message = AUTHORIZATION_ERROR_MESSAGE), - @ApiResponse(code = SERVER_ERROR_CODE, message = SERVER_ERROR_MESSAGE) - } - ) - // @formatter:on - public ResponseEntity> update( - @RequestHeader(name = REQUEST_ID_NAME, required = false) @ApiParam(REQUEST_ID_PARAM_DESCRIPTION) UUID requestId, - @ApiParam(value = "Body of a participant", required = true) @RequestBody Participant body) { - - return ResponseEntity.ok().body(getSimulationProvider().updateParticipant(body)); - } -} diff --git a/participant/participant-impl/participant-impl-simulator/src/main/resources/config/application.yaml b/participant/participant-impl/participant-impl-simulator/src/main/resources/config/application.yaml index d750d46d2..e20f0ebf5 100644 --- a/participant/participant-impl/participant-impl-simulator/src/main/resources/config/application.yaml +++ b/participant/participant-impl/participant-impl-simulator/src/main/resources/config/application.yaml @@ -21,17 +21,17 @@ participant: participantType: name: org.onap.PM_CDS_Blueprint version: 1.0.0 - clampControlLoopTopics: + clampAutomationCompositionTopics: topicSources: - - topic: POLICY-CLRUNTIME-PARTICIPANT + topic: POLICY-ACRUNTIME-PARTICIPANT servers: - ${topicServer:localhost} topicCommInfrastructure: dmaap fetchTimeout: 15000 topicSinks: - - topic: POLICY-CLRUNTIME-PARTICIPANT + topic: POLICY-ACRUNTIME-PARTICIPANT servers: - ${topicServer:localhost} topicCommInfrastructure: dmaap diff --git a/participant/participant-impl/participant-impl-simulator/src/main/resources/version.txt b/participant/participant-impl/participant-impl-simulator/src/main/resources/version.txt index dbd67585f..5fcdcab5a 100644 --- a/participant/participant-impl/participant-impl-simulator/src/main/resources/version.txt +++ b/participant/participant-impl/participant-impl-simulator/src/main/resources/version.txt @@ -1,4 +1,4 @@ -ONAP Tosca defined control loop Participant +ONAP Tosca defined automation composition Participant Version: ${project.version} Built (UTC): ${maven.build.timestamp} ONAP https://wiki.onap.org diff --git a/participant/participant-impl/participant-impl-simulator/src/test/java/org/onap/policy/clamp/acm/participant/simulator/endtoend/ParticipantSimulatorTest.java b/participant/participant-impl/participant-impl-simulator/src/test/java/org/onap/policy/clamp/acm/participant/simulator/endtoend/ParticipantSimulatorTest.java new file mode 100644 index 000000000..de6855d03 --- /dev/null +++ b/participant/participant-impl/participant-impl-simulator/src/test/java/org/onap/policy/clamp/acm/participant/simulator/endtoend/ParticipantSimulatorTest.java @@ -0,0 +1,288 @@ +/*- + * ============LICENSE_START======================================================= + * Copyright (C) 2021 Nordix Foundation. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * SPDX-License-Identifier: Apache-2.0 + * ============LICENSE_END========================================================= + */ + +package org.onap.policy.clamp.acm.participant.simulator.endtoend; + +import static org.assertj.core.api.Assertions.assertThat; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertNotNull; +import static org.junit.jupiter.api.Assertions.assertTrue; + +import java.util.List; +import java.util.Map; +import java.util.UUID; +import javax.ws.rs.client.Client; +import javax.ws.rs.client.ClientBuilder; +import javax.ws.rs.client.Entity; +import javax.ws.rs.client.Invocation; +import javax.ws.rs.client.WebTarget; +import javax.ws.rs.core.GenericType; +import javax.ws.rs.core.MediaType; +import javax.ws.rs.core.MultivaluedMap; +import javax.ws.rs.core.Response; +import org.glassfish.jersey.client.ClientProperties; +import org.glassfish.jersey.client.authentication.HttpAuthenticationFeature; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.ExtendWith; +import org.onap.policy.clamp.acm.participant.intermediary.api.ParticipantIntermediaryApi; +import org.onap.policy.clamp.acm.participant.intermediary.comm.AutomationCompositionUpdateListener; +import org.onap.policy.clamp.acm.participant.intermediary.handler.ParticipantHandler; +import org.onap.policy.clamp.acm.participant.simulator.main.parameters.CommonTestData; +import org.onap.policy.clamp.acm.participant.simulator.main.rest.AbstractRestController; +import org.onap.policy.clamp.acm.participant.simulator.main.rest.TestListenerUtils; +import org.onap.policy.clamp.models.acm.concepts.AutomationComposition; +import org.onap.policy.clamp.models.acm.concepts.AutomationCompositionElement; +import org.onap.policy.clamp.models.acm.concepts.AutomationCompositionOrderedState; +import org.onap.policy.clamp.models.acm.concepts.Participant; +import org.onap.policy.clamp.models.acm.concepts.ParticipantState; +import org.onap.policy.clamp.models.acm.messages.dmaap.participant.AutomationCompositionUpdate; +import org.onap.policy.clamp.models.acm.messages.rest.TypedSimpleResponse; +import org.onap.policy.common.endpoints.event.comm.Topic.CommInfrastructure; +import org.onap.policy.common.gson.GsonMessageBodyHandler; +import org.onap.policy.models.tosca.authorative.concepts.ToscaConceptIdentifier; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.beans.factory.annotation.Value; +import org.springframework.boot.test.context.SpringBootTest; +import org.springframework.boot.test.context.SpringBootTest.WebEnvironment; +import org.springframework.boot.web.server.LocalServerPort; +import org.springframework.test.context.TestPropertySource; +import org.springframework.test.context.junit.jupiter.SpringExtension; + +@ExtendWith(SpringExtension.class) +@SpringBootTest(webEnvironment = WebEnvironment.RANDOM_PORT) +@TestPropertySource(locations = {"classpath:application_test.properties"}) +class ParticipantSimulatorTest { + + private static final String PARTICIPANTS_ENDPOINT = "participants"; + private static final String ELEMENTS_ENDPOINT = "elements"; + private static final CommInfrastructure INFRA = CommInfrastructure.NOOP; + private static final String TOPIC = "my-topic"; + + @Value("${spring.security.user.name}") + private String user; + + @Value("${spring.security.user.password}") + private String password; + + @LocalServerPort + private int randomServerPort; + + @Autowired + private ParticipantIntermediaryApi participantIntermediaryApi; + + @Autowired + private ParticipantHandler participantHandler; + + private static final Object lockit = new Object(); + private boolean check = false; + + private void setUp() throws Exception { + synchronized (lockit) { + if (!check) { + check = true; + AutomationCompositionUpdateListener acUpdateListener = + new AutomationCompositionUpdateListener(participantHandler); + + AutomationCompositionUpdate automationCompositionUpdateMsg = + TestListenerUtils.createAutomationCompositionUpdateMsg(); + acUpdateListener.onTopicEvent(INFRA, TOPIC, null, automationCompositionUpdateMsg); + + } + } + } + + private String getPath(String path) { + return "http://localhost:" + randomServerPort + "/onap/participantsim/v2/" + path; + } + + void testSwagger(String endPoint) { + final Client client = ClientBuilder.newBuilder().build(); + + client.property(ClientProperties.METAINF_SERVICES_LOOKUP_DISABLE, "true"); + client.register(GsonMessageBodyHandler.class); + client.register(HttpAuthenticationFeature.basic(user, password)); + + final WebTarget webTarget = client.target(getPath("api-docs")); + + Response response = webTarget.request(MediaType.APPLICATION_JSON).get(); + + assertThat(response.getStatus()).isEqualTo(200); + assertTrue(response.readEntity(String.class).contains("/onap/participantsim/v2/" + endPoint)); + } + + @Test + void testEndParticipatsSwagger() { + testSwagger(PARTICIPANTS_ENDPOINT); + } + + @Test + void testElementsSwagger() { + testSwagger(ELEMENTS_ENDPOINT); + } + + @Test + void testProducerYaml() { + final Client client = ClientBuilder.newBuilder().build(); + + client.property(ClientProperties.METAINF_SERVICES_LOOKUP_DISABLE, "true"); + client.register(GsonMessageBodyHandler.class); + client.register(HttpAuthenticationFeature.basic(user, password)); + + String path = getPath(PARTICIPANTS_ENDPOINT + "/org.onap.PM_CDS_Blueprint/1"); + final WebTarget webTarget = client.target(path); + + Response response = webTarget.request("application/yaml").get(); + + assertThat(response.getStatus()).isEqualTo(200); + } + + @Test + void testQuery_Unauthorized() throws Exception { + String path = PARTICIPANTS_ENDPOINT + "/org.onap.PM_CDS_Blueprint/1"; + + Response response = performRequest(path, true, null).get(); + assertThat(response.getStatus()).isEqualTo(200); + + // unauthorized call + response = performRequest(path, false, null).get(); + assertThat(response.getStatus()).isEqualTo(401); + } + + private Invocation.Builder performRequest(String endpoint, boolean includeAuth, UUID uuid) { + final Client client = ClientBuilder.newBuilder().build(); + + client.property(ClientProperties.METAINF_SERVICES_LOOKUP_DISABLE, "true"); + client.register(GsonMessageBodyHandler.class); + if (includeAuth) { + client.register(HttpAuthenticationFeature.basic(user, password)); + } + Invocation.Builder builder = client.target(getPath(endpoint)).request(MediaType.APPLICATION_JSON); + if (uuid != null) { + builder = builder.header(AbstractRestController.REQUEST_ID_NAME, uuid.toString()); + } + return builder; + } + + private Response performGet(String endpoint, UUID uuid) throws Exception { + return performRequest(endpoint, true, uuid).get(); + } + + @Test + void testQueryParticipants() throws Exception { + Participant participant = new Participant(); + ToscaConceptIdentifier participantId = CommonTestData.getParticipantId(); + participant.setDefinition(participantId); + participant.setName(participantId.getName()); + participant.setVersion(participantId.getVersion()); + UUID uuid = UUID.randomUUID(); + + // GET REST call for querying the participants + Response response = performGet( + PARTICIPANTS_ENDPOINT + "/" + participant.getKey().getName() + "/" + participant.getKey().getVersion(), + uuid); + checkResponseEntity(response, 200, uuid); + + Participant[] returnValue = response.readEntity(Participant[].class); + assertThat(returnValue).hasSize(1); + // Verify the result of GET participants with what is stored + assertEquals(participant.getDefinition(), returnValue[0].getDefinition()); + } + + private void checkResponseEntity(Response response, int status, UUID uuid) { + assertThat(response.getStatus()).isEqualTo(status); + assertThat(getHeader(response.getHeaders(), AbstractRestController.VERSION_MINOR_NAME)).isEqualTo("0"); + assertThat(getHeader(response.getHeaders(), AbstractRestController.VERSION_PATCH_NAME)).isEqualTo("0"); + assertThat(getHeader(response.getHeaders(), AbstractRestController.VERSION_LATEST_NAME)).isEqualTo("1.0.0"); + assertThat(getHeader(response.getHeaders(), AbstractRestController.REQUEST_ID_NAME)).isEqualTo(uuid.toString()); + } + + private String getHeader(MultivaluedMap httpHeaders, String param) { + List list = httpHeaders.get(param); + assertThat(list).hasSize(1); + assertThat(list.get(0)).isNotNull(); + return (String) list.get(0); + } + + @Test + void testQueryAutomationCompositionElements() throws Exception { + setUp(); + UUID uuid = UUID.randomUUID(); + ToscaConceptIdentifier participantId = CommonTestData.getParticipantId(); + + // GET REST call for querying the automationComposition elements + Response response = + performGet(ELEMENTS_ENDPOINT + "/" + participantId.getName() + "/" + participantId.getVersion(), uuid); + checkResponseEntity(response, 200, uuid); + + Map returnValue = response.readEntity(Map.class); + // Verify the result of GET automation composition elements with what is stored + assertThat(returnValue).isEmpty(); + } + + private Response performPut(String endpoint, final Entity entity, UUID uuid) throws Exception { + return performRequest(endpoint, true, uuid).put(entity); + } + + @Test + void testUpdateParticipant() throws Exception { + setUp(); + List participants = participantIntermediaryApi.getParticipants( + CommonTestData.getParticipantId().getName(), CommonTestData.getParticipantId().getVersion()); + assertEquals(ParticipantState.UNKNOWN, participants.get(0).getParticipantState()); + // Change the state of the participant to PASSIVE from UNKNOWN + participants.get(0).setParticipantState(ParticipantState.PASSIVE); + UUID uuid = UUID.randomUUID(); + + // PUT REST call for updating Participant + Response response = performPut(PARTICIPANTS_ENDPOINT, Entity.json(participants.get(0)), uuid); + checkResponseEntity(response, 200, uuid); + + TypedSimpleResponse resp = + response.readEntity(new GenericType>() {}); + assertNotNull(resp.getResponse()); + // Verify the response and state returned by PUT REST call for updating participants + assertEquals(participants.get(0).getDefinition(), resp.getResponse().getDefinition()); + assertEquals(ParticipantState.PASSIVE, resp.getResponse().getParticipantState()); + } + + @Test + void testUpdateAutomationCompositionElement() throws Exception { + setUp(); + AutomationComposition automationComposition = TestListenerUtils.createAutomationComposition(); + Map automationCompositionElements = + participantIntermediaryApi.getAutomationCompositionElements(automationComposition.getDefinition().getName(), + automationComposition.getDefinition().getVersion()); + + UUID uuid = automationCompositionElements.keySet().iterator().next(); + AutomationCompositionElement automationCompositionElement = automationCompositionElements.get(uuid); + + automationCompositionElement.setOrderedState(AutomationCompositionOrderedState.PASSIVE); + // PUT REST call for updating AutomationCompositionElement + Response response = performPut(ELEMENTS_ENDPOINT, Entity.json(automationCompositionElement), uuid); + checkResponseEntity(response, 200, uuid); + + TypedSimpleResponse resp = + response.readEntity(new GenericType>() {}); + assertNotNull(resp.getResponse()); + // Verify the response and state returned by PUT REST call for updating participants + assertEquals(automationCompositionElement.getDefinition(), resp.getResponse().getDefinition()); + assertEquals(AutomationCompositionOrderedState.PASSIVE, resp.getResponse().getOrderedState()); + } +} diff --git a/participant/participant-impl/participant-impl-simulator/src/test/java/org/onap/policy/clamp/acm/participant/simulator/main/handler/AutomationCompositionElementHandlerTest.java b/participant/participant-impl/participant-impl-simulator/src/test/java/org/onap/policy/clamp/acm/participant/simulator/main/handler/AutomationCompositionElementHandlerTest.java new file mode 100644 index 000000000..360485efa --- /dev/null +++ b/participant/participant-impl/participant-impl-simulator/src/test/java/org/onap/policy/clamp/acm/participant/simulator/main/handler/AutomationCompositionElementHandlerTest.java @@ -0,0 +1,91 @@ +/*- + * ============LICENSE_START======================================================= + * Copyright (C) 2021 Nordix Foundation. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * SPDX-License-Identifier: Apache-2.0 + * ============LICENSE_END========================================================= + */ + +package org.onap.policy.clamp.acm.participant.simulator.main.handler; + +import static org.junit.jupiter.api.Assertions.assertDoesNotThrow; +import static org.mockito.Mockito.when; + +import java.util.UUID; +import org.junit.jupiter.api.Test; +import org.mockito.Mockito; +import org.onap.policy.clamp.acm.participant.intermediary.api.ParticipantIntermediaryApi; +import org.onap.policy.clamp.models.acm.concepts.AutomationCompositionElement; +import org.onap.policy.clamp.models.acm.concepts.AutomationCompositionOrderedState; +import org.onap.policy.clamp.models.acm.concepts.AutomationCompositionState; +import org.onap.policy.models.base.PfModelException; +import org.onap.policy.models.tosca.authorative.concepts.ToscaConceptIdentifier; +import org.onap.policy.models.tosca.authorative.concepts.ToscaNodeTemplate; +import org.onap.policy.models.tosca.authorative.concepts.ToscaServiceTemplate; + +class AutomationCompositionElementHandlerTest { + + private static final String ID_NAME = "org.onap.PM_CDS_Blueprint"; + private static final String ID_VERSION = "1.0.1"; + private static final UUID automationCompositionElementId = UUID.randomUUID(); + private static final ToscaConceptIdentifier automationCompositionId = + new ToscaConceptIdentifier(ID_NAME, ID_VERSION); + + @Test + void testSimulatorHandlerExceptions() throws PfModelException { + AutomationCompositionElementHandler handler = getTestingHandler(); + + assertDoesNotThrow(() -> handler.automationCompositionElementStateChange(automationCompositionId, + automationCompositionElementId, AutomationCompositionState.UNINITIALISED, + AutomationCompositionOrderedState.PASSIVE)); + + assertDoesNotThrow(() -> handler.automationCompositionElementStateChange(automationCompositionId, + automationCompositionElementId, AutomationCompositionState.RUNNING, + AutomationCompositionOrderedState.UNINITIALISED)); + + assertDoesNotThrow(() -> handler.automationCompositionElementStateChange(automationCompositionId, + automationCompositionElementId, AutomationCompositionState.PASSIVE, + AutomationCompositionOrderedState.RUNNING)); + var element = getTestingAcElement(); + var acElementDefinition = Mockito.mock(ToscaNodeTemplate.class); + + assertDoesNotThrow( + () -> handler.automationCompositionElementUpdate(automationCompositionId, element, acElementDefinition)); + + assertDoesNotThrow(() -> handler.handleStatistics(automationCompositionElementId)); + } + + AutomationCompositionElementHandler getTestingHandler() { + var handler = new AutomationCompositionElementHandler(); + var intermediaryApi = Mockito.mock(ParticipantIntermediaryApi.class); + var element = getTestingAcElement(); + when(intermediaryApi.getAutomationCompositionElement(automationCompositionElementId)).thenReturn(element); + handler.setIntermediaryApi(intermediaryApi); + return handler; + } + + AutomationCompositionElement getTestingAcElement() { + var element = new AutomationCompositionElement(); + element.setDefinition(automationCompositionId); + element.setDescription("Description"); + element.setId(automationCompositionElementId); + element.setOrderedState(AutomationCompositionOrderedState.UNINITIALISED); + element.setParticipantId(automationCompositionId); + element.setState(AutomationCompositionState.UNINITIALISED); + var template = Mockito.mock(ToscaServiceTemplate.class); + element.setToscaServiceTemplateFragment(template); + return element; + } +} diff --git a/participant/participant-impl/participant-impl-simulator/src/test/java/org/onap/policy/clamp/acm/participant/simulator/main/parameters/CommonTestData.java b/participant/participant-impl/participant-impl-simulator/src/test/java/org/onap/policy/clamp/acm/participant/simulator/main/parameters/CommonTestData.java new file mode 100644 index 000000000..6af454a42 --- /dev/null +++ b/participant/participant-impl/participant-impl-simulator/src/test/java/org/onap/policy/clamp/acm/participant/simulator/main/parameters/CommonTestData.java @@ -0,0 +1,140 @@ +/*- + * ============LICENSE_START======================================================= + * Copyright (C) 2021 Nordix Foundation. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * SPDX-License-Identifier: Apache-2.0 + * ============LICENSE_END========================================================= + */ + +package org.onap.policy.clamp.acm.participant.simulator.main.parameters; + +import java.util.Arrays; +import java.util.List; +import java.util.Map; +import java.util.TreeMap; +import org.onap.policy.common.endpoints.parameters.TopicParameters; +import org.onap.policy.common.utils.coder.Coder; +import org.onap.policy.common.utils.coder.CoderException; +import org.onap.policy.common.utils.coder.StandardCoder; +import org.onap.policy.models.tosca.authorative.concepts.ToscaConceptIdentifier; + +/** + * Class to hold/create all parameters for test cases. + */ +public class CommonTestData { + public static final String PARTICIPANT_GROUP_NAME = "AutomationCompositionParticipantGroup"; + public static final String DESCRIPTION = "Participant description"; + public static final long TIME_INTERVAL = 2000; + public static final List TOPIC_PARAMS = Arrays.asList(getTopicParams()); + + public static final Coder CODER = new StandardCoder(); + + /** + * Get ParticipantSimulatorParameters. + * + * @return ParticipantSimulatorParameters + */ + public ParticipantSimulatorParameters getParticipantSimulatorParameters() { + try { + return CODER.convert(getParticipantParameterGroupMap(PARTICIPANT_GROUP_NAME), + ParticipantSimulatorParameters.class); + } catch (final CoderException e) { + throw new RuntimeException("cannot create ParticipantSimulatorParameters from map", e); + } + } + + /** + * Returns a property map for a ApexStarterParameterGroup map for test cases. + * + * @param name name of the parameters + * + * @return a property map suitable for constructing an object + */ + public Map getParticipantParameterGroupMap(final String name) { + final Map map = new TreeMap<>(); + + map.put("intermediaryParameters", getIntermediaryParametersMap(false)); + return map; + } + + /** + * Returns a property map for a intermediaryParameters map for test cases. + * + * @param isEmpty boolean value to represent that object created should be empty or not + * @return a property map suitable for constructing an object + */ + public Map getIntermediaryParametersMap(final boolean isEmpty) { + final Map map = new TreeMap<>(); + if (!isEmpty) { + map.put("name", "Participant parameters"); + map.put("reportingTimeIntervalMs", TIME_INTERVAL); + map.put("description", DESCRIPTION); + map.put("participantId", getParticipantId()); + map.put("participantType", getParticipantId()); + map.put("clampAutomationCompositionTopics", getTopicParametersMap(false)); + } + + return map; + } + + /** + * Returns a property map for a TopicParameters map for test cases. + * + * @param isEmpty boolean value to represent that object created should be empty or not + * @return a property map suitable for constructing an object + */ + public Map getTopicParametersMap(final boolean isEmpty) { + final Map map = new TreeMap<>(); + if (!isEmpty) { + map.put("topicSources", TOPIC_PARAMS); + map.put("topicSinks", TOPIC_PARAMS); + } + return map; + } + + /** + * Returns topic parameters for test cases. + * + * @return topic parameters + */ + public static TopicParameters getTopicParams() { + final TopicParameters topicParams = new TopicParameters(); + topicParams.setTopic("POLICY-ACRUNTIME-PARTICIPANT"); + topicParams.setTopicCommInfrastructure("dmaap"); + topicParams.setServers(Arrays.asList("localhost")); + return topicParams; + } + + /** + * Returns participantId for test cases. + * + * @return participant Id + */ + public static ToscaConceptIdentifier getParticipantId() { + final ToscaConceptIdentifier participantId = new ToscaConceptIdentifier("org.onap.PM_CDS_Blueprint", "1.0.0"); + return participantId; + } + + /** + * Nulls out a field within a JSON string. + * + * @param json JSON string + * @param field field to be nulled out + * @return a new JSON string with the field nulled out + */ + public String nullifyField(String json, String field) { + return json.replace(field + "\"", field + "\":null, \"" + field + "Xxx\""); + } +} diff --git a/participant/participant-impl/participant-impl-simulator/src/test/java/org/onap/policy/clamp/acm/participant/simulator/main/parameters/TestParticipantSimulatorParameters.java b/participant/participant-impl/participant-impl-simulator/src/test/java/org/onap/policy/clamp/acm/participant/simulator/main/parameters/TestParticipantSimulatorParameters.java new file mode 100644 index 000000000..c763d09a3 --- /dev/null +++ b/participant/participant-impl/participant-impl-simulator/src/test/java/org/onap/policy/clamp/acm/participant/simulator/main/parameters/TestParticipantSimulatorParameters.java @@ -0,0 +1,62 @@ +/*- + * ============LICENSE_START======================================================= + * Copyright (C) 2021 Nordix Foundation. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * SPDX-License-Identifier: Apache-2.0 + * ============LICENSE_END========================================================= + */ + +package org.onap.policy.clamp.acm.participant.simulator.main.parameters; + +import static org.assertj.core.api.Assertions.assertThat; + +import javax.validation.Validation; +import javax.validation.ValidatorFactory; +import org.junit.jupiter.api.Test; + +/** + * Class to perform unit test of {@link ParticipantParameterGroup}. + */ +class TestParticipantSimulatorParameters { + private CommonTestData commonTestData = new CommonTestData(); + private ValidatorFactory validatorFactory = Validation.buildDefaultValidatorFactory(); + + @Test + void testParticipantParameterGroup() { + final ParticipantSimulatorParameters participantParameters = commonTestData.getParticipantSimulatorParameters(); + assertThat(validatorFactory.getValidator().validate(participantParameters)).isEmpty(); + } + + @Test + void testParticipantParameterGroup_EmptyParticipantIntermediaryParameters() { + final ParticipantSimulatorParameters participantParameters = commonTestData.getParticipantSimulatorParameters(); + participantParameters.setIntermediaryParameters(null); + assertThat(validatorFactory.getValidator().validate(participantParameters)).isNotEmpty(); + } + + @Test + void testParticipantPolicyParameters_NullTopicSinks() { + final ParticipantSimulatorParameters participantParameters = commonTestData.getParticipantSimulatorParameters(); + participantParameters.getIntermediaryParameters().getClampAutomationCompositionTopics().setTopicSinks(null); + assertThat(validatorFactory.getValidator().validate(participantParameters)).isNotEmpty(); + } + + @Test + void testParticipantPolicyParameters_NullTopicSources() { + final ParticipantSimulatorParameters participantParameters = commonTestData.getParticipantSimulatorParameters(); + participantParameters.getIntermediaryParameters().getClampAutomationCompositionTopics().setTopicSources(null); + assertThat(validatorFactory.getValidator().validate(participantParameters)).isNotEmpty(); + } +} diff --git a/participant/participant-impl/participant-impl-simulator/src/test/java/org/onap/policy/clamp/acm/participant/simulator/main/rest/TestListenerUtils.java b/participant/participant-impl/participant-impl-simulator/src/test/java/org/onap/policy/clamp/acm/participant/simulator/main/rest/TestListenerUtils.java new file mode 100644 index 000000000..f43400259 --- /dev/null +++ b/participant/participant-impl/participant-impl-simulator/src/test/java/org/onap/policy/clamp/acm/participant/simulator/main/rest/TestListenerUtils.java @@ -0,0 +1,260 @@ +/*- + * ============LICENSE_START======================================================= + * Copyright (C) 2021 Nordix Foundation. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * SPDX-License-Identifier: Apache-2.0 + * ============LICENSE_END========================================================= + */ + +package org.onap.policy.clamp.acm.participant.simulator.main.rest; + +import static org.junit.Assert.assertTrue; + +import java.io.File; +import java.io.FileNotFoundException; +import java.time.Instant; +import java.util.ArrayList; +import java.util.LinkedHashMap; +import java.util.List; +import java.util.Map; +import java.util.Set; +import java.util.UUID; +import lombok.AccessLevel; +import lombok.NoArgsConstructor; +import org.onap.policy.clamp.acm.participant.simulator.main.parameters.CommonTestData; +import org.onap.policy.clamp.models.acm.concepts.AutomationComposition; +import org.onap.policy.clamp.models.acm.concepts.AutomationCompositionElement; +import org.onap.policy.clamp.models.acm.concepts.AutomationCompositionOrderedState; +import org.onap.policy.clamp.models.acm.concepts.AutomationCompositionState; +import org.onap.policy.clamp.models.acm.concepts.ParticipantDefinition; +import org.onap.policy.clamp.models.acm.concepts.ParticipantUpdates; +import org.onap.policy.clamp.models.acm.concepts.ParticipantUtils; +import org.onap.policy.clamp.models.acm.messages.dmaap.participant.AutomationCompositionStateChange; +import org.onap.policy.clamp.models.acm.messages.dmaap.participant.AutomationCompositionUpdate; +import org.onap.policy.clamp.models.acm.messages.dmaap.participant.ParticipantUpdate; +import org.onap.policy.clamp.models.acm.utils.AcmUtils; +import org.onap.policy.common.utils.coder.Coder; +import org.onap.policy.common.utils.coder.CoderException; +import org.onap.policy.common.utils.coder.StandardCoder; +import org.onap.policy.common.utils.coder.YamlJsonTranslator; +import org.onap.policy.common.utils.resources.ResourceUtils; +import org.onap.policy.models.tosca.authorative.concepts.ToscaConceptIdentifier; +import org.onap.policy.models.tosca.authorative.concepts.ToscaNodeTemplate; +import org.onap.policy.models.tosca.authorative.concepts.ToscaServiceTemplate; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +@NoArgsConstructor(access = AccessLevel.PRIVATE) +public final class TestListenerUtils { + + private static final YamlJsonTranslator yamlTranslator = new YamlJsonTranslator(); + private static final Coder CODER = new StandardCoder(); + static CommonTestData commonTestData = new CommonTestData(); + private static final Logger LOGGER = LoggerFactory.getLogger(TestListenerUtils.class); + + /** + * Method to create a automationComposition from a yaml file. + * + * @return AutomationComposition automation composition + */ + public static AutomationComposition createAutomationComposition() { + AutomationComposition automationComposition = new AutomationComposition(); + Map elements = new LinkedHashMap<>(); + ToscaServiceTemplate toscaServiceTemplate = testAutomationCompositionRead(); + Map nodeTemplatesMap = + toscaServiceTemplate.getToscaTopologyTemplate().getNodeTemplates(); + for (Map.Entry toscaInputEntry : nodeTemplatesMap.entrySet()) { + AutomationCompositionElement acElement = new AutomationCompositionElement(); + acElement.setId(UUID.randomUUID()); + + ToscaConceptIdentifier acElementParticipantId = new ToscaConceptIdentifier(); + acElementParticipantId.setName(toscaInputEntry.getKey()); + acElementParticipantId.setVersion(toscaInputEntry.getValue().getVersion()); + acElement.setParticipantId(acElementParticipantId); + acElement.setParticipantType(acElementParticipantId); + + acElement.setDefinition(acElementParticipantId); + acElement.setState(AutomationCompositionState.UNINITIALISED); + acElement.setDescription(toscaInputEntry.getValue().getDescription()); + acElement.setOrderedState(AutomationCompositionOrderedState.UNINITIALISED); + elements.put(acElement.getId(), acElement); + } + automationComposition.setElements(elements); + automationComposition.setName("PMSHInstance0"); + automationComposition.setVersion("1.0.0"); + + ToscaConceptIdentifier definition = new ToscaConceptIdentifier(); + definition.setName("PMSHInstance0"); + definition.setVersion("1.0.0"); + automationComposition.setDefinition(definition); + + return automationComposition; + } + + /** + * Method to create AutomationCompositionStateChange message from the arguments passed. + * + * @param automationCompositionOrderedState automationCompositionOrderedState + * + * @return AutomationCompositionStateChange message + */ + public static AutomationCompositionStateChange createAutomationCompositionStateChangeMsg( + final AutomationCompositionOrderedState automationCompositionOrderedState) { + final AutomationCompositionStateChange acStateChangeMsg = new AutomationCompositionStateChange(); + + ToscaConceptIdentifier automationCompositionId = new ToscaConceptIdentifier("PMSHInstance0", "1.0.0"); + ToscaConceptIdentifier participantId = new ToscaConceptIdentifier("org.onap.PM_CDS_Blueprint", "1.0.0"); + + acStateChangeMsg.setAutomationCompositionId(automationCompositionId); + acStateChangeMsg.setParticipantId(participantId); + acStateChangeMsg.setTimestamp(Instant.now()); + acStateChangeMsg.setOrderedState(automationCompositionOrderedState); + + return acStateChangeMsg; + } + + /** + * Method to create AutomationCompositionUpdateMsg. + * + * @return AutomationCompositionUpdate message + */ + public static AutomationCompositionUpdate createAutomationCompositionUpdateMsg() { + final AutomationCompositionUpdate acUpdateMsg = new AutomationCompositionUpdate(); + ToscaConceptIdentifier automationCompositionId = new ToscaConceptIdentifier("PMSHInstance0", "1.0.0"); + ToscaConceptIdentifier participantId = new ToscaConceptIdentifier("org.onap.PM_Policy", "0.0.0"); + + acUpdateMsg.setAutomationCompositionId(automationCompositionId); + acUpdateMsg.setParticipantId(participantId); + acUpdateMsg.setMessageId(UUID.randomUUID()); + acUpdateMsg.setTimestamp(Instant.now()); + + Map elements = new LinkedHashMap<>(); + ToscaServiceTemplate toscaServiceTemplate = testAutomationCompositionRead(); + Map nodeTemplatesMap = + toscaServiceTemplate.getToscaTopologyTemplate().getNodeTemplates(); + for (Map.Entry toscaInputEntry : nodeTemplatesMap.entrySet()) { + if (ParticipantUtils.checkIfNodeTemplateIsAutomationCompositionElement(toscaInputEntry.getValue(), + toscaServiceTemplate)) { + AutomationCompositionElement acElement = new AutomationCompositionElement(); + acElement.setId(UUID.randomUUID()); + var acParticipantType = + ParticipantUtils.findParticipantType(toscaInputEntry.getValue().getProperties()); + + acElement.setParticipantId(acParticipantType); + acElement.setParticipantType(acParticipantType); + + acElement.setDefinition( + new ToscaConceptIdentifier(toscaInputEntry.getKey(), toscaInputEntry.getValue().getVersion())); + acElement.setState(AutomationCompositionState.UNINITIALISED); + acElement.setDescription(toscaInputEntry.getValue().getDescription()); + acElement.setOrderedState(AutomationCompositionOrderedState.PASSIVE); + elements.put(acElement.getId(), acElement); + } + } + + List participantUpdates = new ArrayList<>(); + for (AutomationCompositionElement element : elements.values()) { + AcmUtils.prepareParticipantUpdate(element, participantUpdates); + } + acUpdateMsg.setParticipantUpdatesList(participantUpdates); + return acUpdateMsg; + } + + /** + * Method to create participantUpdateMsg. + * + * @return ParticipantUpdate message + */ + public static ParticipantUpdate createParticipantUpdateMsg() { + final ParticipantUpdate participantUpdateMsg = new ParticipantUpdate(); + ToscaConceptIdentifier participantId = new ToscaConceptIdentifier("org.onap.PM_Policy", "1.0.0"); + ToscaConceptIdentifier participantType = + new ToscaConceptIdentifier("org.onap.policy.acm.PolicyAutomationCompositionParticipant", "2.3.1"); + + participantUpdateMsg.setParticipantId(participantId); + participantUpdateMsg.setTimestamp(Instant.now()); + participantUpdateMsg.setParticipantType(participantType); + participantUpdateMsg.setTimestamp(Instant.ofEpochMilli(3000)); + participantUpdateMsg.setMessageId(UUID.randomUUID()); + + ToscaServiceTemplate toscaServiceTemplate = testAutomationCompositionRead(); + // Add policies to the toscaServiceTemplate + List participantDefinitionUpdates = new ArrayList<>(); + for (Map.Entry toscaInputEntry : toscaServiceTemplate.getToscaTopologyTemplate() + .getNodeTemplates().entrySet()) { + if (ParticipantUtils.checkIfNodeTemplateIsAutomationCompositionElement(toscaInputEntry.getValue(), + toscaServiceTemplate)) { + var acParticipantType = + ParticipantUtils.findParticipantType(toscaInputEntry.getValue().getProperties()); + AcmUtils.prepareParticipantDefinitionUpdate(acParticipantType, toscaInputEntry.getKey(), + toscaInputEntry.getValue(), participantDefinitionUpdates, null); + } + } + + participantUpdateMsg.setParticipantDefinitionUpdates(participantDefinitionUpdates); + return participantUpdateMsg; + } + + /** + * Method to create AutomationCompositionUpdate using the arguments passed. + * + * @param jsonFilePath the path of the automation composition content + * + * @return AutomationCompositionUpdate message + * @throws CoderException exception while reading the file to object + */ + public static AutomationCompositionUpdate createParticipantAcUpdateMsgFromJson(String jsonFilePath) + throws CoderException { + AutomationCompositionUpdate automationCompositionUpdateMsg = + CODER.decode(new File(jsonFilePath), AutomationCompositionUpdate.class); + return automationCompositionUpdateMsg; + } + + private static ToscaServiceTemplate testAutomationCompositionRead() { + Set automationCompositionDirectoryContents = + ResourceUtils.getDirectoryContents("src/test/resources/rest/servicetemplates"); + + boolean atLeastOneAutomationCompositionTested = false; + ToscaServiceTemplate toscaServiceTemplate = null; + + for (String automationCompositionFilePath : automationCompositionDirectoryContents) { + if (!automationCompositionFilePath.endsWith(".yaml")) { + continue; + } + atLeastOneAutomationCompositionTested = true; + toscaServiceTemplate = testAutomationCompositionYamlSerialization(automationCompositionFilePath); + } + + assertTrue(atLeastOneAutomationCompositionTested); + return toscaServiceTemplate; + } + + private static ToscaServiceTemplate testAutomationCompositionYamlSerialization( + String automationCompositionFilePath) { + try { + String automationCompositionString = ResourceUtils.getResourceAsString(automationCompositionFilePath); + if (automationCompositionString == null) { + throw new FileNotFoundException(automationCompositionFilePath); + } + + ToscaServiceTemplate serviceTemplate = + yamlTranslator.fromYaml(automationCompositionString, ToscaServiceTemplate.class); + return serviceTemplate; + } catch (FileNotFoundException e) { + LOGGER.error("cannot find YAML file", automationCompositionFilePath); + throw new IllegalArgumentException(e); + } + } +} diff --git a/participant/participant-impl/participant-impl-simulator/src/test/java/org/onap/policy/clamp/controlloop/participant/simulator/endtoend/ParticipantSimulatorTest.java b/participant/participant-impl/participant-impl-simulator/src/test/java/org/onap/policy/clamp/controlloop/participant/simulator/endtoend/ParticipantSimulatorTest.java deleted file mode 100644 index 14f51269a..000000000 --- a/participant/participant-impl/participant-impl-simulator/src/test/java/org/onap/policy/clamp/controlloop/participant/simulator/endtoend/ParticipantSimulatorTest.java +++ /dev/null @@ -1,285 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * Copyright (C) 2021 Nordix Foundation. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - * SPDX-License-Identifier: Apache-2.0 - * ============LICENSE_END========================================================= - */ - -package org.onap.policy.clamp.controlloop.participant.simulator.endtoend; - -import static org.assertj.core.api.Assertions.assertThat; -import static org.junit.jupiter.api.Assertions.assertEquals; -import static org.junit.jupiter.api.Assertions.assertNotNull; -import static org.junit.jupiter.api.Assertions.assertTrue; - -import java.util.List; -import java.util.Map; -import java.util.UUID; -import javax.ws.rs.client.Client; -import javax.ws.rs.client.ClientBuilder; -import javax.ws.rs.client.Entity; -import javax.ws.rs.client.Invocation; -import javax.ws.rs.client.WebTarget; -import javax.ws.rs.core.GenericType; -import javax.ws.rs.core.MediaType; -import javax.ws.rs.core.MultivaluedMap; -import javax.ws.rs.core.Response; -import org.glassfish.jersey.client.ClientProperties; -import org.glassfish.jersey.client.authentication.HttpAuthenticationFeature; -import org.junit.jupiter.api.Test; -import org.junit.jupiter.api.extension.ExtendWith; -import org.onap.policy.clamp.controlloop.models.controlloop.concepts.ControlLoop; -import org.onap.policy.clamp.controlloop.models.controlloop.concepts.ControlLoopElement; -import org.onap.policy.clamp.controlloop.models.controlloop.concepts.ControlLoopOrderedState; -import org.onap.policy.clamp.controlloop.models.controlloop.concepts.Participant; -import org.onap.policy.clamp.controlloop.models.controlloop.concepts.ParticipantState; -import org.onap.policy.clamp.controlloop.models.messages.dmaap.participant.ControlLoopUpdate; -import org.onap.policy.clamp.controlloop.models.messages.rest.TypedSimpleResponse; -import org.onap.policy.clamp.controlloop.participant.intermediary.api.ParticipantIntermediaryApi; -import org.onap.policy.clamp.controlloop.participant.intermediary.comm.ControlLoopUpdateListener; -import org.onap.policy.clamp.controlloop.participant.intermediary.handler.ParticipantHandler; -import org.onap.policy.clamp.controlloop.participant.simulator.main.parameters.CommonTestData; -import org.onap.policy.clamp.controlloop.participant.simulator.main.rest.AbstractRestController; -import org.onap.policy.clamp.controlloop.participant.simulator.main.rest.TestListenerUtils; -import org.onap.policy.common.endpoints.event.comm.Topic.CommInfrastructure; -import org.onap.policy.common.gson.GsonMessageBodyHandler; -import org.onap.policy.models.tosca.authorative.concepts.ToscaConceptIdentifier; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.beans.factory.annotation.Value; -import org.springframework.boot.test.context.SpringBootTest; -import org.springframework.boot.test.context.SpringBootTest.WebEnvironment; -import org.springframework.boot.web.server.LocalServerPort; -import org.springframework.test.context.TestPropertySource; -import org.springframework.test.context.junit.jupiter.SpringExtension; - -@ExtendWith(SpringExtension.class) -@SpringBootTest(webEnvironment = WebEnvironment.RANDOM_PORT) -@TestPropertySource(locations = {"classpath:application_test.properties"}) -class ParticipantSimulatorTest { - - private static final String PARTICIPANTS_ENDPOINT = "participants"; - private static final String ELEMENTS_ENDPOINT = "elements"; - private static final CommInfrastructure INFRA = CommInfrastructure.NOOP; - private static final String TOPIC = "my-topic"; - - @Value("${spring.security.user.name}") - private String user; - - @Value("${spring.security.user.password}") - private String password; - - @LocalServerPort - private int randomServerPort; - - @Autowired - private ParticipantIntermediaryApi participantIntermediaryApi; - - @Autowired - private ParticipantHandler participantHandler; - - private static final Object lockit = new Object(); - private boolean check = false; - - private void setUp() throws Exception { - synchronized (lockit) { - if (!check) { - check = true; - ControlLoopUpdateListener clUpdateListener = new ControlLoopUpdateListener(participantHandler); - - ControlLoopUpdate controlLoopUpdateMsg = TestListenerUtils.createControlLoopUpdateMsg(); - clUpdateListener.onTopicEvent(INFRA, TOPIC, null, controlLoopUpdateMsg); - - } - } - } - - private String getPath(String path) { - return "http://localhost:" + randomServerPort + "/onap/participantsim/v2/" + path; - } - - void testSwagger(String endPoint) { - final Client client = ClientBuilder.newBuilder().build(); - - client.property(ClientProperties.METAINF_SERVICES_LOOKUP_DISABLE, "true"); - client.register(GsonMessageBodyHandler.class); - client.register(HttpAuthenticationFeature.basic(user, password)); - - final WebTarget webTarget = client.target(getPath("api-docs")); - - Response response = webTarget.request(MediaType.APPLICATION_JSON).get(); - - assertThat(response.getStatus()).isEqualTo(200); - assertTrue(response.readEntity(String.class).contains("/onap/participantsim/v2/" + endPoint)); - } - - @Test - void testEndParticipatsSwagger() { - testSwagger(PARTICIPANTS_ENDPOINT); - } - - @Test - void testElementsSwagger() { - testSwagger(ELEMENTS_ENDPOINT); - } - - @Test - void testProducerYaml() { - final Client client = ClientBuilder.newBuilder().build(); - - client.property(ClientProperties.METAINF_SERVICES_LOOKUP_DISABLE, "true"); - client.register(GsonMessageBodyHandler.class); - client.register(HttpAuthenticationFeature.basic(user, password)); - - String path = getPath(PARTICIPANTS_ENDPOINT + "/org.onap.PM_CDS_Blueprint/1"); - final WebTarget webTarget = client.target(path); - - Response response = webTarget.request("application/yaml").get(); - - assertThat(response.getStatus()).isEqualTo(200); - } - - @Test - void testQuery_Unauthorized() throws Exception { - String path = PARTICIPANTS_ENDPOINT + "/org.onap.PM_CDS_Blueprint/1"; - - Response response = performRequest(path, true, null).get(); - assertThat(response.getStatus()).isEqualTo(200); - - // unauthorized call - response = performRequest(path, false, null).get(); - assertThat(response.getStatus()).isEqualTo(401); - } - - private Invocation.Builder performRequest(String endpoint, boolean includeAuth, UUID uuid) { - final Client client = ClientBuilder.newBuilder().build(); - - client.property(ClientProperties.METAINF_SERVICES_LOOKUP_DISABLE, "true"); - client.register(GsonMessageBodyHandler.class); - if (includeAuth) { - client.register(HttpAuthenticationFeature.basic(user, password)); - } - Invocation.Builder builder = client.target(getPath(endpoint)).request(MediaType.APPLICATION_JSON); - if (uuid != null) { - builder = builder.header(AbstractRestController.REQUEST_ID_NAME, uuid.toString()); - } - return builder; - } - - private Response performGet(String endpoint, UUID uuid) throws Exception { - return performRequest(endpoint, true, uuid).get(); - } - - @Test - void testQueryParticipants() throws Exception { - Participant participant = new Participant(); - ToscaConceptIdentifier participantId = CommonTestData.getParticipantId(); - participant.setDefinition(participantId); - participant.setName(participantId.getName()); - participant.setVersion(participantId.getVersion()); - UUID uuid = UUID.randomUUID(); - - // GET REST call for querying the participants - Response response = performGet( - PARTICIPANTS_ENDPOINT + "/" + participant.getKey().getName() + "/" + participant.getKey().getVersion(), - uuid); - checkResponseEntity(response, 200, uuid); - - Participant[] returnValue = response.readEntity(Participant[].class); - assertThat(returnValue).hasSize(1); - // Verify the result of GET participants with what is stored - assertEquals(participant.getDefinition(), returnValue[0].getDefinition()); - } - - private void checkResponseEntity(Response response, int status, UUID uuid) { - assertThat(response.getStatus()).isEqualTo(status); - assertThat(getHeader(response.getHeaders(), AbstractRestController.VERSION_MINOR_NAME)).isEqualTo("0"); - assertThat(getHeader(response.getHeaders(), AbstractRestController.VERSION_PATCH_NAME)).isEqualTo("0"); - assertThat(getHeader(response.getHeaders(), AbstractRestController.VERSION_LATEST_NAME)).isEqualTo("1.0.0"); - assertThat(getHeader(response.getHeaders(), AbstractRestController.REQUEST_ID_NAME)).isEqualTo(uuid.toString()); - } - - private String getHeader(MultivaluedMap httpHeaders, String param) { - List list = httpHeaders.get(param); - assertThat(list).hasSize(1); - assertThat(list.get(0)).isNotNull(); - return (String) list.get(0); - } - - @Test - void testQueryControlLoopElements() throws Exception { - setUp(); - UUID uuid = UUID.randomUUID(); - ToscaConceptIdentifier participantId = CommonTestData.getParticipantId(); - - // GET REST call for querying the controlLoop elements - Response response = - performGet(ELEMENTS_ENDPOINT + "/" + participantId.getName() + "/" + participantId.getVersion(), uuid); - checkResponseEntity(response, 200, uuid); - - Map returnValue = response.readEntity(Map.class); - // Verify the result of GET controlloop elements with what is stored - assertThat(returnValue).isEmpty(); - } - - private Response performPut(String endpoint, final Entity entity, UUID uuid) throws Exception { - return performRequest(endpoint, true, uuid).put(entity); - } - - @Test - void testUpdateParticipant() throws Exception { - setUp(); - List participants = participantIntermediaryApi.getParticipants( - CommonTestData.getParticipantId().getName(), CommonTestData.getParticipantId().getVersion()); - assertEquals(ParticipantState.UNKNOWN, participants.get(0).getParticipantState()); - // Change the state of the participant to PASSIVE from UNKNOWN - participants.get(0).setParticipantState(ParticipantState.PASSIVE); - UUID uuid = UUID.randomUUID(); - - // PUT REST call for updating Participant - Response response = performPut(PARTICIPANTS_ENDPOINT, Entity.json(participants.get(0)), uuid); - checkResponseEntity(response, 200, uuid); - - TypedSimpleResponse resp = - response.readEntity(new GenericType>() {}); - assertNotNull(resp.getResponse()); - // Verify the response and state returned by PUT REST call for updating participants - assertEquals(participants.get(0).getDefinition(), resp.getResponse().getDefinition()); - assertEquals(ParticipantState.PASSIVE, resp.getResponse().getParticipantState()); - } - - @Test - void testUpdateControlLoopElement() throws Exception { - setUp(); - ControlLoop controlLoop = TestListenerUtils.createControlLoop(); - Map controlLoopElements = participantIntermediaryApi.getControlLoopElements( - controlLoop.getDefinition().getName(), controlLoop.getDefinition().getVersion()); - - UUID uuid = controlLoopElements.keySet().iterator().next(); - ControlLoopElement controlLoopElement = controlLoopElements.get(uuid); - - controlLoopElement.setOrderedState(ControlLoopOrderedState.PASSIVE); - // PUT REST call for updating ControlLoopElement - Response response = performPut(ELEMENTS_ENDPOINT, Entity.json(controlLoopElement), uuid); - checkResponseEntity(response, 200, uuid); - - TypedSimpleResponse resp = - response.readEntity(new GenericType>() {}); - assertNotNull(resp.getResponse()); - // Verify the response and state returned by PUT REST call for updating participants - assertEquals(controlLoopElement.getDefinition(), resp.getResponse().getDefinition()); - assertEquals(ControlLoopOrderedState.PASSIVE, resp.getResponse().getOrderedState()); - } -} diff --git a/participant/participant-impl/participant-impl-simulator/src/test/java/org/onap/policy/clamp/controlloop/participant/simulator/main/handler/ControlLoopElementHandlerTest.java b/participant/participant-impl/participant-impl-simulator/src/test/java/org/onap/policy/clamp/controlloop/participant/simulator/main/handler/ControlLoopElementHandlerTest.java deleted file mode 100644 index b38adbc5c..000000000 --- a/participant/participant-impl/participant-impl-simulator/src/test/java/org/onap/policy/clamp/controlloop/participant/simulator/main/handler/ControlLoopElementHandlerTest.java +++ /dev/null @@ -1,98 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * Copyright (C) 2021 Nordix Foundation. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - * SPDX-License-Identifier: Apache-2.0 - * ============LICENSE_END========================================================= - */ - -package org.onap.policy.clamp.controlloop.participant.simulator.main.handler; - -import static org.junit.jupiter.api.Assertions.assertDoesNotThrow; -import static org.mockito.Mockito.when; - -import java.util.UUID; -import org.junit.jupiter.api.Test; -import org.mockito.Mockito; -import org.onap.policy.clamp.controlloop.models.controlloop.concepts.ControlLoopElement; -import org.onap.policy.clamp.controlloop.models.controlloop.concepts.ControlLoopOrderedState; -import org.onap.policy.clamp.controlloop.models.controlloop.concepts.ControlLoopState; -import org.onap.policy.clamp.controlloop.participant.intermediary.api.ParticipantIntermediaryApi; -import org.onap.policy.models.base.PfModelException; -import org.onap.policy.models.tosca.authorative.concepts.ToscaConceptIdentifier; -import org.onap.policy.models.tosca.authorative.concepts.ToscaNodeTemplate; -import org.onap.policy.models.tosca.authorative.concepts.ToscaServiceTemplate; - -class ControlLoopElementHandlerTest { - - private static final String ID_NAME = "org.onap.PM_CDS_Blueprint"; - private static final String ID_VERSION = "1.0.1"; - private static final UUID controlLoopElementId = UUID.randomUUID(); - private static final ToscaConceptIdentifier controlLoopId = new ToscaConceptIdentifier(ID_NAME, ID_VERSION); - - @Test - void testSimulatorHandlerExceptions() throws PfModelException { - ControlLoopElementHandler handler = getTestingHandler(); - - assertDoesNotThrow(() -> handler - .controlLoopElementStateChange(controlLoopId, - controlLoopElementId, - ControlLoopState.UNINITIALISED, - ControlLoopOrderedState.PASSIVE)); - - assertDoesNotThrow(() -> handler - .controlLoopElementStateChange(controlLoopId, - controlLoopElementId, - ControlLoopState.RUNNING, - ControlLoopOrderedState.UNINITIALISED)); - - assertDoesNotThrow(() -> handler - .controlLoopElementStateChange(controlLoopId, - controlLoopElementId, - ControlLoopState.PASSIVE, - ControlLoopOrderedState.RUNNING)); - var element = getTestingClElement(); - var clElementDefinition = Mockito.mock(ToscaNodeTemplate.class); - - assertDoesNotThrow(() -> handler - .controlLoopElementUpdate(controlLoopId, element, clElementDefinition)); - - assertDoesNotThrow(() -> handler - .handleStatistics(controlLoopElementId)); - } - - ControlLoopElementHandler getTestingHandler() { - var handler = new ControlLoopElementHandler(); - var intermediaryApi = Mockito.mock(ParticipantIntermediaryApi.class); - var element = getTestingClElement(); - when(intermediaryApi.getControlLoopElement(controlLoopElementId)).thenReturn(element); - handler.setIntermediaryApi(intermediaryApi); - return handler; - } - - ControlLoopElement getTestingClElement() { - var element = new ControlLoopElement(); - element.setDefinition(controlLoopId); - element.setDescription("Description"); - element.setId(controlLoopElementId); - element.setOrderedState(ControlLoopOrderedState.UNINITIALISED); - element.setParticipantId(controlLoopId); - element.setState(ControlLoopState.UNINITIALISED); - var template = Mockito.mock(ToscaServiceTemplate.class); - element.setToscaServiceTemplateFragment(template); - return element; - } - -} diff --git a/participant/participant-impl/participant-impl-simulator/src/test/java/org/onap/policy/clamp/controlloop/participant/simulator/main/parameters/CommonTestData.java b/participant/participant-impl/participant-impl-simulator/src/test/java/org/onap/policy/clamp/controlloop/participant/simulator/main/parameters/CommonTestData.java deleted file mode 100644 index 9c41c8bcb..000000000 --- a/participant/participant-impl/participant-impl-simulator/src/test/java/org/onap/policy/clamp/controlloop/participant/simulator/main/parameters/CommonTestData.java +++ /dev/null @@ -1,140 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * Copyright (C) 2021 Nordix Foundation. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - * SPDX-License-Identifier: Apache-2.0 - * ============LICENSE_END========================================================= - */ - -package org.onap.policy.clamp.controlloop.participant.simulator.main.parameters; - -import java.util.Arrays; -import java.util.List; -import java.util.Map; -import java.util.TreeMap; -import org.onap.policy.common.endpoints.parameters.TopicParameters; -import org.onap.policy.common.utils.coder.Coder; -import org.onap.policy.common.utils.coder.CoderException; -import org.onap.policy.common.utils.coder.StandardCoder; -import org.onap.policy.models.tosca.authorative.concepts.ToscaConceptIdentifier; - -/** - * Class to hold/create all parameters for test cases. - */ -public class CommonTestData { - public static final String PARTICIPANT_GROUP_NAME = "ControlLoopParticipantGroup"; - public static final String DESCRIPTION = "Participant description"; - public static final long TIME_INTERVAL = 2000; - public static final List TOPIC_PARAMS = Arrays.asList(getTopicParams()); - - public static final Coder CODER = new StandardCoder(); - - /** - * Get ParticipantSimulatorParameters. - * - * @return ParticipantSimulatorParameters - */ - public ParticipantSimulatorParameters getParticipantSimulatorParameters() { - try { - return CODER.convert(getParticipantParameterGroupMap(PARTICIPANT_GROUP_NAME), - ParticipantSimulatorParameters.class); - } catch (final CoderException e) { - throw new RuntimeException("cannot create ParticipantSimulatorParameters from map", e); - } - } - - /** - * Returns a property map for a ApexStarterParameterGroup map for test cases. - * - * @param name name of the parameters - * - * @return a property map suitable for constructing an object - */ - public Map getParticipantParameterGroupMap(final String name) { - final Map map = new TreeMap<>(); - - map.put("intermediaryParameters", getIntermediaryParametersMap(false)); - return map; - } - - /** - * Returns a property map for a intermediaryParameters map for test cases. - * - * @param isEmpty boolean value to represent that object created should be empty or not - * @return a property map suitable for constructing an object - */ - public Map getIntermediaryParametersMap(final boolean isEmpty) { - final Map map = new TreeMap<>(); - if (!isEmpty) { - map.put("name", "Participant parameters"); - map.put("reportingTimeIntervalMs", TIME_INTERVAL); - map.put("description", DESCRIPTION); - map.put("participantId", getParticipantId()); - map.put("participantType", getParticipantId()); - map.put("clampControlLoopTopics", getTopicParametersMap(false)); - } - - return map; - } - - /** - * Returns a property map for a TopicParameters map for test cases. - * - * @param isEmpty boolean value to represent that object created should be empty or not - * @return a property map suitable for constructing an object - */ - public Map getTopicParametersMap(final boolean isEmpty) { - final Map map = new TreeMap<>(); - if (!isEmpty) { - map.put("topicSources", TOPIC_PARAMS); - map.put("topicSinks", TOPIC_PARAMS); - } - return map; - } - - /** - * Returns topic parameters for test cases. - * - * @return topic parameters - */ - public static TopicParameters getTopicParams() { - final TopicParameters topicParams = new TopicParameters(); - topicParams.setTopic("POLICY-CLRUNTIME-PARTICIPANT"); - topicParams.setTopicCommInfrastructure("dmaap"); - topicParams.setServers(Arrays.asList("localhost")); - return topicParams; - } - - /** - * Returns participantId for test cases. - * - * @return participant Id - */ - public static ToscaConceptIdentifier getParticipantId() { - final ToscaConceptIdentifier participantId = new ToscaConceptIdentifier("org.onap.PM_CDS_Blueprint", "1.0.0"); - return participantId; - } - - /** - * Nulls out a field within a JSON string. - * - * @param json JSON string - * @param field field to be nulled out - * @return a new JSON string with the field nulled out - */ - public String nullifyField(String json, String field) { - return json.replace(field + "\"", field + "\":null, \"" + field + "Xxx\""); - } -} diff --git a/participant/participant-impl/participant-impl-simulator/src/test/java/org/onap/policy/clamp/controlloop/participant/simulator/main/parameters/TestParticipantSimulatorParameters.java b/participant/participant-impl/participant-impl-simulator/src/test/java/org/onap/policy/clamp/controlloop/participant/simulator/main/parameters/TestParticipantSimulatorParameters.java deleted file mode 100644 index 3c1d1c2a3..000000000 --- a/participant/participant-impl/participant-impl-simulator/src/test/java/org/onap/policy/clamp/controlloop/participant/simulator/main/parameters/TestParticipantSimulatorParameters.java +++ /dev/null @@ -1,62 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * Copyright (C) 2021 Nordix Foundation. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - * SPDX-License-Identifier: Apache-2.0 - * ============LICENSE_END========================================================= - */ - -package org.onap.policy.clamp.controlloop.participant.simulator.main.parameters; - -import static org.assertj.core.api.Assertions.assertThat; - -import javax.validation.Validation; -import javax.validation.ValidatorFactory; -import org.junit.jupiter.api.Test; - -/** - * Class to perform unit test of {@link ParticipantParameterGroup}. - */ -class TestParticipantSimulatorParameters { - private CommonTestData commonTestData = new CommonTestData(); - private ValidatorFactory validatorFactory = Validation.buildDefaultValidatorFactory(); - - @Test - void testParticipantParameterGroup() { - final ParticipantSimulatorParameters participantParameters = commonTestData.getParticipantSimulatorParameters(); - assertThat(validatorFactory.getValidator().validate(participantParameters)).isEmpty(); - } - - @Test - void testParticipantParameterGroup_EmptyParticipantIntermediaryParameters() { - final ParticipantSimulatorParameters participantParameters = commonTestData.getParticipantSimulatorParameters(); - participantParameters.setIntermediaryParameters(null); - assertThat(validatorFactory.getValidator().validate(participantParameters)).isNotEmpty(); - } - - @Test - void testParticipantPolicyParameters_NullTopicSinks() { - final ParticipantSimulatorParameters participantParameters = commonTestData.getParticipantSimulatorParameters(); - participantParameters.getIntermediaryParameters().getClampControlLoopTopics().setTopicSinks(null); - assertThat(validatorFactory.getValidator().validate(participantParameters)).isNotEmpty(); - } - - @Test - void testParticipantPolicyParameters_NullTopicSources() { - final ParticipantSimulatorParameters participantParameters = commonTestData.getParticipantSimulatorParameters(); - participantParameters.getIntermediaryParameters().getClampControlLoopTopics().setTopicSources(null); - assertThat(validatorFactory.getValidator().validate(participantParameters)).isNotEmpty(); - } -} diff --git a/participant/participant-impl/participant-impl-simulator/src/test/java/org/onap/policy/clamp/controlloop/participant/simulator/main/rest/TestListenerUtils.java b/participant/participant-impl/participant-impl-simulator/src/test/java/org/onap/policy/clamp/controlloop/participant/simulator/main/rest/TestListenerUtils.java deleted file mode 100644 index 9f6a31e28..000000000 --- a/participant/participant-impl/participant-impl-simulator/src/test/java/org/onap/policy/clamp/controlloop/participant/simulator/main/rest/TestListenerUtils.java +++ /dev/null @@ -1,257 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * Copyright (C) 2021 Nordix Foundation. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - * SPDX-License-Identifier: Apache-2.0 - * ============LICENSE_END========================================================= - */ - -package org.onap.policy.clamp.controlloop.participant.simulator.main.rest; - -import static org.junit.Assert.assertTrue; - -import java.io.File; -import java.io.FileNotFoundException; -import java.time.Instant; -import java.util.ArrayList; -import java.util.LinkedHashMap; -import java.util.List; -import java.util.Map; -import java.util.Set; -import java.util.UUID; -import lombok.AccessLevel; -import lombok.NoArgsConstructor; -import org.onap.policy.clamp.controlloop.common.utils.CommonUtils; -import org.onap.policy.clamp.controlloop.models.controlloop.concepts.ControlLoop; -import org.onap.policy.clamp.controlloop.models.controlloop.concepts.ControlLoopElement; -import org.onap.policy.clamp.controlloop.models.controlloop.concepts.ControlLoopOrderedState; -import org.onap.policy.clamp.controlloop.models.controlloop.concepts.ControlLoopState; -import org.onap.policy.clamp.controlloop.models.controlloop.concepts.ParticipantDefinition; -import org.onap.policy.clamp.controlloop.models.controlloop.concepts.ParticipantUpdates; -import org.onap.policy.clamp.controlloop.models.controlloop.concepts.ParticipantUtils; -import org.onap.policy.clamp.controlloop.models.messages.dmaap.participant.ControlLoopStateChange; -import org.onap.policy.clamp.controlloop.models.messages.dmaap.participant.ControlLoopUpdate; -import org.onap.policy.clamp.controlloop.models.messages.dmaap.participant.ParticipantUpdate; -import org.onap.policy.clamp.controlloop.participant.simulator.main.parameters.CommonTestData; -import org.onap.policy.common.utils.coder.Coder; -import org.onap.policy.common.utils.coder.CoderException; -import org.onap.policy.common.utils.coder.StandardCoder; -import org.onap.policy.common.utils.coder.YamlJsonTranslator; -import org.onap.policy.common.utils.resources.ResourceUtils; -import org.onap.policy.models.tosca.authorative.concepts.ToscaConceptIdentifier; -import org.onap.policy.models.tosca.authorative.concepts.ToscaNodeTemplate; -import org.onap.policy.models.tosca.authorative.concepts.ToscaServiceTemplate; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -@NoArgsConstructor(access = AccessLevel.PRIVATE) -public final class TestListenerUtils { - - private static final YamlJsonTranslator yamlTranslator = new YamlJsonTranslator(); - private static final Coder CODER = new StandardCoder(); - static CommonTestData commonTestData = new CommonTestData(); - private static final Logger LOGGER = LoggerFactory.getLogger(TestListenerUtils.class); - - /** - * Method to create a controlLoop from a yaml file. - * - * @return ControlLoop controlloop - */ - public static ControlLoop createControlLoop() { - ControlLoop controlLoop = new ControlLoop(); - Map elements = new LinkedHashMap<>(); - ToscaServiceTemplate toscaServiceTemplate = testControlLoopRead(); - Map nodeTemplatesMap = - toscaServiceTemplate.getToscaTopologyTemplate().getNodeTemplates(); - for (Map.Entry toscaInputEntry : nodeTemplatesMap.entrySet()) { - ControlLoopElement clElement = new ControlLoopElement(); - clElement.setId(UUID.randomUUID()); - - ToscaConceptIdentifier clElementParticipantId = new ToscaConceptIdentifier(); - clElementParticipantId.setName(toscaInputEntry.getKey()); - clElementParticipantId.setVersion(toscaInputEntry.getValue().getVersion()); - clElement.setParticipantId(clElementParticipantId); - clElement.setParticipantType(clElementParticipantId); - - clElement.setDefinition(clElementParticipantId); - clElement.setState(ControlLoopState.UNINITIALISED); - clElement.setDescription(toscaInputEntry.getValue().getDescription()); - clElement.setOrderedState(ControlLoopOrderedState.UNINITIALISED); - elements.put(clElement.getId(), clElement); - } - controlLoop.setElements(elements); - controlLoop.setName("PMSHInstance0"); - controlLoop.setVersion("1.0.0"); - - ToscaConceptIdentifier definition = new ToscaConceptIdentifier(); - definition.setName("PMSHInstance0"); - definition.setVersion("1.0.0"); - controlLoop.setDefinition(definition); - - return controlLoop; - } - - /** - * Method to create ControlLoopStateChange message from the arguments passed. - * - * @param controlLoopOrderedState controlLoopOrderedState - * - * @return ControlLoopStateChange message - */ - public static ControlLoopStateChange createControlLoopStateChangeMsg( - final ControlLoopOrderedState controlLoopOrderedState) { - final ControlLoopStateChange clStateChangeMsg = new ControlLoopStateChange(); - - ToscaConceptIdentifier controlLoopId = new ToscaConceptIdentifier("PMSHInstance0", "1.0.0"); - ToscaConceptIdentifier participantId = new ToscaConceptIdentifier("org.onap.PM_CDS_Blueprint", "1.0.0"); - - clStateChangeMsg.setControlLoopId(controlLoopId); - clStateChangeMsg.setParticipantId(participantId); - clStateChangeMsg.setTimestamp(Instant.now()); - clStateChangeMsg.setOrderedState(controlLoopOrderedState); - - return clStateChangeMsg; - } - - /** - * Method to create ControlLoopUpdateMsg. - * - * @return ControlLoopUpdate message - */ - public static ControlLoopUpdate createControlLoopUpdateMsg() { - final ControlLoopUpdate clUpdateMsg = new ControlLoopUpdate(); - ToscaConceptIdentifier controlLoopId = new ToscaConceptIdentifier("PMSHInstance0", "1.0.0"); - ToscaConceptIdentifier participantId = new ToscaConceptIdentifier("org.onap.PM_Policy", "0.0.0"); - - clUpdateMsg.setControlLoopId(controlLoopId); - clUpdateMsg.setParticipantId(participantId); - clUpdateMsg.setMessageId(UUID.randomUUID()); - clUpdateMsg.setTimestamp(Instant.now()); - - Map elements = new LinkedHashMap<>(); - ToscaServiceTemplate toscaServiceTemplate = testControlLoopRead(); - Map nodeTemplatesMap = - toscaServiceTemplate.getToscaTopologyTemplate().getNodeTemplates(); - for (Map.Entry toscaInputEntry : nodeTemplatesMap.entrySet()) { - if (ParticipantUtils.checkIfNodeTemplateIsControlLoopElement(toscaInputEntry.getValue(), - toscaServiceTemplate)) { - ControlLoopElement clElement = new ControlLoopElement(); - clElement.setId(UUID.randomUUID()); - var clParticipantType = - ParticipantUtils.findParticipantType(toscaInputEntry.getValue().getProperties()); - - clElement.setParticipantId(clParticipantType); - clElement.setParticipantType(clParticipantType); - - clElement.setDefinition( - new ToscaConceptIdentifier(toscaInputEntry.getKey(), toscaInputEntry.getValue().getVersion())); - clElement.setState(ControlLoopState.UNINITIALISED); - clElement.setDescription(toscaInputEntry.getValue().getDescription()); - clElement.setOrderedState(ControlLoopOrderedState.PASSIVE); - elements.put(clElement.getId(), clElement); - } - } - - List participantUpdates = new ArrayList<>(); - for (ControlLoopElement element : elements.values()) { - CommonUtils.prepareParticipantUpdate(element, participantUpdates); - } - clUpdateMsg.setParticipantUpdatesList(participantUpdates); - return clUpdateMsg; - } - - /** - * Method to create participantUpdateMsg. - * - * @return ParticipantUpdate message - */ - public static ParticipantUpdate createParticipantUpdateMsg() { - final ParticipantUpdate participantUpdateMsg = new ParticipantUpdate(); - ToscaConceptIdentifier participantId = new ToscaConceptIdentifier("org.onap.PM_Policy", "1.0.0"); - ToscaConceptIdentifier participantType = - new ToscaConceptIdentifier("org.onap.policy.controlloop.PolicyControlLoopParticipant", "2.3.1"); - - participantUpdateMsg.setParticipantId(participantId); - participantUpdateMsg.setTimestamp(Instant.now()); - participantUpdateMsg.setParticipantType(participantType); - participantUpdateMsg.setTimestamp(Instant.ofEpochMilli(3000)); - participantUpdateMsg.setMessageId(UUID.randomUUID()); - - ToscaServiceTemplate toscaServiceTemplate = testControlLoopRead(); - // Add policies to the toscaServiceTemplate - List participantDefinitionUpdates = new ArrayList<>(); - for (Map.Entry toscaInputEntry : toscaServiceTemplate.getToscaTopologyTemplate() - .getNodeTemplates().entrySet()) { - if (ParticipantUtils.checkIfNodeTemplateIsControlLoopElement(toscaInputEntry.getValue(), - toscaServiceTemplate)) { - var clParticipantType = - ParticipantUtils.findParticipantType(toscaInputEntry.getValue().getProperties()); - CommonUtils.prepareParticipantDefinitionUpdate(clParticipantType, toscaInputEntry.getKey(), - toscaInputEntry.getValue(), participantDefinitionUpdates, null); - } - } - - participantUpdateMsg.setParticipantDefinitionUpdates(participantDefinitionUpdates); - return participantUpdateMsg; - } - - /** - * Method to create ControlLoopUpdate using the arguments passed. - * - * @param jsonFilePath the path of the controlloop content - * - * @return ControlLoopUpdate message - * @throws CoderException exception while reading the file to object - */ - public static ControlLoopUpdate createParticipantClUpdateMsgFromJson(String jsonFilePath) throws CoderException { - ControlLoopUpdate controlLoopUpdateMsg = CODER.decode(new File(jsonFilePath), ControlLoopUpdate.class); - return controlLoopUpdateMsg; - } - - private static ToscaServiceTemplate testControlLoopRead() { - Set controlLoopDirectoryContents = - ResourceUtils.getDirectoryContents("src/test/resources/rest/servicetemplates"); - - boolean atLeastOneControlLoopTested = false; - ToscaServiceTemplate toscaServiceTemplate = null; - - for (String controlLoopFilePath : controlLoopDirectoryContents) { - if (!controlLoopFilePath.endsWith(".yaml")) { - continue; - } - atLeastOneControlLoopTested = true; - toscaServiceTemplate = testControlLoopYamlSerialization(controlLoopFilePath); - } - - assertTrue(atLeastOneControlLoopTested); - return toscaServiceTemplate; - } - - private static ToscaServiceTemplate testControlLoopYamlSerialization(String controlLoopFilePath) { - try { - String controlLoopString = ResourceUtils.getResourceAsString(controlLoopFilePath); - if (controlLoopString == null) { - throw new FileNotFoundException(controlLoopFilePath); - } - - ToscaServiceTemplate serviceTemplate = - yamlTranslator.fromYaml(controlLoopString, ToscaServiceTemplate.class); - return serviceTemplate; - } catch (FileNotFoundException e) { - LOGGER.error("cannot find YAML file", controlLoopFilePath); - throw new IllegalArgumentException(e); - } - } -} diff --git a/participant/participant-impl/participant-impl-simulator/src/test/resources/application_test.properties b/participant/participant-impl/participant-impl-simulator/src/test/resources/application_test.properties index a4a1f99e5..ccc54581e 100644 --- a/participant/participant-impl/participant-impl-simulator/src/test/resources/application_test.properties +++ b/participant/participant-impl/participant-impl-simulator/src/test/resources/application_test.properties @@ -16,10 +16,10 @@ participant.intermediaryParameters.participantId.name=org.onap.PM_CDS_Blueprint participant.intermediaryParameters.participantId.version=1.0.0 participant.intermediaryParameters.participantType.name=org.onap.PM_CDS_Blueprint participant.intermediaryParameters.participantType.version=1.0.0 -participant.intermediaryParameters.clampControlLoopTopics.topicSources[0].topic=POLICY-CLRUNTIME-PARTICIPANT -participant.intermediaryParameters.clampControlLoopTopics.topicSources[0].servers[0]=localhost -participant.intermediaryParameters.clampControlLoopTopics.topicSources[0].topicCommInfrastructure=dmaap -participant.intermediaryParameters.clampControlLoopTopics.topicSources[0].fetchTimeout=15000 -participant.intermediaryParameters.clampControlLoopTopics.topicSinks[0].topic=POLICY-CLRUNTIME-PARTICIPANT -participant.intermediaryParameters.clampControlLoopTopics.topicSinks[0].servers[0]=localhost -participant.intermediaryParameters.clampControlLoopTopics.topicSinks[0].topicCommInfrastructure=dmaap +participant.intermediaryParameters.clampAutomationCompositionTopics.topicSources[0].topic=POLICY-ACRUNTIME-PARTICIPANT +participant.intermediaryParameters.clampAutomationCompositionTopics.topicSources[0].servers[0]=localhost +participant.intermediaryParameters.clampAutomationCompositionTopics.topicSources[0].topicCommInfrastructure=dmaap +participant.intermediaryParameters.clampAutomationCompositionTopics.topicSources[0].fetchTimeout=15000 +participant.intermediaryParameters.clampAutomationCompositionTopics.topicSinks[0].topic=POLICY-ACRUNTIME-PARTICIPANT +participant.intermediaryParameters.clampAutomationCompositionTopics.topicSinks[0].servers[0]=localhost +participant.intermediaryParameters.clampAutomationCompositionTopics.topicSinks[0].topicCommInfrastructure=dmaap diff --git a/participant/participant-impl/participant-impl-simulator/src/test/resources/rest/servicetemplates/pm_automation_composition_tosca.yaml b/participant/participant-impl/participant-impl-simulator/src/test/resources/rest/servicetemplates/pm_automation_composition_tosca.yaml new file mode 100644 index 000000000..6e34c7cce --- /dev/null +++ b/participant/participant-impl/participant-impl-simulator/src/test/resources/rest/servicetemplates/pm_automation_composition_tosca.yaml @@ -0,0 +1,164 @@ +tosca_definitions_version: tosca_simple_yaml_1_3 +data_types: + onap.datatypes.ToscaConceptIdentifier: + derived_from: tosca.datatypes.Root + properties: + name: + type: string + required: true + version: + type: string + required: true +node_types: + org.onap.policy.clamp.acm.Participant: + version: 1.0.1 + derived_from: tosca.nodetypes.Root + properties: + provider: + type: string + requred: false + org.onap.policy.clamp.acm.AutomationCompositionElement: + version: 1.0.1 + derived_from: tosca.nodetypes.Root + properties: + provider: + type: string + requred: false + participantType: + type: onap.datatypes.ToscaConceptIdentifier + requred: true + startPhase: + type: integer + required: false + constraints: + - greater-or-equal: 0 + metadata: + common: true + description: A value indicating the start phase in which this automation composition element will be started, the + first start phase is zero. Automation Composition Elements are started in their start_phase order and stopped + in reverse start phase order. Automation Composition Elements with the same start phase are started and + stopped simultaneously + org.onap.policy.clamp.acm.AutomationComposition: + version: 1.0.1 + derived_from: tosca.nodetypes.Root + properties: + provider: + type: string + requred: false + elements: + type: list + required: true + entry_schema: + type: onap.datatypes.ToscaConceptIdentifier + org.onap.policy.clamp.acm.DCAEMicroserviceAutomationCompositionElement: + version: 1.0.1 + derived_from: org.onap.policy.clamp.acm.AutomationCompositionElement + properties: + dcae_blueprint_id: + type: onap.datatypes.ToscaConceptIdentifier + requred: true + org.onap.policy.clamp.acm.PolicyTypeAutomationCompositionElement: + version: 1.0.1 + derived_from: org.onap.policy.clamp.acm.AutomationCompositionElement + properties: + policy_type_id: + type: onap.datatypes.ToscaConceptIdentifier + requred: true + org.onap.policy.clamp.acm.CDSAutomationCompositionElement: + version: 1.0.1 + derived_from: org.onap.policy.clamp.acm.AutomationCompositionElement + properties: + cds_blueprint_id: + type: onap.datatypes.ToscaConceptIdentifier + requred: true +topology_template: + node_templates: + org.onap.dcae.acm.DCAEMicroserviceAutomationCompositionParticipant: + version: 2.3.4 + type: org.onap.policy.clamp.acm.Participant + type_version: 1.0.1 + description: Participant for DCAE microservices + properties: + provider: ONAP + org.onap.policy.acm.PolicyAutomationCompositionParticipant: + version: 2.3.1 + type: org.onap.policy.clamp.acm.Participant + type_version: 1.0.1 + description: Participant for DCAE microservices + properties: + provider: ONAP + org.onap.ccsdk.cds.acm.CdsAutomationCompositionParticipant: + version: 2.2.1 + type: org.onap.policy.clamp.acm.Participant + type_version: 1.0.1 + description: Participant for DCAE microservices + properties: + provider: ONAP + org.onap.domain.pmsh.PMSH_DCAEMicroservice: + version: 1.2.3 + type: org.onap.policy.clamp.acm.DCAEMicroserviceAutomationCompositionElement + type_version: 1.0.0 + description: Automation composition element for the DCAE microservice for Performance Management Subscription Handling + properties: + provider: Ericsson + participantType: + name: org.onap.dcae.acm.DCAEMicroserviceAutomationCompositionParticipant + version: 2.3.4 + dcae_blueprint_id: + name: org.onap.dcae.blueprints.PMSHBlueprint + version: 1.0.0 + org.onap.domain.pmsh.PMSH_MonitoringPolicyAutomationCompositionElement: + version: 1.2.3 + type: org.onap.policy.clamp.acm.PolicyTypeAutomationCompositionElement + type_version: 1.0.0 + description: Automation composition element for the monitoring policy for Performance Management Subscription Handling + properties: + provider: Ericsson + participantType: + name: org.onap.policy.acm.PolicyAutomationCompositionParticipant + version: 2.3.1 + policy_type_id: + name: onap.policies.monitoring.pm-subscription-handler + version: 1.0.0 + org.onap.domain.pmsh.PMSH_OperationalPolicyAutomationCompositionElement: + version: 1.2.3 + type: org.onap.policy.clamp.acm.PolicyTypeAutomationCompositionElement + type_version: 1.0.0 + description: Automation composition element for the operational policy for Performance Management Subscription Handling + properties: + provider: Ericsson + participantType: + name: org.onap.policy.acm.PolicyAutomationCompositionParticipant + version: 2.3.1 + policy_type_id: + name: onap.policies.operational.pm-subscription-handler + version: 1.0.0 + org.onap.domain.pmsh.PMSH_CDS_AutomationCompositionElement: + version: 1.2.3 + type: org.onap.policy.clamp.acm.AutomationCompositionElement + type_version: 1.0.0 + description: Automation composition element for CDS for Performance Management Subscription Handling + properties: + provider: Ericsson + participantType: + name: org.onap.PM_CDS_Blueprint + version: 1.0.0 + cds_blueprint_id: + name: org.onap.ccsdk.cds.PMSHCdsBlueprint + version: 1.0.0 + org.onap.domain.pmsh.PMSHAutomationCompositionDefinition: + version: 1.2.3 + type: org.onap.policy.clamp.acm.AutomationComposition + type_version: 1.0.0 + description: Automation composition for Performance Management Subscription Handling + properties: + provider: Ericsson + elements: + - name: org.onap.domain.pmsh.PMSH_DCAEMicroservice + version: 1.2.3 + - name: org.onap.domain.pmsh.PMSH_MonitoringPolicyAutomationCompositionElement + version: 1.2.3 + - name: org.onap.domain.pmsh.PMSH_OperationalPolicyAutomationCompositionElement + version: 1.2.3 + - name: org.onap.domain.pmsh.PMSH_CDS_AutomationCompositionElement + version: 1.2.3 diff --git a/participant/participant-impl/participant-impl-simulator/src/test/resources/rest/servicetemplates/pm_control_loop_tosca.yaml b/participant/participant-impl/participant-impl-simulator/src/test/resources/rest/servicetemplates/pm_control_loop_tosca.yaml deleted file mode 100644 index 21d20a8ee..000000000 --- a/participant/participant-impl/participant-impl-simulator/src/test/resources/rest/servicetemplates/pm_control_loop_tosca.yaml +++ /dev/null @@ -1,164 +0,0 @@ -tosca_definitions_version: tosca_simple_yaml_1_3 -data_types: - onap.datatypes.ToscaConceptIdentifier: - derived_from: tosca.datatypes.Root - properties: - name: - type: string - required: true - version: - type: string - required: true -node_types: - org.onap.policy.clamp.controlloop.Participant: - version: 1.0.1 - derived_from: tosca.nodetypes.Root - properties: - provider: - type: string - requred: false - org.onap.policy.clamp.controlloop.ControlLoopElement: - version: 1.0.1 - derived_from: tosca.nodetypes.Root - properties: - provider: - type: string - requred: false - participantType: - type: onap.datatypes.ToscaConceptIdentifier - requred: true - startPhase: - type: integer - required: false - constraints: - - greater-or-equal: 0 - metadata: - common: true - description: A value indicating the start phase in which this control loop element will be started, the - first start phase is zero. Control Loop Elements are started in their start_phase order and stopped - in reverse start phase order. Control Loop Elements with the same start phase are started and - stopped simultaneously - org.onap.policy.clamp.controlloop.ControlLoop: - version: 1.0.1 - derived_from: tosca.nodetypes.Root - properties: - provider: - type: string - requred: false - elements: - type: list - required: true - entry_schema: - type: onap.datatypes.ToscaConceptIdentifier - org.onap.policy.clamp.controlloop.DCAEMicroserviceControlLoopElement: - version: 1.0.1 - derived_from: org.onap.policy.clamp.controlloop.ControlLoopElement - properties: - dcae_blueprint_id: - type: onap.datatypes.ToscaConceptIdentifier - requred: true - org.onap.policy.clamp.controlloop.PolicyTypeControlLoopElement: - version: 1.0.1 - derived_from: org.onap.policy.clamp.controlloop.ControlLoopElement - properties: - policy_type_id: - type: onap.datatypes.ToscaConceptIdentifier - requred: true - org.onap.policy.clamp.controlloop.CDSControlLoopElement: - version: 1.0.1 - derived_from: org.onap.policy.clamp.controlloop.ControlLoopElement - properties: - cds_blueprint_id: - type: onap.datatypes.ToscaConceptIdentifier - requred: true -topology_template: - node_templates: - org.onap.dcae.controlloop.DCAEMicroserviceControlLoopParticipant: - version: 2.3.4 - type: org.onap.policy.clamp.controlloop.Participant - type_version: 1.0.1 - description: Participant for DCAE microservices - properties: - provider: ONAP - org.onap.policy.controlloop.PolicyControlLoopParticipant: - version: 2.3.1 - type: org.onap.policy.clamp.controlloop.Participant - type_version: 1.0.1 - description: Participant for DCAE microservices - properties: - provider: ONAP - org.onap.ccsdk.cds.controlloop.CdsControlLoopParticipant: - version: 2.2.1 - type: org.onap.policy.clamp.controlloop.Participant - type_version: 1.0.1 - description: Participant for DCAE microservices - properties: - provider: ONAP - org.onap.domain.pmsh.PMSH_DCAEMicroservice: - version: 1.2.3 - type: org.onap.policy.clamp.controlloop.DCAEMicroserviceControlLoopElement - type_version: 1.0.0 - description: Control loop element for the DCAE microservice for Performance Management Subscription Handling - properties: - provider: Ericsson - participantType: - name: org.onap.dcae.controlloop.DCAEMicroserviceControlLoopParticipant - version: 2.3.4 - dcae_blueprint_id: - name: org.onap.dcae.blueprints.PMSHBlueprint - version: 1.0.0 - org.onap.domain.pmsh.PMSH_MonitoringPolicyControlLoopElement: - version: 1.2.3 - type: org.onap.policy.clamp.controlloop.PolicyTypeControlLoopElement - type_version: 1.0.0 - description: Control loop element for the monitoring policy for Performance Management Subscription Handling - properties: - provider: Ericsson - participantType: - name: org.onap.policy.controlloop.PolicyControlLoopParticipant - version: 2.3.1 - policy_type_id: - name: onap.policies.monitoring.pm-subscription-handler - version: 1.0.0 - org.onap.domain.pmsh.PMSH_OperationalPolicyControlLoopElement: - version: 1.2.3 - type: org.onap.policy.clamp.controlloop.PolicyTypeControlLoopElement - type_version: 1.0.0 - description: Control loop element for the operational policy for Performance Management Subscription Handling - properties: - provider: Ericsson - participantType: - name: org.onap.policy.controlloop.PolicyControlLoopParticipant - version: 2.3.1 - policy_type_id: - name: onap.policies.operational.pm-subscription-handler - version: 1.0.0 - org.onap.domain.pmsh.PMSH_CDS_ControlLoopElement: - version: 1.2.3 - type: org.onap.policy.clamp.controlloop.ControlLoopElement - type_version: 1.0.0 - description: Control loop element for CDS for Performance Management Subscription Handling - properties: - provider: Ericsson - participantType: - name: org.onap.PM_CDS_Blueprint - version: 1.0.0 - cds_blueprint_id: - name: org.onap.ccsdk.cds.PMSHCdsBlueprint - version: 1.0.0 - org.onap.domain.pmsh.PMSHControlLoopDefinition: - version: 1.2.3 - type: org.onap.policy.clamp.controlloop.ControlLoop - type_version: 1.0.0 - description: Control loop for Performance Management Subscription Handling - properties: - provider: Ericsson - elements: - - name: org.onap.domain.pmsh.PMSH_DCAEMicroservice - version: 1.2.3 - - name: org.onap.domain.pmsh.PMSH_MonitoringPolicyControlLoopElement - version: 1.2.3 - - name: org.onap.domain.pmsh.PMSH_OperationalPolicyControlLoopElement - version: 1.2.3 - - name: org.onap.domain.pmsh.PMSH_CDS_ControlLoopElement - version: 1.2.3 diff --git a/participant/participant-intermediary/pom.xml b/participant/participant-intermediary/pom.xml index c6078360e..936d26b76 100644 --- a/participant/participant-intermediary/pom.xml +++ b/participant/participant-intermediary/pom.xml @@ -30,7 +30,7 @@ policy-clamp-participant-intermediary ${project.artifactId} - Common intermediary library for managing DMaaP participant messaging and holding participant and control - loop state + Common intermediary library for managing DMaaP participant messaging and holding participant and + Automation Composition state diff --git a/participant/participant-intermediary/src/main/java/org/onap/policy/clamp/acm/participant/intermediary/api/AutomationCompositionElementListener.java b/participant/participant-intermediary/src/main/java/org/onap/policy/clamp/acm/participant/intermediary/api/AutomationCompositionElementListener.java new file mode 100644 index 000000000..9affd5751 --- /dev/null +++ b/participant/participant-intermediary/src/main/java/org/onap/policy/clamp/acm/participant/intermediary/api/AutomationCompositionElementListener.java @@ -0,0 +1,65 @@ +/*- + * ============LICENSE_START======================================================= + * Copyright (C) 2021 Nordix Foundation. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * SPDX-License-Identifier: Apache-2.0 + * ============LICENSE_END========================================================= + */ + +package org.onap.policy.clamp.acm.participant.intermediary.api; + +import java.util.UUID; +import org.onap.policy.clamp.models.acm.concepts.AutomationCompositionElement; +import org.onap.policy.clamp.models.acm.concepts.AutomationCompositionOrderedState; +import org.onap.policy.clamp.models.acm.concepts.AutomationCompositionState; +import org.onap.policy.models.base.PfModelException; +import org.onap.policy.models.tosca.authorative.concepts.ToscaConceptIdentifier; +import org.onap.policy.models.tosca.authorative.concepts.ToscaNodeTemplate; + +/** + * This interface is implemented by participant implementations to receive updates on automation composition elements. + */ +public interface AutomationCompositionElementListener { + /** + * Handle a automation composition element state change. + * + * @param automationCompositionElementId the ID of the automation composition element + * @param currentState the current state of the automation composition element + * @param newState the state to which the automation composition element is changing to + * @throws PfModelException in case of a model exception + */ + public void automationCompositionElementStateChange(ToscaConceptIdentifier automationCompositionId, + UUID automationCompositionElementId, AutomationCompositionState currentState, + AutomationCompositionOrderedState newState) throws PfModelException; + + /** + * Handle an update on a automation composition element. + * + * @param element the information on the automation composition element + * @param automationCompositionElementDefinition toscaNodeTemplate + * @throws PfModelException from Policy framework + */ + public void automationCompositionElementUpdate(ToscaConceptIdentifier automationCompositionId, + AutomationCompositionElement element, ToscaNodeTemplate automationCompositionElementDefinition) + throws PfModelException; + + /** + * Handle automationCompositionElement statistics. + * + * @param automationCompositionElementId automationCompositionElement id + * @throws PfModelException in case of a model exception + */ + public void handleStatistics(UUID automationCompositionElementId) throws PfModelException; +} diff --git a/participant/participant-intermediary/src/main/java/org/onap/policy/clamp/acm/participant/intermediary/api/ParticipantIntermediaryApi.java b/participant/participant-intermediary/src/main/java/org/onap/policy/clamp/acm/participant/intermediary/api/ParticipantIntermediaryApi.java new file mode 100644 index 000000000..79f5259bf --- /dev/null +++ b/participant/participant-intermediary/src/main/java/org/onap/policy/clamp/acm/participant/intermediary/api/ParticipantIntermediaryApi.java @@ -0,0 +1,130 @@ +/*- + * ============LICENSE_START======================================================= + * Copyright (C) 2021 Nordix Foundation. + * Modifications Copyright (C) 2021 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * SPDX-License-Identifier: Apache-2.0 + * ============LICENSE_END========================================================= + */ + +package org.onap.policy.clamp.acm.participant.intermediary.api; + +import java.util.List; +import java.util.Map; +import java.util.UUID; +import org.onap.policy.clamp.models.acm.concepts.AcElementStatistics; +import org.onap.policy.clamp.models.acm.concepts.AutomationCompositionElement; +import org.onap.policy.clamp.models.acm.concepts.AutomationCompositionOrderedState; +import org.onap.policy.clamp.models.acm.concepts.AutomationCompositionState; +import org.onap.policy.clamp.models.acm.concepts.AutomationCompositions; +import org.onap.policy.clamp.models.acm.concepts.Participant; +import org.onap.policy.clamp.models.acm.concepts.ParticipantState; +import org.onap.policy.clamp.models.acm.concepts.ParticipantStatistics; +import org.onap.policy.clamp.models.acm.messages.dmaap.participant.ParticipantMessageType; +import org.onap.policy.models.tosca.authorative.concepts.ToscaConceptIdentifier; +import org.onap.policy.models.tosca.authorative.concepts.ToscaProperty; + +/** + * This interface is used by participant implementations to use the participant intermediary. + */ +public interface ParticipantIntermediaryApi { + + /** + * Register a listener for automation composition elements that are mediated by the intermediary. + * + * @param automationCompositionElementListener The automation composition element listener to register + */ + void registerAutomationCompositionElementListener( + AutomationCompositionElementListener automationCompositionElementListener); + + /** + * Get participants loops from the intermediary API. + * + * @param name the participant name, null for all + * @param version the participant version, null for all + * @return the participants + */ + List getParticipants(String name, String version); + + /** + * Get common properties of a automation composition element. + * + * @param acElementDef the automation composition element definition + * @return the common properties + */ + Map getAcElementDefinitionCommonProperties(ToscaConceptIdentifier acElementDef); + + /** + * Update the state of a participant. + * + * @param definition the definition of the participant to update the state on + * @param state the state of the participant + * @return the participant + */ + Participant updateParticipantState(ToscaConceptIdentifier definition, ParticipantState state); + + /** + * Update the statistics of a participant. + * + * @param participantStatistics the statistics of the participant + */ + void updateParticipantStatistics(ParticipantStatistics participantStatistics); + + /** + * Get automation compositions from the intermediary API. + * + * @param name the automation composition element name, null for all + * @param version the automation composition element version, null for all + * @return the automation composition elements + */ + AutomationCompositions getAutomationCompositions(String name, String version); + + /** + * Get automation composition elements from the intermediary API. + * + * @param name the automation composition element name, null for all + * @param version the automation composition element version, null for all + * @return the automation composition elements + */ + Map getAutomationCompositionElements(String name, String version); + + /** + * Get automation composition element from the intermediary API. + * + * @param id automation composition element ID + * @return the automation composition element + */ + AutomationCompositionElement getAutomationCompositionElement(UUID id); + + /** + * Update the state of a automation composition element. + * + * @param id the ID of the automation composition element to update the state on + * @param currentState the state of the automation composition element + * @param newState the state of the automation composition element + * @return AutomationCompositionElement updated automation composition element + */ + AutomationCompositionElement updateAutomationCompositionElementState(ToscaConceptIdentifier automationCompositionId, + UUID id, AutomationCompositionOrderedState currentState, AutomationCompositionState newState, + ParticipantMessageType messageType); + + /** + * Update the automation composition element statistics. + * + * @param id the ID of the automation composition element to update the state on + * @param elementStatistics the updated statistics + */ + void updateAutomationCompositionElementStatistics(UUID id, AcElementStatistics elementStatistics); +} diff --git a/participant/participant-intermediary/src/main/java/org/onap/policy/clamp/acm/participant/intermediary/api/impl/ParticipantIntermediaryApiImpl.java b/participant/participant-intermediary/src/main/java/org/onap/policy/clamp/acm/participant/intermediary/api/impl/ParticipantIntermediaryApiImpl.java new file mode 100644 index 000000000..1a1f8500f --- /dev/null +++ b/participant/participant-intermediary/src/main/java/org/onap/policy/clamp/acm/participant/intermediary/api/impl/ParticipantIntermediaryApiImpl.java @@ -0,0 +1,140 @@ +/*- + * ============LICENSE_START======================================================= + * Copyright (C) 2021 Nordix Foundation. + * Modifications Copyright (C) 2021 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * SPDX-License-Identifier: Apache-2.0 + * ============LICENSE_END========================================================= + */ + +package org.onap.policy.clamp.acm.participant.intermediary.api.impl; + +import java.util.LinkedHashMap; +import java.util.List; +import java.util.Map; +import java.util.UUID; +import org.onap.policy.clamp.acm.participant.intermediary.api.AutomationCompositionElementListener; +import org.onap.policy.clamp.acm.participant.intermediary.api.ParticipantIntermediaryApi; +import org.onap.policy.clamp.acm.participant.intermediary.handler.AutomationCompositionHandler; +import org.onap.policy.clamp.acm.participant.intermediary.handler.ParticipantHandler; +import org.onap.policy.clamp.models.acm.concepts.AcElementStatistics; +import org.onap.policy.clamp.models.acm.concepts.AutomationComposition; +import org.onap.policy.clamp.models.acm.concepts.AutomationCompositionElement; +import org.onap.policy.clamp.models.acm.concepts.AutomationCompositionOrderedState; +import org.onap.policy.clamp.models.acm.concepts.AutomationCompositionState; +import org.onap.policy.clamp.models.acm.concepts.AutomationCompositions; +import org.onap.policy.clamp.models.acm.concepts.Participant; +import org.onap.policy.clamp.models.acm.concepts.ParticipantState; +import org.onap.policy.clamp.models.acm.concepts.ParticipantStatistics; +import org.onap.policy.clamp.models.acm.messages.dmaap.participant.ParticipantMessageType; +import org.onap.policy.models.tosca.authorative.concepts.ToscaConceptIdentifier; +import org.onap.policy.models.tosca.authorative.concepts.ToscaProperty; +import org.springframework.stereotype.Component; + +/** + * This class is api implementation used by participant intermediary. + */ +@Component +public class ParticipantIntermediaryApiImpl implements ParticipantIntermediaryApi { + + // The handler for the participant intermediary + private final ParticipantHandler participantHandler; + + // The handler for the automationComposition intermediary + private final AutomationCompositionHandler automationCompositionHandler; + + /** + * Constructor. + * + * @param participantHandler ParticipantHandler + * @param automationCompositionHandler AutomationCompositionHandler + */ + public ParticipantIntermediaryApiImpl(ParticipantHandler participantHandler, + AutomationCompositionHandler automationCompositionHandler) { + this.participantHandler = participantHandler; + this.automationCompositionHandler = automationCompositionHandler; + } + + @Override + public void registerAutomationCompositionElementListener( + AutomationCompositionElementListener automationCompositionElementListener) { + automationCompositionHandler.registerAutomationCompositionElementListener(automationCompositionElementListener); + } + + @Override + public List getParticipants(String name, String version) { + return List.of(participantHandler.getParticipant(name, version)); + } + + @Override + public Map getAcElementDefinitionCommonProperties(ToscaConceptIdentifier acElementDef) { + return participantHandler.getAcElementDefinitionCommonProperties(acElementDef); + } + + @Override + public Participant updateParticipantState(ToscaConceptIdentifier definition, ParticipantState state) { + return participantHandler.updateParticipantState(definition, state); + } + + @Override + public void updateParticipantStatistics(ParticipantStatistics participantStatistics) { + participantHandler.updateParticipantStatistics(participantStatistics); + } + + @Override + public AutomationCompositions getAutomationCompositions(String name, String version) { + return automationCompositionHandler.getAutomationCompositions(); + } + + @Override + public Map getAutomationCompositionElements(String name, String version) { + List automationCompositions = + automationCompositionHandler.getAutomationCompositions().getAutomationCompositionList(); + + for (AutomationComposition automationComposition : automationCompositions) { + if (name.equals(automationComposition.getDefinition().getName())) { + return automationComposition.getElements(); + } + } + return new LinkedHashMap<>(); + } + + @Override + public AutomationCompositionElement getAutomationCompositionElement(UUID id) { + List automationCompositions = + automationCompositionHandler.getAutomationCompositions().getAutomationCompositionList(); + + for (AutomationComposition automationComposition : automationCompositions) { + AutomationCompositionElement acElement = automationComposition.getElements().get(id); + if (acElement != null) { + return acElement; + } + } + return null; + } + + @Override + public AutomationCompositionElement updateAutomationCompositionElementState( + ToscaConceptIdentifier automationCompositionId, UUID id, AutomationCompositionOrderedState currentState, + AutomationCompositionState newState, ParticipantMessageType messageType) { + return automationCompositionHandler.updateAutomationCompositionElementState(automationCompositionId, id, + currentState, newState); + } + + @Override + public void updateAutomationCompositionElementStatistics(UUID id, AcElementStatistics elementStatistics) { + automationCompositionHandler.updateAutomationCompositionElementStatistics(id, elementStatistics); + } +} diff --git a/participant/participant-intermediary/src/main/java/org/onap/policy/clamp/acm/participant/intermediary/comm/AutomationCompositionStateChangeListener.java b/participant/participant-intermediary/src/main/java/org/onap/policy/clamp/acm/participant/intermediary/comm/AutomationCompositionStateChangeListener.java new file mode 100644 index 000000000..b9ec6a6a0 --- /dev/null +++ b/participant/participant-intermediary/src/main/java/org/onap/policy/clamp/acm/participant/intermediary/comm/AutomationCompositionStateChangeListener.java @@ -0,0 +1,48 @@ +/*- + * ============LICENSE_START======================================================= + * Copyright (C) 2021 Nordix Foundation. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * SPDX-License-Identifier: Apache-2.0 + * ============LICENSE_END========================================================= + */ + +package org.onap.policy.clamp.acm.participant.intermediary.comm; + +import org.onap.policy.clamp.acm.participant.intermediary.handler.ParticipantHandler; +import org.onap.policy.clamp.models.acm.messages.dmaap.participant.AutomationCompositionStateChange; +import org.onap.policy.clamp.models.acm.messages.dmaap.participant.ParticipantMessageType; +import org.springframework.stereotype.Component; + +/** + * Listener for Participant State Change messages sent by CLAMP. + */ +@Component +public class AutomationCompositionStateChangeListener extends ParticipantListener { + + /** + * Constructs the object. + * + * @param participantHandler the handler for managing the state of the participant + */ + public AutomationCompositionStateChangeListener(final ParticipantHandler participantHandler) { + super(AutomationCompositionStateChange.class, participantHandler, + participantHandler::handleAutomationCompositionStateChange); + } + + @Override + public String getType() { + return ParticipantMessageType.AUTOMATION_COMPOSITION_STATE_CHANGE.name(); + } +} diff --git a/participant/participant-intermediary/src/main/java/org/onap/policy/clamp/acm/participant/intermediary/comm/AutomationCompositionUpdateListener.java b/participant/participant-intermediary/src/main/java/org/onap/policy/clamp/acm/participant/intermediary/comm/AutomationCompositionUpdateListener.java new file mode 100644 index 000000000..6c5dc127d --- /dev/null +++ b/participant/participant-intermediary/src/main/java/org/onap/policy/clamp/acm/participant/intermediary/comm/AutomationCompositionUpdateListener.java @@ -0,0 +1,48 @@ +/*- + * ============LICENSE_START======================================================= + * Copyright (C) 2021 Nordix Foundation. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * SPDX-License-Identifier: Apache-2.0 + * ============LICENSE_END========================================================= + */ + +package org.onap.policy.clamp.acm.participant.intermediary.comm; + +import org.onap.policy.clamp.acm.participant.intermediary.handler.ParticipantHandler; +import org.onap.policy.clamp.models.acm.messages.dmaap.participant.AutomationCompositionUpdate; +import org.onap.policy.clamp.models.acm.messages.dmaap.participant.ParticipantMessageType; +import org.springframework.stereotype.Component; + +/** + * Listener for Automation Composition Update messages sent by ACM. + */ +@Component +public class AutomationCompositionUpdateListener extends ParticipantListener { + + /** + * Constructs the object. + * + * @param participantHandler the handler for managing the state of the participant + */ + public AutomationCompositionUpdateListener(final ParticipantHandler participantHandler) { + super(AutomationCompositionUpdate.class, participantHandler, + participantHandler::handleAutomationCompositionUpdate); + } + + @Override + public String getType() { + return ParticipantMessageType.AUTOMATION_COMPOSITION_UPDATE.name(); + } +} diff --git a/participant/participant-intermediary/src/main/java/org/onap/policy/clamp/acm/participant/intermediary/comm/MessageSender.java b/participant/participant-intermediary/src/main/java/org/onap/policy/clamp/acm/participant/intermediary/comm/MessageSender.java new file mode 100644 index 000000000..0810a8a8a --- /dev/null +++ b/participant/participant-intermediary/src/main/java/org/onap/policy/clamp/acm/participant/intermediary/comm/MessageSender.java @@ -0,0 +1,78 @@ +/*- + * ============LICENSE_START======================================================= + * Copyright (C) 2021 Nordix Foundation. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * SPDX-License-Identifier: Apache-2.0 + * ============LICENSE_END========================================================= + */ + +package org.onap.policy.clamp.acm.participant.intermediary.comm; + +import java.io.Closeable; +import java.util.TimerTask; +import java.util.concurrent.Executors; +import java.util.concurrent.ScheduledExecutorService; +import java.util.concurrent.TimeUnit; +import org.onap.policy.clamp.acm.participant.intermediary.handler.ParticipantHandler; +import org.onap.policy.clamp.acm.participant.intermediary.parameters.ParticipantParameters; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.stereotype.Component; + +/** + * This class sends messages from participants to CLAMP. + */ +@Component +public class MessageSender extends TimerTask implements Closeable { + private static final Logger LOGGER = LoggerFactory.getLogger(MessageSender.class); + + private final ParticipantHandler participantHandler; + private ScheduledExecutorService timerPool; + + /** + * Constructor, set the publisher. + * + * @param participantHandler the participant handler to use for gathering information + * @param parameters the parameters of the participant + */ + public MessageSender(ParticipantHandler participantHandler, ParticipantParameters parameters) { + this.participantHandler = participantHandler; + + // Kick off the timer + timerPool = makeTimerPool(); + var interval = parameters.getIntermediaryParameters().getReportingTimeIntervalMs(); + timerPool.scheduleAtFixedRate(this, interval, interval, TimeUnit.MILLISECONDS); + } + + @Override + public void run() { + LOGGER.debug("Sent heartbeat to CLAMP"); + participantHandler.sendHeartbeat(); + } + + @Override + public void close() { + timerPool.shutdown(); + } + + /** + * Makes a new timer pool. + * + * @return a new timer pool + */ + protected ScheduledExecutorService makeTimerPool() { + return Executors.newScheduledThreadPool(1); + } +} diff --git a/participant/participant-intermediary/src/main/java/org/onap/policy/clamp/acm/participant/intermediary/comm/ParticipantAckListener.java b/participant/participant-intermediary/src/main/java/org/onap/policy/clamp/acm/participant/intermediary/comm/ParticipantAckListener.java new file mode 100644 index 000000000..c5427db6b --- /dev/null +++ b/participant/participant-intermediary/src/main/java/org/onap/policy/clamp/acm/participant/intermediary/comm/ParticipantAckListener.java @@ -0,0 +1,67 @@ +/*- + * ============LICENSE_START======================================================= + * Copyright (C) 2021 Nordix Foundation. + * Modifications Copyright (C) 2021 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Modifications Copyright (C) 2021 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * SPDX-License-Identifier: Apache-2.0 + * ============LICENSE_END========================================================= + */ + +package org.onap.policy.clamp.acm.participant.intermediary.comm; + +import java.util.function.Consumer; +import org.onap.policy.clamp.acm.participant.intermediary.handler.Listener; +import org.onap.policy.clamp.acm.participant.intermediary.handler.ParticipantHandler; +import org.onap.policy.clamp.models.acm.messages.dmaap.participant.ParticipantAckMessage; +import org.onap.policy.common.endpoints.event.comm.Topic.CommInfrastructure; +import org.onap.policy.common.endpoints.listeners.ScoListener; +import org.onap.policy.common.utils.coder.StandardCoderObject; + +/** + * Abstract Listener for Participant Ack messages sent by runtime. + */ +public abstract class ParticipantAckListener extends ScoListener + implements Listener { + + private final ParticipantHandler participantHandler; + private final Consumer consumer; + + /** + * Constructs the object. + * + * @param clazz class of message this handles + * @param participantHandler ParticipantHandler + * @param consumer function that handles the message + */ + protected ParticipantAckListener(Class clazz, ParticipantHandler participantHandler, Consumer consumer) { + super(clazz); + this.participantHandler = participantHandler; + this.consumer = consumer; + } + + @Override + public void onTopicEvent(CommInfrastructure infra, String topic, StandardCoderObject sco, T message) { + if (participantHandler.appliesTo(message)) { + consumer.accept(message); + } + } + + @Override + public ScoListener getScoListener() { + return this; + } +} diff --git a/participant/participant-intermediary/src/main/java/org/onap/policy/clamp/acm/participant/intermediary/comm/ParticipantDeregisterAckListener.java b/participant/participant-intermediary/src/main/java/org/onap/policy/clamp/acm/participant/intermediary/comm/ParticipantDeregisterAckListener.java new file mode 100644 index 000000000..51a2d2f9d --- /dev/null +++ b/participant/participant-intermediary/src/main/java/org/onap/policy/clamp/acm/participant/intermediary/comm/ParticipantDeregisterAckListener.java @@ -0,0 +1,48 @@ +/*- + * ============LICENSE_START======================================================= + * Copyright (C) 2021 Nordix Foundation. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * SPDX-License-Identifier: Apache-2.0 + * ============LICENSE_END========================================================= + */ + +package org.onap.policy.clamp.acm.participant.intermediary.comm; + +import org.onap.policy.clamp.acm.participant.intermediary.handler.ParticipantHandler; +import org.onap.policy.clamp.models.acm.messages.dmaap.participant.ParticipantDeregisterAck; +import org.onap.policy.clamp.models.acm.messages.dmaap.participant.ParticipantMessageType; +import org.springframework.stereotype.Component; + +/** + * Listener for Participant Deregister Ack messages sent by runtime. + * + */ +@Component +public class ParticipantDeregisterAckListener extends ParticipantAckListener { + + /** + * Constructs the object. + * + * @param participantHandler the handler for managing the state of the participant + */ + public ParticipantDeregisterAckListener(final ParticipantHandler participantHandler) { + super(ParticipantDeregisterAck.class, participantHandler, participantHandler::handleParticipantDeregisterAck); + } + + @Override + public String getType() { + return ParticipantMessageType.PARTICIPANT_DEREGISTER_ACK.name(); + } +} diff --git a/participant/participant-intermediary/src/main/java/org/onap/policy/clamp/acm/participant/intermediary/comm/ParticipantListener.java b/participant/participant-intermediary/src/main/java/org/onap/policy/clamp/acm/participant/intermediary/comm/ParticipantListener.java new file mode 100644 index 000000000..0eaf25cca --- /dev/null +++ b/participant/participant-intermediary/src/main/java/org/onap/policy/clamp/acm/participant/intermediary/comm/ParticipantListener.java @@ -0,0 +1,64 @@ +/*- + * ============LICENSE_START======================================================= + * Copyright (C) 2021 Nordix Foundation. + * Modifications Copyright (C) 2021 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * SPDX-License-Identifier: Apache-2.0 + * ============LICENSE_END========================================================= + */ + +package org.onap.policy.clamp.acm.participant.intermediary.comm; + +import java.util.function.Consumer; +import org.onap.policy.clamp.acm.participant.intermediary.handler.Listener; +import org.onap.policy.clamp.acm.participant.intermediary.handler.ParticipantHandler; +import org.onap.policy.clamp.models.acm.messages.dmaap.participant.ParticipantMessage; +import org.onap.policy.common.endpoints.event.comm.Topic.CommInfrastructure; +import org.onap.policy.common.endpoints.listeners.ScoListener; +import org.onap.policy.common.utils.coder.StandardCoderObject; + +/** + * Abstract Listener for Participant messages sent by CLAMP. + */ +public abstract class ParticipantListener extends ScoListener implements Listener { + + private final ParticipantHandler participantHandler; + private final Consumer consumer; + + /** + * Constructs the object. + * + * @param clazz class of message this handles + * @param participantHandler ParticipantHandler + * @param consumer function that handles the message + */ + protected ParticipantListener(Class clazz, ParticipantHandler participantHandler, Consumer consumer) { + super(clazz); + this.participantHandler = participantHandler; + this.consumer = consumer; + } + + @Override + public void onTopicEvent(CommInfrastructure infra, String topic, StandardCoderObject sco, T message) { + if (participantHandler.appliesTo(message)) { + consumer.accept(message); + } + } + + @Override + public ScoListener getScoListener() { + return this; + } +} diff --git a/participant/participant-intermediary/src/main/java/org/onap/policy/clamp/acm/participant/intermediary/comm/ParticipantMessagePublisher.java b/participant/participant-intermediary/src/main/java/org/onap/policy/clamp/acm/participant/intermediary/comm/ParticipantMessagePublisher.java new file mode 100644 index 000000000..67814a4e6 --- /dev/null +++ b/participant/participant-intermediary/src/main/java/org/onap/policy/clamp/acm/participant/intermediary/comm/ParticipantMessagePublisher.java @@ -0,0 +1,147 @@ +/*- + * ============LICENSE_START======================================================= + * Copyright (C) 2021 Nordix Foundation. + * Modifications Copyright (C) 2021 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * SPDX-License-Identifier: Apache-2.0 + * ============LICENSE_END========================================================= + */ + +package org.onap.policy.clamp.acm.participant.intermediary.comm; + +import java.util.List; +import javax.ws.rs.core.Response.Status; +import org.onap.policy.clamp.acm.participant.intermediary.handler.Publisher; +import org.onap.policy.clamp.common.acm.exception.AutomationCompositionRuntimeException; +import org.onap.policy.clamp.models.acm.messages.dmaap.participant.AutomationCompositionAck; +import org.onap.policy.clamp.models.acm.messages.dmaap.participant.ParticipantDeregister; +import org.onap.policy.clamp.models.acm.messages.dmaap.participant.ParticipantRegister; +import org.onap.policy.clamp.models.acm.messages.dmaap.participant.ParticipantStatus; +import org.onap.policy.clamp.models.acm.messages.dmaap.participant.ParticipantUpdateAck; +import org.onap.policy.common.endpoints.event.comm.TopicSink; +import org.onap.policy.common.endpoints.event.comm.client.TopicSinkClient; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.stereotype.Component; + +/** + * This class is used to send Participant Status messages to clamp using TopicSinkClient. + * + */ +@Component +public class ParticipantMessagePublisher implements Publisher { + private static final Logger LOGGER = LoggerFactory.getLogger(ParticipantMessagePublisher.class); + private static final String NOT_ACTIVE_TEXT = "Not Active!"; + + private boolean active = false; + private TopicSinkClient topicSinkClient; + + /** + * Constructor for instantiating ParticipantMessagePublisher. + * + * @param topicSinks the topic sinks + */ + @Override + public void active(List topicSinks) { + if (topicSinks.size() != 1) { + throw new IllegalArgumentException("Configuration unsupported, Topic sinks greater than 1"); + } + this.topicSinkClient = new TopicSinkClient(topicSinks.get(0)); + active = true; + } + + /** + * Method to send Participant Status message to clamp on demand. + * + * @param participantStatus the Participant Status + */ + public void sendParticipantStatus(final ParticipantStatus participantStatus) { + if (!active) { + throw new AutomationCompositionRuntimeException(Status.NOT_ACCEPTABLE, NOT_ACTIVE_TEXT); + } + topicSinkClient.send(participantStatus); + LOGGER.debug("Sent Participant Status message to CLAMP - {}", participantStatus); + } + + /** + * Method to send Participant Status message to clamp on demand. + * + * @param participantRegister the Participant Status + */ + public void sendParticipantRegister(final ParticipantRegister participantRegister) { + if (!active) { + throw new AutomationCompositionRuntimeException(Status.NOT_ACCEPTABLE, NOT_ACTIVE_TEXT); + } + topicSinkClient.send(participantRegister); + LOGGER.debug("Sent Participant Register message to CLAMP - {}", participantRegister); + } + + /** + * Method to send Participant Status message to clamp on demand. + * + * @param participantDeregister the Participant Status + */ + public void sendParticipantDeregister(final ParticipantDeregister participantDeregister) { + if (!active) { + throw new AutomationCompositionRuntimeException(Status.NOT_ACCEPTABLE, NOT_ACTIVE_TEXT); + } + topicSinkClient.send(participantDeregister); + LOGGER.debug("Sent Participant Deregister message to CLAMP - {}", participantDeregister); + } + + /** + * Method to send Participant Update Ack message to runtime. + * + * @param participantUpdateAck the Participant Update Ack + */ + public void sendParticipantUpdateAck(final ParticipantUpdateAck participantUpdateAck) { + if (!active) { + throw new AutomationCompositionRuntimeException(Status.NOT_ACCEPTABLE, NOT_ACTIVE_TEXT); + } + topicSinkClient.send(participantUpdateAck); + LOGGER.debug("Sent Participant Update Ack message to CLAMP - {}", participantUpdateAck); + } + + /** + * Method to send AutomationComposition Update/StateChange Ack message to runtime. + * + * @param automationCompositionAck AutomationComposition Update/StateChange Ack + */ + public void sendAutomationCompositionAck(final AutomationCompositionAck automationCompositionAck) { + if (!active) { + throw new AutomationCompositionRuntimeException(Status.NOT_ACCEPTABLE, NOT_ACTIVE_TEXT); + } + topicSinkClient.send(automationCompositionAck); + LOGGER.debug("Sent AutomationComposition Update/StateChange Ack to runtime - {}", automationCompositionAck); + } + + /** + * Method to send Participant heartbeat to clamp on demand. + * + * @param participantStatus the Participant Status + */ + public void sendHeartbeat(final ParticipantStatus participantStatus) { + if (!active) { + throw new AutomationCompositionRuntimeException(Status.NOT_ACCEPTABLE, NOT_ACTIVE_TEXT); + } + topicSinkClient.send(participantStatus); + LOGGER.debug("Sent Participant heartbeat to CLAMP - {}", participantStatus); + } + + @Override + public void stop() { + active = false; + } +} diff --git a/participant/participant-intermediary/src/main/java/org/onap/policy/clamp/acm/participant/intermediary/comm/ParticipantRegisterAckListener.java b/participant/participant-intermediary/src/main/java/org/onap/policy/clamp/acm/participant/intermediary/comm/ParticipantRegisterAckListener.java new file mode 100644 index 000000000..e29fa6f96 --- /dev/null +++ b/participant/participant-intermediary/src/main/java/org/onap/policy/clamp/acm/participant/intermediary/comm/ParticipantRegisterAckListener.java @@ -0,0 +1,48 @@ +/*- + * ============LICENSE_START======================================================= + * Copyright (C) 2021 Nordix Foundation. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * SPDX-License-Identifier: Apache-2.0 + * ============LICENSE_END========================================================= + */ + +package org.onap.policy.clamp.acm.participant.intermediary.comm; + +import org.onap.policy.clamp.acm.participant.intermediary.handler.ParticipantHandler; +import org.onap.policy.clamp.models.acm.messages.dmaap.participant.ParticipantMessageType; +import org.onap.policy.clamp.models.acm.messages.dmaap.participant.ParticipantRegisterAck; +import org.springframework.stereotype.Component; + +/** + * Listener for Participant Register Ack messages sent by runtime. + * + */ +@Component +public class ParticipantRegisterAckListener extends ParticipantAckListener { + + /** + * Constructs the object. + * + * @param participantHandler the handler for managing the state of the participant + */ + public ParticipantRegisterAckListener(final ParticipantHandler participantHandler) { + super(ParticipantRegisterAck.class, participantHandler, participantHandler::handleParticipantRegisterAck); + } + + @Override + public String getType() { + return ParticipantMessageType.PARTICIPANT_REGISTER_ACK.name(); + } +} diff --git a/participant/participant-intermediary/src/main/java/org/onap/policy/clamp/acm/participant/intermediary/comm/ParticipantStatusReqListener.java b/participant/participant-intermediary/src/main/java/org/onap/policy/clamp/acm/participant/intermediary/comm/ParticipantStatusReqListener.java new file mode 100644 index 000000000..7af3678d7 --- /dev/null +++ b/participant/participant-intermediary/src/main/java/org/onap/policy/clamp/acm/participant/intermediary/comm/ParticipantStatusReqListener.java @@ -0,0 +1,47 @@ +/*- + * ============LICENSE_START======================================================= + * Copyright (C) 2021 Nordix Foundation. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * SPDX-License-Identifier: Apache-2.0 + * ============LICENSE_END========================================================= + */ + +package org.onap.policy.clamp.acm.participant.intermediary.comm; + +import org.onap.policy.clamp.acm.participant.intermediary.handler.ParticipantHandler; +import org.onap.policy.clamp.models.acm.messages.dmaap.participant.ParticipantMessageType; +import org.onap.policy.clamp.models.acm.messages.dmaap.participant.ParticipantStatusReq; +import org.springframework.stereotype.Component; + +/** + * Listener for Participant status request messages sent by runtime to all/one participant. + */ +@Component +public class ParticipantStatusReqListener extends ParticipantListener { + + /** + * Constructs the object. + * + * @param participantHandler the handler for managing the state and health of the participant + */ + public ParticipantStatusReqListener(final ParticipantHandler participantHandler) { + super(ParticipantStatusReq.class, participantHandler, participantHandler::handleParticipantStatusReq); + } + + @Override + public String getType() { + return ParticipantMessageType.PARTICIPANT_STATUS_REQ.name(); + } +} diff --git a/participant/participant-intermediary/src/main/java/org/onap/policy/clamp/acm/participant/intermediary/comm/ParticipantUpdateListener.java b/participant/participant-intermediary/src/main/java/org/onap/policy/clamp/acm/participant/intermediary/comm/ParticipantUpdateListener.java new file mode 100644 index 000000000..19eb5fb30 --- /dev/null +++ b/participant/participant-intermediary/src/main/java/org/onap/policy/clamp/acm/participant/intermediary/comm/ParticipantUpdateListener.java @@ -0,0 +1,47 @@ +/*- + * ============LICENSE_START======================================================= + * Copyright (C) 2021 Nordix Foundation. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * SPDX-License-Identifier: Apache-2.0 + * ============LICENSE_END========================================================= + */ + +package org.onap.policy.clamp.acm.participant.intermediary.comm; + +import org.onap.policy.clamp.acm.participant.intermediary.handler.ParticipantHandler; +import org.onap.policy.clamp.models.acm.messages.dmaap.participant.ParticipantMessageType; +import org.onap.policy.clamp.models.acm.messages.dmaap.participant.ParticipantUpdate; +import org.springframework.stereotype.Component; + +/** + * Listener for Participant Update messages sent by runtime. + */ +@Component +public class ParticipantUpdateListener extends ParticipantListener { + + /** + * Constructs the object. + * + * @param participantHandler the handler for managing the state of the participant + */ + public ParticipantUpdateListener(final ParticipantHandler participantHandler) { + super(ParticipantUpdate.class, participantHandler, participantHandler::handleParticipantUpdate); + } + + @Override + public String getType() { + return ParticipantMessageType.PARTICIPANT_UPDATE.name(); + } +} diff --git a/participant/participant-intermediary/src/main/java/org/onap/policy/clamp/acm/participant/intermediary/handler/AutomationCompositionHandler.java b/participant/participant-intermediary/src/main/java/org/onap/policy/clamp/acm/participant/intermediary/handler/AutomationCompositionHandler.java new file mode 100644 index 000000000..7e1fb5443 --- /dev/null +++ b/participant/participant-intermediary/src/main/java/org/onap/policy/clamp/acm/participant/intermediary/handler/AutomationCompositionHandler.java @@ -0,0 +1,476 @@ +/*- + * ============LICENSE_START======================================================= + * Copyright (C) 2021 Nordix Foundation. + * Modifications Copyright (C) 2021 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * SPDX-License-Identifier: Apache-2.0 + * ============LICENSE_END========================================================= + */ + +package org.onap.policy.clamp.acm.participant.intermediary.handler; + +import java.util.ArrayList; +import java.util.HashMap; +import java.util.LinkedHashMap; +import java.util.List; +import java.util.Map; +import java.util.UUID; +import java.util.stream.Collectors; +import lombok.Getter; +import org.onap.policy.clamp.acm.participant.intermediary.api.AutomationCompositionElementListener; +import org.onap.policy.clamp.acm.participant.intermediary.comm.ParticipantMessagePublisher; +import org.onap.policy.clamp.acm.participant.intermediary.parameters.ParticipantParameters; +import org.onap.policy.clamp.models.acm.concepts.AcElementStatistics; +import org.onap.policy.clamp.models.acm.concepts.AutomationComposition; +import org.onap.policy.clamp.models.acm.concepts.AutomationCompositionElement; +import org.onap.policy.clamp.models.acm.concepts.AutomationCompositionElementAck; +import org.onap.policy.clamp.models.acm.concepts.AutomationCompositionElementDefinition; +import org.onap.policy.clamp.models.acm.concepts.AutomationCompositionOrderedState; +import org.onap.policy.clamp.models.acm.concepts.AutomationCompositionState; +import org.onap.policy.clamp.models.acm.concepts.AutomationCompositions; +import org.onap.policy.clamp.models.acm.concepts.ParticipantUpdates; +import org.onap.policy.clamp.models.acm.concepts.ParticipantUtils; +import org.onap.policy.clamp.models.acm.messages.dmaap.participant.AutomationCompositionAck; +import org.onap.policy.clamp.models.acm.messages.dmaap.participant.AutomationCompositionStateChange; +import org.onap.policy.clamp.models.acm.messages.dmaap.participant.AutomationCompositionUpdate; +import org.onap.policy.clamp.models.acm.messages.dmaap.participant.ParticipantMessageType; +import org.onap.policy.models.base.PfModelException; +import org.onap.policy.models.tosca.authorative.concepts.ToscaConceptIdentifier; +import org.onap.policy.models.tosca.authorative.concepts.ToscaNodeTemplate; +import org.onap.policy.models.tosca.authorative.concepts.ToscaProperty; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.stereotype.Component; + +/* + * This class is responsible for managing the state of all automation compositions in the participant. + */ +@Component +public class AutomationCompositionHandler { + private static final Logger LOGGER = LoggerFactory.getLogger(AutomationCompositionHandler.class); + + private final ToscaConceptIdentifier participantType; + private final ToscaConceptIdentifier participantId; + private final ParticipantMessagePublisher publisher; + + @Getter + private final Map automationCompositionMap = new LinkedHashMap<>(); + + @Getter + private final Map elementsOnThisParticipant = new LinkedHashMap<>(); + + @Getter + private List listeners = new ArrayList<>(); + + /** + * Constructor, set the participant ID and messageSender. + * + * @param parameters the parameters of the participant + * @param publisher the ParticipantMessage Publisher + */ + public AutomationCompositionHandler(ParticipantParameters parameters, ParticipantMessagePublisher publisher) { + this.participantType = parameters.getIntermediaryParameters().getParticipantType(); + this.participantId = parameters.getIntermediaryParameters().getParticipantId(); + this.publisher = publisher; + } + + public void registerAutomationCompositionElementListener(AutomationCompositionElementListener listener) { + listeners.add(listener); + } + + /** + * Handle a automation composition element state change message. + * + * @param automationCompositionId the automationComposition Id + * @param id the automationComposition UUID + * @param orderedState the current state + * @param newState the ordered state + * @return automationCompositionElement the updated automation composition element + */ + public AutomationCompositionElement updateAutomationCompositionElementState( + ToscaConceptIdentifier automationCompositionId, UUID id, AutomationCompositionOrderedState orderedState, + AutomationCompositionState newState) { + + if (id == null) { + LOGGER.warn("Cannot update Automation composition element state, id is null"); + return null; + } + + // Update states of AutomationCompositionElement in automationCompositionMap + for (var automationComposition : automationCompositionMap.values()) { + var element = automationComposition.getElements().get(id); + if (element != null) { + element.setOrderedState(orderedState); + element.setState(newState); + } + var checkOpt = automationComposition.getElements().values().stream() + .filter(acElement -> !newState.equals(acElement.getState())).findAny(); + if (checkOpt.isEmpty()) { + automationComposition.setState(newState); + automationComposition.setOrderedState(orderedState); + } + } + + // Update states of AutomationCompositionElement in elementsOnThisParticipant + var acElement = elementsOnThisParticipant.get(id); + if (acElement != null) { + var automationCompositionStateChangeAck = + new AutomationCompositionAck(ParticipantMessageType.AUTOMATION_COMPOSITION_STATECHANGE_ACK); + automationCompositionStateChangeAck.setParticipantId(participantId); + automationCompositionStateChangeAck.setParticipantType(participantType); + automationCompositionStateChangeAck.setAutomationCompositionId(automationCompositionId); + acElement.setOrderedState(orderedState); + acElement.setState(newState); + automationCompositionStateChangeAck.getAutomationCompositionResultMap().put(acElement.getId(), + new AutomationCompositionElementAck(newState, true, + "Automation composition element {} state changed to {}\", id, newState)")); + LOGGER.debug("Automation composition element {} state changed to {}", id, newState); + automationCompositionStateChangeAck + .setMessage("AutomationCompositionElement state changed to {} " + newState); + automationCompositionStateChangeAck.setResult(true); + publisher.sendAutomationCompositionAck(automationCompositionStateChangeAck); + return acElement; + } + return null; + } + + /** + * Handle a automation composition element statistics. + * + * @param id automation composition element id + * @param elementStatistics automation composition element Statistics + */ + public void updateAutomationCompositionElementStatistics(UUID id, AcElementStatistics elementStatistics) { + var acElement = elementsOnThisParticipant.get(id); + if (acElement != null) { + elementStatistics.setParticipantId(participantId); + elementStatistics.setId(id); + acElement.setAcElementStatistics(elementStatistics); + } + } + + /** + * Handle a automation composition state change message. + * + * @param stateChangeMsg the state change message + * @param acElementDefinitions the list of AutomationCompositionElementDefinition + */ + public void handleAutomationCompositionStateChange(AutomationCompositionStateChange stateChangeMsg, + List acElementDefinitions) { + if (stateChangeMsg.getAutomationCompositionId() == null) { + return; + } + + var automationComposition = automationCompositionMap.get(stateChangeMsg.getAutomationCompositionId()); + + if (automationComposition == null) { + var automationCompositionAck = + new AutomationCompositionAck(ParticipantMessageType.AUTOMATION_COMPOSITION_STATECHANGE_ACK); + automationCompositionAck.setParticipantId(participantId); + automationCompositionAck.setParticipantType(participantType); + automationCompositionAck.setMessage("Automation composition " + stateChangeMsg.getAutomationCompositionId() + + " does not use this participant " + participantId); + automationCompositionAck.setResult(false); + automationCompositionAck.setResponseTo(stateChangeMsg.getMessageId()); + automationCompositionAck.setAutomationCompositionId(stateChangeMsg.getAutomationCompositionId()); + publisher.sendAutomationCompositionAck(automationCompositionAck); + LOGGER.debug("Automation composition {} does not use this participant", + stateChangeMsg.getAutomationCompositionId()); + return; + } + + handleState(automationComposition, stateChangeMsg.getOrderedState(), stateChangeMsg.getStartPhase(), + acElementDefinitions); + } + + /** + * Method to handle state changes. + * + * @param automationComposition participant response + * @param orderedState automation composition ordered state + * @param startPhaseMsg startPhase from message + * @param acElementDefinitions the list of AutomationCompositionElementDefinition + */ + private void handleState(final AutomationComposition automationComposition, + AutomationCompositionOrderedState orderedState, Integer startPhaseMsg, + List acElementDefinitions) { + switch (orderedState) { + case UNINITIALISED: + handleUninitialisedState(automationComposition, orderedState, startPhaseMsg, acElementDefinitions); + break; + case PASSIVE: + handlePassiveState(automationComposition, orderedState, startPhaseMsg, acElementDefinitions); + break; + case RUNNING: + handleRunningState(automationComposition, orderedState, startPhaseMsg, acElementDefinitions); + break; + default: + LOGGER.debug("StateChange message has no state, state is null {}", + automationComposition.getDefinition()); + break; + } + } + + /** + * Handle a automation composition update message. + * + * @param updateMsg the update message + * @param acElementDefinitions the list of AutomationCompositionElementDefinition + */ + public void handleAutomationCompositionUpdate(AutomationCompositionUpdate updateMsg, + List acElementDefinitions) { + + if (!updateMsg.appliesTo(participantType, participantId)) { + return; + } + + if (0 == updateMsg.getStartPhase()) { + handleAcUpdatePhase0(updateMsg, acElementDefinitions); + } else { + handleAcUpdatePhaseN(updateMsg, acElementDefinitions); + } + } + + private void handleAcUpdatePhase0(AutomationCompositionUpdate updateMsg, + List acElementDefinitions) { + var automationComposition = automationCompositionMap.get(updateMsg.getAutomationCompositionId()); + + // TODO: Updates to existing AutomationCompositions are not supported yet (Addition/Removal of + // AutomationComposition + // elements to existing AutomationComposition has to be supported). + if (automationComposition != null) { + var automationCompositionUpdateAck = + new AutomationCompositionAck(ParticipantMessageType.AUTOMATION_COMPOSITION_UPDATE_ACK); + automationCompositionUpdateAck.setParticipantId(participantId); + automationCompositionUpdateAck.setParticipantType(participantType); + + automationCompositionUpdateAck.setMessage("Automation composition " + updateMsg.getAutomationCompositionId() + + " already defined on participant " + participantId); + automationCompositionUpdateAck.setResult(false); + automationCompositionUpdateAck.setResponseTo(updateMsg.getMessageId()); + automationCompositionUpdateAck.setAutomationCompositionId(updateMsg.getAutomationCompositionId()); + publisher.sendAutomationCompositionAck(automationCompositionUpdateAck); + return; + } + + if (updateMsg.getParticipantUpdatesList().isEmpty()) { + LOGGER.warn("No AutomationCompositionElement updates in message {}", + updateMsg.getAutomationCompositionId()); + return; + } + + var acElements = storeElementsOnThisParticipant(updateMsg.getParticipantUpdatesList()); + + var acElementMap = prepareAcElementMap(acElements); + automationComposition = new AutomationComposition(); + automationComposition.setDefinition(updateMsg.getAutomationCompositionId()); + automationComposition.setElements(acElementMap); + automationCompositionMap.put(updateMsg.getAutomationCompositionId(), automationComposition); + + handleAutomationCompositionElementUpdate(acElements, acElementDefinitions, updateMsg.getStartPhase(), + updateMsg.getAutomationCompositionId()); + } + + private void handleAcUpdatePhaseN(AutomationCompositionUpdate updateMsg, + List acElementDefinitions) { + + var acElementList = updateMsg.getParticipantUpdatesList().stream() + .flatMap(participantUpdate -> participantUpdate.getAutomationCompositionElementList().stream()) + .filter(element -> participantType.equals(element.getParticipantType())).collect(Collectors.toList()); + + handleAutomationCompositionElementUpdate(acElementList, acElementDefinitions, updateMsg.getStartPhase(), + updateMsg.getAutomationCompositionId()); + } + + private void handleAutomationCompositionElementUpdate(List acElements, + List acElementDefinitions, Integer startPhaseMsg, + ToscaConceptIdentifier automationCompositionId) { + try { + for (var element : acElements) { + var acElementNodeTemplate = getAcElementNodeTemplate(acElementDefinitions, element.getDefinition()); + if (acElementNodeTemplate != null) { + int startPhase = ParticipantUtils.findStartPhase(acElementNodeTemplate.getProperties()); + if (startPhaseMsg.equals(startPhase)) { + for (var acElementListener : listeners) { + acElementListener.automationCompositionElementUpdate(automationCompositionId, element, + acElementNodeTemplate); + } + } + } + } + } catch (PfModelException e) { + LOGGER.debug("Automation composition element update failed {}", automationCompositionId); + } + + } + + private ToscaNodeTemplate getAcElementNodeTemplate( + List acElementDefinitions, ToscaConceptIdentifier acElementDefId) { + + for (var acElementDefinition : acElementDefinitions) { + if (acElementDefId.getName().contains(acElementDefinition.getAcElementDefinitionId().getName())) { + return acElementDefinition.getAutomationCompositionElementToscaNodeTemplate(); + } + } + return null; + } + + private List storeElementsOnThisParticipant( + List participantUpdates) { + var acElementList = participantUpdates.stream() + .flatMap(participantUpdate -> participantUpdate.getAutomationCompositionElementList().stream()) + .filter(element -> participantType.equals(element.getParticipantType())).collect(Collectors.toList()); + + for (var element : acElementList) { + elementsOnThisParticipant.put(element.getId(), element); + } + return acElementList; + } + + private Map prepareAcElementMap(List acElements) { + Map acElementMap = new LinkedHashMap<>(); + for (var element : acElements) { + acElementMap.put(element.getId(), element); + } + return acElementMap; + } + + /** + * Method to handle when the new state from participant is UNINITIALISED state. + * + * @param automationComposition participant response + * @param orderedState orderedState + * @param startPhaseMsg startPhase from message + * @param acElementDefinitions the list of AutomationCompositionElementDefinition + */ + private void handleUninitialisedState(final AutomationComposition automationComposition, + final AutomationCompositionOrderedState orderedState, Integer startPhaseMsg, + List acElementDefinitions) { + handleStateChange(automationComposition, orderedState, startPhaseMsg, acElementDefinitions); + boolean isAllUninitialised = automationComposition.getElements().values().stream() + .filter(element -> !AutomationCompositionState.UNINITIALISED.equals(element.getState())).findAny() + .isEmpty(); + if (isAllUninitialised) { + automationCompositionMap.remove(automationComposition.getDefinition()); + automationComposition.getElements().values() + .forEach(element -> elementsOnThisParticipant.remove(element.getId())); + } + } + + /** + * Method to handle when the new state from participant is PASSIVE state. + * + * @param automationComposition participant response + * @param orderedState orderedState + * @param startPhaseMsg startPhase from message + * @param acElementDefinitions the list of AutomationCompositionElementDefinition + */ + private void handlePassiveState(final AutomationComposition automationComposition, + final AutomationCompositionOrderedState orderedState, Integer startPhaseMsg, + List acElementDefinitions) { + handleStateChange(automationComposition, orderedState, startPhaseMsg, acElementDefinitions); + } + + /** + * Method to handle when the new state from participant is RUNNING state. + * + * @param automationComposition participant response + * @param orderedState orderedState + * @param startPhaseMsg startPhase from message + * @param acElementDefinitions the list of AutomationCompositionElementDefinition + */ + private void handleRunningState(final AutomationComposition automationComposition, + final AutomationCompositionOrderedState orderedState, Integer startPhaseMsg, + List acElementDefinitions) { + handleStateChange(automationComposition, orderedState, startPhaseMsg, acElementDefinitions); + } + + /** + * Method to update the state of automation composition elements. + * + * @param automationComposition participant status in memory + * @param orderedState orderedState the new ordered state the participant should have + * @param startPhaseMsg startPhase from message + * @param acElementDefinitions the list of AutomationCompositionElementDefinition + */ + private void handleStateChange(AutomationComposition automationComposition, + final AutomationCompositionOrderedState orderedState, Integer startPhaseMsg, + List acElementDefinitions) { + + if (orderedState.equals(automationComposition.getOrderedState())) { + var automationCompositionAck = + new AutomationCompositionAck(ParticipantMessageType.AUTOMATION_COMPOSITION_STATECHANGE_ACK); + automationCompositionAck.setParticipantId(participantId); + automationCompositionAck.setParticipantType(participantType); + automationCompositionAck.setMessage("Automation composition is already in state " + orderedState); + automationCompositionAck.setResult(false); + automationCompositionAck.setAutomationCompositionId(automationComposition.getDefinition()); + publisher.sendAutomationCompositionAck(automationCompositionAck); + return; + } + + automationComposition.getElements().values().stream() + .forEach(acElement -> automationCompositionElementStateChange(automationComposition, orderedState, + acElement, startPhaseMsg, acElementDefinitions)); + } + + private void automationCompositionElementStateChange(AutomationComposition automationComposition, + AutomationCompositionOrderedState orderedState, AutomationCompositionElement acElement, Integer startPhaseMsg, + List acElementDefinitions) { + var acElementNodeTemplate = getAcElementNodeTemplate(acElementDefinitions, acElement.getDefinition()); + if (acElementNodeTemplate != null) { + int startPhase = ParticipantUtils.findStartPhase(acElementNodeTemplate.getProperties()); + if (startPhaseMsg.equals(startPhase)) { + for (var acElementListener : listeners) { + try { + acElementListener.automationCompositionElementStateChange(automationComposition.getDefinition(), + acElement.getId(), acElement.getState(), orderedState); + } catch (PfModelException e) { + LOGGER.debug("Automation composition element update failed {}", + automationComposition.getDefinition()); + } + } + } + } + } + + /** + * Get automation compositions as a {@link ConrolLoops} class. + * + * @return the automation compositions + */ + public AutomationCompositions getAutomationCompositions() { + var automationCompositions = new AutomationCompositions(); + automationCompositions.setAutomationCompositionList(new ArrayList<>(automationCompositionMap.values())); + return automationCompositions; + } + + /** + * Get properties of a automation composition element. + * + * @param id the automation composition element id + * @return the instance properties + */ + public Map getAcElementInstanceProperties(UUID id) { + Map propertiesMap = new HashMap<>(); + for (var automationComposition : automationCompositionMap.values()) { + var element = automationComposition.getElements().get(id); + if (element != null) { + propertiesMap.putAll(element.getPropertiesMap()); + } + } + return propertiesMap; + } +} diff --git a/participant/participant-intermediary/src/main/java/org/onap/policy/clamp/acm/participant/intermediary/handler/IntermediaryActivator.java b/participant/participant-intermediary/src/main/java/org/onap/policy/clamp/acm/participant/intermediary/handler/IntermediaryActivator.java new file mode 100644 index 000000000..0144f669c --- /dev/null +++ b/participant/participant-intermediary/src/main/java/org/onap/policy/clamp/acm/participant/intermediary/handler/IntermediaryActivator.java @@ -0,0 +1,153 @@ +/*- + * ============LICENSE_START======================================================= + * Copyright (C) 2021 Nordix Foundation. + * Modifications Copyright (C) 2021 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * SPDX-License-Identifier: Apache-2.0 + * ============LICENSE_END========================================================= + */ + +package org.onap.policy.clamp.acm.participant.intermediary.handler; + +import java.io.Closeable; +import java.io.IOException; +import java.util.List; +import lombok.Getter; +import org.onap.policy.clamp.acm.participant.intermediary.parameters.ParticipantParameters; +import org.onap.policy.common.endpoints.event.comm.TopicEndpointManager; +import org.onap.policy.common.endpoints.event.comm.TopicSink; +import org.onap.policy.common.endpoints.event.comm.TopicSource; +import org.onap.policy.common.endpoints.listeners.MessageTypeDispatcher; +import org.onap.policy.common.utils.services.ServiceManagerContainer; +import org.springframework.context.event.ContextClosedEvent; +import org.springframework.context.event.ContextRefreshedEvent; +import org.springframework.context.event.EventListener; +import org.springframework.stereotype.Component; + +/** + * This class activates the Participant Intermediary together with all its handlers. + */ +@Component +public class IntermediaryActivator extends ServiceManagerContainer implements Closeable { + + private static final String[] MSG_TYPE_NAMES = {"messageType"}; + + // Topics from which the participant receives and to which the participant sends messages + private List topicSinks; + private List topicSources; + + private ParticipantHandler participantHandler; + + @Getter + private final MessageTypeDispatcher msgDispatcher; + + /** + * Instantiate the activator for participant. + * + * @param parameters the ParticipantParameters + * @param participantHandler the ParticipantHandler + * @param publishers list of Publishers + * @param listeners list of Listeners + */ + public IntermediaryActivator(final ParticipantParameters parameters, ParticipantHandler participantHandler, + List publishers, List> listeners) { + this.participantHandler = participantHandler; + + topicSinks = TopicEndpointManager.getManager().addTopicSinks( + parameters.getIntermediaryParameters().getClampAutomationCompositionTopics().getTopicSinks()); + + topicSources = TopicEndpointManager.getManager().addTopicSources( + parameters.getIntermediaryParameters().getClampAutomationCompositionTopics().getTopicSources()); + + msgDispatcher = new MessageTypeDispatcher(MSG_TYPE_NAMES); + + // @formatter:off + addAction("Topic endpoint management", + () -> TopicEndpointManager.getManager().start(), + () -> TopicEndpointManager.getManager().shutdown()); + + publishers.forEach(publisher -> + addAction("Publisher " + publisher.getClass().getSimpleName(), + () -> publisher.active(topicSinks), + publisher::stop)); + + listeners.forEach(listener -> + addAction("Listener " + listener.getClass().getSimpleName(), + () -> msgDispatcher.register(listener.getType(), listener.getScoListener()), + () -> msgDispatcher.unregister(listener.getType()))); + + addAction("Topic Message Dispatcher", this::registerMsgDispatcher, this::unregisterMsgDispatcher); + // @formatter:on + } + + /** + * Handle ContextRefreshEvent. + * + * @param ctxRefreshedEvent ContextRefreshedEvent + */ + @EventListener + public void handleContextRefreshEvent(ContextRefreshedEvent ctxRefreshedEvent) { + if (!isAlive()) { + start(); + sendParticipantRegister(); + } + } + + /** + * Handle ContextClosedEvent. + * + * @param ctxClosedEvent ContextClosedEvent + */ + @EventListener + public void handleContextClosedEvent(ContextClosedEvent ctxClosedEvent) { + if (isAlive()) { + sendParticipantDeregister(); + stop(); + } + } + + private void sendParticipantRegister() { + participantHandler.sendParticipantRegister(); + } + + private void sendParticipantDeregister() { + participantHandler.sendParticipantDeregister(); + } + + /** + * Registers the dispatcher with the topic source(s). + */ + private void registerMsgDispatcher() { + for (final TopicSource source : topicSources) { + source.register(msgDispatcher); + } + } + + /** + * Unregisters the dispatcher from the topic source(s). + */ + private void unregisterMsgDispatcher() { + for (final TopicSource source : topicSources) { + source.unregister(msgDispatcher); + } + } + + @Override + public void close() throws IOException { + if (isAlive()) { + super.shutdown(); + } + } +} diff --git a/participant/participant-intermediary/src/main/java/org/onap/policy/clamp/acm/participant/intermediary/handler/Listener.java b/participant/participant-intermediary/src/main/java/org/onap/policy/clamp/acm/participant/intermediary/handler/Listener.java new file mode 100644 index 000000000..56ed55441 --- /dev/null +++ b/participant/participant-intermediary/src/main/java/org/onap/policy/clamp/acm/participant/intermediary/handler/Listener.java @@ -0,0 +1,41 @@ +/*- + * ============LICENSE_START======================================================= + * Copyright (C) 2021 Nordix Foundation. + * Modifications Copyright (C) 2021 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * SPDX-License-Identifier: Apache-2.0 + * ============LICENSE_END========================================================= + */ + +package org.onap.policy.clamp.acm.participant.intermediary.handler; + +import org.onap.policy.common.endpoints.listeners.ScoListener; + +public interface Listener { + + /** + * Get the type of message of interest to the listener. + * + * @return type of message of interest to the listener + */ + String getType(); + + /** + * Get listener to register. + * + * @return listener to register + */ + ScoListener getScoListener(); +} diff --git a/participant/participant-intermediary/src/main/java/org/onap/policy/clamp/acm/participant/intermediary/handler/ParticipantHandler.java b/participant/participant-intermediary/src/main/java/org/onap/policy/clamp/acm/participant/intermediary/handler/ParticipantHandler.java new file mode 100644 index 000000000..fa02f3dcf --- /dev/null +++ b/participant/participant-intermediary/src/main/java/org/onap/policy/clamp/acm/participant/intermediary/handler/ParticipantHandler.java @@ -0,0 +1,416 @@ +/*- + * ============LICENSE_START======================================================= + * Copyright (C) 2021 Nordix Foundation. + * ================================================================================ + * Modifications Copyright (C) 2021 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * SPDX-License-Identifier: Apache-2.0 + * ============LICENSE_END========================================================= + */ + +package org.onap.policy.clamp.acm.participant.intermediary.handler; + +import java.time.Instant; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.Objects; +import java.util.UUID; +import java.util.stream.Collectors; +import lombok.Getter; +import lombok.Setter; +import org.onap.policy.clamp.acm.participant.intermediary.api.AutomationCompositionElementListener; +import org.onap.policy.clamp.acm.participant.intermediary.comm.ParticipantMessagePublisher; +import org.onap.policy.clamp.acm.participant.intermediary.parameters.ParticipantParameters; +import org.onap.policy.clamp.models.acm.concepts.AcElementStatisticsList; +import org.onap.policy.clamp.models.acm.concepts.AutomationComposition; +import org.onap.policy.clamp.models.acm.concepts.AutomationCompositionElement; +import org.onap.policy.clamp.models.acm.concepts.AutomationCompositionElementDefinition; +import org.onap.policy.clamp.models.acm.concepts.AutomationCompositionInfo; +import org.onap.policy.clamp.models.acm.concepts.AutomationCompositionStatistics; +import org.onap.policy.clamp.models.acm.concepts.AutomationCompositions; +import org.onap.policy.clamp.models.acm.concepts.Participant; +import org.onap.policy.clamp.models.acm.concepts.ParticipantDefinition; +import org.onap.policy.clamp.models.acm.concepts.ParticipantHealthStatus; +import org.onap.policy.clamp.models.acm.concepts.ParticipantState; +import org.onap.policy.clamp.models.acm.concepts.ParticipantStatistics; +import org.onap.policy.clamp.models.acm.messages.dmaap.participant.AutomationCompositionStateChange; +import org.onap.policy.clamp.models.acm.messages.dmaap.participant.AutomationCompositionUpdate; +import org.onap.policy.clamp.models.acm.messages.dmaap.participant.ParticipantAckMessage; +import org.onap.policy.clamp.models.acm.messages.dmaap.participant.ParticipantDeregister; +import org.onap.policy.clamp.models.acm.messages.dmaap.participant.ParticipantDeregisterAck; +import org.onap.policy.clamp.models.acm.messages.dmaap.participant.ParticipantMessage; +import org.onap.policy.clamp.models.acm.messages.dmaap.participant.ParticipantRegister; +import org.onap.policy.clamp.models.acm.messages.dmaap.participant.ParticipantRegisterAck; +import org.onap.policy.clamp.models.acm.messages.dmaap.participant.ParticipantStatus; +import org.onap.policy.clamp.models.acm.messages.dmaap.participant.ParticipantStatusReq; +import org.onap.policy.clamp.models.acm.messages.dmaap.participant.ParticipantUpdate; +import org.onap.policy.clamp.models.acm.messages.dmaap.participant.ParticipantUpdateAck; +import org.onap.policy.models.base.PfModelException; +import org.onap.policy.models.tosca.authorative.concepts.ToscaConceptIdentifier; +import org.onap.policy.models.tosca.authorative.concepts.ToscaProperty; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.stereotype.Component; + +/** + * This class is responsible for managing the state of a participant. + */ +@Component +public class ParticipantHandler { + private static final Logger LOGGER = LoggerFactory.getLogger(ParticipantHandler.class); + + @Getter + private final ToscaConceptIdentifier participantType; + + @Getter + private final ToscaConceptIdentifier participantId; + + private final AutomationCompositionHandler automationCompositionHandler; + private final ParticipantStatistics participantStatistics; + private final ParticipantMessagePublisher publisher; + + @Setter + private ParticipantState state = ParticipantState.UNKNOWN; + + @Setter + private ParticipantHealthStatus healthStatus = ParticipantHealthStatus.UNKNOWN; + + private final List acElementDefsOnThisParticipant = new ArrayList<>(); + + /** + * Constructor, set the participant ID and sender. + * + * @param parameters the parameters of the participant + * @param publisher the publisher for sending responses to messages + */ + public ParticipantHandler(ParticipantParameters parameters, ParticipantMessagePublisher publisher, + AutomationCompositionHandler automationCompositionHandler) { + this.participantType = parameters.getIntermediaryParameters().getParticipantType(); + this.participantId = parameters.getIntermediaryParameters().getParticipantId(); + this.publisher = publisher; + this.automationCompositionHandler = automationCompositionHandler; + this.participantStatistics = new ParticipantStatistics(); + this.participantStatistics.setParticipantId(participantId); + this.participantStatistics.setState(state); + this.participantStatistics.setHealthStatus(healthStatus); + this.participantStatistics.setTimeStamp(Instant.now()); + } + + /** + * Method which handles a participant health check event from clamp. + * + * @param participantStatusReqMsg participant participantStatusReq message + */ + public void handleParticipantStatusReq(final ParticipantStatusReq participantStatusReqMsg) { + var participantStatus = makeHeartbeat(true); + publisher.sendParticipantStatus(participantStatus); + } + + /** + * Update AutomationCompositionElement statistics. The automation composition elements listening will be + * notified to retrieve statistics from respective automation composition elements, and automation + * compositionelements + * data on the handler will be updated. + * + * @param automationCompositions the automation compositions + * @param acElementListener automation composition element listener + */ + private void updateAcElementStatistics(AutomationCompositions automationCompositions, + AutomationCompositionElementListener acElementListener) { + for (AutomationComposition automationComposition : automationCompositions.getAutomationCompositionList()) { + for (AutomationCompositionElement element : automationComposition.getElements().values()) { + try { + acElementListener.handleStatistics(element.getId()); + } catch (PfModelException e) { + LOGGER.debug("Getting statistics for automation composition element failed for element ID {}", + element.getId(), e); + } + } + } + } + + /** + * Handle a automation composition update message. + * + * @param updateMsg the update message + */ + public void handleAutomationCompositionUpdate(AutomationCompositionUpdate updateMsg) { + automationCompositionHandler.handleAutomationCompositionUpdate(updateMsg, acElementDefsOnThisParticipant); + } + + /** + * Handle a automation composition state change message. + * + * @param stateChangeMsg the state change message + */ + public void handleAutomationCompositionStateChange(AutomationCompositionStateChange stateChangeMsg) { + automationCompositionHandler.handleAutomationCompositionStateChange(stateChangeMsg, + acElementDefsOnThisParticipant); + } + + private void handleStateChange(ParticipantState newParticipantState, ParticipantUpdateAck response) { + if (state.equals(newParticipantState)) { + response.setResult(false); + response.setMessage("Participant already in state " + newParticipantState); + } else { + response.setResult(true); + response.setMessage("Participant state changed from " + state + " to " + newParticipantState); + state = newParticipantState; + } + } + + /** + * Method to update participant state. + * + * @param definition participant definition + * @param participantState participant state + * @return the participant + */ + public Participant updateParticipantState(ToscaConceptIdentifier definition, ParticipantState participantState) { + if (!Objects.equals(definition, participantId)) { + LOGGER.debug("No participant with this ID {}", definition.getName()); + return null; + } + + var participantUpdateAck = new ParticipantUpdateAck(); + handleStateChange(participantState, participantUpdateAck); + publisher.sendParticipantUpdateAck(participantUpdateAck); + return getParticipant(definition.getName(), definition.getVersion()); + } + + /** + * Method to update participant statistics. + * + * @param statistics participant statistics + */ + public void updateParticipantStatistics(ParticipantStatistics statistics) { + participantStatistics.setState(statistics.getState()); + participantStatistics.setHealthStatus(statistics.getHealthStatus()); + participantStatistics.setTimeStamp(statistics.getTimeStamp()); + participantStatistics.setAverageExecutionTime(statistics.getAverageExecutionTime()); + participantStatistics.setEventCount(statistics.getEventCount()); + } + + /** + * Get participants as a {@link Participant} class. + * + * @param name the participant name to get + * @param version the version of the participant to get + * @return the participant + */ + public Participant getParticipant(String name, String version) { + if (participantId.getName().equals(name)) { + var participant = new Participant(); + participant.setDefinition(participantId); + participant.setParticipantState(state); + participant.setHealthStatus(healthStatus); + return participant; + } + return null; + } + + /** + * Get common properties of a automation composition element. + * + * @param acElementDef the automation composition element definition + * @return the common properties + */ + public Map getAcElementDefinitionCommonProperties(ToscaConceptIdentifier acElementDef) { + Map commonPropertiesMap = new HashMap<>(); + acElementDefsOnThisParticipant.stream().forEach(definition -> { + if (definition.getAcElementDefinitionId().equals(acElementDef)) { + commonPropertiesMap.putAll(definition.getCommonPropertiesMap()); + } + }); + return commonPropertiesMap; + } + + /** + * Check if a participant message applies to this participant handler. + * + * @param participantMsg the message to check + * @return true if it applies, false otherwise + */ + public boolean appliesTo(ParticipantMessage participantMsg) { + return participantMsg.appliesTo(participantType, participantId); + } + + /** + * Check if a participant message applies to this participant handler. + * + * @param participantMsg the message to check + * @return true if it applies, false otherwise + */ + public boolean appliesTo(ParticipantAckMessage participantMsg) { + return participantMsg.appliesTo(participantType, participantId); + } + + /** + * Method to send ParticipantRegister message to automation composition runtime. + */ + public void sendParticipantRegister() { + var participantRegister = new ParticipantRegister(); + participantRegister.setParticipantId(participantId); + participantRegister.setParticipantType(participantType); + + publisher.sendParticipantRegister(participantRegister); + } + + /** + * Handle a participantRegister Ack message. + * + * @param participantRegisterAckMsg the participantRegisterAck message + */ + public void handleParticipantRegisterAck(ParticipantRegisterAck participantRegisterAckMsg) { + LOGGER.debug("ParticipantRegisterAck message received as responseTo {}", + participantRegisterAckMsg.getResponseTo()); + statusToPassive(); + publisher.sendParticipantStatus(makeHeartbeat(false)); + } + + private void statusToPassive() { + if (ParticipantHealthStatus.UNKNOWN.equals(this.healthStatus)) { + this.healthStatus = ParticipantHealthStatus.HEALTHY; + } + + if (ParticipantState.UNKNOWN.equals(this.state) || ParticipantState.TERMINATED.equals(this.state)) { + this.state = ParticipantState.PASSIVE; + } + + } + + /** + * Method to send ParticipantDeregister message to automation composition runtime. + */ + public void sendParticipantDeregister() { + var participantDeregister = new ParticipantDeregister(); + participantDeregister.setParticipantId(participantId); + participantDeregister.setParticipantType(participantType); + + publisher.sendParticipantDeregister(participantDeregister); + } + + /** + * Handle a participantDeregister Ack message. + * + * @param participantDeregisterAckMsg the participantDeregisterAck message + */ + public void handleParticipantDeregisterAck(ParticipantDeregisterAck participantDeregisterAckMsg) { + LOGGER.debug("ParticipantDeregisterAck message received as responseTo {}", + participantDeregisterAckMsg.getResponseTo()); + } + + /** + * Handle a ParticipantUpdate message. + * + * @param participantUpdateMsg the ParticipantUpdate message + */ + public void handleParticipantUpdate(ParticipantUpdate participantUpdateMsg) { + LOGGER.debug("ParticipantUpdate message received for participantId {}", + participantUpdateMsg.getParticipantId()); + + if (!participantUpdateMsg.getParticipantDefinitionUpdates().isEmpty()) { + statusToPassive(); + // This message is to commission the automation composition + for (ParticipantDefinition participantDefinition : participantUpdateMsg.getParticipantDefinitionUpdates()) { + if (participantDefinition.getParticipantType().equals(participantType)) { + acElementDefsOnThisParticipant + .addAll(participantDefinition.getAutomationCompositionElementDefinitionList()); + break; + } + } + } else { + // This message is to decommission the automation composition + acElementDefsOnThisParticipant.clear(); + this.state = ParticipantState.TERMINATED; + } + sendParticipantUpdateAck(participantUpdateMsg.getMessageId()); + } + + /** + * Method to send ParticipantUpdateAck message to automation composition runtime. + */ + public void sendParticipantUpdateAck(UUID messageId) { + var participantUpdateAck = new ParticipantUpdateAck(); + participantUpdateAck.setResponseTo(messageId); + participantUpdateAck.setMessage("Participant Update Ack message"); + participantUpdateAck.setResult(true); + participantUpdateAck.setParticipantId(participantId); + participantUpdateAck.setParticipantType(participantType); + participantUpdateAck.setState(state); + publisher.sendParticipantUpdateAck(participantUpdateAck); + } + + /** + * Dispatch a heartbeat for this participant. + */ + public void sendHeartbeat() { + publisher.sendHeartbeat(makeHeartbeat(false)); + } + + /** + * Method to send heartbeat to automation composition runtime. + */ + public ParticipantStatus makeHeartbeat(boolean responseToParticipantStatusReq) { + if (!responseToParticipantStatusReq) { + var automationCompositions = automationCompositionHandler.getAutomationCompositions(); + for (var acElementListener : automationCompositionHandler.getListeners()) { + updateAcElementStatistics(automationCompositions, acElementListener); + } + } + this.participantStatistics.setState(state); + this.participantStatistics.setHealthStatus(healthStatus); + this.participantStatistics.setTimeStamp(Instant.now()); + + var heartbeat = new ParticipantStatus(); + heartbeat.setParticipantId(participantId); + heartbeat.setParticipantStatistics(participantStatistics); + heartbeat.setParticipantType(participantType); + heartbeat.setHealthStatus(healthStatus); + heartbeat.setState(state); + heartbeat.setAutomationCompositionInfoList(getAutomationCompositionInfoList()); + + if (responseToParticipantStatusReq) { + ParticipantDefinition participantDefinition = new ParticipantDefinition(); + participantDefinition.setParticipantId(participantId); + participantDefinition.setParticipantType(participantType); + participantDefinition.setAutomationCompositionElementDefinitionList(acElementDefsOnThisParticipant); + heartbeat.setParticipantDefinitionUpdates(List.of(participantDefinition)); + } + + return heartbeat; + } + + private List getAutomationCompositionInfoList() { + List automationCompositionInfoList = new ArrayList<>(); + for (var entry : automationCompositionHandler.getAutomationCompositionMap().entrySet()) { + var acInfo = new AutomationCompositionInfo(); + acInfo.setAutomationCompositionId(entry.getKey()); + var acStatitistics = new AutomationCompositionStatistics(); + acStatitistics.setAutomationCompositionId(entry.getKey()); + var acElementStatisticsList = new AcElementStatisticsList(); + acElementStatisticsList.setAcElementStatistics(entry.getValue().getElements().values().stream() + .map(AutomationCompositionElement::getAcElementStatistics).filter(Objects::nonNull) + .collect(Collectors.toList())); + acStatitistics.setAcElementStatisticsList(acElementStatisticsList); + acInfo.setAutomationCompositionStatistics(acStatitistics); + acInfo.setState(entry.getValue().getState()); + automationCompositionInfoList.add(acInfo); + } + return automationCompositionInfoList; + } +} diff --git a/participant/participant-intermediary/src/main/java/org/onap/policy/clamp/acm/participant/intermediary/handler/Publisher.java b/participant/participant-intermediary/src/main/java/org/onap/policy/clamp/acm/participant/intermediary/handler/Publisher.java new file mode 100644 index 000000000..72aa645fd --- /dev/null +++ b/participant/participant-intermediary/src/main/java/org/onap/policy/clamp/acm/participant/intermediary/handler/Publisher.java @@ -0,0 +1,34 @@ +/*- + * ============LICENSE_START======================================================= + * Copyright (C) 2021 Nordix Foundation. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * SPDX-License-Identifier: Apache-2.0 + * ============LICENSE_END========================================================= + */ + +package org.onap.policy.clamp.acm.participant.intermediary.handler; + +import java.util.List; +import org.onap.policy.common.endpoints.event.comm.TopicSink; + +/** + * Publisher. + */ +public interface Publisher { + + void active(List topicSinks); + + void stop(); +} diff --git a/participant/participant-intermediary/src/main/java/org/onap/policy/clamp/acm/participant/intermediary/parameters/ParticipantIntermediaryParameters.java b/participant/participant-intermediary/src/main/java/org/onap/policy/clamp/acm/participant/intermediary/parameters/ParticipantIntermediaryParameters.java new file mode 100644 index 000000000..dcbfd1b2e --- /dev/null +++ b/participant/participant-intermediary/src/main/java/org/onap/policy/clamp/acm/participant/intermediary/parameters/ParticipantIntermediaryParameters.java @@ -0,0 +1,61 @@ +/*- + * ============LICENSE_START======================================================= + * Copyright (C) 2021 Nordix Foundation. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * SPDX-License-Identifier: Apache-2.0 + * ============LICENSE_END========================================================= + */ + +package org.onap.policy.clamp.acm.participant.intermediary.parameters; + +import javax.validation.Valid; +import javax.validation.constraints.NotBlank; +import javax.validation.constraints.NotNull; +import javax.validation.constraints.Positive; +import lombok.Getter; +import lombok.Setter; +import org.onap.policy.common.endpoints.parameters.TopicParameterGroup; +import org.onap.policy.common.parameters.validation.ParameterGroupConstraint; +import org.onap.policy.models.tosca.authorative.concepts.ToscaConceptIdentifier; + +/** + * Class to hold all parameters needed for participant component. + */ +@Getter +@Setter +public class ParticipantIntermediaryParameters { + + // The ID and description of this participant + @NotNull + @Valid + private ToscaConceptIdentifier participantId; + + @NotBlank + private String description; + + // The participant type of this participant + @NotNull + @Valid + private ToscaConceptIdentifier participantType; + + // The time interval for periodic reporting of status to the CLAMP ACM server + @Valid + @Positive + private long reportingTimeIntervalMs; + + @NotNull + @ParameterGroupConstraint + private TopicParameterGroup clampAutomationCompositionTopics; +} diff --git a/participant/participant-intermediary/src/main/java/org/onap/policy/clamp/acm/participant/intermediary/parameters/ParticipantParameters.java b/participant/participant-intermediary/src/main/java/org/onap/policy/clamp/acm/participant/intermediary/parameters/ParticipantParameters.java new file mode 100644 index 000000000..ca9c56607 --- /dev/null +++ b/participant/participant-intermediary/src/main/java/org/onap/policy/clamp/acm/participant/intermediary/parameters/ParticipantParameters.java @@ -0,0 +1,26 @@ +/*- + * ============LICENSE_START======================================================= + * Copyright (C) 2021 Nordix Foundation. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * SPDX-License-Identifier: Apache-2.0 + * ============LICENSE_END========================================================= + */ + +package org.onap.policy.clamp.acm.participant.intermediary.parameters; + +public interface ParticipantParameters { + + ParticipantIntermediaryParameters getIntermediaryParameters(); +} diff --git a/participant/participant-intermediary/src/main/java/org/onap/policy/clamp/controlloop/participant/intermediary/api/ControlLoopElementListener.java b/participant/participant-intermediary/src/main/java/org/onap/policy/clamp/controlloop/participant/intermediary/api/ControlLoopElementListener.java deleted file mode 100644 index 58378fa41..000000000 --- a/participant/participant-intermediary/src/main/java/org/onap/policy/clamp/controlloop/participant/intermediary/api/ControlLoopElementListener.java +++ /dev/null @@ -1,63 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * Copyright (C) 2021 Nordix Foundation. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - * SPDX-License-Identifier: Apache-2.0 - * ============LICENSE_END========================================================= - */ - -package org.onap.policy.clamp.controlloop.participant.intermediary.api; - -import java.util.UUID; -import org.onap.policy.clamp.controlloop.models.controlloop.concepts.ControlLoopElement; -import org.onap.policy.clamp.controlloop.models.controlloop.concepts.ControlLoopOrderedState; -import org.onap.policy.clamp.controlloop.models.controlloop.concepts.ControlLoopState; -import org.onap.policy.models.base.PfModelException; -import org.onap.policy.models.tosca.authorative.concepts.ToscaConceptIdentifier; -import org.onap.policy.models.tosca.authorative.concepts.ToscaNodeTemplate; - -/** - * This interface is implemented by participant implementations to receive updates on control loop elements. - */ -public interface ControlLoopElementListener { - /** - * Handle a control loop element state change. - * - * @param controlLoopElementId the ID of the control loop element - * @param currentState the current state of the control loop element - * @param newState the state to which the control loop element is changing to - * @throws PfModelException in case of a model exception - */ - public void controlLoopElementStateChange(ToscaConceptIdentifier controlLoopId, UUID controlLoopElementId, - ControlLoopState currentState, ControlLoopOrderedState newState) throws PfModelException; - - /** - * Handle an update on a control loop element. - * - * @param element the information on the control loop element - * @param controlLoopElementDefinition toscaNodeTemplate - * @throws PfModelException from Policy framework - */ - public void controlLoopElementUpdate(ToscaConceptIdentifier controlLoopId, ControlLoopElement element, - ToscaNodeTemplate controlLoopElementDefinition) throws PfModelException; - - /** - * Handle controlLoopElement statistics. - * - * @param controlLoopElementId controlLoopElement id - * @throws PfModelException in case of a model exception - */ - public void handleStatistics(UUID controlLoopElementId) throws PfModelException; -} diff --git a/participant/participant-intermediary/src/main/java/org/onap/policy/clamp/controlloop/participant/intermediary/api/ParticipantIntermediaryApi.java b/participant/participant-intermediary/src/main/java/org/onap/policy/clamp/controlloop/participant/intermediary/api/ParticipantIntermediaryApi.java deleted file mode 100644 index 0cb4963ec..000000000 --- a/participant/participant-intermediary/src/main/java/org/onap/policy/clamp/controlloop/participant/intermediary/api/ParticipantIntermediaryApi.java +++ /dev/null @@ -1,129 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * Copyright (C) 2021 Nordix Foundation. - * Modifications Copyright (C) 2021 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - * SPDX-License-Identifier: Apache-2.0 - * ============LICENSE_END========================================================= - */ - -package org.onap.policy.clamp.controlloop.participant.intermediary.api; - -import java.util.List; -import java.util.Map; -import java.util.UUID; -import org.onap.policy.clamp.controlloop.models.controlloop.concepts.ClElementStatistics; -import org.onap.policy.clamp.controlloop.models.controlloop.concepts.ControlLoopElement; -import org.onap.policy.clamp.controlloop.models.controlloop.concepts.ControlLoopOrderedState; -import org.onap.policy.clamp.controlloop.models.controlloop.concepts.ControlLoopState; -import org.onap.policy.clamp.controlloop.models.controlloop.concepts.ControlLoops; -import org.onap.policy.clamp.controlloop.models.controlloop.concepts.Participant; -import org.onap.policy.clamp.controlloop.models.controlloop.concepts.ParticipantState; -import org.onap.policy.clamp.controlloop.models.controlloop.concepts.ParticipantStatistics; -import org.onap.policy.clamp.controlloop.models.messages.dmaap.participant.ParticipantMessageType; -import org.onap.policy.models.tosca.authorative.concepts.ToscaConceptIdentifier; -import org.onap.policy.models.tosca.authorative.concepts.ToscaProperty; - -/** - * This interface is used by participant implementations to use the participant intermediary. - */ -public interface ParticipantIntermediaryApi { - - /** - * Register a listener for control loop elements that are mediated by the intermediary. - * - * @param controlLoopElementListener The control loop element listener to register - */ - void registerControlLoopElementListener(ControlLoopElementListener controlLoopElementListener); - - /** - * Get participants loops from the intermediary API. - * - * @param name the participant name, null for all - * @param version the participant version, null for all - * @return the participants - */ - List getParticipants(String name, String version); - - /** - * Get common properties of a controlloopelement. - * - * @param clElementDef the control loop element definition - * @return the common properties - */ - Map getClElementDefinitionCommonProperties(ToscaConceptIdentifier clElementDef); - - /** - * Update the state of a participant. - * - * @param definition the definition of the participant to update the state on - * @param state the state of the participant - * @return the participant - */ - Participant updateParticipantState(ToscaConceptIdentifier definition, ParticipantState state); - - /** - * Update the statistics of a participant. - * - * @param participantStatistics the statistics of the participant - */ - void updateParticipantStatistics(ParticipantStatistics participantStatistics); - - /** - * Get control loops from the intermediary API. - * - * @param name the control loop element name, null for all - * @param version the control loop element version, null for all - * @return the control loop elements - */ - ControlLoops getControlLoops(String name, String version); - - /** - * Get control loop elements from the intermediary API. - * - * @param name the control loop element name, null for all - * @param version the control loop element version, null for all - * @return the control loop elements - */ - Map getControlLoopElements(String name, String version); - - /** - * Get control loop element from the intermediary API. - * - * @param id control loop element ID - * @return the control loop element - */ - ControlLoopElement getControlLoopElement(UUID id); - - /** - * Update the state of a control loop element. - * - * @param id the ID of the control loop element to update the state on - * @param currentState the state of the control loop element - * @param newState the state of the control loop element - * @return ControlLoopElement updated control loop element - */ - ControlLoopElement updateControlLoopElementState(ToscaConceptIdentifier controlLoopId, - UUID id, ControlLoopOrderedState currentState, - ControlLoopState newState, ParticipantMessageType messageType); - - /** - * Update the control loop element statistics. - * - * @param id the ID of the control loop element to update the state on - * @param elementStatistics the updated statistics - */ - void updateControlLoopElementStatistics(UUID id, ClElementStatistics elementStatistics); -} diff --git a/participant/participant-intermediary/src/main/java/org/onap/policy/clamp/controlloop/participant/intermediary/api/impl/ParticipantIntermediaryApiImpl.java b/participant/participant-intermediary/src/main/java/org/onap/policy/clamp/controlloop/participant/intermediary/api/impl/ParticipantIntermediaryApiImpl.java deleted file mode 100644 index bbafc4678..000000000 --- a/participant/participant-intermediary/src/main/java/org/onap/policy/clamp/controlloop/participant/intermediary/api/impl/ParticipantIntermediaryApiImpl.java +++ /dev/null @@ -1,137 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * Copyright (C) 2021 Nordix Foundation. - * Modifications Copyright (C) 2021 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - * SPDX-License-Identifier: Apache-2.0 - * ============LICENSE_END========================================================= - */ - -package org.onap.policy.clamp.controlloop.participant.intermediary.api.impl; - -import java.util.LinkedHashMap; -import java.util.List; -import java.util.Map; -import java.util.UUID; -import org.onap.policy.clamp.controlloop.models.controlloop.concepts.ClElementStatistics; -import org.onap.policy.clamp.controlloop.models.controlloop.concepts.ControlLoop; -import org.onap.policy.clamp.controlloop.models.controlloop.concepts.ControlLoopElement; -import org.onap.policy.clamp.controlloop.models.controlloop.concepts.ControlLoopOrderedState; -import org.onap.policy.clamp.controlloop.models.controlloop.concepts.ControlLoopState; -import org.onap.policy.clamp.controlloop.models.controlloop.concepts.ControlLoops; -import org.onap.policy.clamp.controlloop.models.controlloop.concepts.Participant; -import org.onap.policy.clamp.controlloop.models.controlloop.concepts.ParticipantState; -import org.onap.policy.clamp.controlloop.models.controlloop.concepts.ParticipantStatistics; -import org.onap.policy.clamp.controlloop.models.messages.dmaap.participant.ParticipantMessageType; -import org.onap.policy.clamp.controlloop.participant.intermediary.api.ControlLoopElementListener; -import org.onap.policy.clamp.controlloop.participant.intermediary.api.ParticipantIntermediaryApi; -import org.onap.policy.clamp.controlloop.participant.intermediary.handler.ControlLoopHandler; -import org.onap.policy.clamp.controlloop.participant.intermediary.handler.ParticipantHandler; -import org.onap.policy.models.tosca.authorative.concepts.ToscaConceptIdentifier; -import org.onap.policy.models.tosca.authorative.concepts.ToscaProperty; -import org.springframework.stereotype.Component; - -/** - * This class is api implementation used by participant intermediary. - */ -@Component -public class ParticipantIntermediaryApiImpl implements ParticipantIntermediaryApi { - - // The handler for the participant intermediary - private final ParticipantHandler participantHandler; - - // The handler for the controlLoop intermediary - private final ControlLoopHandler controlLoopHandler; - - /** - * Constructor. - * - * @param participantHandler ParticipantHandler - * @param controlLoopHandler ControlLoopHandler - */ - public ParticipantIntermediaryApiImpl(ParticipantHandler participantHandler, - ControlLoopHandler controlLoopHandler) { - this.participantHandler = participantHandler; - this.controlLoopHandler = controlLoopHandler; - } - - @Override - public void registerControlLoopElementListener(ControlLoopElementListener controlLoopElementListener) { - controlLoopHandler.registerControlLoopElementListener(controlLoopElementListener); - } - - @Override - public List getParticipants(String name, String version) { - return List.of(participantHandler.getParticipant(name, version)); - } - - @Override - public Map getClElementDefinitionCommonProperties(ToscaConceptIdentifier clElementDef) { - return participantHandler.getClElementDefinitionCommonProperties(clElementDef); - } - - @Override - public Participant updateParticipantState(ToscaConceptIdentifier definition, ParticipantState state) { - return participantHandler.updateParticipantState(definition, state); - } - - @Override - public void updateParticipantStatistics(ParticipantStatistics participantStatistics) { - participantHandler.updateParticipantStatistics(participantStatistics); - } - - @Override - public ControlLoops getControlLoops(String name, String version) { - return controlLoopHandler.getControlLoops(); - } - - @Override - public Map getControlLoopElements(String name, String version) { - List controlLoops = controlLoopHandler.getControlLoops().getControlLoopList(); - - for (ControlLoop controlLoop : controlLoops) { - if (name.equals(controlLoop.getDefinition().getName())) { - return controlLoop.getElements(); - } - } - return new LinkedHashMap<>(); - } - - @Override - public ControlLoopElement getControlLoopElement(UUID id) { - List controlLoops = controlLoopHandler.getControlLoops().getControlLoopList(); - - for (ControlLoop controlLoop : controlLoops) { - ControlLoopElement clElement = controlLoop.getElements().get(id); - if (clElement != null) { - return clElement; - } - } - return null; - } - - @Override - public ControlLoopElement updateControlLoopElementState(ToscaConceptIdentifier controlLoopId, - UUID id, ControlLoopOrderedState currentState, - ControlLoopState newState, ParticipantMessageType messageType) { - return controlLoopHandler.updateControlLoopElementState(controlLoopId, - id, currentState, newState); - } - - @Override - public void updateControlLoopElementStatistics(UUID id, ClElementStatistics elementStatistics) { - controlLoopHandler.updateControlLoopElementStatistics(id, elementStatistics); - } -} diff --git a/participant/participant-intermediary/src/main/java/org/onap/policy/clamp/controlloop/participant/intermediary/comm/ControlLoopStateChangeListener.java b/participant/participant-intermediary/src/main/java/org/onap/policy/clamp/controlloop/participant/intermediary/comm/ControlLoopStateChangeListener.java deleted file mode 100644 index d24f32f2f..000000000 --- a/participant/participant-intermediary/src/main/java/org/onap/policy/clamp/controlloop/participant/intermediary/comm/ControlLoopStateChangeListener.java +++ /dev/null @@ -1,48 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * Copyright (C) 2021 Nordix Foundation. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - * SPDX-License-Identifier: Apache-2.0 - * ============LICENSE_END========================================================= - */ - -package org.onap.policy.clamp.controlloop.participant.intermediary.comm; - -import org.onap.policy.clamp.controlloop.models.messages.dmaap.participant.ControlLoopStateChange; -import org.onap.policy.clamp.controlloop.models.messages.dmaap.participant.ParticipantMessageType; -import org.onap.policy.clamp.controlloop.participant.intermediary.handler.ParticipantHandler; -import org.springframework.stereotype.Component; - -/** - * Listener for Participant State Change messages sent by CLAMP. - */ -@Component -public class ControlLoopStateChangeListener extends ParticipantListener { - - /** - * Constructs the object. - * - * @param participantHandler the handler for managing the state of the participant - */ - public ControlLoopStateChangeListener(final ParticipantHandler participantHandler) { - super(ControlLoopStateChange.class, participantHandler, - participantHandler::handleControlLoopStateChange); - } - - @Override - public String getType() { - return ParticipantMessageType.CONTROL_LOOP_STATE_CHANGE.name(); - } -} diff --git a/participant/participant-intermediary/src/main/java/org/onap/policy/clamp/controlloop/participant/intermediary/comm/ControlLoopUpdateListener.java b/participant/participant-intermediary/src/main/java/org/onap/policy/clamp/controlloop/participant/intermediary/comm/ControlLoopUpdateListener.java deleted file mode 100644 index f9dec1863..000000000 --- a/participant/participant-intermediary/src/main/java/org/onap/policy/clamp/controlloop/participant/intermediary/comm/ControlLoopUpdateListener.java +++ /dev/null @@ -1,47 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * Copyright (C) 2021 Nordix Foundation. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - * SPDX-License-Identifier: Apache-2.0 - * ============LICENSE_END========================================================= - */ - -package org.onap.policy.clamp.controlloop.participant.intermediary.comm; - -import org.onap.policy.clamp.controlloop.models.messages.dmaap.participant.ControlLoopUpdate; -import org.onap.policy.clamp.controlloop.models.messages.dmaap.participant.ParticipantMessageType; -import org.onap.policy.clamp.controlloop.participant.intermediary.handler.ParticipantHandler; -import org.springframework.stereotype.Component; - -/** - * Listener for Control Loop Update messages sent by CLAMP. - */ -@Component -public class ControlLoopUpdateListener extends ParticipantListener { - - /** - * Constructs the object. - * - * @param participantHandler the handler for managing the state of the participant - */ - public ControlLoopUpdateListener(final ParticipantHandler participantHandler) { - super(ControlLoopUpdate.class, participantHandler, participantHandler::handleControlLoopUpdate); - } - - @Override - public String getType() { - return ParticipantMessageType.CONTROL_LOOP_UPDATE.name(); - } -} diff --git a/participant/participant-intermediary/src/main/java/org/onap/policy/clamp/controlloop/participant/intermediary/comm/MessageSender.java b/participant/participant-intermediary/src/main/java/org/onap/policy/clamp/controlloop/participant/intermediary/comm/MessageSender.java deleted file mode 100644 index e11c883b4..000000000 --- a/participant/participant-intermediary/src/main/java/org/onap/policy/clamp/controlloop/participant/intermediary/comm/MessageSender.java +++ /dev/null @@ -1,78 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * Copyright (C) 2021 Nordix Foundation. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - * SPDX-License-Identifier: Apache-2.0 - * ============LICENSE_END========================================================= - */ - -package org.onap.policy.clamp.controlloop.participant.intermediary.comm; - -import java.io.Closeable; -import java.util.TimerTask; -import java.util.concurrent.Executors; -import java.util.concurrent.ScheduledExecutorService; -import java.util.concurrent.TimeUnit; -import org.onap.policy.clamp.controlloop.participant.intermediary.handler.ParticipantHandler; -import org.onap.policy.clamp.controlloop.participant.intermediary.parameters.ParticipantParameters; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; -import org.springframework.stereotype.Component; - -/** - * This class sends messages from participants to CLAMP. - */ -@Component -public class MessageSender extends TimerTask implements Closeable { - private static final Logger LOGGER = LoggerFactory.getLogger(MessageSender.class); - - private final ParticipantHandler participantHandler; - private ScheduledExecutorService timerPool; - - /** - * Constructor, set the publisher. - * - * @param participantHandler the participant handler to use for gathering information - * @param parameters the parameters of the participant - */ - public MessageSender(ParticipantHandler participantHandler, ParticipantParameters parameters) { - this.participantHandler = participantHandler; - - // Kick off the timer - timerPool = makeTimerPool(); - var interval = parameters.getIntermediaryParameters().getReportingTimeIntervalMs(); - timerPool.scheduleAtFixedRate(this, interval, interval, TimeUnit.MILLISECONDS); - } - - @Override - public void run() { - LOGGER.debug("Sent heartbeat to CLAMP"); - participantHandler.sendHeartbeat(); - } - - @Override - public void close() { - timerPool.shutdown(); - } - - /** - * Makes a new timer pool. - * - * @return a new timer pool - */ - protected ScheduledExecutorService makeTimerPool() { - return Executors.newScheduledThreadPool(1); - } -} diff --git a/participant/participant-intermediary/src/main/java/org/onap/policy/clamp/controlloop/participant/intermediary/comm/ParticipantAckListener.java b/participant/participant-intermediary/src/main/java/org/onap/policy/clamp/controlloop/participant/intermediary/comm/ParticipantAckListener.java deleted file mode 100644 index 95bbb2940..000000000 --- a/participant/participant-intermediary/src/main/java/org/onap/policy/clamp/controlloop/participant/intermediary/comm/ParticipantAckListener.java +++ /dev/null @@ -1,67 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * Copyright (C) 2021 Nordix Foundation. - * Modifications Copyright (C) 2021 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * Modifications Copyright (C) 2021 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - * SPDX-License-Identifier: Apache-2.0 - * ============LICENSE_END========================================================= - */ - -package org.onap.policy.clamp.controlloop.participant.intermediary.comm; - -import java.util.function.Consumer; -import org.onap.policy.clamp.controlloop.models.messages.dmaap.participant.ParticipantAckMessage; -import org.onap.policy.clamp.controlloop.participant.intermediary.handler.Listener; -import org.onap.policy.clamp.controlloop.participant.intermediary.handler.ParticipantHandler; -import org.onap.policy.common.endpoints.event.comm.Topic.CommInfrastructure; -import org.onap.policy.common.endpoints.listeners.ScoListener; -import org.onap.policy.common.utils.coder.StandardCoderObject; - -/** - * Abstract Listener for Participant Ack messages sent by runtime. - */ -public abstract class ParticipantAckListener extends ScoListener - implements Listener { - - private final ParticipantHandler participantHandler; - private final Consumer consumer; - - /** - * Constructs the object. - * - * @param clazz class of message this handles - * @param participantHandler ParticipantHandler - * @param consumer function that handles the message - */ - protected ParticipantAckListener(Class clazz, ParticipantHandler participantHandler, Consumer consumer) { - super(clazz); - this.participantHandler = participantHandler; - this.consumer = consumer; - } - - @Override - public void onTopicEvent(CommInfrastructure infra, String topic, StandardCoderObject sco, T message) { - if (participantHandler.appliesTo(message)) { - consumer.accept(message); - } - } - - @Override - public ScoListener getScoListener() { - return this; - } -} diff --git a/participant/participant-intermediary/src/main/java/org/onap/policy/clamp/controlloop/participant/intermediary/comm/ParticipantDeregisterAckListener.java b/participant/participant-intermediary/src/main/java/org/onap/policy/clamp/controlloop/participant/intermediary/comm/ParticipantDeregisterAckListener.java deleted file mode 100644 index 5440e005b..000000000 --- a/participant/participant-intermediary/src/main/java/org/onap/policy/clamp/controlloop/participant/intermediary/comm/ParticipantDeregisterAckListener.java +++ /dev/null @@ -1,48 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * Copyright (C) 2021 Nordix Foundation. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - * SPDX-License-Identifier: Apache-2.0 - * ============LICENSE_END========================================================= - */ - -package org.onap.policy.clamp.controlloop.participant.intermediary.comm; - -import org.onap.policy.clamp.controlloop.models.messages.dmaap.participant.ParticipantDeregisterAck; -import org.onap.policy.clamp.controlloop.models.messages.dmaap.participant.ParticipantMessageType; -import org.onap.policy.clamp.controlloop.participant.intermediary.handler.ParticipantHandler; -import org.springframework.stereotype.Component; - -/** - * Listener for Participant Deregister Ack messages sent by runtime. - * - */ -@Component -public class ParticipantDeregisterAckListener extends ParticipantAckListener { - - /** - * Constructs the object. - * - * @param participantHandler the handler for managing the state of the participant - */ - public ParticipantDeregisterAckListener(final ParticipantHandler participantHandler) { - super(ParticipantDeregisterAck.class, participantHandler, participantHandler::handleParticipantDeregisterAck); - } - - @Override - public String getType() { - return ParticipantMessageType.PARTICIPANT_DEREGISTER_ACK.name(); - } -} diff --git a/participant/participant-intermediary/src/main/java/org/onap/policy/clamp/controlloop/participant/intermediary/comm/ParticipantListener.java b/participant/participant-intermediary/src/main/java/org/onap/policy/clamp/controlloop/participant/intermediary/comm/ParticipantListener.java deleted file mode 100644 index 5326ccddc..000000000 --- a/participant/participant-intermediary/src/main/java/org/onap/policy/clamp/controlloop/participant/intermediary/comm/ParticipantListener.java +++ /dev/null @@ -1,64 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * Copyright (C) 2021 Nordix Foundation. - * Modifications Copyright (C) 2021 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - * SPDX-License-Identifier: Apache-2.0 - * ============LICENSE_END========================================================= - */ - -package org.onap.policy.clamp.controlloop.participant.intermediary.comm; - -import java.util.function.Consumer; -import org.onap.policy.clamp.controlloop.models.messages.dmaap.participant.ParticipantMessage; -import org.onap.policy.clamp.controlloop.participant.intermediary.handler.Listener; -import org.onap.policy.clamp.controlloop.participant.intermediary.handler.ParticipantHandler; -import org.onap.policy.common.endpoints.event.comm.Topic.CommInfrastructure; -import org.onap.policy.common.endpoints.listeners.ScoListener; -import org.onap.policy.common.utils.coder.StandardCoderObject; - -/** - * Abstract Listener for Participant messages sent by CLAMP. - */ -public abstract class ParticipantListener extends ScoListener implements Listener { - - private final ParticipantHandler participantHandler; - private final Consumer consumer; - - /** - * Constructs the object. - * - * @param clazz class of message this handles - * @param participantHandler ParticipantHandler - * @param consumer function that handles the message - */ - protected ParticipantListener(Class clazz, ParticipantHandler participantHandler, Consumer consumer) { - super(clazz); - this.participantHandler = participantHandler; - this.consumer = consumer; - } - - @Override - public void onTopicEvent(CommInfrastructure infra, String topic, StandardCoderObject sco, T message) { - if (participantHandler.appliesTo(message)) { - consumer.accept(message); - } - } - - @Override - public ScoListener getScoListener() { - return this; - } -} diff --git a/participant/participant-intermediary/src/main/java/org/onap/policy/clamp/controlloop/participant/intermediary/comm/ParticipantMessagePublisher.java b/participant/participant-intermediary/src/main/java/org/onap/policy/clamp/controlloop/participant/intermediary/comm/ParticipantMessagePublisher.java deleted file mode 100644 index 79d62623c..000000000 --- a/participant/participant-intermediary/src/main/java/org/onap/policy/clamp/controlloop/participant/intermediary/comm/ParticipantMessagePublisher.java +++ /dev/null @@ -1,147 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * Copyright (C) 2021 Nordix Foundation. - * Modifications Copyright (C) 2021 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - * SPDX-License-Identifier: Apache-2.0 - * ============LICENSE_END========================================================= - */ - -package org.onap.policy.clamp.controlloop.participant.intermediary.comm; - -import java.util.List; -import javax.ws.rs.core.Response.Status; -import org.onap.policy.clamp.controlloop.common.exception.ControlLoopRuntimeException; -import org.onap.policy.clamp.controlloop.models.messages.dmaap.participant.ControlLoopAck; -import org.onap.policy.clamp.controlloop.models.messages.dmaap.participant.ParticipantDeregister; -import org.onap.policy.clamp.controlloop.models.messages.dmaap.participant.ParticipantRegister; -import org.onap.policy.clamp.controlloop.models.messages.dmaap.participant.ParticipantStatus; -import org.onap.policy.clamp.controlloop.models.messages.dmaap.participant.ParticipantUpdateAck; -import org.onap.policy.clamp.controlloop.participant.intermediary.handler.Publisher; -import org.onap.policy.common.endpoints.event.comm.TopicSink; -import org.onap.policy.common.endpoints.event.comm.client.TopicSinkClient; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; -import org.springframework.stereotype.Component; - -/** - * This class is used to send Participant Status messages to clamp using TopicSinkClient. - * - */ -@Component -public class ParticipantMessagePublisher implements Publisher { - private static final Logger LOGGER = LoggerFactory.getLogger(ParticipantMessagePublisher.class); - private static final String NOT_ACTIVE_TEXT = "Not Active!"; - - private boolean active = false; - private TopicSinkClient topicSinkClient; - - /** - * Constructor for instantiating ParticipantMessagePublisher. - * - * @param topicSinks the topic sinks - */ - @Override - public void active(List topicSinks) { - if (topicSinks.size() != 1) { - throw new IllegalArgumentException("Configuration unsupported, Topic sinks greater than 1"); - } - this.topicSinkClient = new TopicSinkClient(topicSinks.get(0)); - active = true; - } - - /** - * Method to send Participant Status message to clamp on demand. - * - * @param participantStatus the Participant Status - */ - public void sendParticipantStatus(final ParticipantStatus participantStatus) { - if (!active) { - throw new ControlLoopRuntimeException(Status.NOT_ACCEPTABLE, NOT_ACTIVE_TEXT); - } - topicSinkClient.send(participantStatus); - LOGGER.debug("Sent Participant Status message to CLAMP - {}", participantStatus); - } - - /** - * Method to send Participant Status message to clamp on demand. - * - * @param participantRegister the Participant Status - */ - public void sendParticipantRegister(final ParticipantRegister participantRegister) { - if (!active) { - throw new ControlLoopRuntimeException(Status.NOT_ACCEPTABLE, NOT_ACTIVE_TEXT); - } - topicSinkClient.send(participantRegister); - LOGGER.debug("Sent Participant Register message to CLAMP - {}", participantRegister); - } - - /** - * Method to send Participant Status message to clamp on demand. - * - * @param participantDeregister the Participant Status - */ - public void sendParticipantDeregister(final ParticipantDeregister participantDeregister) { - if (!active) { - throw new ControlLoopRuntimeException(Status.NOT_ACCEPTABLE, NOT_ACTIVE_TEXT); - } - topicSinkClient.send(participantDeregister); - LOGGER.debug("Sent Participant Deregister message to CLAMP - {}", participantDeregister); - } - - /** - * Method to send Participant Update Ack message to runtime. - * - * @param participantUpdateAck the Participant Update Ack - */ - public void sendParticipantUpdateAck(final ParticipantUpdateAck participantUpdateAck) { - if (!active) { - throw new ControlLoopRuntimeException(Status.NOT_ACCEPTABLE, NOT_ACTIVE_TEXT); - } - topicSinkClient.send(participantUpdateAck); - LOGGER.debug("Sent Participant Update Ack message to CLAMP - {}", participantUpdateAck); - } - - /** - * Method to send ControlLoop Update/StateChange Ack message to runtime. - * - * @param controlLoopAck ControlLoop Update/StateChange Ack - */ - public void sendControlLoopAck(final ControlLoopAck controlLoopAck) { - if (!active) { - throw new ControlLoopRuntimeException(Status.NOT_ACCEPTABLE, NOT_ACTIVE_TEXT); - } - topicSinkClient.send(controlLoopAck); - LOGGER.debug("Sent ControlLoop Update/StateChange Ack to runtime - {}", controlLoopAck); - } - - /** - * Method to send Participant heartbeat to clamp on demand. - * - * @param participantStatus the Participant Status - */ - public void sendHeartbeat(final ParticipantStatus participantStatus) { - if (!active) { - throw new ControlLoopRuntimeException(Status.NOT_ACCEPTABLE, NOT_ACTIVE_TEXT); - } - topicSinkClient.send(participantStatus); - LOGGER.debug("Sent Participant heartbeat to CLAMP - {}", participantStatus); - } - - @Override - public void stop() { - active = false; - } -} diff --git a/participant/participant-intermediary/src/main/java/org/onap/policy/clamp/controlloop/participant/intermediary/comm/ParticipantRegisterAckListener.java b/participant/participant-intermediary/src/main/java/org/onap/policy/clamp/controlloop/participant/intermediary/comm/ParticipantRegisterAckListener.java deleted file mode 100644 index 7be460815..000000000 --- a/participant/participant-intermediary/src/main/java/org/onap/policy/clamp/controlloop/participant/intermediary/comm/ParticipantRegisterAckListener.java +++ /dev/null @@ -1,48 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * Copyright (C) 2021 Nordix Foundation. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - * SPDX-License-Identifier: Apache-2.0 - * ============LICENSE_END========================================================= - */ - -package org.onap.policy.clamp.controlloop.participant.intermediary.comm; - -import org.onap.policy.clamp.controlloop.models.messages.dmaap.participant.ParticipantMessageType; -import org.onap.policy.clamp.controlloop.models.messages.dmaap.participant.ParticipantRegisterAck; -import org.onap.policy.clamp.controlloop.participant.intermediary.handler.ParticipantHandler; -import org.springframework.stereotype.Component; - -/** - * Listener for Participant Register Ack messages sent by runtime. - * - */ -@Component -public class ParticipantRegisterAckListener extends ParticipantAckListener { - - /** - * Constructs the object. - * - * @param participantHandler the handler for managing the state of the participant - */ - public ParticipantRegisterAckListener(final ParticipantHandler participantHandler) { - super(ParticipantRegisterAck.class, participantHandler, participantHandler::handleParticipantRegisterAck); - } - - @Override - public String getType() { - return ParticipantMessageType.PARTICIPANT_REGISTER_ACK.name(); - } -} diff --git a/participant/participant-intermediary/src/main/java/org/onap/policy/clamp/controlloop/participant/intermediary/comm/ParticipantStatusReqListener.java b/participant/participant-intermediary/src/main/java/org/onap/policy/clamp/controlloop/participant/intermediary/comm/ParticipantStatusReqListener.java deleted file mode 100644 index 9e978fe75..000000000 --- a/participant/participant-intermediary/src/main/java/org/onap/policy/clamp/controlloop/participant/intermediary/comm/ParticipantStatusReqListener.java +++ /dev/null @@ -1,47 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * Copyright (C) 2021 Nordix Foundation. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - * SPDX-License-Identifier: Apache-2.0 - * ============LICENSE_END========================================================= - */ - -package org.onap.policy.clamp.controlloop.participant.intermediary.comm; - -import org.onap.policy.clamp.controlloop.models.messages.dmaap.participant.ParticipantMessageType; -import org.onap.policy.clamp.controlloop.models.messages.dmaap.participant.ParticipantStatusReq; -import org.onap.policy.clamp.controlloop.participant.intermediary.handler.ParticipantHandler; -import org.springframework.stereotype.Component; - -/** - * Listener for Participant status request messages sent by runtime to all/one participant. - */ -@Component -public class ParticipantStatusReqListener extends ParticipantListener { - - /** - * Constructs the object. - * - * @param participantHandler the handler for managing the state and health of the participant - */ - public ParticipantStatusReqListener(final ParticipantHandler participantHandler) { - super(ParticipantStatusReq.class, participantHandler, participantHandler::handleParticipantStatusReq); - } - - @Override - public String getType() { - return ParticipantMessageType.PARTICIPANT_STATUS_REQ.name(); - } -} diff --git a/participant/participant-intermediary/src/main/java/org/onap/policy/clamp/controlloop/participant/intermediary/comm/ParticipantUpdateListener.java b/participant/participant-intermediary/src/main/java/org/onap/policy/clamp/controlloop/participant/intermediary/comm/ParticipantUpdateListener.java deleted file mode 100644 index da45501e7..000000000 --- a/participant/participant-intermediary/src/main/java/org/onap/policy/clamp/controlloop/participant/intermediary/comm/ParticipantUpdateListener.java +++ /dev/null @@ -1,47 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * Copyright (C) 2021 Nordix Foundation. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - * SPDX-License-Identifier: Apache-2.0 - * ============LICENSE_END========================================================= - */ - -package org.onap.policy.clamp.controlloop.participant.intermediary.comm; - -import org.onap.policy.clamp.controlloop.models.messages.dmaap.participant.ParticipantMessageType; -import org.onap.policy.clamp.controlloop.models.messages.dmaap.participant.ParticipantUpdate; -import org.onap.policy.clamp.controlloop.participant.intermediary.handler.ParticipantHandler; -import org.springframework.stereotype.Component; - -/** - * Listener for Participant Update messages sent by runtime. - */ -@Component -public class ParticipantUpdateListener extends ParticipantListener { - - /** - * Constructs the object. - * - * @param participantHandler the handler for managing the state of the participant - */ - public ParticipantUpdateListener(final ParticipantHandler participantHandler) { - super(ParticipantUpdate.class, participantHandler, participantHandler::handleParticipantUpdate); - } - - @Override - public String getType() { - return ParticipantMessageType.PARTICIPANT_UPDATE.name(); - } -} diff --git a/participant/participant-intermediary/src/main/java/org/onap/policy/clamp/controlloop/participant/intermediary/handler/ControlLoopHandler.java b/participant/participant-intermediary/src/main/java/org/onap/policy/clamp/controlloop/participant/intermediary/handler/ControlLoopHandler.java deleted file mode 100644 index 5a0f4989f..000000000 --- a/participant/participant-intermediary/src/main/java/org/onap/policy/clamp/controlloop/participant/intermediary/handler/ControlLoopHandler.java +++ /dev/null @@ -1,454 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * Copyright (C) 2021 Nordix Foundation. - * Modifications Copyright (C) 2021 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - * SPDX-License-Identifier: Apache-2.0 - * ============LICENSE_END========================================================= - */ - -package org.onap.policy.clamp.controlloop.participant.intermediary.handler; - -import java.util.ArrayList; -import java.util.HashMap; -import java.util.LinkedHashMap; -import java.util.List; -import java.util.Map; -import java.util.UUID; -import java.util.stream.Collectors; -import lombok.Getter; -import org.onap.policy.clamp.controlloop.models.controlloop.concepts.ClElementStatistics; -import org.onap.policy.clamp.controlloop.models.controlloop.concepts.ControlLoop; -import org.onap.policy.clamp.controlloop.models.controlloop.concepts.ControlLoopElement; -import org.onap.policy.clamp.controlloop.models.controlloop.concepts.ControlLoopElementAck; -import org.onap.policy.clamp.controlloop.models.controlloop.concepts.ControlLoopElementDefinition; -import org.onap.policy.clamp.controlloop.models.controlloop.concepts.ControlLoopOrderedState; -import org.onap.policy.clamp.controlloop.models.controlloop.concepts.ControlLoopState; -import org.onap.policy.clamp.controlloop.models.controlloop.concepts.ControlLoops; -import org.onap.policy.clamp.controlloop.models.controlloop.concepts.ParticipantUpdates; -import org.onap.policy.clamp.controlloop.models.controlloop.concepts.ParticipantUtils; -import org.onap.policy.clamp.controlloop.models.messages.dmaap.participant.ControlLoopAck; -import org.onap.policy.clamp.controlloop.models.messages.dmaap.participant.ControlLoopStateChange; -import org.onap.policy.clamp.controlloop.models.messages.dmaap.participant.ControlLoopUpdate; -import org.onap.policy.clamp.controlloop.models.messages.dmaap.participant.ParticipantMessageType; -import org.onap.policy.clamp.controlloop.participant.intermediary.api.ControlLoopElementListener; -import org.onap.policy.clamp.controlloop.participant.intermediary.comm.ParticipantMessagePublisher; -import org.onap.policy.clamp.controlloop.participant.intermediary.parameters.ParticipantParameters; -import org.onap.policy.models.base.PfModelException; -import org.onap.policy.models.tosca.authorative.concepts.ToscaConceptIdentifier; -import org.onap.policy.models.tosca.authorative.concepts.ToscaNodeTemplate; -import org.onap.policy.models.tosca.authorative.concepts.ToscaProperty; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; -import org.springframework.stereotype.Component; - -/* - * This class is responsible for managing the state of all control loops in the participant. - */ -@Component -public class ControlLoopHandler { - private static final Logger LOGGER = LoggerFactory.getLogger(ControlLoopHandler.class); - - private final ToscaConceptIdentifier participantType; - private final ToscaConceptIdentifier participantId; - private final ParticipantMessagePublisher publisher; - - @Getter - private final Map controlLoopMap = new LinkedHashMap<>(); - - @Getter - private final Map elementsOnThisParticipant = new LinkedHashMap<>(); - - @Getter - private List listeners = new ArrayList<>(); - - /** - * Constructor, set the participant ID and messageSender. - * - * @param parameters the parameters of the participant - * @param publisher the ParticipantMessage Publisher - */ - public ControlLoopHandler(ParticipantParameters parameters, ParticipantMessagePublisher publisher) { - this.participantType = parameters.getIntermediaryParameters().getParticipantType(); - this.participantId = parameters.getIntermediaryParameters().getParticipantId(); - this.publisher = publisher; - } - - public void registerControlLoopElementListener(ControlLoopElementListener listener) { - listeners.add(listener); - } - - /** - * Handle a control loop element state change message. - * - * @param controlLoopId the controlLoop Id - * @param id the controlLoop UUID - * @param orderedState the current state - * @param newState the ordered state - * @return controlLoopElement the updated controlloop element - */ - public ControlLoopElement updateControlLoopElementState(ToscaConceptIdentifier controlLoopId, UUID id, - ControlLoopOrderedState orderedState, ControlLoopState newState) { - - if (id == null) { - LOGGER.warn("Cannot update Control loop element state, id is null"); - return null; - } - - // Update states of ControlLoopElement in controlLoopMap - for (var controlLoop : controlLoopMap.values()) { - var element = controlLoop.getElements().get(id); - if (element != null) { - element.setOrderedState(orderedState); - element.setState(newState); - } - var checkOpt = controlLoop.getElements().values().stream() - .filter(clElement -> !newState.equals(clElement.getState())).findAny(); - if (checkOpt.isEmpty()) { - controlLoop.setState(newState); - controlLoop.setOrderedState(orderedState); - } - } - - // Update states of ControlLoopElement in elementsOnThisParticipant - var clElement = elementsOnThisParticipant.get(id); - if (clElement != null) { - var controlLoopStateChangeAck = new ControlLoopAck(ParticipantMessageType.CONTROLLOOP_STATECHANGE_ACK); - controlLoopStateChangeAck.setParticipantId(participantId); - controlLoopStateChangeAck.setParticipantType(participantType); - controlLoopStateChangeAck.setControlLoopId(controlLoopId); - clElement.setOrderedState(orderedState); - clElement.setState(newState); - controlLoopStateChangeAck.getControlLoopResultMap().put(clElement.getId(), new ControlLoopElementAck( - newState, true, "Control loop element {} state changed to {}\", id, newState)")); - LOGGER.debug("Control loop element {} state changed to {}", id, newState); - controlLoopStateChangeAck.setMessage("ControlLoopElement state changed to {} " + newState); - controlLoopStateChangeAck.setResult(true); - publisher.sendControlLoopAck(controlLoopStateChangeAck); - return clElement; - } - return null; - } - - /** - * Handle a control loop element statistics. - * - * @param id controlloop element id - * @param elementStatistics control loop element Statistics - */ - public void updateControlLoopElementStatistics(UUID id, ClElementStatistics elementStatistics) { - var clElement = elementsOnThisParticipant.get(id); - if (clElement != null) { - elementStatistics.setParticipantId(participantId); - elementStatistics.setId(id); - clElement.setClElementStatistics(elementStatistics); - } - } - - /** - * Handle a control loop state change message. - * - * @param stateChangeMsg the state change message - * @param clElementDefinitions the list of ControlLoopElementDefinition - */ - public void handleControlLoopStateChange(ControlLoopStateChange stateChangeMsg, - List clElementDefinitions) { - if (stateChangeMsg.getControlLoopId() == null) { - return; - } - - var controlLoop = controlLoopMap.get(stateChangeMsg.getControlLoopId()); - - if (controlLoop == null) { - var controlLoopAck = new ControlLoopAck(ParticipantMessageType.CONTROLLOOP_STATECHANGE_ACK); - controlLoopAck.setParticipantId(participantId); - controlLoopAck.setParticipantType(participantType); - controlLoopAck.setMessage("Control loop " + stateChangeMsg.getControlLoopId() - + " does not use this participant " + participantId); - controlLoopAck.setResult(false); - controlLoopAck.setResponseTo(stateChangeMsg.getMessageId()); - controlLoopAck.setControlLoopId(stateChangeMsg.getControlLoopId()); - publisher.sendControlLoopAck(controlLoopAck); - LOGGER.debug("Control loop {} does not use this participant", stateChangeMsg.getControlLoopId()); - return; - } - - handleState(controlLoop, stateChangeMsg.getOrderedState(), stateChangeMsg.getStartPhase(), - clElementDefinitions); - } - - /** - * Method to handle state changes. - * - * @param controlLoop participant response - * @param orderedState controlloop ordered state - * @param startPhaseMsg startPhase from message - * @param clElementDefinitions the list of ControlLoopElementDefinition - */ - private void handleState(final ControlLoop controlLoop, ControlLoopOrderedState orderedState, Integer startPhaseMsg, - List clElementDefinitions) { - switch (orderedState) { - case UNINITIALISED: - handleUninitialisedState(controlLoop, orderedState, startPhaseMsg, clElementDefinitions); - break; - case PASSIVE: - handlePassiveState(controlLoop, orderedState, startPhaseMsg, clElementDefinitions); - break; - case RUNNING: - handleRunningState(controlLoop, orderedState, startPhaseMsg, clElementDefinitions); - break; - default: - LOGGER.debug("StateChange message has no state, state is null {}", controlLoop.getDefinition()); - break; - } - } - - /** - * Handle a control loop update message. - * - * @param updateMsg the update message - * @param clElementDefinitions the list of ControlLoopElementDefinition - */ - public void handleControlLoopUpdate(ControlLoopUpdate updateMsg, - List clElementDefinitions) { - - if (!updateMsg.appliesTo(participantType, participantId)) { - return; - } - - if (0 == updateMsg.getStartPhase()) { - handleClUpdatePhase0(updateMsg, clElementDefinitions); - } else { - handleClUpdatePhaseN(updateMsg, clElementDefinitions); - } - } - - private void handleClUpdatePhase0(ControlLoopUpdate updateMsg, - List clElementDefinitions) { - var controlLoop = controlLoopMap.get(updateMsg.getControlLoopId()); - - // TODO: Updates to existing ControlLoops are not supported yet (Addition/Removal of ControlLoop - // elements to existing ControlLoop has to be supported). - if (controlLoop != null) { - var controlLoopUpdateAck = new ControlLoopAck(ParticipantMessageType.CONTROLLOOP_UPDATE_ACK); - controlLoopUpdateAck.setParticipantId(participantId); - controlLoopUpdateAck.setParticipantType(participantType); - - controlLoopUpdateAck.setMessage("Control loop " + updateMsg.getControlLoopId() - + " already defined on participant " + participantId); - controlLoopUpdateAck.setResult(false); - controlLoopUpdateAck.setResponseTo(updateMsg.getMessageId()); - controlLoopUpdateAck.setControlLoopId(updateMsg.getControlLoopId()); - publisher.sendControlLoopAck(controlLoopUpdateAck); - return; - } - - if (updateMsg.getParticipantUpdatesList().isEmpty()) { - LOGGER.warn("No ControlLoopElement updates in message {}", updateMsg.getControlLoopId()); - return; - } - - var clElements = storeElementsOnThisParticipant(updateMsg.getParticipantUpdatesList()); - - var clElementMap = prepareClElementMap(clElements); - controlLoop = new ControlLoop(); - controlLoop.setDefinition(updateMsg.getControlLoopId()); - controlLoop.setElements(clElementMap); - controlLoopMap.put(updateMsg.getControlLoopId(), controlLoop); - - handleControlLoopElementUpdate(clElements, clElementDefinitions, updateMsg.getStartPhase(), - updateMsg.getControlLoopId()); - } - - private void handleClUpdatePhaseN(ControlLoopUpdate updateMsg, - List clElementDefinitions) { - - var clElementList = updateMsg.getParticipantUpdatesList().stream() - .flatMap(participantUpdate -> participantUpdate.getControlLoopElementList().stream()) - .filter(element -> participantType.equals(element.getParticipantType())).collect(Collectors.toList()); - - handleControlLoopElementUpdate(clElementList, clElementDefinitions, updateMsg.getStartPhase(), - updateMsg.getControlLoopId()); - } - - private void handleControlLoopElementUpdate(List clElements, - List clElementDefinitions, Integer startPhaseMsg, - ToscaConceptIdentifier controlLoopId) { - try { - for (var element : clElements) { - var clElementNodeTemplate = getClElementNodeTemplate(clElementDefinitions, element.getDefinition()); - if (clElementNodeTemplate != null) { - int startPhase = ParticipantUtils.findStartPhase(clElementNodeTemplate.getProperties()); - if (startPhaseMsg.equals(startPhase)) { - for (var clElementListener : listeners) { - clElementListener.controlLoopElementUpdate(controlLoopId, element, clElementNodeTemplate); - } - } - } - } - } catch (PfModelException e) { - LOGGER.debug("Control loop element update failed {}", controlLoopId); - } - - } - - private ToscaNodeTemplate getClElementNodeTemplate(List clElementDefinitions, - ToscaConceptIdentifier clElementDefId) { - - for (var clElementDefinition : clElementDefinitions) { - if (clElementDefId.getName().contains(clElementDefinition.getClElementDefinitionId().getName())) { - return clElementDefinition.getControlLoopElementToscaNodeTemplate(); - } - } - return null; - } - - private List storeElementsOnThisParticipant(List participantUpdates) { - var clElementList = participantUpdates.stream() - .flatMap(participantUpdate -> participantUpdate.getControlLoopElementList().stream()) - .filter(element -> participantType.equals(element.getParticipantType())).collect(Collectors.toList()); - - for (var element : clElementList) { - elementsOnThisParticipant.put(element.getId(), element); - } - return clElementList; - } - - private Map prepareClElementMap(List clElements) { - Map clElementMap = new LinkedHashMap<>(); - for (var element : clElements) { - clElementMap.put(element.getId(), element); - } - return clElementMap; - } - - /** - * Method to handle when the new state from participant is UNINITIALISED state. - * - * @param controlLoop participant response - * @param orderedState orderedState - * @param startPhaseMsg startPhase from message - * @param clElementDefinitions the list of ControlLoopElementDefinition - */ - private void handleUninitialisedState(final ControlLoop controlLoop, final ControlLoopOrderedState orderedState, - Integer startPhaseMsg, List clElementDefinitions) { - handleStateChange(controlLoop, orderedState, startPhaseMsg, clElementDefinitions); - boolean isAllUninitialised = controlLoop.getElements().values().stream() - .filter(element -> !ControlLoopState.UNINITIALISED.equals(element.getState())).findAny().isEmpty(); - if (isAllUninitialised) { - controlLoopMap.remove(controlLoop.getDefinition()); - controlLoop.getElements().values().forEach(element -> elementsOnThisParticipant.remove(element.getId())); - } - } - - /** - * Method to handle when the new state from participant is PASSIVE state. - * - * @param controlLoop participant response - * @param orderedState orderedState - * @param startPhaseMsg startPhase from message - * @param clElementDefinitions the list of ControlLoopElementDefinition - */ - private void handlePassiveState(final ControlLoop controlLoop, final ControlLoopOrderedState orderedState, - Integer startPhaseMsg, List clElementDefinitions) { - handleStateChange(controlLoop, orderedState, startPhaseMsg, clElementDefinitions); - } - - /** - * Method to handle when the new state from participant is RUNNING state. - * - * @param controlLoop participant response - * @param orderedState orderedState - * @param startPhaseMsg startPhase from message - * @param clElementDefinitions the list of ControlLoopElementDefinition - */ - private void handleRunningState(final ControlLoop controlLoop, final ControlLoopOrderedState orderedState, - Integer startPhaseMsg, List clElementDefinitions) { - handleStateChange(controlLoop, orderedState, startPhaseMsg, clElementDefinitions); - } - - /** - * Method to update the state of control loop elements. - * - * @param controlLoop participant status in memory - * @param orderedState orderedState the new ordered state the participant should have - * @param startPhaseMsg startPhase from message - * @param clElementDefinitions the list of ControlLoopElementDefinition - */ - private void handleStateChange(ControlLoop controlLoop, final ControlLoopOrderedState orderedState, - Integer startPhaseMsg, List clElementDefinitions) { - - if (orderedState.equals(controlLoop.getOrderedState())) { - var controlLoopAck = new ControlLoopAck(ParticipantMessageType.CONTROLLOOP_STATECHANGE_ACK); - controlLoopAck.setParticipantId(participantId); - controlLoopAck.setParticipantType(participantType); - controlLoopAck.setMessage("Control loop is already in state " + orderedState); - controlLoopAck.setResult(false); - controlLoopAck.setControlLoopId(controlLoop.getDefinition()); - publisher.sendControlLoopAck(controlLoopAck); - return; - } - - controlLoop.getElements().values().stream().forEach(clElement -> controlLoopElementStateChange(controlLoop, - orderedState, clElement, startPhaseMsg, clElementDefinitions)); - } - - private void controlLoopElementStateChange(ControlLoop controlLoop, ControlLoopOrderedState orderedState, - ControlLoopElement clElement, Integer startPhaseMsg, - List clElementDefinitions) { - var clElementNodeTemplate = getClElementNodeTemplate(clElementDefinitions, clElement.getDefinition()); - if (clElementNodeTemplate != null) { - int startPhase = ParticipantUtils.findStartPhase(clElementNodeTemplate.getProperties()); - if (startPhaseMsg.equals(startPhase)) { - for (var clElementListener : listeners) { - try { - clElementListener.controlLoopElementStateChange(controlLoop.getDefinition(), clElement.getId(), - clElement.getState(), orderedState); - } catch (PfModelException e) { - LOGGER.debug("Control loop element update failed {}", controlLoop.getDefinition()); - } - } - } - } - } - - /** - * Get control loops as a {@link ConrolLoops} class. - * - * @return the control loops - */ - public ControlLoops getControlLoops() { - var controlLoops = new ControlLoops(); - controlLoops.setControlLoopList(new ArrayList<>(controlLoopMap.values())); - return controlLoops; - } - - /** - * Get properties of a controlloopelement. - * - * @param id the control loop element id - * @return the instance properties - */ - public Map getClElementInstanceProperties(UUID id) { - Map propertiesMap = new HashMap<>(); - for (var controlLoop : controlLoopMap.values()) { - var element = controlLoop.getElements().get(id); - if (element != null) { - propertiesMap.putAll(element.getPropertiesMap()); - } - } - return propertiesMap; - } -} diff --git a/participant/participant-intermediary/src/main/java/org/onap/policy/clamp/controlloop/participant/intermediary/handler/IntermediaryActivator.java b/participant/participant-intermediary/src/main/java/org/onap/policy/clamp/controlloop/participant/intermediary/handler/IntermediaryActivator.java deleted file mode 100644 index e42fac46e..000000000 --- a/participant/participant-intermediary/src/main/java/org/onap/policy/clamp/controlloop/participant/intermediary/handler/IntermediaryActivator.java +++ /dev/null @@ -1,154 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * Copyright (C) 2021 Nordix Foundation. - * Modifications Copyright (C) 2021 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - * SPDX-License-Identifier: Apache-2.0 - * ============LICENSE_END========================================================= - */ - -package org.onap.policy.clamp.controlloop.participant.intermediary.handler; - -import java.io.Closeable; -import java.io.IOException; -import java.util.List; -import lombok.Getter; -import org.onap.policy.clamp.controlloop.participant.intermediary.parameters.ParticipantParameters; -import org.onap.policy.common.endpoints.event.comm.TopicEndpointManager; -import org.onap.policy.common.endpoints.event.comm.TopicSink; -import org.onap.policy.common.endpoints.event.comm.TopicSource; -import org.onap.policy.common.endpoints.listeners.MessageTypeDispatcher; -import org.onap.policy.common.utils.services.ServiceManagerContainer; -import org.springframework.context.event.ContextClosedEvent; -import org.springframework.context.event.ContextRefreshedEvent; -import org.springframework.context.event.EventListener; -import org.springframework.stereotype.Component; - -/** - * This class activates the Participant Intermediary together with all its handlers. - */ -@Component -public class IntermediaryActivator extends ServiceManagerContainer implements Closeable { - - private static final String[] MSG_TYPE_NAMES = {"messageType"}; - - // Topics from which the participant receives and to which the participant sends messages - private List topicSinks; - private List topicSources; - - private ParticipantHandler participantHandler; - - @Getter - private final MessageTypeDispatcher msgDispatcher; - - /** - * Instantiate the activator for participant. - * - * @param parameters the ParticipantParameters - * @param participantHandler the ParticipantHandler - * @param publishers list of Publishers - * @param listeners list of Listeners - */ - public IntermediaryActivator(final ParticipantParameters parameters, - ParticipantHandler participantHandler, List publishers, - List> listeners) { - this.participantHandler = participantHandler; - - topicSinks = TopicEndpointManager.getManager() - .addTopicSinks(parameters.getIntermediaryParameters().getClampControlLoopTopics().getTopicSinks()); - - topicSources = TopicEndpointManager.getManager() - .addTopicSources(parameters.getIntermediaryParameters().getClampControlLoopTopics().getTopicSources()); - - msgDispatcher = new MessageTypeDispatcher(MSG_TYPE_NAMES); - - // @formatter:off - addAction("Topic endpoint management", - () -> TopicEndpointManager.getManager().start(), - () -> TopicEndpointManager.getManager().shutdown()); - - publishers.forEach(publisher -> - addAction("Publisher " + publisher.getClass().getSimpleName(), - () -> publisher.active(topicSinks), - publisher::stop)); - - listeners.forEach(listener -> - addAction("Listener " + listener.getClass().getSimpleName(), - () -> msgDispatcher.register(listener.getType(), listener.getScoListener()), - () -> msgDispatcher.unregister(listener.getType()))); - - addAction("Topic Message Dispatcher", this::registerMsgDispatcher, this::unregisterMsgDispatcher); - // @formatter:on - } - - /** - * Handle ContextRefreshEvent. - * - * @param ctxRefreshedEvent ContextRefreshedEvent - */ - @EventListener - public void handleContextRefreshEvent(ContextRefreshedEvent ctxRefreshedEvent) { - if (!isAlive()) { - start(); - sendParticipantRegister(); - } - } - - /** - * Handle ContextClosedEvent. - * - * @param ctxClosedEvent ContextClosedEvent - */ - @EventListener - public void handleContextClosedEvent(ContextClosedEvent ctxClosedEvent) { - if (isAlive()) { - sendParticipantDeregister(); - stop(); - } - } - - private void sendParticipantRegister() { - participantHandler.sendParticipantRegister(); - } - - private void sendParticipantDeregister() { - participantHandler.sendParticipantDeregister(); - } - - /** - * Registers the dispatcher with the topic source(s). - */ - private void registerMsgDispatcher() { - for (final TopicSource source : topicSources) { - source.register(msgDispatcher); - } - } - - /** - * Unregisters the dispatcher from the topic source(s). - */ - private void unregisterMsgDispatcher() { - for (final TopicSource source : topicSources) { - source.unregister(msgDispatcher); - } - } - - @Override - public void close() throws IOException { - if (isAlive()) { - super.shutdown(); - } - } -} diff --git a/participant/participant-intermediary/src/main/java/org/onap/policy/clamp/controlloop/participant/intermediary/handler/Listener.java b/participant/participant-intermediary/src/main/java/org/onap/policy/clamp/controlloop/participant/intermediary/handler/Listener.java deleted file mode 100644 index 19bad9a67..000000000 --- a/participant/participant-intermediary/src/main/java/org/onap/policy/clamp/controlloop/participant/intermediary/handler/Listener.java +++ /dev/null @@ -1,41 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * Copyright (C) 2021 Nordix Foundation. - * Modifications Copyright (C) 2021 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - * SPDX-License-Identifier: Apache-2.0 - * ============LICENSE_END========================================================= - */ - -package org.onap.policy.clamp.controlloop.participant.intermediary.handler; - -import org.onap.policy.common.endpoints.listeners.ScoListener; - -public interface Listener { - - /** - * Get the type of message of interest to the listener. - * - * @return type of message of interest to the listener - */ - String getType(); - - /** - * Get listener to register. - * - * @return listener to register - */ - ScoListener getScoListener(); -} diff --git a/participant/participant-intermediary/src/main/java/org/onap/policy/clamp/controlloop/participant/intermediary/handler/ParticipantHandler.java b/participant/participant-intermediary/src/main/java/org/onap/policy/clamp/controlloop/participant/intermediary/handler/ParticipantHandler.java deleted file mode 100644 index 89a13a84b..000000000 --- a/participant/participant-intermediary/src/main/java/org/onap/policy/clamp/controlloop/participant/intermediary/handler/ParticipantHandler.java +++ /dev/null @@ -1,415 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * Copyright (C) 2021 Nordix Foundation. - * ================================================================================ - * Modifications Copyright (C) 2021 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - * SPDX-License-Identifier: Apache-2.0 - * ============LICENSE_END========================================================= - */ - -package org.onap.policy.clamp.controlloop.participant.intermediary.handler; - -import java.time.Instant; -import java.util.ArrayList; -import java.util.HashMap; -import java.util.List; -import java.util.Map; -import java.util.Objects; -import java.util.UUID; -import java.util.stream.Collectors; -import lombok.Getter; -import lombok.Setter; -import org.onap.policy.clamp.controlloop.models.controlloop.concepts.ClElementStatisticsList; -import org.onap.policy.clamp.controlloop.models.controlloop.concepts.ControlLoop; -import org.onap.policy.clamp.controlloop.models.controlloop.concepts.ControlLoopElement; -import org.onap.policy.clamp.controlloop.models.controlloop.concepts.ControlLoopElementDefinition; -import org.onap.policy.clamp.controlloop.models.controlloop.concepts.ControlLoopInfo; -import org.onap.policy.clamp.controlloop.models.controlloop.concepts.ControlLoopStatistics; -import org.onap.policy.clamp.controlloop.models.controlloop.concepts.ControlLoops; -import org.onap.policy.clamp.controlloop.models.controlloop.concepts.Participant; -import org.onap.policy.clamp.controlloop.models.controlloop.concepts.ParticipantDefinition; -import org.onap.policy.clamp.controlloop.models.controlloop.concepts.ParticipantHealthStatus; -import org.onap.policy.clamp.controlloop.models.controlloop.concepts.ParticipantState; -import org.onap.policy.clamp.controlloop.models.controlloop.concepts.ParticipantStatistics; -import org.onap.policy.clamp.controlloop.models.messages.dmaap.participant.ControlLoopStateChange; -import org.onap.policy.clamp.controlloop.models.messages.dmaap.participant.ControlLoopUpdate; -import org.onap.policy.clamp.controlloop.models.messages.dmaap.participant.ParticipantAckMessage; -import org.onap.policy.clamp.controlloop.models.messages.dmaap.participant.ParticipantDeregister; -import org.onap.policy.clamp.controlloop.models.messages.dmaap.participant.ParticipantDeregisterAck; -import org.onap.policy.clamp.controlloop.models.messages.dmaap.participant.ParticipantMessage; -import org.onap.policy.clamp.controlloop.models.messages.dmaap.participant.ParticipantRegister; -import org.onap.policy.clamp.controlloop.models.messages.dmaap.participant.ParticipantRegisterAck; -import org.onap.policy.clamp.controlloop.models.messages.dmaap.participant.ParticipantStatus; -import org.onap.policy.clamp.controlloop.models.messages.dmaap.participant.ParticipantStatusReq; -import org.onap.policy.clamp.controlloop.models.messages.dmaap.participant.ParticipantUpdate; -import org.onap.policy.clamp.controlloop.models.messages.dmaap.participant.ParticipantUpdateAck; -import org.onap.policy.clamp.controlloop.participant.intermediary.api.ControlLoopElementListener; -import org.onap.policy.clamp.controlloop.participant.intermediary.comm.ParticipantMessagePublisher; -import org.onap.policy.clamp.controlloop.participant.intermediary.parameters.ParticipantParameters; -import org.onap.policy.models.base.PfModelException; -import org.onap.policy.models.tosca.authorative.concepts.ToscaConceptIdentifier; -import org.onap.policy.models.tosca.authorative.concepts.ToscaProperty; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; -import org.springframework.stereotype.Component; - -/** - * This class is responsible for managing the state of a participant. - */ -@Component -public class ParticipantHandler { - private static final Logger LOGGER = LoggerFactory.getLogger(ParticipantHandler.class); - - @Getter - private final ToscaConceptIdentifier participantType; - - @Getter - private final ToscaConceptIdentifier participantId; - - private final ControlLoopHandler controlLoopHandler; - private final ParticipantStatistics participantStatistics; - private final ParticipantMessagePublisher publisher; - - @Setter - private ParticipantState state = ParticipantState.UNKNOWN; - - @Setter - private ParticipantHealthStatus healthStatus = ParticipantHealthStatus.UNKNOWN; - - private final List clElementDefsOnThisParticipant = new ArrayList<>(); - - /** - * Constructor, set the participant ID and sender. - * - * @param parameters the parameters of the participant - * @param publisher the publisher for sending responses to messages - */ - public ParticipantHandler(ParticipantParameters parameters, ParticipantMessagePublisher publisher, - ControlLoopHandler controlLoopHandler) { - this.participantType = parameters.getIntermediaryParameters().getParticipantType(); - this.participantId = parameters.getIntermediaryParameters().getParticipantId(); - this.publisher = publisher; - this.controlLoopHandler = controlLoopHandler; - this.participantStatistics = new ParticipantStatistics(); - this.participantStatistics.setParticipantId(participantId); - this.participantStatistics.setState(state); - this.participantStatistics.setHealthStatus(healthStatus); - this.participantStatistics.setTimeStamp(Instant.now()); - } - - /** - * Method which handles a participant health check event from clamp. - * - * @param participantStatusReqMsg participant participantStatusReq message - */ - public void handleParticipantStatusReq(final ParticipantStatusReq participantStatusReqMsg) { - var participantStatus = makeHeartbeat(true); - publisher.sendParticipantStatus(participantStatus); - } - - /** - * Update ControlLoopElement statistics. The control loop elements listening will be - * notified to retrieve statistics from respective controlloop elements, and controlloopelements - * data on the handler will be updated. - * - * @param controlLoops the control loops - * @param clElementListener control loop element listener - */ - private void updateClElementStatistics(ControlLoops controlLoops, ControlLoopElementListener clElementListener) { - for (ControlLoop controlLoop : controlLoops.getControlLoopList()) { - for (ControlLoopElement element : controlLoop.getElements().values()) { - try { - clElementListener.handleStatistics(element.getId()); - } catch (PfModelException e) { - LOGGER.debug("Getting statistics for Control loop element failed for element ID {}", - element.getId(), e); - } - } - } - } - - /** - * Handle a control loop update message. - * - * @param updateMsg the update message - */ - public void handleControlLoopUpdate(ControlLoopUpdate updateMsg) { - controlLoopHandler.handleControlLoopUpdate(updateMsg, clElementDefsOnThisParticipant); - } - - /** - * Handle a control loop state change message. - * - * @param stateChangeMsg the state change message - */ - public void handleControlLoopStateChange(ControlLoopStateChange stateChangeMsg) { - controlLoopHandler.handleControlLoopStateChange(stateChangeMsg, clElementDefsOnThisParticipant); - } - - private void handleStateChange(ParticipantState newParticipantState, ParticipantUpdateAck response) { - if (state.equals(newParticipantState)) { - response.setResult(false); - response.setMessage("Participant already in state " + newParticipantState); - } else { - response.setResult(true); - response.setMessage("Participant state changed from " + state + " to " + newParticipantState); - state = newParticipantState; - } - } - - /** - * Method to update participant state. - * - * @param definition participant definition - * @param participantState participant state - * @return the participant - */ - public Participant updateParticipantState(ToscaConceptIdentifier definition, ParticipantState participantState) { - if (!Objects.equals(definition, participantId)) { - LOGGER.debug("No participant with this ID {}", definition.getName()); - return null; - } - - var participantUpdateAck = new ParticipantUpdateAck(); - handleStateChange(participantState, participantUpdateAck); - publisher.sendParticipantUpdateAck(participantUpdateAck); - return getParticipant(definition.getName(), definition.getVersion()); - } - - /** - * Method to update participant statistics. - * - * @param statistics participant statistics - */ - public void updateParticipantStatistics(ParticipantStatistics statistics) { - participantStatistics.setState(statistics.getState()); - participantStatistics.setHealthStatus(statistics.getHealthStatus()); - participantStatistics.setTimeStamp(statistics.getTimeStamp()); - participantStatistics.setAverageExecutionTime(statistics.getAverageExecutionTime()); - participantStatistics.setEventCount(statistics.getEventCount()); - } - - /** - * Get participants as a {@link Participant} class. - * - * @param name the participant name to get - * @param version the version of the participant to get - * @return the participant - */ - public Participant getParticipant(String name, String version) { - if (participantId.getName().equals(name)) { - var participant = new Participant(); - participant.setDefinition(participantId); - participant.setParticipantState(state); - participant.setHealthStatus(healthStatus); - return participant; - } - return null; - } - - /** - * Get common properties of a controlloopelement. - * - * @param clElementDef the control loop element definition - * @return the common properties - */ - public Map getClElementDefinitionCommonProperties(ToscaConceptIdentifier clElementDef) { - Map commonPropertiesMap = new HashMap<>(); - clElementDefsOnThisParticipant.stream().forEach(definition -> { - if (definition.getClElementDefinitionId().equals(clElementDef)) { - commonPropertiesMap.putAll(definition.getCommonPropertiesMap()); - } - }); - return commonPropertiesMap; - } - - /** - * Check if a participant message applies to this participant handler. - * - * @param participantMsg the message to check - * @return true if it applies, false otherwise - */ - public boolean appliesTo(ParticipantMessage participantMsg) { - return participantMsg.appliesTo(participantType, participantId); - } - - /** - * Check if a participant message applies to this participant handler. - * - * @param participantMsg the message to check - * @return true if it applies, false otherwise - */ - public boolean appliesTo(ParticipantAckMessage participantMsg) { - return participantMsg.appliesTo(participantType, participantId); - } - - /** - * Method to send ParticipantRegister message to controlloop runtime. - */ - public void sendParticipantRegister() { - var participantRegister = new ParticipantRegister(); - participantRegister.setParticipantId(participantId); - participantRegister.setParticipantType(participantType); - - publisher.sendParticipantRegister(participantRegister); - } - - /** - * Handle a participantRegister Ack message. - * - * @param participantRegisterAckMsg the participantRegisterAck message - */ - public void handleParticipantRegisterAck(ParticipantRegisterAck participantRegisterAckMsg) { - LOGGER.debug("ParticipantRegisterAck message received as responseTo {}", - participantRegisterAckMsg.getResponseTo()); - statusToPassive(); - publisher.sendParticipantStatus(makeHeartbeat(false)); - } - - private void statusToPassive() { - if (ParticipantHealthStatus.UNKNOWN.equals(this.healthStatus)) { - this.healthStatus = ParticipantHealthStatus.HEALTHY; - } - - if (ParticipantState.UNKNOWN.equals(this.state) || ParticipantState.TERMINATED.equals(this.state)) { - this.state = ParticipantState.PASSIVE; - } - - } - - /** - * Method to send ParticipantDeregister message to controlloop runtime. - */ - public void sendParticipantDeregister() { - var participantDeregister = new ParticipantDeregister(); - participantDeregister.setParticipantId(participantId); - participantDeregister.setParticipantType(participantType); - - publisher.sendParticipantDeregister(participantDeregister); - } - - /** - * Handle a participantDeregister Ack message. - * - * @param participantDeregisterAckMsg the participantDeregisterAck message - */ - public void handleParticipantDeregisterAck(ParticipantDeregisterAck participantDeregisterAckMsg) { - LOGGER.debug("ParticipantDeregisterAck message received as responseTo {}", - participantDeregisterAckMsg.getResponseTo()); - } - - /** - * Handle a ParticipantUpdate message. - * - * @param participantUpdateMsg the ParticipantUpdate message - */ - public void handleParticipantUpdate(ParticipantUpdate participantUpdateMsg) { - LOGGER.debug("ParticipantUpdate message received for participantId {}", - participantUpdateMsg.getParticipantId()); - - if (!participantUpdateMsg.getParticipantDefinitionUpdates().isEmpty()) { - statusToPassive(); - // This message is to commission the controlloop - for (ParticipantDefinition participantDefinition : participantUpdateMsg.getParticipantDefinitionUpdates()) { - if (participantDefinition.getParticipantType().equals(participantType)) { - clElementDefsOnThisParticipant.addAll(participantDefinition.getControlLoopElementDefinitionList()); - break; - } - } - } else { - // This message is to decommission the controlloop - clElementDefsOnThisParticipant.clear(); - this.state = ParticipantState.TERMINATED; - } - sendParticipantUpdateAck(participantUpdateMsg.getMessageId()); - } - - /** - * Method to send ParticipantUpdateAck message to controlloop runtime. - */ - public void sendParticipantUpdateAck(UUID messageId) { - var participantUpdateAck = new ParticipantUpdateAck(); - participantUpdateAck.setResponseTo(messageId); - participantUpdateAck.setMessage("Participant Update Ack message"); - participantUpdateAck.setResult(true); - participantUpdateAck.setParticipantId(participantId); - participantUpdateAck.setParticipantType(participantType); - participantUpdateAck.setState(state); - publisher.sendParticipantUpdateAck(participantUpdateAck); - } - - /** - * Dispatch a heartbeat for this participant. - */ - public void sendHeartbeat() { - publisher.sendHeartbeat(makeHeartbeat(false)); - } - - /** - * Method to send heartbeat to controlloop runtime. - */ - public ParticipantStatus makeHeartbeat(boolean responseToParticipantStatusReq) { - if (!responseToParticipantStatusReq) { - var controlLoops = controlLoopHandler.getControlLoops(); - for (var clElementListener : controlLoopHandler.getListeners()) { - updateClElementStatistics(controlLoops, clElementListener); - } - } - this.participantStatistics.setState(state); - this.participantStatistics.setHealthStatus(healthStatus); - this.participantStatistics.setTimeStamp(Instant.now()); - - var heartbeat = new ParticipantStatus(); - heartbeat.setParticipantId(participantId); - heartbeat.setParticipantStatistics(participantStatistics); - heartbeat.setParticipantType(participantType); - heartbeat.setHealthStatus(healthStatus); - heartbeat.setState(state); - heartbeat.setControlLoopInfoList(getControlLoopInfoList()); - - if (responseToParticipantStatusReq) { - ParticipantDefinition participantDefinition = new ParticipantDefinition(); - participantDefinition.setParticipantId(participantId); - participantDefinition.setParticipantType(participantType); - participantDefinition.setControlLoopElementDefinitionList(clElementDefsOnThisParticipant); - heartbeat.setParticipantDefinitionUpdates(List.of(participantDefinition)); - } - - return heartbeat; - } - - private List getControlLoopInfoList() { - List controlLoopInfoList = new ArrayList<>(); - for (var entry : controlLoopHandler.getControlLoopMap().entrySet()) { - var clInfo = new ControlLoopInfo(); - clInfo.setControlLoopId(entry.getKey()); - var clStatitistics = new ControlLoopStatistics(); - clStatitistics.setControlLoopId(entry.getKey()); - var clElementStatisticsList = new ClElementStatisticsList(); - clElementStatisticsList - .setClElementStatistics(entry.getValue().getElements().values() - .stream() - .map(ControlLoopElement::getClElementStatistics) - .filter(Objects::nonNull) - .collect(Collectors.toList())); - clStatitistics.setClElementStatisticsList(clElementStatisticsList); - clInfo.setControlLoopStatistics(clStatitistics); - clInfo.setState(entry.getValue().getState()); - controlLoopInfoList.add(clInfo); - } - return controlLoopInfoList; - } -} diff --git a/participant/participant-intermediary/src/main/java/org/onap/policy/clamp/controlloop/participant/intermediary/handler/Publisher.java b/participant/participant-intermediary/src/main/java/org/onap/policy/clamp/controlloop/participant/intermediary/handler/Publisher.java deleted file mode 100644 index 287d7c055..000000000 --- a/participant/participant-intermediary/src/main/java/org/onap/policy/clamp/controlloop/participant/intermediary/handler/Publisher.java +++ /dev/null @@ -1,34 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * Copyright (C) 2021 Nordix Foundation. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - * SPDX-License-Identifier: Apache-2.0 - * ============LICENSE_END========================================================= - */ - -package org.onap.policy.clamp.controlloop.participant.intermediary.handler; - -import java.util.List; -import org.onap.policy.common.endpoints.event.comm.TopicSink; - -/** - * Publisher. - */ -public interface Publisher { - - void active(List topicSinks); - - void stop(); -} diff --git a/participant/participant-intermediary/src/main/java/org/onap/policy/clamp/controlloop/participant/intermediary/parameters/ParticipantIntermediaryParameters.java b/participant/participant-intermediary/src/main/java/org/onap/policy/clamp/controlloop/participant/intermediary/parameters/ParticipantIntermediaryParameters.java deleted file mode 100644 index fdc451e6b..000000000 --- a/participant/participant-intermediary/src/main/java/org/onap/policy/clamp/controlloop/participant/intermediary/parameters/ParticipantIntermediaryParameters.java +++ /dev/null @@ -1,61 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * Copyright (C) 2021 Nordix Foundation. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - * SPDX-License-Identifier: Apache-2.0 - * ============LICENSE_END========================================================= - */ - -package org.onap.policy.clamp.controlloop.participant.intermediary.parameters; - -import javax.validation.Valid; -import javax.validation.constraints.NotBlank; -import javax.validation.constraints.NotNull; -import javax.validation.constraints.Positive; -import lombok.Getter; -import lombok.Setter; -import org.onap.policy.common.endpoints.parameters.TopicParameterGroup; -import org.onap.policy.common.parameters.validation.ParameterGroupConstraint; -import org.onap.policy.models.tosca.authorative.concepts.ToscaConceptIdentifier; - -/** - * Class to hold all parameters needed for participant component. - */ -@Getter -@Setter -public class ParticipantIntermediaryParameters { - - // The ID and description of this participant - @NotNull - @Valid - private ToscaConceptIdentifier participantId; - - @NotBlank - private String description; - - // The participant type of this participant - @NotNull - @Valid - private ToscaConceptIdentifier participantType; - - // The time interval for periodic reporting of status to the CLAMP control loop server - @Valid - @Positive - private long reportingTimeIntervalMs; - - @NotNull - @ParameterGroupConstraint - private TopicParameterGroup clampControlLoopTopics; -} diff --git a/participant/participant-intermediary/src/main/java/org/onap/policy/clamp/controlloop/participant/intermediary/parameters/ParticipantParameters.java b/participant/participant-intermediary/src/main/java/org/onap/policy/clamp/controlloop/participant/intermediary/parameters/ParticipantParameters.java deleted file mode 100644 index c350b1b95..000000000 --- a/participant/participant-intermediary/src/main/java/org/onap/policy/clamp/controlloop/participant/intermediary/parameters/ParticipantParameters.java +++ /dev/null @@ -1,26 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * Copyright (C) 2021 Nordix Foundation. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - * SPDX-License-Identifier: Apache-2.0 - * ============LICENSE_END========================================================= - */ - -package org.onap.policy.clamp.controlloop.participant.intermediary.parameters; - -public interface ParticipantParameters { - - ParticipantIntermediaryParameters getIntermediaryParameters(); -} diff --git a/participant/participant-intermediary/src/test/java/org/onap/policy/clamp/acm/participant/intermediary/api/impl/ParticipantIntermediaryApiImplTest.java b/participant/participant-intermediary/src/test/java/org/onap/policy/clamp/acm/participant/intermediary/api/impl/ParticipantIntermediaryApiImplTest.java new file mode 100644 index 000000000..5d9675606 --- /dev/null +++ b/participant/participant-intermediary/src/test/java/org/onap/policy/clamp/acm/participant/intermediary/api/impl/ParticipantIntermediaryApiImplTest.java @@ -0,0 +1,103 @@ +/*- + * ============LICENSE_START======================================================= + * Copyright (C) 2021 Nordix Foundation. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * SPDX-License-Identifier: Apache-2.0 + * ============LICENSE_END========================================================= + */ + +package org.onap.policy.clamp.acm.participant.intermediary.api.impl; + +import static org.assertj.core.api.Assertions.assertThat; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertNotNull; + +import java.time.Instant; +import java.util.UUID; +import org.junit.jupiter.api.Test; +import org.mockito.Mockito; +import org.onap.policy.clamp.acm.participant.intermediary.api.AutomationCompositionElementListener; +import org.onap.policy.clamp.acm.participant.intermediary.main.parameters.CommonTestData; +import org.onap.policy.clamp.models.acm.concepts.AcElementStatistics; +import org.onap.policy.clamp.models.acm.concepts.AutomationCompositionOrderedState; +import org.onap.policy.clamp.models.acm.concepts.AutomationCompositionState; +import org.onap.policy.clamp.models.acm.concepts.ParticipantHealthStatus; +import org.onap.policy.clamp.models.acm.concepts.ParticipantState; +import org.onap.policy.clamp.models.acm.concepts.ParticipantStatistics; +import org.onap.policy.clamp.models.acm.messages.dmaap.participant.ParticipantMessageType; +import org.onap.policy.common.utils.coder.CoderException; +import org.onap.policy.models.tosca.authorative.concepts.ToscaConceptIdentifier; + +class ParticipantIntermediaryApiImplTest { + + private CommonTestData commonTestData = new CommonTestData(); + private static final String ID_NAME = "org.onap.PM_CDS_Blueprint"; + private static final String ID_VERSION = "1.0.1"; + + private static final String ID_NAME_E = "org.onap.domain.pmsh.PMSHAutomationCompositionDefinition"; + private static final String ID_VERSION_E = "1.0.0"; + + private static final String ID_NAME_TYPE = "org.onap.dcae.acm.DCAEMicroserviceAutomationCompositionParticipant"; + private static final String ID_VERSION_TYPE = "2.3.4"; + + @Test + void mockParticipantIntermediaryApiImplTest() throws CoderException { + var uuid = UUID.randomUUID(); + var id = new ToscaConceptIdentifier(ID_NAME, ID_VERSION); + var participantHandler = commonTestData.getParticipantHandlerAutomationCompositions(); + var automationComposiitonHandler = commonTestData.setTestAutomationCompositionHandler(id, uuid); + var apiImpl = new ParticipantIntermediaryApiImpl(participantHandler, automationComposiitonHandler); + var acElementListener = Mockito.mock(AutomationCompositionElementListener.class); + apiImpl.registerAutomationCompositionElementListener(acElementListener); + + assertNotNull(apiImpl.getAutomationCompositions(id.getName(), id.getVersion())); + assertThat(apiImpl.getAcElementDefinitionCommonProperties(id)).isEmpty(); + + var participantStatistics = new ParticipantStatistics(); + participantStatistics.setParticipantId(id); + participantStatistics.setTimeStamp(Instant.ofEpochMilli(123456L)); + participantStatistics.setState(ParticipantState.PASSIVE); + participantStatistics.setHealthStatus(ParticipantHealthStatus.HEALTHY); + apiImpl.updateParticipantStatistics(participantStatistics); + + var participants = apiImpl.getParticipants(id.getName(), id.getVersion()); + assertEquals(ParticipantState.UNKNOWN, participants.get(0).getParticipantState()); + + var participant = apiImpl.updateParticipantState(id, ParticipantState.TERMINATED); + assertEquals(ParticipantState.TERMINATED, participant.getParticipantState()); + + var elements = apiImpl.getAutomationCompositionElements(ID_NAME_E, ID_VERSION_E); + assertFalse(elements.containsKey(uuid)); + + var element = apiImpl.getAutomationCompositionElement(elements.keySet().iterator().next()); + var idType = new ToscaConceptIdentifier(ID_NAME_TYPE, ID_VERSION_TYPE); + assertEquals(idType, element.getParticipantType()); + + var acElementStatistics = new AcElementStatistics(); + var automationCompositionId = new ToscaConceptIdentifier("defName", "0.0.1"); + acElementStatistics.setParticipantId(automationCompositionId); + acElementStatistics.setState(AutomationCompositionState.RUNNING); + acElementStatistics.setTimeStamp(Instant.now()); + + apiImpl.updateAutomationCompositionElementStatistics(uuid, acElementStatistics); + var acElement = + apiImpl.updateAutomationCompositionElementState(id, uuid, AutomationCompositionOrderedState.UNINITIALISED, + AutomationCompositionState.PASSIVE, ParticipantMessageType.AUTOMATION_COMPOSITION_STATECHANGE_ACK); + assertEquals(AutomationCompositionOrderedState.UNINITIALISED, acElement.getOrderedState()); + assertEquals(uuid, acElement.getId()); + + } +} diff --git a/participant/participant-intermediary/src/test/java/org/onap/policy/clamp/acm/participant/intermediary/comm/ParticipantCommTest.java b/participant/participant-intermediary/src/test/java/org/onap/policy/clamp/acm/participant/intermediary/comm/ParticipantCommTest.java new file mode 100644 index 000000000..26dddc9ba --- /dev/null +++ b/participant/participant-intermediary/src/test/java/org/onap/policy/clamp/acm/participant/intermediary/comm/ParticipantCommTest.java @@ -0,0 +1,116 @@ +/*- + * ============LICENSE_START======================================================= + * Copyright (C) 2021 Nordix Foundation. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * SPDX-License-Identifier: Apache-2.0 + * ============LICENSE_END========================================================= + */ + +package org.onap.policy.clamp.acm.participant.intermediary.comm; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertFalse; +import static org.junit.jupiter.api.Assertions.assertThrows; + +import java.util.Collections; +import java.util.List; +import org.junit.jupiter.api.Test; +import org.mockito.Mockito; +import org.onap.policy.clamp.acm.participant.intermediary.main.parameters.CommonTestData; +import org.onap.policy.clamp.common.acm.exception.AutomationCompositionRuntimeException; +import org.onap.policy.clamp.models.acm.messages.dmaap.participant.AutomationCompositionAck; +import org.onap.policy.clamp.models.acm.messages.dmaap.participant.ParticipantDeregister; +import org.onap.policy.clamp.models.acm.messages.dmaap.participant.ParticipantMessageType; +import org.onap.policy.clamp.models.acm.messages.dmaap.participant.ParticipantRegister; +import org.onap.policy.clamp.models.acm.messages.dmaap.participant.ParticipantStatus; +import org.onap.policy.common.endpoints.event.comm.TopicSink; +import org.onap.policy.common.utils.coder.CoderException; + +class ParticipantCommTest { + + private CommonTestData commonTestData = new CommonTestData(); + + @Test + void participantReqTest() throws CoderException { + var participantHandler = commonTestData.getParticipantHandlerAutomationCompositions(); + + var participantRegisterAckListener = new ParticipantRegisterAckListener(participantHandler); + assertEquals(ParticipantMessageType.PARTICIPANT_REGISTER_ACK.name(), participantRegisterAckListener.getType()); + + var participantStatusReqListener = new ParticipantStatusReqListener(participantHandler); + assertEquals(ParticipantMessageType.PARTICIPANT_STATUS_REQ.name(), participantStatusReqListener.getType()); + + var participantDeregisterAckListener = new ParticipantDeregisterAckListener(participantHandler); + assertEquals(ParticipantMessageType.PARTICIPANT_DEREGISTER_ACK.name(), + participantDeregisterAckListener.getType()); + + var participantUpdateListener = new ParticipantUpdateListener(participantHandler); + assertEquals(ParticipantMessageType.PARTICIPANT_UPDATE.name(), participantUpdateListener.getType()); + + var automationCompositionUpdateListener = new AutomationCompositionUpdateListener(participantHandler); + assertEquals(ParticipantMessageType.AUTOMATION_COMPOSITION_UPDATE.name(), + automationCompositionUpdateListener.getType()); + + var automationCompositionStateChangeListener = new AutomationCompositionStateChangeListener(participantHandler); + assertEquals(ParticipantMessageType.AUTOMATION_COMPOSITION_STATE_CHANGE.name(), + automationCompositionStateChangeListener.getType()); + } + + @Test + void participantMessagePublisherExceptionsTest() { + var participantMessagePublisher = new ParticipantMessagePublisher(); + + var participantStatus = Mockito.mock(ParticipantStatus.class); + assertThrows(AutomationCompositionRuntimeException.class, () -> { + participantMessagePublisher.sendParticipantStatus(participantStatus); + }); + assertThrows(AutomationCompositionRuntimeException.class, () -> { + participantMessagePublisher.sendHeartbeat(participantStatus); + }); + + var participantRegister = Mockito.mock(ParticipantRegister.class); + assertThrows(AutomationCompositionRuntimeException.class, () -> { + participantMessagePublisher.sendParticipantRegister(participantRegister); + }); + + var participantDeregister = Mockito.mock(ParticipantDeregister.class); + assertThrows(AutomationCompositionRuntimeException.class, () -> { + participantMessagePublisher.sendParticipantDeregister(participantDeregister); + }); + + var automationCompositionAck = Mockito.mock(AutomationCompositionAck.class); + assertThrows(AutomationCompositionRuntimeException.class, () -> { + participantMessagePublisher.sendAutomationCompositionAck(automationCompositionAck); + }); + + List emptyList = Collections.emptyList(); + assertThrows(IllegalArgumentException.class, () -> { + participantMessagePublisher.active(emptyList); + }); + + participantMessagePublisher.stop(); + } + + @Test + void messageSenderTest() throws CoderException { + var participantHandler = commonTestData.getParticipantHandlerAutomationCompositions(); + var participantParameters = CommonTestData.getParticipantParameters(); + var messageSender = new MessageSender(participantHandler, participantParameters); + messageSender.run(); + assertFalse(messageSender.makeTimerPool().isTerminated()); + messageSender.close(); + } + +} diff --git a/participant/participant-intermediary/src/test/java/org/onap/policy/clamp/acm/participant/intermediary/handler/AutomationCompositionHandlerTest.java b/participant/participant-intermediary/src/test/java/org/onap/policy/clamp/acm/participant/intermediary/handler/AutomationCompositionHandlerTest.java new file mode 100644 index 000000000..5585e5190 --- /dev/null +++ b/participant/participant-intermediary/src/test/java/org/onap/policy/clamp/acm/participant/intermediary/handler/AutomationCompositionHandlerTest.java @@ -0,0 +1,227 @@ +/*- + * ============LICENSE_START======================================================= + * Copyright (C) 2021 Nordix Foundation. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * SPDX-License-Identifier: Apache-2.0 + * ============LICENSE_END========================================================= + */ + +package org.onap.policy.clamp.acm.participant.intermediary.handler; + +import static org.assertj.core.api.Assertions.assertThat; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNotEquals; +import static org.junit.Assert.assertNotNull; +import static org.junit.Assert.assertNull; +import static org.junit.jupiter.api.Assertions.assertDoesNotThrow; +import static org.mockito.Mockito.mock; + +import java.time.Instant; +import java.util.List; +import java.util.UUID; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.ExtendWith; +import org.onap.policy.clamp.acm.participant.intermediary.api.AutomationCompositionElementListener; +import org.onap.policy.clamp.acm.participant.intermediary.main.parameters.CommonTestData; +import org.onap.policy.clamp.models.acm.concepts.AcElementStatistics; +import org.onap.policy.clamp.models.acm.concepts.AutomationCompositionElement; +import org.onap.policy.clamp.models.acm.concepts.AutomationCompositionElementDefinition; +import org.onap.policy.clamp.models.acm.concepts.AutomationCompositionOrderedState; +import org.onap.policy.clamp.models.acm.concepts.AutomationCompositionState; +import org.onap.policy.clamp.models.acm.concepts.ParticipantUpdates; +import org.onap.policy.clamp.models.acm.messages.dmaap.participant.AutomationCompositionStateChange; +import org.onap.policy.clamp.models.acm.messages.dmaap.participant.AutomationCompositionUpdate; +import org.onap.policy.common.utils.coder.CoderException; +import org.onap.policy.models.tosca.authorative.concepts.ToscaConceptIdentifier; +import org.onap.policy.models.tosca.authorative.concepts.ToscaNodeTemplate; +import org.springframework.test.context.junit.jupiter.SpringExtension; + +@ExtendWith(SpringExtension.class) +class AutomationCompositionHandlerTest { + + private CommonTestData commonTestData = new CommonTestData(); + + @Test + void automationCompositionHandlerTest() { + var ach = commonTestData.getMockAutomationCompositionHandler(); + assertNotNull(ach.getAutomationCompositions()); + + assertNotNull(ach.getAutomationCompositionMap()); + assertNotNull(ach.getElementsOnThisParticipant()); + + var elementId1 = UUID.randomUUID(); + var element = new AutomationCompositionElement(); + element.setId(elementId1); + element.setDefinition( + new ToscaConceptIdentifier("org.onap.policy.acm.PolicyAutomationCompositionParticipant", "1.0.1")); + + element.setOrderedState(AutomationCompositionOrderedState.PASSIVE); + + AutomationCompositionElementListener listener = mock(AutomationCompositionElementListener.class); + ach.registerAutomationCompositionElementListener(listener); + assertThat(ach.getListeners()).contains(listener); + } + + @Test + void updateNullAutomationCompositionHandlerTest() { + var id = UUID.randomUUID(); + + var ach = commonTestData.getMockAutomationCompositionHandler(); + assertNull(ach.updateAutomationCompositionElementState(null, null, + AutomationCompositionOrderedState.UNINITIALISED, AutomationCompositionState.PASSIVE)); + + assertNull(ach.updateAutomationCompositionElementState(null, id, + AutomationCompositionOrderedState.UNINITIALISED, AutomationCompositionState.PASSIVE)); + + var acElementStatistics = new AcElementStatistics(); + var automationCompositionId = new ToscaConceptIdentifier("defName", "0.0.1"); + acElementStatistics.setParticipantId(automationCompositionId); + acElementStatistics.setState(AutomationCompositionState.RUNNING); + acElementStatistics.setTimeStamp(Instant.now()); + + ach.updateAutomationCompositionElementStatistics(id, acElementStatistics); + assertNull(ach.updateAutomationCompositionElementState(automationCompositionId, id, + AutomationCompositionOrderedState.UNINITIALISED, AutomationCompositionState.PASSIVE)); + } + + @Test + void updateAutomationCompositionHandlerTest() throws CoderException { + var uuid = UUID.randomUUID(); + var id = CommonTestData.getParticipantId(); + + var ach = commonTestData.setTestAutomationCompositionHandler(id, uuid); + var key = ach.getElementsOnThisParticipant().keySet().iterator().next(); + var value = ach.getElementsOnThisParticipant().get(key); + assertEquals(AutomationCompositionState.UNINITIALISED, value.getState()); + ach.updateAutomationCompositionElementState(id, uuid, AutomationCompositionOrderedState.UNINITIALISED, + AutomationCompositionState.PASSIVE); + assertEquals(AutomationCompositionState.PASSIVE, value.getState()); + + ach.getAutomationCompositionMap().values().iterator().next().getElements().putIfAbsent(key, value); + ach.updateAutomationCompositionElementState(id, key, AutomationCompositionOrderedState.PASSIVE, + AutomationCompositionState.RUNNING); + assertEquals(AutomationCompositionState.RUNNING, value.getState()); + + var acElementStatistics = new AcElementStatistics(); + acElementStatistics.setParticipantId(id); + acElementStatistics.setState(AutomationCompositionState.RUNNING); + acElementStatistics.setTimeStamp(Instant.now()); + + assertNotEquals(uuid, value.getAcElementStatistics().getId()); + ach.updateAutomationCompositionElementStatistics(uuid, acElementStatistics); + assertEquals(uuid, value.getAcElementStatistics().getId()); + + ach.getElementsOnThisParticipant().remove(key, value); + ach.getAutomationCompositionMap().values().iterator().next().getElements().clear(); + assertNull(ach.updateAutomationCompositionElementState(id, key, AutomationCompositionOrderedState.PASSIVE, + AutomationCompositionState.RUNNING)); + + } + + @Test + void handleAutomationCompositionUpdateExceptionTest() throws CoderException { + var uuid = UUID.randomUUID(); + var id = CommonTestData.getParticipantId(); + var stateChange = getStateChange(id, uuid, AutomationCompositionOrderedState.RUNNING); + var ach = commonTestData.setTestAutomationCompositionHandler(id, uuid); + assertDoesNotThrow( + () -> ach.handleAutomationCompositionStateChange(mock(AutomationCompositionStateChange.class), List.of())); + + ach.handleAutomationCompositionStateChange(stateChange, List.of()); + var newid = new ToscaConceptIdentifier("id", "1.2.3"); + stateChange.setAutomationCompositionId(newid); + stateChange.setParticipantId(newid); + assertDoesNotThrow(() -> ach.handleAutomationCompositionStateChange(stateChange, List.of())); + + var acd = new AutomationCompositionElementDefinition(); + acd.setAcElementDefinitionId(id); + var updateMsg = new AutomationCompositionUpdate(); + updateMsg.setAutomationCompositionId(id); + updateMsg.setMessageId(uuid); + updateMsg.setParticipantId(id); + updateMsg.setStartPhase(0); + var acElementDefinitions = List.of(acd); + assertDoesNotThrow(() -> ach.handleAutomationCompositionUpdate(updateMsg, acElementDefinitions)); + updateMsg.setStartPhase(1); + assertDoesNotThrow(() -> ach.handleAutomationCompositionUpdate(updateMsg, acElementDefinitions)); + assertThat(ach.getAcElementInstanceProperties(uuid)).isEmpty(); + + ach.getAutomationCompositionMap().clear(); + updateMsg.setStartPhase(0); + assertDoesNotThrow(() -> ach.handleAutomationCompositionUpdate(updateMsg, acElementDefinitions)); + + updateMsg.setAutomationCompositionId(new ToscaConceptIdentifier("new", "0.0.1")); + updateMsg.setParticipantUpdatesList(List.of(mock(ParticipantUpdates.class))); + assertDoesNotThrow(() -> ach.handleAutomationCompositionUpdate(updateMsg, acElementDefinitions)); + + updateMsg.setStartPhase(1); + var participantUpdate = new ParticipantUpdates(); + participantUpdate.setParticipantId(id); + var element = new AutomationCompositionElement(); + element.setParticipantType(id); + element.setDefinition(id); + participantUpdate.setAutomationCompositionElementList(List.of(element)); + updateMsg.setParticipantUpdatesList(List.of(participantUpdate)); + + var acd2 = new AutomationCompositionElementDefinition(); + acd2.setAcElementDefinitionId(id); + acd2.setAutomationCompositionElementToscaNodeTemplate(mock(ToscaNodeTemplate.class)); + assertDoesNotThrow(() -> ach.handleAutomationCompositionUpdate(updateMsg, List.of(acd2))); + + } + + @Test + void automationCompositionStateChangeUninitialisedTest() throws CoderException { + var uuid = UUID.randomUUID(); + var id = CommonTestData.getParticipantId(); + + var stateChangeUninitialised = getStateChange(id, uuid, AutomationCompositionOrderedState.UNINITIALISED); + + var ach = commonTestData.setTestAutomationCompositionHandler(id, uuid); + ach.handleAutomationCompositionStateChange(stateChangeUninitialised, List.of()); + var newid = new ToscaConceptIdentifier("id", "1.2.3"); + stateChangeUninitialised.setAutomationCompositionId(newid); + stateChangeUninitialised.setParticipantId(newid); + assertDoesNotThrow(() -> ach.handleAutomationCompositionStateChange(stateChangeUninitialised, List.of())); + } + + @Test + void automationCompositionStateChangePassiveTest() throws CoderException { + var uuid = UUID.randomUUID(); + var id = CommonTestData.getParticipantId(); + + var stateChangePassive = getStateChange(id, uuid, AutomationCompositionOrderedState.PASSIVE); + + var ach = commonTestData.setTestAutomationCompositionHandler(id, uuid); + ach.handleAutomationCompositionStateChange(stateChangePassive, List.of()); + var newid = new ToscaConceptIdentifier("id", "1.2.3"); + stateChangePassive.setAutomationCompositionId(newid); + stateChangePassive.setParticipantId(newid); + assertDoesNotThrow(() -> ach.handleAutomationCompositionStateChange(stateChangePassive, List.of())); + } + + private AutomationCompositionStateChange getStateChange(ToscaConceptIdentifier id, UUID uuid, + AutomationCompositionOrderedState state) { + var stateChange = new AutomationCompositionStateChange(); + stateChange.setAutomationCompositionId(id); + stateChange.setParticipantId(id); + stateChange.setMessageId(uuid); + stateChange.setOrderedState(state); + stateChange.setCurrentState(AutomationCompositionState.UNINITIALISED); + stateChange.setTimestamp(Instant.ofEpochMilli(3000)); + return stateChange; + } + +} diff --git a/participant/participant-intermediary/src/test/java/org/onap/policy/clamp/acm/participant/intermediary/handler/DummyParticipantParameters.java b/participant/participant-intermediary/src/test/java/org/onap/policy/clamp/acm/participant/intermediary/handler/DummyParticipantParameters.java new file mode 100644 index 000000000..b82fbed6a --- /dev/null +++ b/participant/participant-intermediary/src/test/java/org/onap/policy/clamp/acm/participant/intermediary/handler/DummyParticipantParameters.java @@ -0,0 +1,35 @@ +/*- + * ============LICENSE_START======================================================= + * Copyright (C) 2021 Nordix Foundation. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * SPDX-License-Identifier: Apache-2.0 + * ============LICENSE_END========================================================= + */ + +package org.onap.policy.clamp.acm.participant.intermediary.handler; + +import javax.validation.constraints.NotNull; +import lombok.Getter; +import lombok.Setter; +import org.onap.policy.clamp.acm.participant.intermediary.parameters.ParticipantIntermediaryParameters; +import org.onap.policy.clamp.acm.participant.intermediary.parameters.ParticipantParameters; + +@Getter +@Setter +public class DummyParticipantParameters implements ParticipantParameters { + + @NotNull + private ParticipantIntermediaryParameters intermediaryParameters; +} diff --git a/participant/participant-intermediary/src/test/java/org/onap/policy/clamp/acm/participant/intermediary/handler/IntermediaryActivatorTest.java b/participant/participant-intermediary/src/test/java/org/onap/policy/clamp/acm/participant/intermediary/handler/IntermediaryActivatorTest.java new file mode 100644 index 000000000..9ecf59ba4 --- /dev/null +++ b/participant/participant-intermediary/src/test/java/org/onap/policy/clamp/acm/participant/intermediary/handler/IntermediaryActivatorTest.java @@ -0,0 +1,103 @@ +/*- + * ============LICENSE_START======================================================= + * Copyright (C) 2021 Nordix Foundation. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * SPDX-License-Identifier: Apache-2.0 + * ============LICENSE_END========================================================= + */ + +package org.onap.policy.clamp.acm.participant.intermediary.handler; + +import static org.assertj.core.api.Assertions.assertThatIllegalStateException; +import static org.junit.jupiter.api.Assertions.assertDoesNotThrow; +import static org.junit.jupiter.api.Assertions.assertFalse; +import static org.junit.jupiter.api.Assertions.assertTrue; +import static org.mockito.ArgumentMatchers.any; +import static org.mockito.ArgumentMatchers.anyList; +import static org.mockito.Mockito.mock; +import static org.mockito.Mockito.spy; +import static org.mockito.Mockito.times; +import static org.mockito.Mockito.verify; +import static org.mockito.Mockito.when; + +import java.util.List; +import org.junit.jupiter.api.Test; +import org.onap.policy.clamp.acm.participant.intermediary.comm.ParticipantStatusReqListener; +import org.onap.policy.clamp.acm.participant.intermediary.main.parameters.CommonTestData; +import org.onap.policy.clamp.acm.participant.intermediary.parameters.ParticipantParameters; +import org.onap.policy.clamp.models.acm.messages.dmaap.participant.ParticipantStatusReq; +import org.onap.policy.common.utils.coder.Coder; +import org.onap.policy.common.utils.coder.StandardCoder; +import org.onap.policy.common.utils.coder.StandardCoderObject; +import org.springframework.context.event.ContextClosedEvent; +import org.springframework.context.event.ContextRefreshedEvent; + +class IntermediaryActivatorTest { + private static final Coder CODER = new StandardCoder(); + + private static final String TOPIC_FIRST = "TOPIC1"; + private static final String TOPIC_SECOND = "TOPIC2"; + + @Test + void testStartAndStop() throws Exception { + ParticipantParameters parameters = CommonTestData.getParticipantParameters(); + + var publisherFirst = spy(mock(Publisher.class)); + var publisherSecond = spy(mock(Publisher.class)); + var publishers = List.of(publisherFirst, publisherSecond); + + var listenerFirst = spy(mock(ParticipantStatusReqListener.class)); + when(listenerFirst.getType()).thenReturn(TOPIC_FIRST); + when(listenerFirst.getScoListener()).thenReturn(listenerFirst); + + var listenerSecond = spy(mock(ParticipantStatusReqListener.class)); + when(listenerSecond.getType()).thenReturn(TOPIC_SECOND); + when(listenerSecond.getScoListener()).thenReturn(listenerSecond); + + List> listeners = List.of(listenerFirst, listenerSecond); + + ParticipantHandler handler = mock(ParticipantHandler.class); + try (var activator = new IntermediaryActivator(parameters, handler, publishers, listeners)) { + + assertFalse(activator.isAlive()); + activator.start(); + assertTrue(activator.isAlive()); + + // repeat start - should throw an exception + assertThatIllegalStateException().isThrownBy(() -> activator.start()); + assertTrue(activator.isAlive()); + verify(publisherFirst, times(1)).active(anyList()); + verify(publisherSecond, times(1)).active(anyList()); + + StandardCoderObject sco = CODER.decode("{messageType:" + TOPIC_FIRST + "}", StandardCoderObject.class); + activator.getMsgDispatcher().onTopicEvent(null, "msg", sco); + verify(listenerFirst, times(1)).onTopicEvent(any(), any(), any()); + + sco = CODER.decode("{messageType:" + TOPIC_SECOND + "}", StandardCoderObject.class); + activator.getMsgDispatcher().onTopicEvent(null, "msg", sco); + verify(listenerSecond, times(1)).onTopicEvent(any(), any(), any()); + + activator.close(); + assertFalse(activator.isAlive()); + + // repeat stop - should throw an exception + assertThatIllegalStateException().isThrownBy(() -> activator.stop()); + assertFalse(activator.isAlive()); + + assertDoesNotThrow(() -> activator.handleContextRefreshEvent(mock(ContextRefreshedEvent.class))); + assertDoesNotThrow(() -> activator.handleContextClosedEvent(mock(ContextClosedEvent.class))); + } + } +} diff --git a/participant/participant-intermediary/src/test/java/org/onap/policy/clamp/acm/participant/intermediary/handler/ParticipantHandlerTest.java b/participant/participant-intermediary/src/test/java/org/onap/policy/clamp/acm/participant/intermediary/handler/ParticipantHandlerTest.java new file mode 100644 index 000000000..8e22784db --- /dev/null +++ b/participant/participant-intermediary/src/test/java/org/onap/policy/clamp/acm/participant/intermediary/handler/ParticipantHandlerTest.java @@ -0,0 +1,176 @@ +/*- + * ============LICENSE_START======================================================= + * Copyright (C) 2021 Nordix Foundation. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * SPDX-License-Identifier: Apache-2.0 + * ============LICENSE_END========================================================= + */ + +package org.onap.policy.clamp.acm.participant.intermediary.handler; + +import static org.assertj.core.api.Assertions.assertThat; +import static org.assertj.core.api.Assertions.assertThatThrownBy; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertNull; +import static org.junit.Assert.assertTrue; + +import java.time.Instant; +import java.util.ArrayList; +import java.util.List; +import java.util.UUID; +import org.junit.jupiter.api.Test; +import org.onap.policy.clamp.acm.participant.intermediary.comm.ParticipantMessagePublisher; +import org.onap.policy.clamp.acm.participant.intermediary.main.parameters.CommonTestData; +import org.onap.policy.clamp.models.acm.concepts.ParticipantDefinition; +import org.onap.policy.clamp.models.acm.concepts.ParticipantHealthStatus; +import org.onap.policy.clamp.models.acm.concepts.ParticipantState; +import org.onap.policy.clamp.models.acm.messages.dmaap.participant.ParticipantAckMessage; +import org.onap.policy.clamp.models.acm.messages.dmaap.participant.ParticipantMessage; +import org.onap.policy.clamp.models.acm.messages.dmaap.participant.ParticipantMessageType; +import org.onap.policy.clamp.models.acm.messages.dmaap.participant.ParticipantRegisterAck; +import org.onap.policy.clamp.models.acm.messages.dmaap.participant.ParticipantUpdate; +import org.onap.policy.common.utils.coder.CoderException; +import org.onap.policy.models.tosca.authorative.concepts.ToscaConceptIdentifier; + +class ParticipantHandlerTest { + + private CommonTestData commonTestData = new CommonTestData(); + private static final String ID_NAME = "org.onap.PM_CDS_Blueprint"; + private static final String ID_VERSION = "1.0.1"; + + @Test + void mockParticipantHandlerTest() { + var participantHandler = commonTestData.getMockParticipantHandler(); + assertNull(participantHandler.getParticipant(null, null)); + assertEquals("org.onap.PM_CDS_Blueprint 1.0.1", participantHandler.getParticipantId().toString()); + + var id = new ToscaConceptIdentifier(ID_NAME, ID_VERSION); + assertEquals(id, participantHandler.getParticipantId()); + assertEquals(id, participantHandler.getParticipantType()); + assertThat(participantHandler.getAcElementDefinitionCommonProperties(id)).isEmpty(); + + } + + @Test + void handleUpdateTest() { + var parameters = CommonTestData.getParticipantParameters(); + var automationCompositionHander = commonTestData.getMockAutomationCompositionHandler(); + var publisher = new ParticipantMessagePublisher(); + var emptyParticipantHandler = + new ParticipantHandler(parameters, publisher, automationCompositionHander); + var participantUpdateMsg = new ParticipantUpdate(); + + assertThatThrownBy(() -> + emptyParticipantHandler.handleParticipantUpdate(participantUpdateMsg)) + .isInstanceOf(RuntimeException.class); + + var participantHandler = commonTestData.getMockParticipantHandler(); + + var id = new ToscaConceptIdentifier(ID_NAME, ID_VERSION); + participantUpdateMsg.setAutomationCompositionId(id); + participantUpdateMsg.setParticipantId(id); + participantUpdateMsg.setParticipantType(id); + participantUpdateMsg.setMessageId(UUID.randomUUID()); + participantUpdateMsg.setTimestamp(Instant.ofEpochMilli(3000)); + + var heartbeatF = participantHandler.makeHeartbeat(false); + assertEquals(id, heartbeatF.getParticipantId()); + assertEquals(ParticipantState.UNKNOWN, heartbeatF.getParticipantStatistics().getState()); + assertThat(heartbeatF.getAutomationCompositionInfoList()).isEmpty(); + + participantHandler.handleParticipantUpdate(participantUpdateMsg); + assertThat(participantHandler.getAcElementDefinitionCommonProperties(id)).isEmpty(); + + var heartbeatT = participantHandler.makeHeartbeat(true); + assertEquals(id, heartbeatT.getParticipantId()); + assertEquals(ParticipantState.TERMINATED, heartbeatT.getParticipantStatistics().getState()); + assertThat(heartbeatT.getParticipantDefinitionUpdates()).isNotEmpty(); + assertEquals(id, heartbeatT.getParticipantDefinitionUpdates().get(0).getParticipantId()); + + var pum = setListParticipantDefinition(participantUpdateMsg); + participantHandler.handleParticipantUpdate(pum); + var heartbeatTAfterUpdate = participantHandler.makeHeartbeat(true); + assertEquals(id, heartbeatTAfterUpdate.getParticipantId()); + assertEquals(ParticipantState.PASSIVE, heartbeatTAfterUpdate.getParticipantStatistics().getState()); + + } + + private ParticipantUpdate setListParticipantDefinition(ParticipantUpdate participantUpdateMsg) { + var id = new ToscaConceptIdentifier(ID_NAME, ID_VERSION); + List participantDefinitionUpdates = new ArrayList<>(); + var def = new ParticipantDefinition(); + def.setParticipantId(id); + def.setParticipantType(id); + participantDefinitionUpdates.add(def); + participantUpdateMsg.setParticipantDefinitionUpdates(participantDefinitionUpdates); + return participantUpdateMsg; + } + + @Test + void handleParticipantTest() { + var participantHandler = commonTestData.getMockParticipantHandler(); + var id = new ToscaConceptIdentifier(ID_NAME, ID_VERSION); + var p = participantHandler.getParticipant(id.getName(), id.getVersion()); + assertEquals(ParticipantState.UNKNOWN, p.getParticipantState()); + + participantHandler.updateParticipantState(id, ParticipantState.PASSIVE); + var p2 = participantHandler.getParticipant(id.getName(), id.getVersion()); + assertEquals(ParticipantState.PASSIVE, p2.getParticipantState()); + + var participantRegisterAckMsg = new ParticipantRegisterAck(); + participantRegisterAckMsg.setState(ParticipantState.TERMINATED); + participantHandler.handleParticipantRegisterAck(participantRegisterAckMsg); + assertEquals(ParticipantHealthStatus.HEALTHY, participantHandler.makeHeartbeat(false).getHealthStatus()); + + var emptyid = new ToscaConceptIdentifier("", ID_VERSION); + assertNull(participantHandler.updateParticipantState(emptyid, ParticipantState.PASSIVE)); + + var sameid = new ToscaConceptIdentifier(ID_NAME, ID_VERSION); + var participant = participantHandler.updateParticipantState(sameid, ParticipantState.PASSIVE); + assertEquals(participant.getDefinition(), sameid); + + } + + @Test + void checkAppliesTo() { + var participantHandler = commonTestData.getMockParticipantHandler(); + var participantAckMsg = + new ParticipantAckMessage(ParticipantMessageType.AUTOMATION_COMPOSITION_UPDATE); + assertTrue(participantHandler.appliesTo(participantAckMsg)); + + var participantMsg = + new ParticipantMessage(ParticipantMessageType.PARTICIPANT_STATUS); + assertTrue(participantHandler.appliesTo(participantMsg)); + + var emptyid = new ToscaConceptIdentifier("", ID_VERSION); + participantMsg.setParticipantType(emptyid); + assertFalse(participantHandler.appliesTo(participantMsg)); + + } + + @Test + void getAutomationCompositionInfoListTest() throws CoderException { + var participantHandler = commonTestData.getParticipantHandlerAutomationCompositions(); + var id = new ToscaConceptIdentifier(ID_NAME, ID_VERSION); + participantHandler.sendHeartbeat(); + assertEquals(id, participantHandler.makeHeartbeat(false) + .getAutomationCompositionInfoList() + .get(0) + .getAutomationCompositionId()); + + } + +} diff --git a/participant/participant-intermediary/src/test/java/org/onap/policy/clamp/acm/participant/intermediary/main/parameters/CommonTestData.java b/participant/participant-intermediary/src/test/java/org/onap/policy/clamp/acm/participant/intermediary/main/parameters/CommonTestData.java new file mode 100644 index 000000000..ad54d402c --- /dev/null +++ b/participant/participant-intermediary/src/test/java/org/onap/policy/clamp/acm/participant/intermediary/main/parameters/CommonTestData.java @@ -0,0 +1,294 @@ +/*- + * ============LICENSE_START======================================================= + * Copyright (C) 2021 Nordix Foundation. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * SPDX-License-Identifier: Apache-2.0 + * ============LICENSE_END========================================================= + */ + +package org.onap.policy.clamp.acm.participant.intermediary.main.parameters; + +import java.io.File; +import java.time.Instant; +import java.util.Arrays; +import java.util.Collections; +import java.util.LinkedHashMap; +import java.util.List; +import java.util.Map; +import java.util.TreeMap; +import java.util.UUID; +import org.mockito.Mockito; +import org.onap.policy.clamp.acm.participant.intermediary.comm.ParticipantMessagePublisher; +import org.onap.policy.clamp.acm.participant.intermediary.handler.AutomationCompositionHandler; +import org.onap.policy.clamp.acm.participant.intermediary.handler.DummyParticipantParameters; +import org.onap.policy.clamp.acm.participant.intermediary.handler.ParticipantHandler; +import org.onap.policy.clamp.acm.participant.intermediary.parameters.ParticipantIntermediaryParameters; +import org.onap.policy.clamp.models.acm.concepts.AcElementStatistics; +import org.onap.policy.clamp.models.acm.concepts.AutomationComposition; +import org.onap.policy.clamp.models.acm.concepts.AutomationCompositionElement; +import org.onap.policy.clamp.models.acm.concepts.AutomationCompositionOrderedState; +import org.onap.policy.clamp.models.acm.concepts.AutomationCompositionState; +import org.onap.policy.clamp.models.acm.concepts.AutomationCompositions; +import org.onap.policy.clamp.models.acm.messages.dmaap.participant.ParticipantDeregisterAck; +import org.onap.policy.common.endpoints.event.comm.TopicSink; +import org.onap.policy.common.endpoints.parameters.TopicParameters; +import org.onap.policy.common.utils.coder.Coder; +import org.onap.policy.common.utils.coder.CoderException; +import org.onap.policy.common.utils.coder.StandardCoder; +import org.onap.policy.models.tosca.authorative.concepts.ToscaConceptIdentifier; + +/** + * Class to hold/create all parameters for test cases. + */ +public class CommonTestData { + public static final String PARTICIPANT_GROUP_NAME = "AutomationCompositionParticipantGroup"; + public static final String DESCRIPTION = "Participant description"; + public static final long TIME_INTERVAL = 2000; + public static final List TOPIC_PARAMS = Arrays.asList(getTopicParams()); + public static final Coder CODER = new StandardCoder(); + private static final Object lockit = new Object(); + + /** + * Get ParticipantIntermediaryParameters. + * + * @return ParticipantIntermediaryParameters + */ + public ParticipantIntermediaryParameters getParticipantIntermediaryParameters() { + try { + return CODER.convert(getIntermediaryParametersMap(PARTICIPANT_GROUP_NAME), + ParticipantIntermediaryParameters.class); + } catch (final CoderException e) { + throw new RuntimeException("cannot create ParticipantSimulatorParameters from map", e); + } + } + + /** + * Get ParticipantParameters. + * + * @return ParticipantParameters + */ + public static DummyParticipantParameters getParticipantParameters() { + try { + return CODER.convert(getParametersMap(PARTICIPANT_GROUP_NAME), DummyParticipantParameters.class); + } catch (final CoderException e) { + throw new RuntimeException("cannot create ParticipantSimulatorParameters from map", e); + } + } + + /** + * Returns a property map for a Parameters map for test cases. + * + * @param name name of the parameters + * @return a property map suitable for constructing an object + */ + public static Map getParametersMap(final String name) { + final Map map = new TreeMap<>(); + map.put("intermediaryParameters", getIntermediaryParametersMap(name)); + return map; + } + + /** + * Returns a property map for a intermediaryParameters map for test cases. + * + * @param name name of the parameters + * @return a property map suitable for constructing an object + */ + public static Map getIntermediaryParametersMap(final String name) { + final Map map = new TreeMap<>(); + map.put("name", name); + map.put("participantId", getParticipantId()); + map.put("description", DESCRIPTION); + map.put("participantType", getParticipantId()); + map.put("reportingTimeIntervalMs", TIME_INTERVAL); + map.put("clampAutomationCompositionTopics", getTopicParametersMap(false)); + + return map; + } + + /** + * Returns a property map for a TopicParameters map for test cases. + * + * @param isEmpty boolean value to represent that object created should be empty or not + * @return a property map suitable for constructing an object + */ + public static Map getTopicParametersMap(final boolean isEmpty) { + final Map map = new TreeMap<>(); + if (!isEmpty) { + map.put("topicSources", TOPIC_PARAMS); + map.put("topicSinks", TOPIC_PARAMS); + } + return map; + } + + /** + * Returns topic parameters for test cases. + * + * @return topic parameters + */ + public static TopicParameters getTopicParams() { + final var topicParams = new TopicParameters(); + topicParams.setTopic("POLICY-ACRUNTIME-PARTICIPANT"); + topicParams.setTopicCommInfrastructure("dmaap"); + topicParams.setServers(Arrays.asList("localhost")); + return topicParams; + } + + /** + * Returns participantId for test cases. + * + * @return participant Id + */ + public static ToscaConceptIdentifier getParticipantId() { + return new ToscaConceptIdentifier("org.onap.PM_CDS_Blueprint", "1.0.1"); + } + + /** + * Returns a participantMessagePublisher for MessageSender. + * + * @return participant Message Publisher + */ + private ParticipantMessagePublisher getParticipantMessagePublisher() { + synchronized (lockit) { + var participantMessagePublisher = new ParticipantMessagePublisher(); + participantMessagePublisher.active(Collections.singletonList(Mockito.mock(TopicSink.class))); + return participantMessagePublisher; + } + } + + /** + * Returns a mocked AutomationCompositionHandler for test cases. + * + * @return AutomationCompositionHandler + */ + public AutomationCompositionHandler getMockAutomationCompositionHandler() { + return new AutomationCompositionHandler(getParticipantParameters(), getParticipantMessagePublisher()); + } + + /** + * Returns a mocked ParticipantHandler for test cases. + * + * @return participant Handler + */ + public ParticipantHandler getMockParticipantHandler() { + var parameters = getParticipantParameters(); + var automationCompositionHandler = getMockAutomationCompositionHandler(); + var publisher = new ParticipantMessagePublisher(); + publisher.active(Collections.singletonList(Mockito.mock(TopicSink.class))); + var participantHandler = new ParticipantHandler(parameters, publisher, automationCompositionHandler); + return participantHandler; + } + + /** + * Returns a mocked ParticipantHandler for test cases. + * + * @return participant Handler + * + * @throws CoderException if there is an error with .json file. + */ + public ParticipantHandler getParticipantHandlerAutomationCompositions() throws CoderException { + var automationCompositionHandler = Mockito.mock(AutomationCompositionHandler.class); + Mockito.doReturn(getTestAutomationCompositions()).when(automationCompositionHandler) + .getAutomationCompositions(); + Mockito.doReturn(getTestAutomationCompositionMap()).when(automationCompositionHandler) + .getAutomationCompositionMap(); + var publisher = new ParticipantMessagePublisher(); + publisher.active(Collections.singletonList(Mockito.mock(TopicSink.class))); + var parameters = getParticipantParameters(); + var participantHandler = new ParticipantHandler(parameters, publisher, automationCompositionHandler); + participantHandler.sendParticipantRegister(); + participantHandler.handleParticipantStatusReq(null); + participantHandler.sendParticipantDeregister(); + var participantDeregisterAckMsg = new ParticipantDeregisterAck(); + participantDeregisterAckMsg.setResponseTo(UUID.randomUUID()); + participantHandler.handleParticipantDeregisterAck(participantDeregisterAckMsg); + return participantHandler; + } + + /** + * Returns a Map of ToscaConceptIdentifier and AutomationComposition for test cases. + * + * @return automationCompositionMap + * + * @throws CoderException if there is an error with .json file. + */ + public Map getTestAutomationCompositionMap() throws CoderException { + var automationCompositions = getTestAutomationCompositions(); + var automationComposition = automationCompositions.getAutomationCompositionList().get(1); + var id = getParticipantId(); + Map automationCompositionMap = new LinkedHashMap<>(); + automationCompositionMap.put(id, automationComposition); + return automationCompositionMap; + } + + /** + * Returns List of AutomationComposition for test cases. + * + * @return AutomationCompositions + * + * @throws CoderException if there is an error with .json file. + */ + public AutomationCompositions getTestAutomationCompositions() throws CoderException { + return new StandardCoder().decode(new File("src/test/resources/providers/TestAutomationCompositions.json"), + AutomationCompositions.class); + } + + /** + * Returns a map for a elementsOnThisParticipant for test cases. + * + * @param uuid UUID and id ToscaConceptIdentifier + * @return a map suitable for elementsOnThisParticipant + */ + public Map setAutomationCompositionElementTest(UUID uuid, + ToscaConceptIdentifier id) { + var acElement = new AutomationCompositionElement(); + acElement.setId(uuid); + acElement.setParticipantId(id); + acElement.setDefinition(id); + acElement.setOrderedState(AutomationCompositionOrderedState.UNINITIALISED); + + var acElementStatistics = new AcElementStatistics(); + acElementStatistics.setParticipantId(id); + acElementStatistics.setState(AutomationCompositionState.UNINITIALISED); + acElementStatistics.setTimeStamp(Instant.now()); + + acElement.setAcElementStatistics(acElementStatistics); + + Map elementsOnThisParticipant = new LinkedHashMap<>(); + elementsOnThisParticipant.put(uuid, acElement); + return elementsOnThisParticipant; + } + + /** + * Returns a AutomationCompositionHandler with elements on the id,uuid. + * + * @param id ToscaConceptIdentifier and uuid UUID + * @return a AutomationCompositionHander with elements + */ + public AutomationCompositionHandler setTestAutomationCompositionHandler(ToscaConceptIdentifier id, UUID uuid) + throws CoderException { + var ach = getMockAutomationCompositionHandler(); + + var key = getTestAutomationCompositionMap().keySet().iterator().next(); + var value = getTestAutomationCompositionMap().get(key); + ach.getAutomationCompositionMap().put(key, value); + + var keyElem = setAutomationCompositionElementTest(uuid, id).keySet().iterator().next(); + var valueElem = setAutomationCompositionElementTest(uuid, id).get(keyElem); + ach.getElementsOnThisParticipant().put(keyElem, valueElem); + + return ach; + } + +} diff --git a/participant/participant-intermediary/src/test/java/org/onap/policy/clamp/acm/participant/intermediary/main/parameters/TestParticipantIntermediaryParameters.java b/participant/participant-intermediary/src/test/java/org/onap/policy/clamp/acm/participant/intermediary/main/parameters/TestParticipantIntermediaryParameters.java new file mode 100644 index 000000000..cc2b110f3 --- /dev/null +++ b/participant/participant-intermediary/src/test/java/org/onap/policy/clamp/acm/participant/intermediary/main/parameters/TestParticipantIntermediaryParameters.java @@ -0,0 +1,67 @@ +/*- + * ============LICENSE_START======================================================= + * Copyright (C) 2021 Nordix Foundation. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * SPDX-License-Identifier: Apache-2.0 + * ============LICENSE_END========================================================= + */ + +package org.onap.policy.clamp.acm.participant.intermediary.main.parameters; + +import static org.assertj.core.api.Assertions.assertThat; + +import javax.validation.Validation; +import javax.validation.ValidatorFactory; +import org.junit.jupiter.api.Test; +import org.onap.policy.clamp.acm.participant.intermediary.parameters.ParticipantIntermediaryParameters; + +/** + * Class to perform unit test of {@link ParticipantParameterGroup}. + */ +class TestParticipantIntermediaryParameters { + private CommonTestData commonTestData = new CommonTestData(); + private ValidatorFactory validatorFactory = Validation.buildDefaultValidatorFactory(); + + @Test + void testParticipantIntermediaryParameterGroup() { + final ParticipantIntermediaryParameters participantParameters = + commonTestData.getParticipantIntermediaryParameters(); + assertThat(validatorFactory.getValidator().validate(participantParameters)).isEmpty(); + } + + @Test + void testParticipantIntermediaryParameterGroup_EmptyParameter() { + final ParticipantIntermediaryParameters participantParameters = + commonTestData.getParticipantIntermediaryParameters(); + participantParameters.setClampAutomationCompositionTopics(null); + assertThat(validatorFactory.getValidator().validate(participantParameters)).isNotEmpty(); + } + + @Test + void testParticipantIntermediaryParameters_NullTopicSinks() { + final ParticipantIntermediaryParameters participantParameters = + commonTestData.getParticipantIntermediaryParameters(); + participantParameters.getClampAutomationCompositionTopics().setTopicSinks(null); + assertThat(validatorFactory.getValidator().validate(participantParameters)).isNotEmpty(); + } + + @Test + void testParticipantIntermediaryParameters_NullTopicSources() { + final ParticipantIntermediaryParameters participantParameters = + commonTestData.getParticipantIntermediaryParameters(); + participantParameters.getClampAutomationCompositionTopics().setTopicSources(null); + assertThat(validatorFactory.getValidator().validate(participantParameters)).isNotEmpty(); + } +} diff --git a/participant/participant-intermediary/src/test/java/org/onap/policy/clamp/controlloop/participant/intermediary/api/impl/ParticipantIntermediaryApiImplTest.java b/participant/participant-intermediary/src/test/java/org/onap/policy/clamp/controlloop/participant/intermediary/api/impl/ParticipantIntermediaryApiImplTest.java deleted file mode 100644 index b08e796b7..000000000 --- a/participant/participant-intermediary/src/test/java/org/onap/policy/clamp/controlloop/participant/intermediary/api/impl/ParticipantIntermediaryApiImplTest.java +++ /dev/null @@ -1,102 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * Copyright (C) 2021 Nordix Foundation. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - * SPDX-License-Identifier: Apache-2.0 - * ============LICENSE_END========================================================= - */ - -package org.onap.policy.clamp.controlloop.participant.intermediary.api.impl; - -import static org.assertj.core.api.Assertions.assertThat; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertFalse; -import static org.junit.Assert.assertNotNull; - -import java.time.Instant; -import java.util.UUID; -import org.junit.jupiter.api.Test; -import org.mockito.Mockito; -import org.onap.policy.clamp.controlloop.models.controlloop.concepts.ClElementStatistics; -import org.onap.policy.clamp.controlloop.models.controlloop.concepts.ControlLoopOrderedState; -import org.onap.policy.clamp.controlloop.models.controlloop.concepts.ControlLoopState; -import org.onap.policy.clamp.controlloop.models.controlloop.concepts.ParticipantHealthStatus; -import org.onap.policy.clamp.controlloop.models.controlloop.concepts.ParticipantState; -import org.onap.policy.clamp.controlloop.models.controlloop.concepts.ParticipantStatistics; -import org.onap.policy.clamp.controlloop.models.messages.dmaap.participant.ParticipantMessageType; -import org.onap.policy.clamp.controlloop.participant.intermediary.api.ControlLoopElementListener; -import org.onap.policy.clamp.controlloop.participant.intermediary.main.parameters.CommonTestData; -import org.onap.policy.common.utils.coder.CoderException; -import org.onap.policy.models.tosca.authorative.concepts.ToscaConceptIdentifier; - -class ParticipantIntermediaryApiImplTest { - - private CommonTestData commonTestData = new CommonTestData(); - private static final String ID_NAME = "org.onap.PM_CDS_Blueprint"; - private static final String ID_VERSION = "1.0.1"; - - private static final String ID_NAME_E = "org.onap.domain.pmsh.PMSHControlLoopDefinition"; - private static final String ID_VERSION_E = "1.0.0"; - - private static final String ID_NAME_TYPE = "org.onap.dcae.controlloop.DCAEMicroserviceControlLoopParticipant"; - private static final String ID_VERSION_TYPE = "2.3.4"; - - @Test - void mockParticipantIntermediaryApiImplTest() throws CoderException { - var uuid = UUID.randomUUID(); - var id = new ToscaConceptIdentifier(ID_NAME, ID_VERSION); - var participantHandler = commonTestData.getParticipantHandlerControlLoops(); - var controlLoopHandler = commonTestData.setTestControlLoopHandler(id, uuid); - var apiImpl = new ParticipantIntermediaryApiImpl(participantHandler, controlLoopHandler); - var clElementListener = Mockito.mock(ControlLoopElementListener.class); - apiImpl.registerControlLoopElementListener(clElementListener); - - assertNotNull(apiImpl.getControlLoops(id.getName(), id.getVersion())); - assertThat(apiImpl.getClElementDefinitionCommonProperties(id)).isEmpty(); - - var participantStatistics = new ParticipantStatistics(); - participantStatistics.setParticipantId(id); - participantStatistics.setTimeStamp(Instant.ofEpochMilli(123456L)); - participantStatistics.setState(ParticipantState.PASSIVE); - participantStatistics.setHealthStatus(ParticipantHealthStatus.HEALTHY); - apiImpl.updateParticipantStatistics(participantStatistics); - - var participants = apiImpl.getParticipants(id.getName(), id.getVersion()); - assertEquals(ParticipantState.UNKNOWN, participants.get(0).getParticipantState()); - - var participant = apiImpl.updateParticipantState(id, ParticipantState.TERMINATED); - assertEquals(ParticipantState.TERMINATED, participant.getParticipantState()); - - var elements = apiImpl.getControlLoopElements(ID_NAME_E, ID_VERSION_E); - assertFalse(elements.containsKey(uuid)); - - var element = apiImpl.getControlLoopElement(elements.keySet().iterator().next()); - var idType = new ToscaConceptIdentifier(ID_NAME_TYPE, ID_VERSION_TYPE); - assertEquals(idType, element.getParticipantType()); - - var clElementStatistics = new ClElementStatistics(); - var controlLoopId = new ToscaConceptIdentifier("defName", "0.0.1"); - clElementStatistics.setParticipantId(controlLoopId); - clElementStatistics.setControlLoopState(ControlLoopState.RUNNING); - clElementStatistics.setTimeStamp(Instant.now()); - - apiImpl.updateControlLoopElementStatistics(uuid, clElementStatistics); - var clElement = apiImpl.updateControlLoopElementState(id, uuid, ControlLoopOrderedState.UNINITIALISED, - ControlLoopState.PASSIVE, ParticipantMessageType.CONTROLLOOP_STATECHANGE_ACK); - assertEquals(ControlLoopOrderedState.UNINITIALISED, clElement.getOrderedState()); - assertEquals(uuid, clElement.getId()); - - } -} diff --git a/participant/participant-intermediary/src/test/java/org/onap/policy/clamp/controlloop/participant/intermediary/comm/ParticipantCommTest.java b/participant/participant-intermediary/src/test/java/org/onap/policy/clamp/controlloop/participant/intermediary/comm/ParticipantCommTest.java deleted file mode 100644 index a40a41853..000000000 --- a/participant/participant-intermediary/src/test/java/org/onap/policy/clamp/controlloop/participant/intermediary/comm/ParticipantCommTest.java +++ /dev/null @@ -1,119 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * Copyright (C) 2021 Nordix Foundation. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - * SPDX-License-Identifier: Apache-2.0 - * ============LICENSE_END========================================================= - */ - -package org.onap.policy.clamp.controlloop.participant.intermediary.comm; - -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertFalse; -import static org.junit.jupiter.api.Assertions.assertThrows; - -import java.util.Collections; -import java.util.List; -import org.junit.jupiter.api.Test; -import org.mockito.Mockito; -import org.onap.policy.clamp.controlloop.common.exception.ControlLoopRuntimeException; -import org.onap.policy.clamp.controlloop.models.messages.dmaap.participant.ControlLoopAck; -import org.onap.policy.clamp.controlloop.models.messages.dmaap.participant.ParticipantDeregister; -import org.onap.policy.clamp.controlloop.models.messages.dmaap.participant.ParticipantMessageType; -import org.onap.policy.clamp.controlloop.models.messages.dmaap.participant.ParticipantRegister; -import org.onap.policy.clamp.controlloop.models.messages.dmaap.participant.ParticipantStatus; -import org.onap.policy.clamp.controlloop.participant.intermediary.main.parameters.CommonTestData; -import org.onap.policy.common.endpoints.event.comm.TopicSink; -import org.onap.policy.common.utils.coder.CoderException; - -class ParticipantCommTest { - - private CommonTestData commonTestData = new CommonTestData(); - - @Test - void participantReqTest() throws CoderException { - var participantHandler = commonTestData.getParticipantHandlerControlLoops(); - - var participantRegisterAckListener = new ParticipantRegisterAckListener(participantHandler); - assertEquals(ParticipantMessageType.PARTICIPANT_REGISTER_ACK.name(), - participantRegisterAckListener.getType()); - - var participantStatusReqListener = new ParticipantStatusReqListener(participantHandler); - assertEquals(ParticipantMessageType.PARTICIPANT_STATUS_REQ.name(), - participantStatusReqListener.getType()); - - var participantDeregisterAckListener = new ParticipantDeregisterAckListener(participantHandler); - assertEquals(ParticipantMessageType.PARTICIPANT_DEREGISTER_ACK.name(), - participantDeregisterAckListener.getType()); - - var participantUpdateListener = new ParticipantUpdateListener(participantHandler); - assertEquals(ParticipantMessageType.PARTICIPANT_UPDATE.name(), - participantUpdateListener.getType()); - - var controlLoopUpdateListener = new ControlLoopUpdateListener(participantHandler); - assertEquals(ParticipantMessageType.CONTROL_LOOP_UPDATE.name(), - controlLoopUpdateListener.getType()); - - var controlLoopStateChangeListener = new ControlLoopStateChangeListener(participantHandler); - assertEquals(ParticipantMessageType.CONTROL_LOOP_STATE_CHANGE.name(), - controlLoopStateChangeListener.getType()); - } - - @Test - void participantMessagePublisherExceptionsTest() { - var participantMessagePublisher = new ParticipantMessagePublisher(); - - var participantStatus = Mockito.mock(ParticipantStatus.class); - assertThrows(ControlLoopRuntimeException.class, () -> { - participantMessagePublisher.sendParticipantStatus(participantStatus); - }); - assertThrows(ControlLoopRuntimeException.class, () -> { - participantMessagePublisher.sendHeartbeat(participantStatus); - }); - - var participantRegister = Mockito.mock(ParticipantRegister.class); - assertThrows(ControlLoopRuntimeException.class, () -> { - participantMessagePublisher.sendParticipantRegister(participantRegister); - }); - - var participantDeregister = Mockito.mock(ParticipantDeregister.class); - assertThrows(ControlLoopRuntimeException.class, () -> { - participantMessagePublisher.sendParticipantDeregister(participantDeregister); - }); - - var controlLoopAck = Mockito.mock(ControlLoopAck.class); - assertThrows(ControlLoopRuntimeException.class, () -> { - participantMessagePublisher.sendControlLoopAck(controlLoopAck); - }); - - List emptyList = Collections.emptyList(); - assertThrows(IllegalArgumentException.class, () -> { - participantMessagePublisher.active(emptyList); - }); - - participantMessagePublisher.stop(); - } - - @Test - void messageSenderTest() throws CoderException { - var participantHandler = commonTestData.getParticipantHandlerControlLoops(); - var participantParameters = CommonTestData.getParticipantParameters(); - var messageSender = new MessageSender(participantHandler, participantParameters); - messageSender.run(); - assertFalse(messageSender.makeTimerPool().isTerminated()); - messageSender.close(); - } - -} diff --git a/participant/participant-intermediary/src/test/java/org/onap/policy/clamp/controlloop/participant/intermediary/handler/ControlLoopHandlerTest.java b/participant/participant-intermediary/src/test/java/org/onap/policy/clamp/controlloop/participant/intermediary/handler/ControlLoopHandlerTest.java deleted file mode 100644 index 43b43e3bf..000000000 --- a/participant/participant-intermediary/src/test/java/org/onap/policy/clamp/controlloop/participant/intermediary/handler/ControlLoopHandlerTest.java +++ /dev/null @@ -1,226 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * Copyright (C) 2021 Nordix Foundation. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - * SPDX-License-Identifier: Apache-2.0 - * ============LICENSE_END========================================================= - */ - -package org.onap.policy.clamp.controlloop.participant.intermediary.handler; - -import static org.assertj.core.api.Assertions.assertThat; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertNotEquals; -import static org.junit.Assert.assertNotNull; -import static org.junit.Assert.assertNull; -import static org.junit.jupiter.api.Assertions.assertDoesNotThrow; -import static org.mockito.Mockito.mock; - -import java.time.Instant; -import java.util.List; -import java.util.UUID; -import org.junit.jupiter.api.Test; -import org.junit.jupiter.api.extension.ExtendWith; -import org.onap.policy.clamp.controlloop.models.controlloop.concepts.ClElementStatistics; -import org.onap.policy.clamp.controlloop.models.controlloop.concepts.ControlLoopElement; -import org.onap.policy.clamp.controlloop.models.controlloop.concepts.ControlLoopElementDefinition; -import org.onap.policy.clamp.controlloop.models.controlloop.concepts.ControlLoopOrderedState; -import org.onap.policy.clamp.controlloop.models.controlloop.concepts.ControlLoopState; -import org.onap.policy.clamp.controlloop.models.controlloop.concepts.ParticipantUpdates; -import org.onap.policy.clamp.controlloop.models.messages.dmaap.participant.ControlLoopStateChange; -import org.onap.policy.clamp.controlloop.models.messages.dmaap.participant.ControlLoopUpdate; -import org.onap.policy.clamp.controlloop.participant.intermediary.api.ControlLoopElementListener; -import org.onap.policy.clamp.controlloop.participant.intermediary.main.parameters.CommonTestData; -import org.onap.policy.common.utils.coder.CoderException; -import org.onap.policy.models.tosca.authorative.concepts.ToscaConceptIdentifier; -import org.onap.policy.models.tosca.authorative.concepts.ToscaNodeTemplate; -import org.springframework.test.context.junit.jupiter.SpringExtension; - -@ExtendWith(SpringExtension.class) -class ControlLoopHandlerTest { - - private CommonTestData commonTestData = new CommonTestData(); - - @Test - void controlLoopHandlerTest() { - var clh = commonTestData.getMockControlLoopHandler(); - assertNotNull(clh.getControlLoops()); - - assertNotNull(clh.getControlLoopMap()); - assertNotNull(clh.getElementsOnThisParticipant()); - - var elementId1 = UUID.randomUUID(); - var element = new ControlLoopElement(); - element.setId(elementId1); - element.setDefinition(new ToscaConceptIdentifier( - "org.onap.policy.controlloop.PolicyControlLoopParticipant", "1.0.1")); - - element.setOrderedState(ControlLoopOrderedState.PASSIVE); - - ControlLoopElementListener listener = mock(ControlLoopElementListener.class); - clh.registerControlLoopElementListener(listener); - assertThat(clh.getListeners()).contains(listener); - } - - @Test - void updateNullControlLoopHandlerTest() { - var id = UUID.randomUUID(); - - var clh = commonTestData.getMockControlLoopHandler(); - assertNull(clh.updateControlLoopElementState(null, null, ControlLoopOrderedState.UNINITIALISED, - ControlLoopState.PASSIVE)); - - assertNull(clh.updateControlLoopElementState(null, id, ControlLoopOrderedState.UNINITIALISED, - ControlLoopState.PASSIVE)); - - var clElementStatistics = new ClElementStatistics(); - var controlLoopId = new ToscaConceptIdentifier("defName", "0.0.1"); - clElementStatistics.setParticipantId(controlLoopId); - clElementStatistics.setControlLoopState(ControlLoopState.RUNNING); - clElementStatistics.setTimeStamp(Instant.now()); - - clh.updateControlLoopElementStatistics(id, clElementStatistics); - assertNull(clh.updateControlLoopElementState(controlLoopId, id, ControlLoopOrderedState.UNINITIALISED, - ControlLoopState.PASSIVE)); - } - - @Test - void updateControlLoopHandlerTest() throws CoderException { - var uuid = UUID.randomUUID(); - var id = CommonTestData.getParticipantId(); - - var clh = commonTestData.setTestControlLoopHandler(id, uuid); - var key = clh.getElementsOnThisParticipant().keySet().iterator().next(); - var value = clh.getElementsOnThisParticipant().get(key); - assertEquals(ControlLoopState.UNINITIALISED, value.getState()); - clh.updateControlLoopElementState(id, uuid, ControlLoopOrderedState.UNINITIALISED, - ControlLoopState.PASSIVE); - assertEquals(ControlLoopState.PASSIVE, value.getState()); - - clh.getControlLoopMap().values().iterator().next().getElements().putIfAbsent(key, value); - clh.updateControlLoopElementState(id, key, ControlLoopOrderedState.PASSIVE, - ControlLoopState.RUNNING); - assertEquals(ControlLoopState.RUNNING, value.getState()); - - var clElementStatistics = new ClElementStatistics(); - clElementStatistics.setParticipantId(id); - clElementStatistics.setControlLoopState(ControlLoopState.RUNNING); - clElementStatistics.setTimeStamp(Instant.now()); - - assertNotEquals(uuid, value.getClElementStatistics().getId()); - clh.updateControlLoopElementStatistics(uuid, clElementStatistics); - assertEquals(uuid, value.getClElementStatistics().getId()); - - clh.getElementsOnThisParticipant().remove(key, value); - clh.getControlLoopMap().values().iterator().next().getElements().clear(); - assertNull(clh.updateControlLoopElementState(id, key, ControlLoopOrderedState.PASSIVE, - ControlLoopState.RUNNING)); - - } - - @Test - void handleControlLoopUpdateExceptionTest() throws CoderException { - var uuid = UUID.randomUUID(); - var id = CommonTestData.getParticipantId(); - var stateChange = getStateChange(id, uuid, ControlLoopOrderedState.RUNNING); - var clh = commonTestData.setTestControlLoopHandler(id, uuid); - assertDoesNotThrow(() -> clh.handleControlLoopStateChange(mock(ControlLoopStateChange.class), List.of())); - - clh.handleControlLoopStateChange(stateChange, List.of()); - var newid = new ToscaConceptIdentifier("id", "1.2.3"); - stateChange.setControlLoopId(newid); - stateChange.setParticipantId(newid); - assertDoesNotThrow(() -> clh.handleControlLoopStateChange(stateChange, List.of())); - - var cld = new ControlLoopElementDefinition(); - cld.setClElementDefinitionId(id); - var updateMsg = new ControlLoopUpdate(); - updateMsg.setControlLoopId(id); - updateMsg.setMessageId(uuid); - updateMsg.setParticipantId(id); - updateMsg.setStartPhase(0); - var clElementDefinitions = List.of(cld); - assertDoesNotThrow(() -> clh.handleControlLoopUpdate(updateMsg, clElementDefinitions)); - updateMsg.setStartPhase(1); - assertDoesNotThrow(() -> clh.handleControlLoopUpdate(updateMsg, clElementDefinitions)); - assertThat(clh.getClElementInstanceProperties(uuid)).isEmpty(); - - clh.getControlLoopMap().clear(); - updateMsg.setStartPhase(0); - assertDoesNotThrow(() -> clh.handleControlLoopUpdate(updateMsg, clElementDefinitions)); - - updateMsg.setControlLoopId(new ToscaConceptIdentifier("new", "0.0.1")); - updateMsg.setParticipantUpdatesList(List.of(mock(ParticipantUpdates.class))); - assertDoesNotThrow(() -> clh.handleControlLoopUpdate(updateMsg, clElementDefinitions)); - - updateMsg.setStartPhase(1); - var participantUpdate = new ParticipantUpdates(); - participantUpdate.setParticipantId(id); - var element = new ControlLoopElement(); - element.setParticipantType(id); - element.setDefinition(id); - participantUpdate.setControlLoopElementList(List.of(element)); - updateMsg.setParticipantUpdatesList(List.of(participantUpdate)); - - var cld2 = new ControlLoopElementDefinition(); - cld2.setClElementDefinitionId(id); - cld2.setControlLoopElementToscaNodeTemplate(mock(ToscaNodeTemplate.class)); - assertDoesNotThrow(() -> clh.handleControlLoopUpdate(updateMsg, List.of(cld2))); - - } - - @Test - void controlLoopStateChangeUninitialisedTest() throws CoderException { - var uuid = UUID.randomUUID(); - var id = CommonTestData.getParticipantId(); - - var stateChangeUninitialised = getStateChange(id, uuid, ControlLoopOrderedState.UNINITIALISED); - - var clh = commonTestData.setTestControlLoopHandler(id, uuid); - clh.handleControlLoopStateChange(stateChangeUninitialised, List.of()); - var newid = new ToscaConceptIdentifier("id", "1.2.3"); - stateChangeUninitialised.setControlLoopId(newid); - stateChangeUninitialised.setParticipantId(newid); - assertDoesNotThrow(() -> clh.handleControlLoopStateChange(stateChangeUninitialised, List.of())); - } - - @Test - void controlLoopStateChangePassiveTest() throws CoderException { - var uuid = UUID.randomUUID(); - var id = CommonTestData.getParticipantId(); - - var stateChangePassive = getStateChange(id, uuid, ControlLoopOrderedState.PASSIVE); - - var clh = commonTestData.setTestControlLoopHandler(id, uuid); - clh.handleControlLoopStateChange(stateChangePassive, List.of()); - var newid = new ToscaConceptIdentifier("id", "1.2.3"); - stateChangePassive.setControlLoopId(newid); - stateChangePassive.setParticipantId(newid); - assertDoesNotThrow(() -> clh.handleControlLoopStateChange(stateChangePassive, List.of())); - } - - - private ControlLoopStateChange getStateChange(ToscaConceptIdentifier id, UUID uuid, ControlLoopOrderedState state) { - var stateChange = new ControlLoopStateChange(); - stateChange.setControlLoopId(id); - stateChange.setParticipantId(id); - stateChange.setMessageId(uuid); - stateChange.setOrderedState(state); - stateChange.setCurrentState(ControlLoopState.UNINITIALISED); - stateChange.setTimestamp(Instant.ofEpochMilli(3000)); - return stateChange; - } - -} diff --git a/participant/participant-intermediary/src/test/java/org/onap/policy/clamp/controlloop/participant/intermediary/handler/DummyParticipantParameters.java b/participant/participant-intermediary/src/test/java/org/onap/policy/clamp/controlloop/participant/intermediary/handler/DummyParticipantParameters.java deleted file mode 100644 index d60bb71bc..000000000 --- a/participant/participant-intermediary/src/test/java/org/onap/policy/clamp/controlloop/participant/intermediary/handler/DummyParticipantParameters.java +++ /dev/null @@ -1,35 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * Copyright (C) 2021 Nordix Foundation. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - * SPDX-License-Identifier: Apache-2.0 - * ============LICENSE_END========================================================= - */ - -package org.onap.policy.clamp.controlloop.participant.intermediary.handler; - -import javax.validation.constraints.NotNull; -import lombok.Getter; -import lombok.Setter; -import org.onap.policy.clamp.controlloop.participant.intermediary.parameters.ParticipantIntermediaryParameters; -import org.onap.policy.clamp.controlloop.participant.intermediary.parameters.ParticipantParameters; - -@Getter -@Setter -public class DummyParticipantParameters implements ParticipantParameters { - - @NotNull - private ParticipantIntermediaryParameters intermediaryParameters; -} diff --git a/participant/participant-intermediary/src/test/java/org/onap/policy/clamp/controlloop/participant/intermediary/handler/IntermediaryActivatorTest.java b/participant/participant-intermediary/src/test/java/org/onap/policy/clamp/controlloop/participant/intermediary/handler/IntermediaryActivatorTest.java deleted file mode 100644 index 8c400c12f..000000000 --- a/participant/participant-intermediary/src/test/java/org/onap/policy/clamp/controlloop/participant/intermediary/handler/IntermediaryActivatorTest.java +++ /dev/null @@ -1,103 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * Copyright (C) 2021 Nordix Foundation. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - * SPDX-License-Identifier: Apache-2.0 - * ============LICENSE_END========================================================= - */ - -package org.onap.policy.clamp.controlloop.participant.intermediary.handler; - -import static org.assertj.core.api.Assertions.assertThatIllegalStateException; -import static org.junit.jupiter.api.Assertions.assertDoesNotThrow; -import static org.junit.jupiter.api.Assertions.assertFalse; -import static org.junit.jupiter.api.Assertions.assertTrue; -import static org.mockito.ArgumentMatchers.any; -import static org.mockito.ArgumentMatchers.anyList; -import static org.mockito.Mockito.mock; -import static org.mockito.Mockito.spy; -import static org.mockito.Mockito.times; -import static org.mockito.Mockito.verify; -import static org.mockito.Mockito.when; - -import java.util.List; -import org.junit.jupiter.api.Test; -import org.onap.policy.clamp.controlloop.models.messages.dmaap.participant.ParticipantStatusReq; -import org.onap.policy.clamp.controlloop.participant.intermediary.comm.ParticipantStatusReqListener; -import org.onap.policy.clamp.controlloop.participant.intermediary.main.parameters.CommonTestData; -import org.onap.policy.clamp.controlloop.participant.intermediary.parameters.ParticipantParameters; -import org.onap.policy.common.utils.coder.Coder; -import org.onap.policy.common.utils.coder.StandardCoder; -import org.onap.policy.common.utils.coder.StandardCoderObject; -import org.springframework.context.event.ContextClosedEvent; -import org.springframework.context.event.ContextRefreshedEvent; - -class IntermediaryActivatorTest { - private static final Coder CODER = new StandardCoder(); - - private static final String TOPIC_FIRST = "TOPIC1"; - private static final String TOPIC_SECOND = "TOPIC2"; - - @Test - void testStartAndStop() throws Exception { - ParticipantParameters parameters = CommonTestData.getParticipantParameters(); - - var publisherFirst = spy(mock(Publisher.class)); - var publisherSecond = spy(mock(Publisher.class)); - var publishers = List.of(publisherFirst, publisherSecond); - - var listenerFirst = spy(mock(ParticipantStatusReqListener.class)); - when(listenerFirst.getType()).thenReturn(TOPIC_FIRST); - when(listenerFirst.getScoListener()).thenReturn(listenerFirst); - - var listenerSecond = spy(mock(ParticipantStatusReqListener.class)); - when(listenerSecond.getType()).thenReturn(TOPIC_SECOND); - when(listenerSecond.getScoListener()).thenReturn(listenerSecond); - - List> listeners = List.of(listenerFirst, listenerSecond); - - ParticipantHandler handler = mock(ParticipantHandler.class); - try (var activator = new IntermediaryActivator(parameters, handler, publishers, listeners)) { - - assertFalse(activator.isAlive()); - activator.start(); - assertTrue(activator.isAlive()); - - // repeat start - should throw an exception - assertThatIllegalStateException().isThrownBy(() -> activator.start()); - assertTrue(activator.isAlive()); - verify(publisherFirst, times(1)).active(anyList()); - verify(publisherSecond, times(1)).active(anyList()); - - StandardCoderObject sco = CODER.decode("{messageType:" + TOPIC_FIRST + "}", StandardCoderObject.class); - activator.getMsgDispatcher().onTopicEvent(null, "msg", sco); - verify(listenerFirst, times(1)).onTopicEvent(any(), any(), any()); - - sco = CODER.decode("{messageType:" + TOPIC_SECOND + "}", StandardCoderObject.class); - activator.getMsgDispatcher().onTopicEvent(null, "msg", sco); - verify(listenerSecond, times(1)).onTopicEvent(any(), any(), any()); - - activator.close(); - assertFalse(activator.isAlive()); - - // repeat stop - should throw an exception - assertThatIllegalStateException().isThrownBy(() -> activator.stop()); - assertFalse(activator.isAlive()); - - assertDoesNotThrow(() -> activator.handleContextRefreshEvent(mock(ContextRefreshedEvent.class))); - assertDoesNotThrow(() -> activator.handleContextClosedEvent(mock(ContextClosedEvent.class))); - } - } -} diff --git a/participant/participant-intermediary/src/test/java/org/onap/policy/clamp/controlloop/participant/intermediary/handler/ParticipantHandlerTest.java b/participant/participant-intermediary/src/test/java/org/onap/policy/clamp/controlloop/participant/intermediary/handler/ParticipantHandlerTest.java deleted file mode 100644 index d00697521..000000000 --- a/participant/participant-intermediary/src/test/java/org/onap/policy/clamp/controlloop/participant/intermediary/handler/ParticipantHandlerTest.java +++ /dev/null @@ -1,176 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * Copyright (C) 2021 Nordix Foundation. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - * SPDX-License-Identifier: Apache-2.0 - * ============LICENSE_END========================================================= - */ - -package org.onap.policy.clamp.controlloop.participant.intermediary.handler; - -import static org.assertj.core.api.Assertions.assertThat; -import static org.assertj.core.api.Assertions.assertThatThrownBy; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertFalse; -import static org.junit.Assert.assertNull; -import static org.junit.Assert.assertTrue; - -import java.time.Instant; -import java.util.ArrayList; -import java.util.List; -import java.util.UUID; -import org.junit.jupiter.api.Test; -import org.onap.policy.clamp.controlloop.models.controlloop.concepts.ParticipantDefinition; -import org.onap.policy.clamp.controlloop.models.controlloop.concepts.ParticipantHealthStatus; -import org.onap.policy.clamp.controlloop.models.controlloop.concepts.ParticipantState; -import org.onap.policy.clamp.controlloop.models.messages.dmaap.participant.ParticipantAckMessage; -import org.onap.policy.clamp.controlloop.models.messages.dmaap.participant.ParticipantMessage; -import org.onap.policy.clamp.controlloop.models.messages.dmaap.participant.ParticipantMessageType; -import org.onap.policy.clamp.controlloop.models.messages.dmaap.participant.ParticipantRegisterAck; -import org.onap.policy.clamp.controlloop.models.messages.dmaap.participant.ParticipantUpdate; -import org.onap.policy.clamp.controlloop.participant.intermediary.comm.ParticipantMessagePublisher; -import org.onap.policy.clamp.controlloop.participant.intermediary.main.parameters.CommonTestData; -import org.onap.policy.common.utils.coder.CoderException; -import org.onap.policy.models.tosca.authorative.concepts.ToscaConceptIdentifier; - -class ParticipantHandlerTest { - - private CommonTestData commonTestData = new CommonTestData(); - private static final String ID_NAME = "org.onap.PM_CDS_Blueprint"; - private static final String ID_VERSION = "1.0.1"; - - @Test - void mockParticipantHandlerTest() { - var participantHandler = commonTestData.getMockParticipantHandler(); - assertNull(participantHandler.getParticipant(null, null)); - assertEquals("org.onap.PM_CDS_Blueprint 1.0.1", participantHandler.getParticipantId().toString()); - - var id = new ToscaConceptIdentifier(ID_NAME, ID_VERSION); - assertEquals(id, participantHandler.getParticipantId()); - assertEquals(id, participantHandler.getParticipantType()); - assertThat(participantHandler.getClElementDefinitionCommonProperties(id)).isEmpty(); - - } - - @Test - void handleUpdateTest() { - var parameters = CommonTestData.getParticipantParameters(); - var controlLoopHander = commonTestData.getMockControlLoopHandler(); - var publisher = new ParticipantMessagePublisher(); - var emptyParticipantHandler = - new ParticipantHandler(parameters, publisher, controlLoopHander); - var participantUpdateMsg = new ParticipantUpdate(); - - assertThatThrownBy(() -> - emptyParticipantHandler.handleParticipantUpdate(participantUpdateMsg)) - .isInstanceOf(RuntimeException.class); - - var participantHandler = commonTestData.getMockParticipantHandler(); - - var id = new ToscaConceptIdentifier(ID_NAME, ID_VERSION); - participantUpdateMsg.setControlLoopId(id); - participantUpdateMsg.setParticipantId(id); - participantUpdateMsg.setParticipantType(id); - participantUpdateMsg.setMessageId(UUID.randomUUID()); - participantUpdateMsg.setTimestamp(Instant.ofEpochMilli(3000)); - - var heartbeatF = participantHandler.makeHeartbeat(false); - assertEquals(id, heartbeatF.getParticipantId()); - assertEquals(ParticipantState.UNKNOWN, heartbeatF.getParticipantStatistics().getState()); - assertThat(heartbeatF.getControlLoopInfoList()).isEmpty(); - - participantHandler.handleParticipantUpdate(participantUpdateMsg); - assertThat(participantHandler.getClElementDefinitionCommonProperties(id)).isEmpty(); - - var heartbeatT = participantHandler.makeHeartbeat(true); - assertEquals(id, heartbeatT.getParticipantId()); - assertEquals(ParticipantState.TERMINATED, heartbeatT.getParticipantStatistics().getState()); - assertThat(heartbeatT.getParticipantDefinitionUpdates()).isNotEmpty(); - assertEquals(id, heartbeatT.getParticipantDefinitionUpdates().get(0).getParticipantId()); - - var pum = setListParticipantDefinition(participantUpdateMsg); - participantHandler.handleParticipantUpdate(pum); - var heartbeatTAfterUpdate = participantHandler.makeHeartbeat(true); - assertEquals(id, heartbeatTAfterUpdate.getParticipantId()); - assertEquals(ParticipantState.PASSIVE, heartbeatTAfterUpdate.getParticipantStatistics().getState()); - - } - - private ParticipantUpdate setListParticipantDefinition(ParticipantUpdate participantUpdateMsg) { - var id = new ToscaConceptIdentifier(ID_NAME, ID_VERSION); - List participantDefinitionUpdates = new ArrayList<>(); - var def = new ParticipantDefinition(); - def.setParticipantId(id); - def.setParticipantType(id); - participantDefinitionUpdates.add(def); - participantUpdateMsg.setParticipantDefinitionUpdates(participantDefinitionUpdates); - return participantUpdateMsg; - } - - @Test - void handleParticipantTest() { - var participantHandler = commonTestData.getMockParticipantHandler(); - var id = new ToscaConceptIdentifier(ID_NAME, ID_VERSION); - var p = participantHandler.getParticipant(id.getName(), id.getVersion()); - assertEquals(ParticipantState.UNKNOWN, p.getParticipantState()); - - participantHandler.updateParticipantState(id, ParticipantState.PASSIVE); - var p2 = participantHandler.getParticipant(id.getName(), id.getVersion()); - assertEquals(ParticipantState.PASSIVE, p2.getParticipantState()); - - var participantRegisterAckMsg = new ParticipantRegisterAck(); - participantRegisterAckMsg.setState(ParticipantState.TERMINATED); - participantHandler.handleParticipantRegisterAck(participantRegisterAckMsg); - assertEquals(ParticipantHealthStatus.HEALTHY, participantHandler.makeHeartbeat(false).getHealthStatus()); - - var emptyid = new ToscaConceptIdentifier("", ID_VERSION); - assertNull(participantHandler.updateParticipantState(emptyid, ParticipantState.PASSIVE)); - - var sameid = new ToscaConceptIdentifier(ID_NAME, ID_VERSION); - var participant = participantHandler.updateParticipantState(sameid, ParticipantState.PASSIVE); - assertEquals(participant.getDefinition(), sameid); - - } - - @Test - void checkAppliesTo() { - var participantHandler = commonTestData.getMockParticipantHandler(); - var participantAckMsg = - new ParticipantAckMessage(ParticipantMessageType.CONTROL_LOOP_UPDATE); - assertTrue(participantHandler.appliesTo(participantAckMsg)); - - var participantMsg = - new ParticipantMessage(ParticipantMessageType.PARTICIPANT_STATUS); - assertTrue(participantHandler.appliesTo(participantMsg)); - - var emptyid = new ToscaConceptIdentifier("", ID_VERSION); - participantMsg.setParticipantType(emptyid); - assertFalse(participantHandler.appliesTo(participantMsg)); - - } - - @Test - void getControlLoopInfoListTest() throws CoderException { - var participantHandler = commonTestData.getParticipantHandlerControlLoops(); - var id = new ToscaConceptIdentifier(ID_NAME, ID_VERSION); - participantHandler.sendHeartbeat(); - assertEquals(id, participantHandler.makeHeartbeat(false) - .getControlLoopInfoList() - .get(0) - .getControlLoopId()); - - } - -} diff --git a/participant/participant-intermediary/src/test/java/org/onap/policy/clamp/controlloop/participant/intermediary/main/parameters/CommonTestData.java b/participant/participant-intermediary/src/test/java/org/onap/policy/clamp/controlloop/participant/intermediary/main/parameters/CommonTestData.java deleted file mode 100644 index 9bbf8964c..000000000 --- a/participant/participant-intermediary/src/test/java/org/onap/policy/clamp/controlloop/participant/intermediary/main/parameters/CommonTestData.java +++ /dev/null @@ -1,293 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * Copyright (C) 2021 Nordix Foundation. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - * SPDX-License-Identifier: Apache-2.0 - * ============LICENSE_END========================================================= - */ - -package org.onap.policy.clamp.controlloop.participant.intermediary.main.parameters; - -import java.io.File; -import java.time.Instant; -import java.util.Arrays; -import java.util.Collections; -import java.util.LinkedHashMap; -import java.util.List; -import java.util.Map; -import java.util.TreeMap; -import java.util.UUID; -import org.mockito.Mockito; -import org.onap.policy.clamp.controlloop.models.controlloop.concepts.ClElementStatistics; -import org.onap.policy.clamp.controlloop.models.controlloop.concepts.ControlLoop; -import org.onap.policy.clamp.controlloop.models.controlloop.concepts.ControlLoopElement; -import org.onap.policy.clamp.controlloop.models.controlloop.concepts.ControlLoopOrderedState; -import org.onap.policy.clamp.controlloop.models.controlloop.concepts.ControlLoopState; -import org.onap.policy.clamp.controlloop.models.controlloop.concepts.ControlLoops; -import org.onap.policy.clamp.controlloop.models.messages.dmaap.participant.ParticipantDeregisterAck; -import org.onap.policy.clamp.controlloop.participant.intermediary.comm.ParticipantMessagePublisher; -import org.onap.policy.clamp.controlloop.participant.intermediary.handler.ControlLoopHandler; -import org.onap.policy.clamp.controlloop.participant.intermediary.handler.DummyParticipantParameters; -import org.onap.policy.clamp.controlloop.participant.intermediary.handler.ParticipantHandler; -import org.onap.policy.clamp.controlloop.participant.intermediary.parameters.ParticipantIntermediaryParameters; -import org.onap.policy.common.endpoints.event.comm.TopicSink; -import org.onap.policy.common.endpoints.parameters.TopicParameters; -import org.onap.policy.common.utils.coder.Coder; -import org.onap.policy.common.utils.coder.CoderException; -import org.onap.policy.common.utils.coder.StandardCoder; -import org.onap.policy.models.tosca.authorative.concepts.ToscaConceptIdentifier; - -/** - * Class to hold/create all parameters for test cases. - */ -public class CommonTestData { - public static final String PARTICIPANT_GROUP_NAME = "ControlLoopParticipantGroup"; - public static final String DESCRIPTION = "Participant description"; - public static final long TIME_INTERVAL = 2000; - public static final List TOPIC_PARAMS = Arrays.asList(getTopicParams()); - public static final Coder CODER = new StandardCoder(); - private static final Object lockit = new Object(); - - /** - * Get ParticipantIntermediaryParameters. - * - * @return ParticipantIntermediaryParameters - */ - public ParticipantIntermediaryParameters getParticipantIntermediaryParameters() { - try { - return CODER.convert(getIntermediaryParametersMap(PARTICIPANT_GROUP_NAME), - ParticipantIntermediaryParameters.class); - } catch (final CoderException e) { - throw new RuntimeException("cannot create ParticipantSimulatorParameters from map", e); - } - } - - /** - * Get ParticipantParameters. - * - * @return ParticipantParameters - */ - public static DummyParticipantParameters getParticipantParameters() { - try { - return CODER.convert(getParametersMap(PARTICIPANT_GROUP_NAME), - DummyParticipantParameters.class); - } catch (final CoderException e) { - throw new RuntimeException("cannot create ParticipantSimulatorParameters from map", e); - } - } - - /** - * Returns a property map for a Parameters map for test cases. - * - * @param name name of the parameters - * @return a property map suitable for constructing an object - */ - public static Map getParametersMap(final String name) { - final Map map = new TreeMap<>(); - map.put("intermediaryParameters", getIntermediaryParametersMap(name)); - return map; - } - - /** - * Returns a property map for a intermediaryParameters map for test cases. - * - * @param name name of the parameters - * @return a property map suitable for constructing an object - */ - public static Map getIntermediaryParametersMap(final String name) { - final Map map = new TreeMap<>(); - map.put("name", name); - map.put("participantId", getParticipantId()); - map.put("description", DESCRIPTION); - map.put("participantType", getParticipantId()); - map.put("reportingTimeIntervalMs", TIME_INTERVAL); - map.put("clampControlLoopTopics", getTopicParametersMap(false)); - - return map; - } - - /** - * Returns a property map for a TopicParameters map for test cases. - * - * @param isEmpty boolean value to represent that object created should be empty or not - * @return a property map suitable for constructing an object - */ - public static Map getTopicParametersMap(final boolean isEmpty) { - final Map map = new TreeMap<>(); - if (!isEmpty) { - map.put("topicSources", TOPIC_PARAMS); - map.put("topicSinks", TOPIC_PARAMS); - } - return map; - } - - /** - * Returns topic parameters for test cases. - * - * @return topic parameters - */ - public static TopicParameters getTopicParams() { - final var topicParams = new TopicParameters(); - topicParams.setTopic("POLICY-CLRUNTIME-PARTICIPANT"); - topicParams.setTopicCommInfrastructure("dmaap"); - topicParams.setServers(Arrays.asList("localhost")); - return topicParams; - } - - /** - * Returns participantId for test cases. - * - * @return participant Id - */ - public static ToscaConceptIdentifier getParticipantId() { - return new ToscaConceptIdentifier("org.onap.PM_CDS_Blueprint", "1.0.1"); - } - - /** - * Returns a participantMessagePublisher for MessageSender. - * - * @return participant Message Publisher - */ - private ParticipantMessagePublisher getParticipantMessagePublisher() { - synchronized (lockit) { - var participantMessagePublisher = new ParticipantMessagePublisher(); - participantMessagePublisher.active(Collections.singletonList(Mockito.mock(TopicSink.class))); - return participantMessagePublisher; - } - } - - /** - * Returns a mocked ControlLoopHandler for test cases. - * - * @return ControlLoopHandler - */ - public ControlLoopHandler getMockControlLoopHandler() { - return new ControlLoopHandler( - getParticipantParameters(), - getParticipantMessagePublisher()); - } - - /** - * Returns a mocked ParticipantHandler for test cases. - * - * @return participant Handler - */ - public ParticipantHandler getMockParticipantHandler() { - var parameters = getParticipantParameters(); - var controlLoopHandler = getMockControlLoopHandler(); - var publisher = new ParticipantMessagePublisher(); - publisher.active(Collections.singletonList(Mockito.mock(TopicSink.class))); - var participantHandler = new ParticipantHandler(parameters, publisher, controlLoopHandler); - return participantHandler; - } - - /** - * Returns a mocked ParticipantHandler for test cases. - * - * @return participant Handler - * - * @throws CoderException if there is an error with .json file. - */ - public ParticipantHandler getParticipantHandlerControlLoops() throws CoderException { - var controlLoopHandler = Mockito.mock(ControlLoopHandler.class); - Mockito.doReturn(getTestControlLoops()).when(controlLoopHandler).getControlLoops(); - Mockito.doReturn(getTestControlLoopMap()).when(controlLoopHandler).getControlLoopMap(); - var publisher = new ParticipantMessagePublisher(); - publisher.active(Collections.singletonList(Mockito.mock(TopicSink.class))); - var parameters = getParticipantParameters(); - var participantHandler = new ParticipantHandler(parameters, publisher, controlLoopHandler); - participantHandler.sendParticipantRegister(); - participantHandler.handleParticipantStatusReq(null); - participantHandler.sendParticipantDeregister(); - var participantDeregisterAckMsg = new ParticipantDeregisterAck(); - participantDeregisterAckMsg.setResponseTo(UUID.randomUUID()); - participantHandler.handleParticipantDeregisterAck(participantDeregisterAckMsg); - return participantHandler; - } - - /** - * Returns a Map of ToscaConceptIdentifier and ControlLoop for test cases. - * - * @return controlLoopMap - * - * @throws CoderException if there is an error with .json file. - */ - public Map getTestControlLoopMap() throws CoderException { - var controlLoops = getTestControlLoops(); - var controlLoop = controlLoops.getControlLoopList().get(1); - var id = getParticipantId(); - Map controlLoopMap = new LinkedHashMap<>(); - controlLoopMap.put(id, controlLoop); - return controlLoopMap; - } - - /** - * Returns List of ControlLoop for test cases. - * - * @return ControlLoops - * - * @throws CoderException if there is an error with .json file. - */ - public ControlLoops getTestControlLoops() throws CoderException { - return new StandardCoder() - .decode(new File("src/test/resources/providers/TestControlLoops.json"), ControlLoops.class); - } - - /** - * Returns a map for a elementsOnThisParticipant for test cases. - * - * @param uuid UUID and id ToscaConceptIdentifier - * @return a map suitable for elementsOnThisParticipant - */ - public Map setControlLoopElementTest(UUID uuid, ToscaConceptIdentifier id) { - var clElement = new ControlLoopElement(); - clElement.setId(uuid); - clElement.setParticipantId(id); - clElement.setDefinition(id); - clElement.setOrderedState(ControlLoopOrderedState.UNINITIALISED); - - var clElementStatistics = new ClElementStatistics(); - clElementStatistics.setParticipantId(id); - clElementStatistics.setControlLoopState(ControlLoopState.UNINITIALISED); - clElementStatistics.setTimeStamp(Instant.now()); - - clElement.setClElementStatistics(clElementStatistics); - - Map elementsOnThisParticipant = new LinkedHashMap<>(); - elementsOnThisParticipant.put(uuid, clElement); - return elementsOnThisParticipant; - } - - /** - * Returns a ControlLoopHandler with elements on the id,uuid. - * - * @param id ToscaConceptIdentifier and uuid UUID - * @return a ControlLoopHander with elements - */ - public ControlLoopHandler setTestControlLoopHandler(ToscaConceptIdentifier id, UUID uuid) throws CoderException { - var clh = getMockControlLoopHandler(); - - var key = getTestControlLoopMap().keySet().iterator().next(); - var value = getTestControlLoopMap().get(key); - clh.getControlLoopMap().put(key, value); - - var keyElem = setControlLoopElementTest(uuid, id).keySet().iterator().next(); - var valueElem = setControlLoopElementTest(uuid, id).get(keyElem); - clh.getElementsOnThisParticipant().put(keyElem, valueElem); - - return clh; - } - -} diff --git a/participant/participant-intermediary/src/test/java/org/onap/policy/clamp/controlloop/participant/intermediary/main/parameters/TestParticipantIntermediaryParameters.java b/participant/participant-intermediary/src/test/java/org/onap/policy/clamp/controlloop/participant/intermediary/main/parameters/TestParticipantIntermediaryParameters.java deleted file mode 100644 index d554a55b6..000000000 --- a/participant/participant-intermediary/src/test/java/org/onap/policy/clamp/controlloop/participant/intermediary/main/parameters/TestParticipantIntermediaryParameters.java +++ /dev/null @@ -1,67 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * Copyright (C) 2021 Nordix Foundation. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - * SPDX-License-Identifier: Apache-2.0 - * ============LICENSE_END========================================================= - */ - -package org.onap.policy.clamp.controlloop.participant.intermediary.main.parameters; - -import static org.assertj.core.api.Assertions.assertThat; - -import javax.validation.Validation; -import javax.validation.ValidatorFactory; -import org.junit.jupiter.api.Test; -import org.onap.policy.clamp.controlloop.participant.intermediary.parameters.ParticipantIntermediaryParameters; - -/** - * Class to perform unit test of {@link ParticipantParameterGroup}. - */ -class TestParticipantIntermediaryParameters { - private CommonTestData commonTestData = new CommonTestData(); - private ValidatorFactory validatorFactory = Validation.buildDefaultValidatorFactory(); - - @Test - void testParticipantIntermediaryParameterGroup() { - final ParticipantIntermediaryParameters participantParameters = - commonTestData.getParticipantIntermediaryParameters(); - assertThat(validatorFactory.getValidator().validate(participantParameters)).isEmpty(); - } - - @Test - void testParticipantIntermediaryParameterGroup_EmptyParameter() { - final ParticipantIntermediaryParameters participantParameters = - commonTestData.getParticipantIntermediaryParameters(); - participantParameters.setClampControlLoopTopics(null); - assertThat(validatorFactory.getValidator().validate(participantParameters)).isNotEmpty(); - } - - @Test - void testParticipantIntermediaryParameters_NullTopicSinks() { - final ParticipantIntermediaryParameters participantParameters = - commonTestData.getParticipantIntermediaryParameters(); - participantParameters.getClampControlLoopTopics().setTopicSinks(null); - assertThat(validatorFactory.getValidator().validate(participantParameters)).isNotEmpty(); - } - - @Test - void testParticipantIntermediaryParameters_NullTopicSources() { - final ParticipantIntermediaryParameters participantParameters = - commonTestData.getParticipantIntermediaryParameters(); - participantParameters.getClampControlLoopTopics().setTopicSources(null); - assertThat(validatorFactory.getValidator().validate(participantParameters)).isNotEmpty(); - } -} diff --git a/participant/participant-intermediary/src/test/resources/providers/TestAutomationCompositions.json b/participant/participant-intermediary/src/test/resources/providers/TestAutomationCompositions.json new file mode 100644 index 000000000..4e0f08981 --- /dev/null +++ b/participant/participant-intermediary/src/test/resources/providers/TestAutomationCompositions.json @@ -0,0 +1,142 @@ +{ + "automationCompositionList": [ + { + "definition": { + "name": "org.onap.domain.pmsh.PMSHAutomationCompositionDefinition", + "version": "1.0.0" + }, + "state": "UNINITIALISED", + "orderedState": "UNINITIALISED", + "elements": { + "709c62b3-8918-41b9-a747-e21eb79c6c20": { + "id": "709c62b3-8918-41b9-a747-d21eb79c6c20", + "definition": { + "name": "org.onap.domain.pmsh.PMSH_DCAEMicroservice", + "version": "1.2.3" + }, + "participantType": { + "name": "org.onap.dcae.acm.DCAEMicroserviceAutomationCompositionParticipant", + "version": "2.3.4" + }, + "state": "UNINITIALISED", + "orderedState": "UNINITIALISED", + "description": "DCAE Automation Composition Element for the PMSH instance 0 automation composition" + }, + "709c62b3-8918-41b9-a747-e21eb79c6c21": { + "id": "709c62b3-8918-41b9-a747-d21eb79c6c21", + "definition": { + "name": "org.onap.domain.pmsh.PMSH_MonitoringPolicyAutomationCompositionElement", + "version": "1.2.3" + }, + "participantType": { + "name": "org.onap.policy.acm.PolicyAutomationCompositionParticipant", + "version": "2.3.1" + }, + "state": "UNINITIALISED", + "orderedState": "UNINITIALISED", + "description": "Monitoring Policy Automation Composition Element for the PMSH instance 0 automation composition" + }, + "709c62b3-8918-41b9-a747-e21eb79c6c22": { + "id": "709c62b3-8918-41b9-a747-d21eb79c6c22", + "definition": { + "name": "org.onap.domain.pmsh.PMSH_OperationalPolicyAutomationCompositionElement", + "version": "1.2.3" + }, + "participantType": { + "name": "org.onap.policy.acm.PolicyAutomationCompositionParticipant", + "version": "2.3.1" + }, + "state": "UNINITIALISED", + "orderedState": "UNINITIALISED", + "description": "Operational Policy Automation Composition Element for the PMSH instance 0 automation composition" + }, + "709c62b3-8918-41b9-a747-e21eb79c6c23": { + "id": "709c62b3-8918-41b9-a747-d21eb79c6c23", + "definition": { + "name": "org.onap.domain.pmsh.PMSH_CDS_AutomationCompositionElement", + "version": "1.2.3" + }, + "participantType": { + "name": "org.onap.ccsdk.cds.acm.CdsAutomationCompositionParticipant", + "version": "2.2.1" + }, + "state": "UNINITIALISED", + "orderedState": "UNINITIALISED", + "description": "CDS Automation Composition Element for the PMSH instance 0 automation composition" + } + }, + "name": "PMSHInstance0", + "version": "1.0.1", + "description": "PMSH automation composition instance 0" + }, + { + "definition": { + "name": "org.onap.domain.pmsh.PMSHAutomationCompositionDefinition", + "version": "1.0.0" + }, + "state": "UNINITIALISED", + "orderedState": "UNINITIALISED", + "elements": { + "709c62b3-8918-41b9-a747-e21eb79c6c24": { + "id": "709c62b3-8918-41b9-a747-e21eb79c6c24", + "definition": { + "name": "org.onap.domain.pmsh.PMSH_DCAEMicroservice", + "version": "1.2.3" + }, + "participantType": { + "name": "org.onap.dcae.acm.DCAEMicroserviceAutomationCompositionParticipant", + "version": "2.3.4" + }, + "state": "UNINITIALISED", + "orderedState": "UNINITIALISED", + "description": "DCAE Automation Composition Element for the PMSH instance 1 automation composition" + }, + "709c62b3-8918-41b9-a747-e21eb79c6c25": { + "id": "709c62b3-8918-41b9-a747-e21eb79c6c25", + "definition": { + "name": "org.onap.domain.pmsh.PMSH_MonitoringPolicyAutomationCompositionElement", + "version": "1.2.3" + }, + "participantType": { + "name": "org.onap.policy.acm.PolicyAutomationCompositionParticipant", + "version": "2.3.1" + }, + "state": "UNINITIALISED", + "orderedState": "UNINITIALISED", + "description": "Monitoring Policy Automation Composition Element for the PMSH instance 1 automation composition" + }, + "709c62b3-8918-41b9-a747-e21eb79c6c26": { + "id": "709c62b3-8918-41b9-a747-e21eb79c6c26", + "definition": { + "name": "org.onap.domain.pmsh.PMSH_OperationalPolicyAutomationCompositionElement", + "version": "1.2.3" + }, + "participantType": { + "name": "org.onap.policy.acm.PolicyAutomationCompositionParticipant", + "version": "2.3.1" + }, + "state": "UNINITIALISED", + "orderedState": "UNINITIALISED", + "description": "Operational Policy Automation Composition Element for the PMSH instance 1 automation composition" + }, + "709c62b3-8918-41b9-a747-e21eb79c6c27": { + "id": "709c62b3-8918-41b9-a747-e21eb79c6c27", + "definition": { + "name": "org.onap.domain.pmsh.PMSH_CDS_AutomationCompositionElement", + "version": "1.2.3" + }, + "participantType": { + "name": "org.onap.ccsdk.cds.acm.CdsAutomationCompositionParticipant", + "version": "2.2.1" + }, + "state": "UNINITIALISED", + "orderedState": "UNINITIALISED", + "description": "CDS Automation Composition Element for the PMSH instance 1 automation composition" + } + }, + "name": "PMSHInstance1", + "version": "1.0.1", + "description": "PMSH automation composition instance 1" + } + ] +} diff --git a/participant/participant-intermediary/src/test/resources/providers/TestControlLoops.json b/participant/participant-intermediary/src/test/resources/providers/TestControlLoops.json deleted file mode 100644 index fedda9600..000000000 --- a/participant/participant-intermediary/src/test/resources/providers/TestControlLoops.json +++ /dev/null @@ -1,142 +0,0 @@ -{ - "controlLoopList": [ - { - "definition": { - "name": "org.onap.domain.pmsh.PMSHControlLoopDefinition", - "version": "1.0.0" - }, - "state": "UNINITIALISED", - "orderedState": "UNINITIALISED", - "elements": { - "709c62b3-8918-41b9-a747-e21eb79c6c20": { - "id": "709c62b3-8918-41b9-a747-d21eb79c6c20", - "definition": { - "name": "org.onap.domain.pmsh.PMSH_DCAEMicroservice", - "version": "1.2.3" - }, - "participantType": { - "name": "org.onap.dcae.controlloop.DCAEMicroserviceControlLoopParticipant", - "version": "2.3.4" - }, - "state": "UNINITIALISED", - "orderedState": "UNINITIALISED", - "description": "DCAE Control Loop Element for the PMSH instance 0 control loop" - }, - "709c62b3-8918-41b9-a747-e21eb79c6c21": { - "id": "709c62b3-8918-41b9-a747-d21eb79c6c21", - "definition": { - "name": "org.onap.domain.pmsh.PMSH_MonitoringPolicyControlLoopElement", - "version": "1.2.3" - }, - "participantType": { - "name": "org.onap.policy.controlloop.PolicyControlLoopParticipant", - "version": "2.3.1" - }, - "state": "UNINITIALISED", - "orderedState": "UNINITIALISED", - "description": "Monitoring Policy Control Loop Element for the PMSH instance 0 control loop" - }, - "709c62b3-8918-41b9-a747-e21eb79c6c22": { - "id": "709c62b3-8918-41b9-a747-d21eb79c6c22", - "definition": { - "name": "org.onap.domain.pmsh.PMSH_OperationalPolicyControlLoopElement", - "version": "1.2.3" - }, - "participantType": { - "name": "org.onap.policy.controlloop.PolicyControlLoopParticipant", - "version": "2.3.1" - }, - "state": "UNINITIALISED", - "orderedState": "UNINITIALISED", - "description": "Operational Policy Control Loop Element for the PMSH instance 0 control loop" - }, - "709c62b3-8918-41b9-a747-e21eb79c6c23": { - "id": "709c62b3-8918-41b9-a747-d21eb79c6c23", - "definition": { - "name": "org.onap.domain.pmsh.PMSH_CDS_ControlLoopElement", - "version": "1.2.3" - }, - "participantType": { - "name": "org.onap.ccsdk.cds.controlloop.CdsControlLoopParticipant", - "version": "2.2.1" - }, - "state": "UNINITIALISED", - "orderedState": "UNINITIALISED", - "description": "CDS Control Loop Element for the PMSH instance 0 control loop" - } - }, - "name": "PMSHInstance0", - "version": "1.0.1", - "description": "PMSH control loop instance 0" - }, - { - "definition": { - "name": "org.onap.domain.pmsh.PMSHControlLoopDefinition", - "version": "1.0.0" - }, - "state": "UNINITIALISED", - "orderedState": "UNINITIALISED", - "elements": { - "709c62b3-8918-41b9-a747-e21eb79c6c24": { - "id": "709c62b3-8918-41b9-a747-e21eb79c6c24", - "definition": { - "name": "org.onap.domain.pmsh.PMSH_DCAEMicroservice", - "version": "1.2.3" - }, - "participantType": { - "name": "org.onap.dcae.controlloop.DCAEMicroserviceControlLoopParticipant", - "version": "2.3.4" - }, - "state": "UNINITIALISED", - "orderedState": "UNINITIALISED", - "description": "DCAE Control Loop Element for the PMSH instance 1 control loop" - }, - "709c62b3-8918-41b9-a747-e21eb79c6c25": { - "id": "709c62b3-8918-41b9-a747-e21eb79c6c25", - "definition": { - "name": "org.onap.domain.pmsh.PMSH_MonitoringPolicyControlLoopElement", - "version": "1.2.3" - }, - "participantType": { - "name": "org.onap.policy.controlloop.PolicyControlLoopParticipant", - "version": "2.3.1" - }, - "state": "UNINITIALISED", - "orderedState": "UNINITIALISED", - "description": "Monitoring Policy Control Loop Element for the PMSH instance 1 control loop" - }, - "709c62b3-8918-41b9-a747-e21eb79c6c26": { - "id": "709c62b3-8918-41b9-a747-e21eb79c6c26", - "definition": { - "name": "org.onap.domain.pmsh.PMSH_OperationalPolicyControlLoopElement", - "version": "1.2.3" - }, - "participantType": { - "name": "org.onap.policy.controlloop.PolicyControlLoopParticipant", - "version": "2.3.1" - }, - "state": "UNINITIALISED", - "orderedState": "UNINITIALISED", - "description": "Operational Policy Control Loop Element for the PMSH instance 1 control loop" - }, - "709c62b3-8918-41b9-a747-e21eb79c6c27": { - "id": "709c62b3-8918-41b9-a747-e21eb79c6c27", - "definition": { - "name": "org.onap.domain.pmsh.PMSH_CDS_ControlLoopElement", - "version": "1.2.3" - }, - "participantType": { - "name": "org.onap.ccsdk.cds.controlloop.CdsControlLoopParticipant", - "version": "2.2.1" - }, - "state": "UNINITIALISED", - "orderedState": "UNINITIALISED", - "description": "CDS Control Loop Element for the PMSH instance 1 control loop" - } - }, - "name": "PMSHInstance1", - "version": "1.0.1", - "description": "PMSH control loop instance 1" - } - ] -} diff --git a/pom.xml b/pom.xml index 713cf5ecf..d6df94623 100644 --- a/pom.xml +++ b/pom.xml @@ -41,7 +41,8 @@ - policy-clamp-common: Common code for all Policy/CLAMP modules - policy-clamp-models: POJOs and other model code for REST and DMaaP messages and for persistence - policy-clamp-runtime: The runtime server for CLAMP - - policy-clamp-participant: Modules for CLAMP control loop participants + - policy-clamp-runtime-acm: The runtime server for Automation Composition Management + - policy-clamp-participant: Modules for CLAMP automation composition participants o policy-clamp-participant-intermediary: A common JAR that handles participant state and DMaaP handling o policy-clamp-participant-impl-cds: A standard participant for interworking with CDS o policy-clamp-participant-impl-kubernetes: A standard participant for Kubernetes microservices @@ -60,7 +61,7 @@ models packages runtime - runtime-controlloop + runtime-acm participant diff --git a/runtime-acm/pom.xml b/runtime-acm/pom.xml new file mode 100644 index 000000000..7712d8235 --- /dev/null +++ b/runtime-acm/pom.xml @@ -0,0 +1,124 @@ + + + + + 4.0.0 + + + org.onap.policy.clamp + policy-clamp + 6.2.1-SNAPSHOT + + + policy-clamp-runtime-acm + ${project.artifactId} + + + + org.onap.policy.clamp + policy-clamp-common + ${project.version} + + + org.onap.policy.clamp + policy-clamp-models + ${project.version} + + + com.fasterxml.jackson.module + jackson-module-jsonSchema + ${version.jackson} + + + javax.validation + validation-api + + + + + org.springframework.boot + spring-boot-starter-web + + + org.springframework.boot + spring-boot-starter-json + + + + + org.springframework.boot + spring-boot-starter-aop + ${version.springboot} + + + org.springframework.boot + spring-boot-starter-security + + + org.springframework.boot + spring-boot-starter-validation + + + io.springfox + springfox-boot-starter + ${version.springfox} + + + org.springframework.boot + spring-boot-starter-actuator + ${version.springboot} + + + io.micrometer + micrometer-registry-prometheus + ${version.io.micrometer} + + + io.springfox + springfox-swagger-ui + runtime + + + org.springframework.boot + spring-boot-starter-test + test + + + + + + + org.springframework.boot + spring-boot-maven-plugin + + + + repackage + + package + + + + + + diff --git a/runtime-acm/src/main/java/org/onap/policy/clamp/acm/runtime/Application.java b/runtime-acm/src/main/java/org/onap/policy/clamp/acm/runtime/Application.java new file mode 100644 index 000000000..d9298b15e --- /dev/null +++ b/runtime-acm/src/main/java/org/onap/policy/clamp/acm/runtime/Application.java @@ -0,0 +1,53 @@ +/*- + * ============LICENSE_START======================================================= + * Copyright (C) 2021 Nordix Foundation. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * SPDX-License-Identifier: Apache-2.0 + * ============LICENSE_END========================================================= + */ + +package org.onap.policy.clamp.acm.runtime; + +import org.springframework.boot.SpringApplication; +import org.springframework.boot.autoconfigure.SpringBootApplication; +import org.springframework.boot.autoconfigure.domain.EntityScan; +import org.springframework.boot.context.properties.ConfigurationPropertiesScan; +import org.springframework.context.annotation.ComponentScan; +import org.springframework.data.jpa.repository.config.EnableJpaRepositories; +import org.springframework.scheduling.annotation.EnableScheduling; + +// @formatter:off +@EnableScheduling +@SpringBootApplication +@EnableJpaRepositories({ + "org.onap.policy.clamp.models.acm.persistence.repository" +}) +@ComponentScan({ + "org.onap.policy.clamp.models.acm.persistence.provider", + "org.onap.policy.clamp.acm.runtime", + "org.onap.policy.clamp.common.acm.rest" +}) +@ConfigurationPropertiesScan("org.onap.policy.clamp.acm.runtime.main.parameters") +@EntityScan({ + "org.onap.policy.models.tosca.simple.concepts", + "org.onap.policy.clamp.models.acm.persistence.concepts" +}) +//@formatter:on +public class Application { + + public static void main(String[] args) { + SpringApplication.run(Application.class, args); + } +} diff --git a/runtime-acm/src/main/java/org/onap/policy/clamp/acm/runtime/commissioning/CommissioningProvider.java b/runtime-acm/src/main/java/org/onap/policy/clamp/acm/runtime/commissioning/CommissioningProvider.java new file mode 100644 index 000000000..dfb9d151b --- /dev/null +++ b/runtime-acm/src/main/java/org/onap/policy/clamp/acm/runtime/commissioning/CommissioningProvider.java @@ -0,0 +1,383 @@ +/*- + * ============LICENSE_START======================================================= + * Copyright (C) 2021 Nordix Foundation. + * Modifications Copyright (C) 2021 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * SPDX-License-Identifier: Apache-2.0 + * ============LICENSE_END========================================================= + */ + +package org.onap.policy.clamp.acm.runtime.commissioning; + +import com.fasterxml.jackson.core.JsonProcessingException; +import com.fasterxml.jackson.databind.ObjectMapper; +import com.fasterxml.jackson.databind.PropertyNamingStrategies; +import com.fasterxml.jackson.module.jsonSchema.factories.SchemaFactoryWrapper; +import java.util.ArrayList; +import java.util.Collections; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.stream.Collectors; +import javax.ws.rs.core.Response.Status; +import org.apache.commons.collections4.CollectionUtils; +import org.apache.commons.collections4.MapUtils; +import org.onap.policy.clamp.acm.runtime.supervision.SupervisionHandler; +import org.onap.policy.clamp.models.acm.concepts.Participant; +import org.onap.policy.clamp.models.acm.messages.rest.commissioning.CommissioningResponse; +import org.onap.policy.clamp.models.acm.persistence.provider.AutomationCompositionProvider; +import org.onap.policy.clamp.models.acm.persistence.provider.ParticipantProvider; +import org.onap.policy.clamp.models.acm.persistence.provider.ServiceTemplateProvider; +import org.onap.policy.models.base.PfModelException; +import org.onap.policy.models.tosca.authorative.concepts.ToscaCapabilityType; +import org.onap.policy.models.tosca.authorative.concepts.ToscaConceptIdentifier; +import org.onap.policy.models.tosca.authorative.concepts.ToscaDataType; +import org.onap.policy.models.tosca.authorative.concepts.ToscaNodeTemplate; +import org.onap.policy.models.tosca.authorative.concepts.ToscaNodeType; +import org.onap.policy.models.tosca.authorative.concepts.ToscaPolicyType; +import org.onap.policy.models.tosca.authorative.concepts.ToscaRelationshipType; +import org.onap.policy.models.tosca.authorative.concepts.ToscaServiceTemplate; +import org.onap.policy.models.tosca.authorative.concepts.ToscaServiceTemplates; +import org.onap.policy.models.tosca.authorative.concepts.ToscaTopologyTemplate; +import org.onap.policy.models.tosca.authorative.concepts.ToscaTypedEntityFilter; +import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; + +/** + * This class provides the create, read and delete actions on Commissioning of automation composition concepts in the + * database to the callers. + */ +@Service +@Transactional +public class CommissioningProvider { + public static final String AUTOMATION_COMPOSITION_NODE_TYPE = "org.onap.policy.clamp.acm.AutomationComposition"; + private static final String INSTANCE_TEXT = "_Instance"; + + private final ServiceTemplateProvider serviceTemplateProvider; + private final AutomationCompositionProvider acProvider; + private final ObjectMapper mapper = new ObjectMapper(); + private final ParticipantProvider participantProvider; + private final SupervisionHandler supervisionHandler; + + /** + * Create a commissioning provider. + * + * @param serviceTemplateProvider the ServiceTemplate Provider + * @param acProvider the AutomationComposition Provider + * @param supervisionHandler the Supervision Handler + * @param participantProvider the Participant Provider + */ + public CommissioningProvider(ServiceTemplateProvider serviceTemplateProvider, + AutomationCompositionProvider acProvider, SupervisionHandler supervisionHandler, + ParticipantProvider participantProvider) { + this.serviceTemplateProvider = serviceTemplateProvider; + this.acProvider = acProvider; + this.supervisionHandler = supervisionHandler; + this.participantProvider = participantProvider; + mapper.setPropertyNamingStrategy(PropertyNamingStrategies.SNAKE_CASE); + } + + /** + * Create automation compositions from a service template. + * + * @param serviceTemplate the service template + * @return the result of the commissioning operation + * @throws PfModelException on creation errors + */ + public CommissioningResponse createAutomationCompositionDefinitions(ToscaServiceTemplate serviceTemplate) + throws PfModelException { + + if (verifyIfInstancePropertiesExists()) { + throw new PfModelException(Status.BAD_REQUEST, + "Delete instances, to commission automation composition definitions"); + } + serviceTemplate = serviceTemplateProvider.createServiceTemplate(serviceTemplate); + List participantList = participantProvider.getParticipants(); + if (!participantList.isEmpty()) { + supervisionHandler.handleSendCommissionMessage(serviceTemplate.getName(), serviceTemplate.getVersion()); + } + var response = new CommissioningResponse(); + // @formatter:off + response.setAffectedAutomationCompositionDefinitions( + serviceTemplate.getToscaTopologyTemplate().getNodeTemplates() + .values() + .stream() + .map(template -> template.getKey().asIdentifier()) + .collect(Collectors.toList())); + // @formatter:on + + return response; + } + + /** + * Delete the automation composition definition with the given name and version. + * + * @param name the name of the automation composition definition to delete + * @param version the version of the automation composition to delete + * @return the result of the deletion + * @throws PfModelException on deletion errors + */ + public CommissioningResponse deleteAutomationCompositionDefinition(String name, String version) + throws PfModelException { + + if (verifyIfInstancePropertiesExists()) { + throw new PfModelException(Status.BAD_REQUEST, + "Delete instances, to commission automation composition definitions"); + } + List participantList = participantProvider.getParticipants(); + if (!participantList.isEmpty()) { + supervisionHandler.handleSendDeCommissionMessage(); + } + serviceTemplateProvider.deleteServiceTemplate(name, version); + var response = new CommissioningResponse(); + response.setAffectedAutomationCompositionDefinitions(List.of(new ToscaConceptIdentifier(name, version))); + + return response; + } + + /** + * Get automation composition node templates. + * + * @param acName the name of the automation composition, null for all + * @param acVersion the version of the automation composition, null for all + * @return list of automation composition node templates + * @throws PfModelException on errors getting automation composition definitions + */ + @Transactional(readOnly = true) + public List getAutomationCompositionDefinitions(String acName, String acVersion) + throws PfModelException { + + // @formatter:off + ToscaTypedEntityFilter nodeTemplateFilter = ToscaTypedEntityFilter + .builder() + .name(acName) + .version(acVersion) + .type(AUTOMATION_COMPOSITION_NODE_TYPE) + .build(); + // @formatter:on + + return acProvider.getFilteredNodeTemplates(nodeTemplateFilter); + } + + /** + * Get the automation composition elements from a automation composition node template. + * + * @param automationCompositionNodeTemplate the automation composition node template + * @return a list of the automation composition element node templates in a automation composition node template + * @throws PfModelException on errors get automation composition element node templates + */ + @Transactional(readOnly = true) + public List getAutomationCompositionElementDefinitions( + ToscaNodeTemplate automationCompositionNodeTemplate) throws PfModelException { + if (!AUTOMATION_COMPOSITION_NODE_TYPE.equals(automationCompositionNodeTemplate.getType())) { + return Collections.emptyList(); + } + + if (MapUtils.isEmpty(automationCompositionNodeTemplate.getProperties())) { + return Collections.emptyList(); + } + + @SuppressWarnings("unchecked") + List> automationCompositionElements = + (List>) automationCompositionNodeTemplate.getProperties().get("elements"); + + if (CollectionUtils.isEmpty(automationCompositionElements)) { + return Collections.emptyList(); + } + + List automationCompositionElementList = new ArrayList<>(); + // @formatter:off + automationCompositionElementList.addAll( + automationCompositionElements + .stream() + .map(elementMap -> acProvider.getNodeTemplates(elementMap.get("name"), + elementMap.get("version"))) + .flatMap(List::stream) + .collect(Collectors.toList()) + ); + // @formatter:on + + return automationCompositionElementList; + } + + /** + * Get node templates with common properties added. + * + * @param common boolean indicating common or instance properties to be used + * @param name the name of the definition to use, null for all definitions + * @param version the version of the definition to use, null for all definitions + * @return the nodes templates with common or instance properties + * @throws PfModelException on errors getting common or instance properties from node_templates + */ + @Transactional(readOnly = true) + public Map getNodeTemplatesWithCommonOrInstanceProperties(boolean common, String name, + String version) throws PfModelException { + + if (common && verifyIfInstancePropertiesExists()) { + throw new PfModelException(Status.BAD_REQUEST, + "Cannot create or edit common properties, delete all the instantiations first"); + } + + var serviceTemplateList = serviceTemplateProvider.getServiceTemplateList(name, version); + var commonOrInstanceNodeTypeProps = + serviceTemplateProvider.getCommonOrInstancePropertiesFromNodeTypes(common, serviceTemplateList.get(0)); + + var serviceTemplates = new ToscaServiceTemplates(); + serviceTemplates.setServiceTemplates(filterToscaNodeTemplateInstance(serviceTemplateList)); + + return serviceTemplateProvider.getDerivedCommonOrInstanceNodeTemplates( + serviceTemplates.getServiceTemplates().get(0).getToscaTopologyTemplate().getNodeTemplates(), + commonOrInstanceNodeTypeProps); + } + + /** + * Get the requested automation composition definitions. + * + * @param name the name of the definition to get, null for all definitions + * @param version the version of the definition to get, null for all definitions + * @return the automation composition definitions + * @throws PfModelException on errors getting automation composition definitions + */ + @Transactional(readOnly = true) + public ToscaServiceTemplate getToscaServiceTemplate(String name, String version) throws PfModelException { + return serviceTemplateProvider.getToscaServiceTemplate(name, version); + } + + /** + * Get All the requested automation composition definitions. + * + * @return the automation composition definitions + * @throws PfModelException on errors getting automation composition definitions + */ + @Transactional(readOnly = true) + public List getAllToscaServiceTemplate() throws PfModelException { + return serviceTemplateProvider.getAllServiceTemplates(); + } + + /** + * Get the tosca service template with only required sections. + * + * @param name the name of the template to get, null for all definitions + * @param version the version of the template to get, null for all definitions + * @return the tosca service template + * @throws PfModelException on errors getting tosca service template + */ + @Transactional(readOnly = true) + public String getToscaServiceTemplateReduced(String name, String version) throws PfModelException { + var serviceTemplateList = serviceTemplateProvider.getServiceTemplateList(name, version); + + List filteredServiceTemplateList = filterToscaNodeTemplateInstance(serviceTemplateList); + + if (filteredServiceTemplateList.isEmpty()) { + throw new PfModelException(Status.BAD_REQUEST, "Invalid Service Template"); + } + + ToscaServiceTemplate fullTemplate = filteredServiceTemplateList.get(0); + + var template = new HashMap(); + template.put("tosca_definitions_version", fullTemplate.getToscaDefinitionsVersion()); + template.put("data_types", fullTemplate.getDataTypes()); + template.put("policy_types", fullTemplate.getPolicyTypes()); + template.put("node_types", fullTemplate.getNodeTypes()); + template.put("topology_template", fullTemplate.getToscaTopologyTemplate()); + + try { + return mapper.writerWithDefaultPrettyPrinter().writeValueAsString(template); + + } catch (JsonProcessingException e) { + throw new PfModelException(Status.BAD_REQUEST, "Converion to Json Schema failed", e); + } + } + + /** + * Get the requested json schema. + * + * @param section section of the tosca service template to get schema for + * @return the specified tosca service template or section Json Schema + * @throws PfModelException on errors with retrieving the classes + */ + @Transactional(readOnly = true) + public String getToscaServiceTemplateSchema(String section) throws PfModelException { + var visitor = new SchemaFactoryWrapper(); + + try { + switch (section) { + case "data_types": + mapper.acceptJsonFormatVisitor(mapper.constructType(ToscaDataType.class), visitor); + break; + case "capability_types": + mapper.acceptJsonFormatVisitor(mapper.constructType(ToscaCapabilityType.class), visitor); + break; + case "node_types": + mapper.acceptJsonFormatVisitor(mapper.constructType(ToscaNodeType.class), visitor); + break; + case "relationship_types": + mapper.acceptJsonFormatVisitor(mapper.constructType(ToscaRelationshipType.class), visitor); + break; + case "policy_types": + mapper.acceptJsonFormatVisitor(mapper.constructType(ToscaPolicyType.class), visitor); + break; + case "topology_template": + mapper.acceptJsonFormatVisitor(mapper.constructType(ToscaTopologyTemplate.class), visitor); + break; + case "node_templates": + mapper.acceptJsonFormatVisitor( + mapper.getTypeFactory().constructCollectionType(List.class, ToscaNodeTemplate.class), visitor); + break; + default: + mapper.acceptJsonFormatVisitor(mapper.constructType(ToscaServiceTemplate.class), visitor); + } + + var jsonSchema = visitor.finalSchema(); + return mapper.writerWithDefaultPrettyPrinter().writeValueAsString(jsonSchema); + } catch (JsonProcessingException e) { + throw new PfModelException(Status.BAD_REQUEST, "Converion to Json Schema failed", e); + } + } + + private List filterToscaNodeTemplateInstance(List serviceTemplates) { + + List toscaServiceTemplates = new ArrayList<>(); + + serviceTemplates.stream().forEach(serviceTemplate -> { + + Map toscaNodeTemplates = new HashMap<>(); + + serviceTemplate.getToscaTopologyTemplate().getNodeTemplates().forEach((key, nodeTemplate) -> { + if (!nodeTemplate.getName().contains(INSTANCE_TEXT)) { + toscaNodeTemplates.put(key, nodeTemplate); + } + }); + + serviceTemplate.getToscaTopologyTemplate().getNodeTemplates().clear(); + serviceTemplate.getToscaTopologyTemplate().setNodeTemplates(toscaNodeTemplates); + + toscaServiceTemplates.add(serviceTemplate); + }); + + return toscaServiceTemplates; + } + + /** + * Validates to see if there is any instance properties saved. + * + * @return true if exists instance properties + */ + private boolean verifyIfInstancePropertiesExists() { + return acProvider.getAllNodeTemplates().stream() + .anyMatch(nodeTemplate -> nodeTemplate.getKey().getName().contains(INSTANCE_TEXT)); + + } +} diff --git a/runtime-acm/src/main/java/org/onap/policy/clamp/acm/runtime/config/AafConfiguration.java b/runtime-acm/src/main/java/org/onap/policy/clamp/acm/runtime/config/AafConfiguration.java new file mode 100644 index 000000000..b1f408048 --- /dev/null +++ b/runtime-acm/src/main/java/org/onap/policy/clamp/acm/runtime/config/AafConfiguration.java @@ -0,0 +1,43 @@ +/*- + * ============LICENSE_START======================================================= + * Copyright (C) 2021 Nordix Foundation. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END============================================ + * =================================================================== + * + */ + +package org.onap.policy.clamp.acm.runtime.config; + +import javax.servlet.Filter; +import org.onap.policy.clamp.acm.runtime.main.web.AutomationConfiguraitonAafFilter; +import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.Configuration; +import org.springframework.context.annotation.Profile; + +@Configuration +@Profile("clamp-aaf-authentication") +public class AafConfiguration { + + /** + * Method to return AAF filter. + * + * @return Filter + */ + @Bean + public Filter aafFilter() { + return new AutomationConfiguraitonAafFilter(); + } + +} diff --git a/runtime-acm/src/main/java/org/onap/policy/clamp/acm/runtime/config/ConverterConfiguration.java b/runtime-acm/src/main/java/org/onap/policy/clamp/acm/runtime/config/ConverterConfiguration.java new file mode 100644 index 000000000..f51497266 --- /dev/null +++ b/runtime-acm/src/main/java/org/onap/policy/clamp/acm/runtime/config/ConverterConfiguration.java @@ -0,0 +1,44 @@ +/*- + * ============LICENSE_START======================================================= + * Copyright (C) 2021 Nordix Foundation. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * SPDX-License-Identifier: Apache-2.0 + * ============LICENSE_END========================================================= + */ + +package org.onap.policy.clamp.acm.runtime.config; + +import java.util.Arrays; +import java.util.List; +import org.onap.policy.clamp.common.acm.rest.CoderHttpMesageConverter; +import org.springframework.context.annotation.Configuration; +import org.springframework.http.MediaType; +import org.springframework.http.converter.HttpMessageConverter; +import org.springframework.http.converter.StringHttpMessageConverter; +import org.springframework.web.servlet.config.annotation.WebMvcConfigurer; + +@Configuration +public class ConverterConfiguration implements WebMvcConfigurer { + + @Override + public void extendMessageConverters(List> converters) { + converters.add(new CoderHttpMesageConverter<>("yaml")); + converters.add(new CoderHttpMesageConverter<>("json")); + + StringHttpMessageConverter converter = new StringHttpMessageConverter(); + converter.setSupportedMediaTypes(Arrays.asList(MediaType.TEXT_PLAIN)); + converters.add(converter); + } +} diff --git a/runtime-acm/src/main/java/org/onap/policy/clamp/acm/runtime/config/FilterConfig.java b/runtime-acm/src/main/java/org/onap/policy/clamp/acm/runtime/config/FilterConfig.java new file mode 100644 index 000000000..4dcd94c25 --- /dev/null +++ b/runtime-acm/src/main/java/org/onap/policy/clamp/acm/runtime/config/FilterConfig.java @@ -0,0 +1,45 @@ +/*- + * ============LICENSE_START======================================================= + * Copyright (C) 2021 Nordix Foundation. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * SPDX-License-Identifier: Apache-2.0 + * ============LICENSE_END========================================================= + */ + +package org.onap.policy.clamp.acm.runtime.config; + +import org.onap.policy.clamp.common.acm.rest.RequestResponseLoggingFilter; +import org.springframework.boot.web.servlet.FilterRegistrationBean; +import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.Configuration; + +@Configuration +public class FilterConfig { + + /** + * Logging Filter configuration. + * + * @return FilterRegistrationBean + */ + @Bean + public FilterRegistrationBean loggingFilter() { + FilterRegistrationBean registrationBean = new FilterRegistrationBean<>(); + + registrationBean.setFilter(new RequestResponseLoggingFilter()); + registrationBean.addUrlPatterns("/onap/policy/clamp/acm/v2/*"); + + return registrationBean; + } +} diff --git a/runtime-acm/src/main/java/org/onap/policy/clamp/acm/runtime/config/SecurityConfig.java b/runtime-acm/src/main/java/org/onap/policy/clamp/acm/runtime/config/SecurityConfig.java new file mode 100644 index 000000000..ade7c56b3 --- /dev/null +++ b/runtime-acm/src/main/java/org/onap/policy/clamp/acm/runtime/config/SecurityConfig.java @@ -0,0 +1,47 @@ +/*- + * ============LICENSE_START======================================================= + * Copyright (C) 2021 Nordix Foundation. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * SPDX-License-Identifier: Apache-2.0 + * ============LICENSE_END========================================================= + */ + +package org.onap.policy.clamp.acm.runtime.config; + +import org.springframework.beans.factory.annotation.Value; +import org.springframework.context.annotation.Configuration; +import org.springframework.security.config.annotation.web.builders.HttpSecurity; +import org.springframework.security.config.annotation.web.configuration.WebSecurityConfigurerAdapter; + +@Configuration +public class SecurityConfig extends WebSecurityConfigurerAdapter { + + @Value("${security.enable-csrf:true}") + private boolean csrfEnabled = true; + + @Override + protected void configure(HttpSecurity http) throws Exception { + // @formatter:off + http.authorizeRequests() + .antMatchers().authenticated() + .anyRequest().authenticated() + .and().httpBasic(); + // @formatter:on + + if (!csrfEnabled) { + http.csrf().disable(); + } + } +} diff --git a/runtime-acm/src/main/java/org/onap/policy/clamp/acm/runtime/config/SpringFoxConfig.java b/runtime-acm/src/main/java/org/onap/policy/clamp/acm/runtime/config/SpringFoxConfig.java new file mode 100644 index 000000000..94c8bce06 --- /dev/null +++ b/runtime-acm/src/main/java/org/onap/policy/clamp/acm/runtime/config/SpringFoxConfig.java @@ -0,0 +1,45 @@ +/*- + * ============LICENSE_START======================================================= + * Copyright (C) 2021 Nordix Foundation. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * SPDX-License-Identifier: Apache-2.0 + * ============LICENSE_END========================================================= + */ + +package org.onap.policy.clamp.acm.runtime.config; + +import org.onap.policy.clamp.acm.runtime.main.rest.MonitoringQueryController; +import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.Configuration; +import springfox.documentation.builders.PathSelectors; +import springfox.documentation.builders.RequestHandlerSelectors; +import springfox.documentation.spi.DocumentationType; +import springfox.documentation.spring.web.plugins.Docket; + +@Configuration +public class SpringFoxConfig { + + /** + * Docket Spring Fox Config. + * + * @return Docket + */ + @Bean + public Docket api() { + return new Docket(DocumentationType.SWAGGER_2).select() + .apis(RequestHandlerSelectors.basePackage(MonitoringQueryController.class.getPackageName())) + .paths(PathSelectors.any()).build(); + } +} diff --git a/runtime-acm/src/main/java/org/onap/policy/clamp/acm/runtime/config/messaging/Listener.java b/runtime-acm/src/main/java/org/onap/policy/clamp/acm/runtime/config/messaging/Listener.java new file mode 100644 index 000000000..23240ab8a --- /dev/null +++ b/runtime-acm/src/main/java/org/onap/policy/clamp/acm/runtime/config/messaging/Listener.java @@ -0,0 +1,41 @@ +/*- + * ============LICENSE_START======================================================= + * Copyright (C) 2021 Nordix Foundation. + * Modifications Copyright (C) 2021 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * SPDX-License-Identifier: Apache-2.0 + * ============LICENSE_END========================================================= + */ + +package org.onap.policy.clamp.acm.runtime.config.messaging; + +import org.onap.policy.common.endpoints.listeners.ScoListener; + +public interface Listener { + + /** + * Get the type of message of interest to the listener. + * + * @return type of message of interest to the listener + */ + String getType(); + + /** + * Get listener to register. + * + * @return listener to register + */ + ScoListener getScoListener(); +} diff --git a/runtime-acm/src/main/java/org/onap/policy/clamp/acm/runtime/config/messaging/MessageDispatcherActivator.java b/runtime-acm/src/main/java/org/onap/policy/clamp/acm/runtime/config/messaging/MessageDispatcherActivator.java new file mode 100644 index 000000000..0d9de205e --- /dev/null +++ b/runtime-acm/src/main/java/org/onap/policy/clamp/acm/runtime/config/messaging/MessageDispatcherActivator.java @@ -0,0 +1,137 @@ +/*- + * ============LICENSE_START======================================================= + * Copyright (C) 2021 Nordix Foundation. + * Modifications Copyright (C) 2021 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * SPDX-License-Identifier: Apache-2.0 + * ============LICENSE_END========================================================= + */ + +package org.onap.policy.clamp.acm.runtime.config.messaging; + +import java.io.Closeable; +import java.io.IOException; +import java.util.List; +import lombok.Getter; +import org.onap.policy.clamp.acm.runtime.main.parameters.AcRuntimeParameterGroup; +import org.onap.policy.clamp.common.acm.exception.AutomationCompositionRuntimeException; +import org.onap.policy.common.endpoints.event.comm.TopicEndpointManager; +import org.onap.policy.common.endpoints.event.comm.TopicSink; +import org.onap.policy.common.endpoints.event.comm.TopicSource; +import org.onap.policy.common.endpoints.listeners.MessageTypeDispatcher; +import org.onap.policy.common.utils.services.ServiceManagerContainer; +import org.springframework.context.event.ContextClosedEvent; +import org.springframework.context.event.ContextRefreshedEvent; +import org.springframework.context.event.EventListener; +import org.springframework.stereotype.Component; + +@Component +public class MessageDispatcherActivator extends ServiceManagerContainer implements Closeable { + + private static final String[] MSG_TYPE_NAMES = {"messageType"}; + + // Topics from which the application receives and to which the application sends messages + private List topicSinks; + private List topicSources; + + @Getter + private final MessageTypeDispatcher msgDispatcher; + + /** + * Constructor. + * + * @param acRuntimeParameterGroup the parameters for the automation composition runtime service + * @param publishers list of Publishers + * @param listeners list of Listeners + * @throws AutomationCompositionRuntimeException if the activator does not start + */ + public MessageDispatcherActivator(final AcRuntimeParameterGroup acRuntimeParameterGroup, + List publishers, List> listeners) { + topicSinks = TopicEndpointManager.getManager() + .addTopicSinks(acRuntimeParameterGroup.getTopicParameterGroup().getTopicSinks()); + + topicSources = TopicEndpointManager.getManager() + .addTopicSources(acRuntimeParameterGroup.getTopicParameterGroup().getTopicSources()); + + msgDispatcher = new MessageTypeDispatcher(MSG_TYPE_NAMES); + + // @formatter:off + addAction("Topic endpoint management", + () -> TopicEndpointManager.getManager().start(), + () -> TopicEndpointManager.getManager().shutdown()); + + publishers.forEach(publisher -> + addAction("Publisher " + publisher.getClass().getSimpleName(), + () -> publisher.active(topicSinks), + publisher::stop)); + + listeners.forEach(listener -> + addAction("Listener " + listener.getClass().getSimpleName(), + () -> msgDispatcher.register(listener.getType(), listener.getScoListener()), + () -> msgDispatcher.unregister(listener.getType()))); + + addAction("Topic Message Dispatcher", this::registerMsgDispatcher, this::unregisterMsgDispatcher); + // @formatter:on + } + + /** + * Registers the dispatcher with the topic source(s). + */ + private void registerMsgDispatcher() { + for (final TopicSource source : topicSources) { + source.register(msgDispatcher); + } + } + + /** + * Unregisters the dispatcher from the topic source(s). + */ + private void unregisterMsgDispatcher() { + for (final TopicSource source : topicSources) { + source.unregister(msgDispatcher); + } + } + + /** + * Start Manager after the application is Started. + * + * @param cre Refreshed Event + */ + @EventListener + public void handleContextStart(ContextRefreshedEvent cre) { + if (!isAlive()) { + start(); + } + } + + /** + * Handle ContextClosedEvent. + * + * @param ctxClosedEvent ContextClosedEvent + */ + @EventListener + public void handleContextClosedEvent(ContextClosedEvent ctxClosedEvent) { + if (isAlive()) { + stop(); + } + } + + @Override + public void close() throws IOException { + if (isAlive()) { + super.shutdown(); + } + } +} diff --git a/runtime-acm/src/main/java/org/onap/policy/clamp/acm/runtime/config/messaging/Publisher.java b/runtime-acm/src/main/java/org/onap/policy/clamp/acm/runtime/config/messaging/Publisher.java new file mode 100644 index 000000000..a7acc47b3 --- /dev/null +++ b/runtime-acm/src/main/java/org/onap/policy/clamp/acm/runtime/config/messaging/Publisher.java @@ -0,0 +1,34 @@ +/*- + * ============LICENSE_START======================================================= + * Copyright (C) 2021 Nordix Foundation. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * SPDX-License-Identifier: Apache-2.0 + * ============LICENSE_END========================================================= + */ + +package org.onap.policy.clamp.acm.runtime.config.messaging; + +import java.util.List; +import org.onap.policy.common.endpoints.event.comm.TopicSink; + +/** + * Publisher. + */ +public interface Publisher { + + void active(List topicSinks); + + void stop(); +} diff --git a/runtime-acm/src/main/java/org/onap/policy/clamp/acm/runtime/instantiation/AutomationCompositionInstantiationProvider.java b/runtime-acm/src/main/java/org/onap/policy/clamp/acm/runtime/instantiation/AutomationCompositionInstantiationProvider.java new file mode 100644 index 000000000..39d84026b --- /dev/null +++ b/runtime-acm/src/main/java/org/onap/policy/clamp/acm/runtime/instantiation/AutomationCompositionInstantiationProvider.java @@ -0,0 +1,637 @@ +/*- + * ============LICENSE_START======================================================= + * Copyright (C) 2021 Nordix Foundation. + * Modifications Copyright (C) 2021 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * SPDX-License-Identifier: Apache-2.0 + * ============LICENSE_END========================================================= + */ + +package org.onap.policy.clamp.acm.runtime.instantiation; + +import com.google.gson.Gson; +import com.google.gson.internal.LinkedTreeMap; +import com.google.gson.reflect.TypeToken; +import java.lang.reflect.Type; +import java.util.ArrayList; +import java.util.Collection; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.UUID; +import java.util.function.Function; +import java.util.function.UnaryOperator; +import java.util.stream.Collectors; +import java.util.stream.Stream; +import javax.ws.rs.core.Response; +import javax.ws.rs.core.Response.Status; +import lombok.AllArgsConstructor; +import org.onap.policy.clamp.acm.runtime.commissioning.CommissioningProvider; +import org.onap.policy.clamp.acm.runtime.supervision.SupervisionHandler; +import org.onap.policy.clamp.common.acm.exception.AutomationCompositionException; +import org.onap.policy.clamp.models.acm.concepts.AutomationComposition; +import org.onap.policy.clamp.models.acm.concepts.AutomationCompositionElement; +import org.onap.policy.clamp.models.acm.concepts.AutomationCompositionOrderedState; +import org.onap.policy.clamp.models.acm.concepts.AutomationCompositionState; +import org.onap.policy.clamp.models.acm.concepts.AutomationCompositions; +import org.onap.policy.clamp.models.acm.concepts.Participant; +import org.onap.policy.clamp.models.acm.messages.rest.GenericNameVersion; +import org.onap.policy.clamp.models.acm.messages.rest.instantiation.AutomationCompositionOrderStateResponse; +import org.onap.policy.clamp.models.acm.messages.rest.instantiation.AutomationCompositionPrimed; +import org.onap.policy.clamp.models.acm.messages.rest.instantiation.AutomationCompositionPrimedResponse; +import org.onap.policy.clamp.models.acm.messages.rest.instantiation.InstancePropertiesResponse; +import org.onap.policy.clamp.models.acm.messages.rest.instantiation.InstantiationCommand; +import org.onap.policy.clamp.models.acm.messages.rest.instantiation.InstantiationResponse; +import org.onap.policy.clamp.models.acm.persistence.provider.AutomationCompositionProvider; +import org.onap.policy.clamp.models.acm.persistence.provider.ParticipantProvider; +import org.onap.policy.common.parameters.BeanValidationResult; +import org.onap.policy.common.parameters.ObjectValidationResult; +import org.onap.policy.common.parameters.ValidationResult; +import org.onap.policy.common.parameters.ValidationStatus; +import org.onap.policy.models.base.PfModelException; +import org.onap.policy.models.tosca.authorative.concepts.ToscaConceptIdentifier; +import org.onap.policy.models.tosca.authorative.concepts.ToscaNameVersion; +import org.onap.policy.models.tosca.authorative.concepts.ToscaNodeTemplate; +import org.onap.policy.models.tosca.authorative.concepts.ToscaServiceTemplate; +import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; + +/** + * This class is dedicated to the Instantiation of Commissioned automation composition. + */ +@Service +@Transactional +@AllArgsConstructor +public class AutomationCompositionInstantiationProvider { + private static final String AUTOMATION_COMPOSITION_NODE_TYPE = "org.onap.policy.clamp.acm.AutomationComposition"; + private static final String AUTOMATION_COMPOSITION_NODE_ELEMENT_TYPE = "AutomationCompositionElement"; + private static final String PARTICIPANT_ID_PROPERTY_KEY = "participant_id"; + private static final String PARTICIPANT_TYPE_PROPERTY_KEY = "participantType"; + private static final String AC_ELEMENT_NAME = "name"; + private static final String AC_ELEMENT_VERSION = "version"; + private static final String INSTANCE_TEXT = "_Instance"; + + private static final Gson GSON = new Gson(); + + private final AutomationCompositionProvider automationCompositionProvider; + private final CommissioningProvider commissioningProvider; + private final SupervisionHandler supervisionHandler; + private final ParticipantProvider participantProvider; + private static final String ENTRY = "entry "; + + /** + * Creates Instance Properties and automation composition. + * + * @param serviceTemplate the service template + * @return the result of the instantiation operation + * @throws PfModelException on creation errors + */ + public InstancePropertiesResponse createInstanceProperties(ToscaServiceTemplate serviceTemplate) + throws PfModelException { + + String instanceName = generateSequentialInstanceName(); + AutomationComposition automationComposition = new AutomationComposition(); + Map automationCompositionElements = new HashMap<>(); + + ToscaServiceTemplate toscaServiceTemplate = commissioningProvider.getAllToscaServiceTemplate().get(0); + + Map persistedNodeTemplateMap = + toscaServiceTemplate.getToscaTopologyTemplate().getNodeTemplates(); + + Map nodeTemplates = deepCloneNodeTemplate(serviceTemplate); + + nodeTemplates.forEach((key, template) -> { + ToscaNodeTemplate newNodeTemplate = new ToscaNodeTemplate(); + String name = key + instanceName; + String version = template.getVersion(); + String description = template.getDescription() + instanceName; + newNodeTemplate.setName(name); + newNodeTemplate.setVersion(version); + newNodeTemplate.setDescription(description); + newNodeTemplate.setProperties(new HashMap<>(template.getProperties())); + newNodeTemplate.setType(template.getType()); + newNodeTemplate.setTypeVersion(template.getTypeVersion()); + newNodeTemplate.setMetadata(template.getMetadata()); + + crateNewAutomationCompositionInstance(instanceName, automationComposition, automationCompositionElements, + template, newNodeTemplate); + + persistedNodeTemplateMap.put(name, newNodeTemplate); + }); + + AutomationCompositions automationCompositions = new AutomationCompositions(); + + serviceTemplate.getToscaTopologyTemplate().getNodeTemplates().putAll(persistedNodeTemplateMap); + + automationComposition.setElements(automationCompositionElements); + automationCompositions.getAutomationCompositionList().add(automationComposition); + + return saveInstancePropertiesAndAutomationComposition(serviceTemplate, automationCompositions); + } + + /** + * Deletes Instance Properties. + * + * @param name the name of the automation composition to delete + * @param version the version of the automation composition to delete + * @return the result of the deletion + * @throws PfModelException on deletion errors + */ + public InstantiationResponse deleteInstanceProperties(String name, String version) throws PfModelException { + + String instanceName = getInstancePropertyName(name, version); + + Map filteredToscaNodeTemplateMap = new HashMap<>(); + + ToscaServiceTemplate toscaServiceTemplate = commissioningProvider.getAllToscaServiceTemplate().get(0); + + toscaServiceTemplate.getToscaTopologyTemplate().getNodeTemplates().forEach((key, nodeTemplate) -> { + if (!nodeTemplate.getName().contains(instanceName)) { + filteredToscaNodeTemplateMap.put(key, nodeTemplate); + } + }); + + List filteredToscaNodeTemplateList = + toscaServiceTemplate.getToscaTopologyTemplate().getNodeTemplates().values().stream() + .filter(nodeTemplate -> nodeTemplate.getName().contains(instanceName)).collect(Collectors.toList()); + + InstantiationResponse response = this.deleteAutomationComposition(name, version); + + automationCompositionProvider.deleteInstanceProperties(filteredToscaNodeTemplateMap, + filteredToscaNodeTemplateList); + + return response; + } + + /** + * Create automation compositions. + * + * @param automationCompositions the automation composition + * @return the result of the instantiation operation + * @throws PfModelException on creation errors + */ + public InstantiationResponse createAutomationCompositions(AutomationCompositions automationCompositions) + throws PfModelException { + for (AutomationComposition automationComposition : automationCompositions.getAutomationCompositionList()) { + var checkAutomationCompositionOpt = + automationCompositionProvider.findAutomationComposition(automationComposition.getKey().asIdentifier()); + if (checkAutomationCompositionOpt.isPresent()) { + throw new PfModelException(Response.Status.BAD_REQUEST, + automationComposition.getKey().asIdentifier() + " already defined"); + } + } + BeanValidationResult validationResult = validateAutomationCompositions(automationCompositions); + if (!validationResult.isValid()) { + throw new PfModelException(Response.Status.BAD_REQUEST, validationResult.getResult()); + } + automationCompositionProvider.saveAutomationCompositions(automationCompositions.getAutomationCompositionList()); + + var response = new InstantiationResponse(); + response.setAffectedAutomationCompositions(automationCompositions.getAutomationCompositionList().stream() + .map(ac -> ac.getKey().asIdentifier()).collect(Collectors.toList())); + + return response; + } + + /** + * Update automation compositions. + * + * @param automationCompositions the automation composition + * @return the result of the instantiation operation + * @throws PfModelException on update errors + */ + public InstantiationResponse updateAutomationCompositions(AutomationCompositions automationCompositions) + throws PfModelException { + BeanValidationResult validationResult = validateAutomationCompositions(automationCompositions); + if (!validationResult.isValid()) { + throw new PfModelException(Response.Status.BAD_REQUEST, validationResult.getResult()); + } + automationCompositionProvider.saveAutomationCompositions(automationCompositions.getAutomationCompositionList()); + + var response = new InstantiationResponse(); + response.setAffectedAutomationCompositions(automationCompositions.getAutomationCompositionList().stream() + .map(ac -> ac.getKey().asIdentifier()).collect(Collectors.toList())); + + return response; + } + + /** + * Validate AutomationCompositions. + * + * @param automationCompositions AutomationCompositions to validate + * @return the result of validation + * @throws PfModelException if automationCompositions is not valid + */ + private BeanValidationResult validateAutomationCompositions(AutomationCompositions automationCompositions) + throws PfModelException { + + var result = new BeanValidationResult("AutomationCompositions", automationCompositions); + + for (AutomationComposition automationComposition : automationCompositions.getAutomationCompositionList()) { + var subResult = new BeanValidationResult(ENTRY + automationComposition.getDefinition().getName(), + automationComposition); + + List toscaNodeTemplates = commissioningProvider.getAutomationCompositionDefinitions( + automationComposition.getDefinition().getName(), automationComposition.getDefinition().getVersion()); + + if (toscaNodeTemplates.isEmpty()) { + subResult.addResult( + new ObjectValidationResult("AutomationComposition", automationComposition.getDefinition().getName(), + ValidationStatus.INVALID, "Commissioned automation composition definition not found")); + } else if (toscaNodeTemplates.size() > 1) { + subResult.addResult( + new ObjectValidationResult("AutomationComposition", automationComposition.getDefinition().getName(), + ValidationStatus.INVALID, "Commissioned automation composition definition not valid")); + } else { + + List acElementDefinitions = + commissioningProvider.getAutomationCompositionElementDefinitions(toscaNodeTemplates.get(0)); + + // @formatter:off + Map definitions = acElementDefinitions + .stream() + .map(nodeTemplate -> nodeTemplate.getKey().asIdentifier()) + .collect(Collectors.toMap(ToscaConceptIdentifier::getName, UnaryOperator.identity())); + // @formatter:on + + for (AutomationCompositionElement element : automationComposition.getElements().values()) { + subResult.addResult(validateDefinition(definitions, element.getDefinition())); + } + } + result.addResult(subResult); + } + return result; + } + + /** + * Validate ToscaConceptIdentifier, checking if exist in ToscaConceptIdentifiers map. + * + * @param definitions map of all ToscaConceptIdentifiers + * @param definition ToscaConceptIdentifier to validate + * @return the validation result + */ + private ValidationResult validateDefinition(Map definitions, + ToscaConceptIdentifier definition) { + var result = new BeanValidationResult(ENTRY + definition.getName(), definition); + ToscaConceptIdentifier identifier = definitions.get(definition.getName()); + if (identifier == null) { + result.setResult(ValidationStatus.INVALID, "Not found"); + } else if (!identifier.equals(definition)) { + result.setResult(ValidationStatus.INVALID, "Version not matching"); + } + return (result.isClean() ? null : result); + } + + /** + * Delete the automation composition with the given name and version. + * + * @param name the name of the automation composition to delete + * @param version the version of the automation composition to delete + * @return the result of the deletion + * @throws PfModelException on deletion errors + */ + public InstantiationResponse deleteAutomationComposition(String name, String version) throws PfModelException { + var automationCompositionOpt = automationCompositionProvider.findAutomationComposition(name, version); + if (automationCompositionOpt.isEmpty()) { + throw new PfModelException(Response.Status.NOT_FOUND, "Automation composition not found"); + } + var automationComposition = automationCompositionOpt.get(); + if (!AutomationCompositionState.UNINITIALISED.equals(automationComposition.getState())) { + throw new PfModelException(Response.Status.BAD_REQUEST, + "Automation composition state is still " + automationComposition.getState()); + } + var response = new InstantiationResponse(); + response.setAffectedAutomationCompositions( + List.of(automationCompositionProvider.deleteAutomationComposition(name, version).getKey().asIdentifier())); + return response; + } + + /** + * Get the requested automation compositions. + * + * @param name the name of the automation composition to get, null for all automation compositions + * @param version the version of the automation composition to get, null for all automation compositions + * @return the automation compositions + * @throws PfModelException on errors getting automation compositions + */ + @Transactional(readOnly = true) + public AutomationCompositions getAutomationCompositions(String name, String version) throws PfModelException { + var automationCompositions = new AutomationCompositions(); + automationCompositions + .setAutomationCompositionList(automationCompositionProvider.getAutomationCompositions(name, version)); + + return automationCompositions; + } + + /** + * Issue a command to automation compositions, setting their ordered state. + * + * @param command the command to issue to automation compositions + * @return the result of the initiation command + * @throws PfModelException on errors setting the ordered state on the automation compositions + * @throws AutomationCompositionException on ordered state invalid + */ + public InstantiationResponse issueAutomationCompositionCommand(InstantiationCommand command) + throws AutomationCompositionException, PfModelException { + + if (command.getOrderedState() == null) { + throw new AutomationCompositionException(Status.BAD_REQUEST, + "ordered state invalid or not specified on command"); + } + + var participants = participantProvider.getParticipants(); + if (participants.isEmpty()) { + throw new AutomationCompositionException(Status.BAD_REQUEST, "No participants registered"); + } + var validationResult = new BeanValidationResult("InstantiationCommand", command); + List automationCompositions = + new ArrayList<>(command.getAutomationCompositionIdentifierList().size()); + for (ToscaConceptIdentifier id : command.getAutomationCompositionIdentifierList()) { + var automationCompositionOpt = automationCompositionProvider.findAutomationComposition(id); + if (automationCompositionOpt.isEmpty()) { + validationResult.addResult("ToscaConceptIdentifier", id, ValidationStatus.INVALID, + "AutomationComposition with id " + id + " not found"); + } else { + var automationComposition = automationCompositionOpt.get(); + automationComposition.setCascadedOrderedState(command.getOrderedState()); + automationCompositions.add(automationComposition); + } + } + if (validationResult.isValid()) { + validationResult = validateIssueAutomationCompositions(automationCompositions, participants); + } + if (!validationResult.isValid()) { + throw new PfModelException(Response.Status.BAD_REQUEST, validationResult.getResult()); + } + automationCompositionProvider.saveAutomationCompositions(automationCompositions); + + supervisionHandler.triggerAutomationCompositionSupervision(command.getAutomationCompositionIdentifierList()); + var response = new InstantiationResponse(); + response.setAffectedAutomationCompositions(command.getAutomationCompositionIdentifierList()); + + return response; + } + + private BeanValidationResult validateIssueAutomationCompositions(List automationCompositions, + List participants) { + var result = new BeanValidationResult("AutomationCompositions", automationCompositions); + + Map participantMap = participants.stream() + .collect(Collectors.toMap(participant -> participant.getKey().asIdentifier(), Function.identity())); + + for (AutomationComposition automationComposition : automationCompositions) { + + for (var element : automationComposition.getElements().values()) { + + var subResult = new BeanValidationResult(ENTRY + element.getDefinition().getName(), element); + Participant p = participantMap.get(element.getParticipantId()); + if (p == null) { + subResult.addResult(new ObjectValidationResult(AUTOMATION_COMPOSITION_NODE_ELEMENT_TYPE, + element.getDefinition().getName(), ValidationStatus.INVALID, + "Participant with ID " + element.getParticipantId() + " is not registered")); + } else if (!p.getParticipantType().equals(element.getParticipantType())) { + subResult.addResult(new ObjectValidationResult(AUTOMATION_COMPOSITION_NODE_ELEMENT_TYPE, + element.getDefinition().getName(), ValidationStatus.INVALID, + "Participant with ID " + element.getParticipantType() + " - " + element.getParticipantId() + + " is not registered")); + } + result.addResult(subResult); + } + + } + + return result; + } + + /** + * Gets a list of automation compositions with it's ordered state. + * + * @param name the name of the automation composition to get, null for all automation compositions + * @param version the version of the automation composition to get, null for all automation compositions + * @return a list of Instantiation Command + * @throws PfModelException on errors getting automation compositions + */ + @Transactional(readOnly = true) + public AutomationCompositionOrderStateResponse getInstantiationOrderState(String name, String version) + throws PfModelException { + + List automationCompositions = + automationCompositionProvider.getAutomationCompositions(name, version); + + var response = new AutomationCompositionOrderStateResponse(); + + automationCompositions.forEach(automationComposition -> { + var genericNameVersion = new GenericNameVersion(); + genericNameVersion.setName(automationComposition.getName()); + genericNameVersion.setVersion(automationComposition.getVersion()); + response.getAutomationCompositionIdentifierList().add(genericNameVersion); + }); + + return response; + } + + /** + * Saves Instance Properties and automation composition. + * Gets a list of automation compositions which are primed or de-primed. + * + * @param name the name of the automation composition to get, null for all automation compositions + * @param version the version of the automation composition to get, null for all automation compositions + * @return a list of Instantiation Command + * @throws PfModelException on errors getting automation compositions + */ + @Transactional(readOnly = true) + public AutomationCompositionPrimedResponse getAutomationCompositionPriming(String name, String version) + throws PfModelException { + + List automationCompositions = + automationCompositionProvider.getAutomationCompositions(name, version); + + var response = new AutomationCompositionPrimedResponse(); + + automationCompositions.forEach(automationComposition -> { + var primed = new AutomationCompositionPrimed(); + primed.setName(automationComposition.getName()); + primed.setVersion(automationComposition.getVersion()); + primed.setPrimed(automationComposition.getPrimed()); + response.getPrimedAutomationCompositionsList().add(primed); + }); + + return response; + } + + /** + * Creates instance element name. + * + * @param serviceTemplate the service template + * @param automationCompositions a list of automation compositions + * @return the result of the instance properties and instantiation operation + * @throws PfModelException on creation errors + */ + private InstancePropertiesResponse saveInstancePropertiesAndAutomationComposition( + ToscaServiceTemplate serviceTemplate, AutomationCompositions automationCompositions) throws PfModelException { + + for (var automationComposition : automationCompositions.getAutomationCompositionList()) { + var checkAutomationCompositionOpt = + automationCompositionProvider.findAutomationComposition(automationComposition.getKey().asIdentifier()); + if (checkAutomationCompositionOpt.isPresent()) { + throw new PfModelException(Response.Status.BAD_REQUEST, "Automation composition with id " + + automationComposition.getKey().asIdentifier() + " already defined"); + } + } + Map toscaSavedNodeTemplate = + automationCompositionProvider.saveInstanceProperties(serviceTemplate); + automationCompositionProvider.saveAutomationCompositions(automationCompositions.getAutomationCompositionList()); + List affectedAutomationCompositions = automationCompositions + .getAutomationCompositionList().stream().map(ac -> ac.getKey().asIdentifier()).collect(Collectors.toList()); + + List toscaAffectedProperties = toscaSavedNodeTemplate.values().stream() + .map(template -> template.getKey().asIdentifier()).collect(Collectors.toList()); + + var response = new InstancePropertiesResponse(); + response.setAffectedInstanceProperties(Stream.of(affectedAutomationCompositions, toscaAffectedProperties) + .flatMap(Collection::stream).collect(Collectors.toList())); + + return response; + } + + /** + * Crates a new automation composition instance. + * + * @param instanceName automation composition Instance name + * @param automationComposition empty automation composition + * @param automationCompositionElements new automation composition Element map + * @param template original Cloned Tosca Node Template + * @param newNodeTemplate new Tosca Node Template + */ + private void crateNewAutomationCompositionInstance(String instanceName, AutomationComposition automationComposition, + Map automationCompositionElements, ToscaNodeTemplate template, + ToscaNodeTemplate newNodeTemplate) { + if (template.getType().equals(AUTOMATION_COMPOSITION_NODE_TYPE)) { + automationComposition.setDefinition(getAutomationCompositionDefinition(newNodeTemplate)); + } + + if (template.getType().contains(AUTOMATION_COMPOSITION_NODE_ELEMENT_TYPE)) { + AutomationCompositionElement automationCompositionElement = + getAutomationCompositionElement(newNodeTemplate); + automationCompositionElements.put(automationCompositionElement.getId(), automationCompositionElement); + } + + automationComposition.setName("PMSH" + instanceName); + automationComposition.setVersion(template.getVersion()); + automationComposition.setDescription("PMSH automation composition " + instanceName); + automationComposition.setState(AutomationCompositionState.UNINITIALISED); + automationComposition.setOrderedState(AutomationCompositionOrderedState.UNINITIALISED); + } + + /** + * Get's the instance property name of the automation composition. + * + * @param name the name of the automation composition to get, null for all automation compositions + * @param version the version of the automation composition to get, null for all automation compositions + * @return the instance name of the automation composition instance properties + * @throws PfModelException on errors getting automation compositions + */ + private String getInstancePropertyName(String name, String version) throws PfModelException { + List toscaDefinitionsNames = + automationCompositionProvider.getAutomationCompositions(name, version).stream() + .map(AutomationComposition::getDefinition).map(ToscaNameVersion::getName).collect(Collectors.toList()); + + return toscaDefinitionsNames.stream().reduce("", (s1, s2) -> { + + if (s2.contains(INSTANCE_TEXT)) { + String[] instances = s2.split(INSTANCE_TEXT); + + return INSTANCE_TEXT + instances[1]; + } + + return s1; + }); + } + + /** + * Generates Instance Name in sequential order and return it to append to the Node Template Name. + * + * @return instanceName + */ + private String generateSequentialInstanceName() { + List nodeTemplates = automationCompositionProvider.getAllNodeTemplates(); + + int instanceNumber = nodeTemplates.stream().map(ToscaNodeTemplate::getName) + .filter(name -> name.contains(INSTANCE_TEXT)).map(n -> { + String[] defNameArr = n.split(INSTANCE_TEXT); + + return Integer.parseInt(defNameArr[1]); + }).reduce(0, Math::max); + + return INSTANCE_TEXT + (instanceNumber + 1); + } + + /** + * Retrieves automation composition Definition. + * + * @param template tosca node template + * @return automation composition definition + */ + private ToscaConceptIdentifier getAutomationCompositionDefinition(ToscaNodeTemplate template) { + ToscaConceptIdentifier definition = new ToscaConceptIdentifier(); + definition.setName(template.getName()); + definition.setVersion(template.getVersion()); + return definition; + } + + /** + * Retrieves automation composition Element. + * + * @param template tosca node template + * @return a automation composition element + */ + @SuppressWarnings("unchecked") + private AutomationCompositionElement getAutomationCompositionElement(ToscaNodeTemplate template) { + AutomationCompositionElement automationCompositionElement = new AutomationCompositionElement(); + ToscaConceptIdentifier definition = new ToscaConceptIdentifier(); + definition.setName(template.getName()); + definition.setVersion(template.getVersion()); + automationCompositionElement.setDefinition(definition); + LinkedTreeMap participantId = + (LinkedTreeMap) template.getProperties().get(PARTICIPANT_ID_PROPERTY_KEY); + if (participantId != null) { + ToscaConceptIdentifier participantIdProperty = new ToscaConceptIdentifier(); + participantIdProperty.setName(String.valueOf(participantId.get(AC_ELEMENT_NAME))); + participantIdProperty.setVersion(String.valueOf(participantId.get(AC_ELEMENT_VERSION))); + automationCompositionElement.setParticipantId(participantIdProperty); + } + LinkedTreeMap participantType = + (LinkedTreeMap) template.getProperties().get(PARTICIPANT_TYPE_PROPERTY_KEY); + if (participantType != null) { + ToscaConceptIdentifier participantTypeProperty = new ToscaConceptIdentifier(); + participantTypeProperty.setName(String.valueOf(participantType.get(AC_ELEMENT_NAME))); + participantTypeProperty.setVersion(participantType.get(AC_ELEMENT_VERSION).toString()); + automationCompositionElement.setParticipantType(participantTypeProperty); + } + return automationCompositionElement; + } + + /** + * Deep clones ToscaNodeTemplate. + * + * @param serviceTemplate ToscaServiceTemplate + * @return a cloned Hash Map of ToscaNodeTemplate + */ + private Map deepCloneNodeTemplate(ToscaServiceTemplate serviceTemplate) { + String jsonString = GSON.toJson(serviceTemplate.getToscaTopologyTemplate().getNodeTemplates()); + Type type = new TypeToken>() {}.getType(); + return GSON.fromJson(jsonString, type); + } +} diff --git a/runtime-acm/src/main/java/org/onap/policy/clamp/acm/runtime/main/parameters/AcRuntimeParameterGroup.java b/runtime-acm/src/main/java/org/onap/policy/clamp/acm/runtime/main/parameters/AcRuntimeParameterGroup.java new file mode 100644 index 000000000..563da1268 --- /dev/null +++ b/runtime-acm/src/main/java/org/onap/policy/clamp/acm/runtime/main/parameters/AcRuntimeParameterGroup.java @@ -0,0 +1,49 @@ +/*- + * ============LICENSE_START======================================================= + * Copyright (C) 2021 Nordix Foundation. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * SPDX-License-Identifier: Apache-2.0 + * ============LICENSE_END========================================================= + */ + +package org.onap.policy.clamp.acm.runtime.main.parameters; + +import javax.validation.Valid; +import javax.validation.constraints.NotNull; +import lombok.Getter; +import lombok.Setter; +import org.onap.policy.common.endpoints.parameters.TopicParameterGroup; +import org.onap.policy.common.parameters.validation.ParameterGroupConstraint; +import org.springframework.boot.context.properties.ConfigurationProperties; +import org.springframework.validation.annotation.Validated; + +/** + * Class to hold all parameters needed for the ACM runtime component. + * + */ +@Validated +@Getter +@Setter +@ConfigurationProperties(prefix = "runtime") +public class AcRuntimeParameterGroup { + + @Valid + @NotNull + private ParticipantParameters participantParameters; + + @NotNull + @ParameterGroupConstraint + private TopicParameterGroup topicParameterGroup; +} diff --git a/runtime-acm/src/main/java/org/onap/policy/clamp/acm/runtime/main/parameters/ParticipantParameters.java b/runtime-acm/src/main/java/org/onap/policy/clamp/acm/runtime/main/parameters/ParticipantParameters.java new file mode 100644 index 000000000..248824f11 --- /dev/null +++ b/runtime-acm/src/main/java/org/onap/policy/clamp/acm/runtime/main/parameters/ParticipantParameters.java @@ -0,0 +1,45 @@ +/*- + * ============LICENSE_START======================================================= + * Copyright (C) 2021 Nordix Foundation. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.onap.policy.clamp.acm.runtime.main.parameters; + +import javax.validation.Valid; +import javax.validation.constraints.Min; +import javax.validation.constraints.NotNull; +import lombok.Getter; +import lombok.Setter; +import org.springframework.validation.annotation.Validated; + +/** + * Parameters for communicating with participants. + */ +@Getter +@Setter +@Validated +public class ParticipantParameters { + + @Min(100) + private long heartBeatMs; + + @Min(100) + private long maxStatusWaitMs; + + @Valid + @NotNull + private ParticipantUpdateParameters updateParameters; +} diff --git a/runtime-acm/src/main/java/org/onap/policy/clamp/acm/runtime/main/parameters/ParticipantUpdateParameters.java b/runtime-acm/src/main/java/org/onap/policy/clamp/acm/runtime/main/parameters/ParticipantUpdateParameters.java new file mode 100644 index 000000000..5ffaf39c0 --- /dev/null +++ b/runtime-acm/src/main/java/org/onap/policy/clamp/acm/runtime/main/parameters/ParticipantUpdateParameters.java @@ -0,0 +1,46 @@ +/* + * ============LICENSE_START======================================================= + * Copyright (C) 2021 Nordix Foundation. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.onap.policy.clamp.acm.runtime.main.parameters; + +import javax.validation.constraints.Min; +import lombok.Getter; +import lombok.Setter; +import org.springframework.validation.annotation.Validated; + +/** + * Parameters for Participant UPDATE requests. + */ +@Getter +@Setter +@Validated +public class ParticipantUpdateParameters { + + /** + * Maximum number of times to re-send a request to a PDP. + */ + @Min(value = 1) + private int maxRetryCount; + + /** + * Maximum time to wait, in milliseconds, for a PDP response. + */ + @Min(value = 100) + private long maxWaitMs; + +} diff --git a/runtime-acm/src/main/java/org/onap/policy/clamp/acm/runtime/main/rest/CommissioningController.java b/runtime-acm/src/main/java/org/onap/policy/clamp/acm/runtime/main/rest/CommissioningController.java new file mode 100644 index 000000000..0fd8661b4 --- /dev/null +++ b/runtime-acm/src/main/java/org/onap/policy/clamp/acm/runtime/main/rest/CommissioningController.java @@ -0,0 +1,501 @@ +/*- + * ============LICENSE_START======================================================= + * Copyright (C) 2021 Nordix Foundation. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * SPDX-License-Identifier: Apache-2.0 + * ============LICENSE_END========================================================= + */ + +package org.onap.policy.clamp.acm.runtime.main.rest; + +import io.swagger.annotations.ApiOperation; +import io.swagger.annotations.ApiParam; +import io.swagger.annotations.ApiResponse; +import io.swagger.annotations.ApiResponses; +import io.swagger.annotations.Authorization; +import io.swagger.annotations.Extension; +import io.swagger.annotations.ExtensionProperty; +import io.swagger.annotations.ResponseHeader; +import java.util.List; +import java.util.Map; +import java.util.UUID; +import javax.ws.rs.core.Response.Status; +import lombok.RequiredArgsConstructor; +import org.onap.policy.clamp.acm.runtime.commissioning.CommissioningProvider; +import org.onap.policy.clamp.acm.runtime.main.web.AbstractRestController; +import org.onap.policy.clamp.common.acm.exception.AutomationCompositionException; +import org.onap.policy.clamp.models.acm.messages.rest.commissioning.CommissioningResponse; +import org.onap.policy.models.base.PfModelException; +import org.onap.policy.models.tosca.authorative.concepts.ToscaNodeTemplate; +import org.onap.policy.models.tosca.authorative.concepts.ToscaServiceTemplate; +import org.springframework.http.MediaType; +import org.springframework.http.ResponseEntity; +import org.springframework.web.bind.annotation.DeleteMapping; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.PostMapping; +import org.springframework.web.bind.annotation.RequestBody; +import org.springframework.web.bind.annotation.RequestHeader; +import org.springframework.web.bind.annotation.RequestParam; +import org.springframework.web.bind.annotation.RestController; + +/** + * Class to provide REST end points for creating, deleting, querying commissioned automation compositions. + */ +@RestController +@RequiredArgsConstructor +public class CommissioningController extends AbstractRestController { + + private static final String TAGS = "Clamp Automation Composition Commissioning API"; + + private final CommissioningProvider provider; + + /** + * Creates a automation composition definition. + * + * @param requestId request ID used in ONAP logging + * @param body the body of automation composition following TOSCA definition + * @return a response + * @throws PfModelException on errors creating a automation composition definition + */ + // @formatter:off + @PostMapping(value = "/commission", + consumes = {MediaType.APPLICATION_JSON_VALUE, APPLICATION_YAML}, + produces = {MediaType.APPLICATION_JSON_VALUE, APPLICATION_YAML}) + @ApiOperation( + value = "Commissions automation composition definitions", + notes = "Commissions automation composition definitions, returning commissioned definition IDs", + response = CommissioningResponse.class, + tags = {TAGS}, + authorizations = @Authorization(value = AUTHORIZATION_TYPE), + responseHeaders = { + @ResponseHeader( + name = VERSION_MINOR_NAME, + description = VERSION_MINOR_DESCRIPTION, + response = String.class), + @ResponseHeader( + name = VERSION_PATCH_NAME, + description = VERSION_PATCH_DESCRIPTION, + response = String.class), + @ResponseHeader( + name = VERSION_LATEST_NAME, + description = VERSION_LATEST_DESCRIPTION, + response = String.class), + @ResponseHeader( + name = REQUEST_ID_NAME, + description = REQUEST_ID_HDR_DESCRIPTION, + response = UUID.class) + }, + extensions = { + @Extension + ( + name = EXTENSION_NAME, + properties = { + @ExtensionProperty(name = API_VERSION_NAME, value = API_VERSION), + @ExtensionProperty(name = LAST_MOD_NAME, value = LAST_MOD_RELEASE) + } + ) + } + ) + @ApiResponses( + value = { + @ApiResponse(code = AUTHENTICATION_ERROR_CODE, message = AUTHENTICATION_ERROR_MESSAGE), + @ApiResponse(code = AUTHORIZATION_ERROR_CODE, message = AUTHORIZATION_ERROR_MESSAGE), + @ApiResponse(code = SERVER_ERROR_CODE, message = SERVER_ERROR_MESSAGE) + } + ) + // @formatter:on + public ResponseEntity create( + @RequestHeader(name = REQUEST_ID_NAME, required = false) @ApiParam(REQUEST_ID_PARAM_DESCRIPTION) UUID requestId, + @ApiParam( + value = "Entity Body of Automation Composition", + required = true) @RequestBody ToscaServiceTemplate body) + throws PfModelException { + + return ResponseEntity.ok().body(provider.createAutomationCompositionDefinitions(body)); + } + + /** + * Deletes a automation composition definition. + * + * @param requestId request ID used in ONAP logging + * @param name the name of the automation composition definition to delete + * @param version the version of the automation composition definition to delete + * @return a response + * @throws PfModelException on errors deleting a automation composition definition + */ + // @formatter:off + @DeleteMapping(value = "/commission", + produces = {MediaType.APPLICATION_JSON_VALUE, APPLICATION_YAML}) + @ApiOperation(value = "Delete a commissioned automation composition", + notes = "Deletes a Commissioned Automation Composition, returning optional error details", + response = CommissioningResponse.class, + tags = {TAGS}, + authorizations = @Authorization(value = AUTHORIZATION_TYPE), + responseHeaders = { + @ResponseHeader( + name = VERSION_MINOR_NAME, + description = VERSION_MINOR_DESCRIPTION, + response = String.class), + @ResponseHeader( + name = VERSION_PATCH_NAME, + description = VERSION_PATCH_DESCRIPTION, + response = String.class), + @ResponseHeader( + name = VERSION_LATEST_NAME, + description = VERSION_LATEST_DESCRIPTION, + response = String.class), + @ResponseHeader( + name = REQUEST_ID_NAME, + description = REQUEST_ID_HDR_DESCRIPTION, + response = UUID.class)}, + extensions = { + @Extension + ( + name = EXTENSION_NAME, + properties = { + @ExtensionProperty(name = API_VERSION_NAME, value = API_VERSION), + @ExtensionProperty(name = LAST_MOD_NAME, value = LAST_MOD_RELEASE) + } + ) + } + ) + @ApiResponses( + value = { + @ApiResponse(code = AUTHENTICATION_ERROR_CODE, message = AUTHENTICATION_ERROR_MESSAGE), + @ApiResponse(code = AUTHORIZATION_ERROR_CODE, message = AUTHORIZATION_ERROR_MESSAGE), + @ApiResponse(code = SERVER_ERROR_CODE, message = SERVER_ERROR_MESSAGE) + } + ) + // @formatter:on + public ResponseEntity delete( + @RequestHeader(name = REQUEST_ID_NAME, required = false) @ApiParam(REQUEST_ID_PARAM_DESCRIPTION) UUID requestId, + @ApiParam(value = "Automation composition definition name", required = true) @RequestParam( + value = "name") String name, + @ApiParam( + value = "Automation composition definition version", + required = true) @RequestParam("version") String version) + throws PfModelException { + + return ResponseEntity.ok().body(provider.deleteAutomationCompositionDefinition(name, version)); + } + + /** + * Queries details of all or specific automation composition definitions. + * + * @param requestId request ID used in ONAP logging + * @param name the name of the automation composition definition to get, null for all definitions + * @param version the version of the automation composition definition to get, null for all definitions + * @return the automation composition definitions + * @throws PfModelException on errors getting details of all or specific automation composition definitions + */ + // @formatter:off + @GetMapping(value = "/commission", + produces = {MediaType.APPLICATION_JSON_VALUE, APPLICATION_YAML}) + @ApiOperation(value = "Query details of the requested commissioned automation composition definitions", + notes = "Queries details of the requested commissioned automation composition definitions, " + + "returning all automation composition details", + response = ToscaNodeTemplate.class, + tags = {TAGS}, + authorizations = @Authorization(value = AUTHORIZATION_TYPE), + responseHeaders = { + @ResponseHeader( + name = VERSION_MINOR_NAME, description = VERSION_MINOR_DESCRIPTION, + response = String.class), + @ResponseHeader(name = VERSION_PATCH_NAME, description = VERSION_PATCH_DESCRIPTION, + response = String.class), + @ResponseHeader(name = VERSION_LATEST_NAME, description = VERSION_LATEST_DESCRIPTION, + response = String.class), + @ResponseHeader(name = REQUEST_ID_NAME, description = REQUEST_ID_HDR_DESCRIPTION, + response = UUID.class)}, + extensions = { + @Extension + ( + name = EXTENSION_NAME, + properties = { + @ExtensionProperty(name = API_VERSION_NAME, value = API_VERSION), + @ExtensionProperty(name = LAST_MOD_NAME, value = LAST_MOD_RELEASE) + } + ) + } + ) + @ApiResponses( + value = { + @ApiResponse(code = AUTHENTICATION_ERROR_CODE, message = AUTHENTICATION_ERROR_MESSAGE), + @ApiResponse(code = AUTHORIZATION_ERROR_CODE, message = AUTHORIZATION_ERROR_MESSAGE), + @ApiResponse(code = SERVER_ERROR_CODE, message = SERVER_ERROR_MESSAGE) + } + ) + // @formatter:on + public ResponseEntity> query( + @RequestHeader(name = REQUEST_ID_NAME, required = false) @ApiParam(REQUEST_ID_PARAM_DESCRIPTION) UUID requestId, + @ApiParam(value = "Automation composition definition name", required = false) @RequestParam( + value = "name", + required = false) String name, + @ApiParam(value = "Automation composition definition version", required = false) @RequestParam( + value = "version", + required = false) String version) + throws PfModelException { + + return ResponseEntity.ok().body(provider.getAutomationCompositionDefinitions(name, version)); + } + + /** + * Retrieves the Tosca Service Template. + * + * @param requestId request ID used in ONAP logging + * @param name the name of the tosca service template to retrieve + * @param version the version of the tosca service template to get + * @return the specified tosca service template + * @throws PfModelException on errors getting the Tosca Service Template + */ + // @formatter:off + @GetMapping(value = "/commission/toscaservicetemplate", + produces = {MediaType.APPLICATION_JSON_VALUE, APPLICATION_YAML}) + @ApiOperation(value = "Query details of the requested tosca service templates", + notes = "Queries details of the requested commissioned tosca service template, " + + "returning all tosca service template details", + response = ToscaServiceTemplate.class, + tags = {TAGS}, + authorizations = @Authorization(value = AUTHORIZATION_TYPE), + responseHeaders = { + @ResponseHeader( + name = VERSION_MINOR_NAME, description = VERSION_MINOR_DESCRIPTION, + response = String.class), + @ResponseHeader(name = VERSION_PATCH_NAME, description = VERSION_PATCH_DESCRIPTION, + response = String.class), + @ResponseHeader(name = VERSION_LATEST_NAME, description = VERSION_LATEST_DESCRIPTION, + response = String.class), + @ResponseHeader(name = REQUEST_ID_NAME, description = REQUEST_ID_HDR_DESCRIPTION, + response = UUID.class)}, + extensions = { + @Extension + ( + name = EXTENSION_NAME, + properties = { + @ExtensionProperty(name = API_VERSION_NAME, value = API_VERSION), + @ExtensionProperty(name = LAST_MOD_NAME, value = LAST_MOD_RELEASE) + } + ) + } + ) + @ApiResponses( + value = { + @ApiResponse(code = AUTHENTICATION_ERROR_CODE, message = AUTHENTICATION_ERROR_MESSAGE), + @ApiResponse(code = AUTHORIZATION_ERROR_CODE, message = AUTHORIZATION_ERROR_MESSAGE), + @ApiResponse(code = SERVER_ERROR_CODE, message = SERVER_ERROR_MESSAGE) + } + ) + // @formatter:on + public ResponseEntity queryToscaServiceTemplate( + @RequestHeader(name = REQUEST_ID_NAME, required = false) @ApiParam(REQUEST_ID_PARAM_DESCRIPTION) UUID requestId, + @ApiParam(value = "Tosca service template name", required = false) @RequestParam( + value = "name", + required = false) String name, + @ApiParam(value = "Tosca service template version", required = false) @RequestParam( + value = "version", + required = false) String version) + throws PfModelException { + + return ResponseEntity.ok().body(provider.getToscaServiceTemplateReduced(name, version)); + } + + /** + * Retrieves the Json Schema for the specified Tosca Service Template. + * + * @param requestId request ID used in ONAP logging + * @param section section of the tosca service template to get schema for + * @return the specified tosca service template or section Json Schema + * @throws PfModelException on errros getting the Json Schema for the specified Tosca Service Template + */ + // @formatter:off + @GetMapping(value = "/commission/toscaServiceTemplateSchema", + produces = {MediaType.APPLICATION_JSON_VALUE, APPLICATION_YAML}) + @ApiOperation(value = "Query details of the requested tosca service template json schema", + notes = "Queries details of the requested commissioned tosca service template json schema, " + + "returning all tosca service template json schema details", + response = ToscaServiceTemplate.class, + tags = {TAGS}, + authorizations = @Authorization(value = AUTHORIZATION_TYPE), + responseHeaders = { + @ResponseHeader( + name = VERSION_MINOR_NAME, description = VERSION_MINOR_DESCRIPTION, + response = String.class), + @ResponseHeader(name = VERSION_PATCH_NAME, description = VERSION_PATCH_DESCRIPTION, + response = String.class), + @ResponseHeader(name = VERSION_LATEST_NAME, description = VERSION_LATEST_DESCRIPTION, + response = String.class), + @ResponseHeader(name = REQUEST_ID_NAME, description = REQUEST_ID_HDR_DESCRIPTION, + response = UUID.class)}, + extensions = { + @Extension + ( + name = EXTENSION_NAME, + properties = { + @ExtensionProperty(name = API_VERSION_NAME, value = API_VERSION), + @ExtensionProperty(name = LAST_MOD_NAME, value = LAST_MOD_RELEASE) + } + ) + } + ) + @ApiResponses( + value = { + @ApiResponse(code = AUTHENTICATION_ERROR_CODE, message = AUTHENTICATION_ERROR_MESSAGE), + @ApiResponse(code = AUTHORIZATION_ERROR_CODE, message = AUTHORIZATION_ERROR_MESSAGE), + @ApiResponse(code = SERVER_ERROR_CODE, message = SERVER_ERROR_MESSAGE) + } + ) + // @formatter:on + public ResponseEntity queryToscaServiceTemplateJsonSchema( + @RequestHeader(name = REQUEST_ID_NAME, required = false) @ApiParam(REQUEST_ID_PARAM_DESCRIPTION) UUID requestId, + @ApiParam( + value = "Section of Template schema is desired for", + required = false) @RequestParam(value = "section", required = false, defaultValue = "all") String section) + throws PfModelException { + + return ResponseEntity.ok().body(provider.getToscaServiceTemplateSchema(section)); + } + + /** + * Retrieves the Common or Instance Properties for the specified Tosca Service Template. + * + * @param requestId request ID used in ONAP logging + * @param common a flag, true to get common properties, false to get instance properties + * @param name the name of the tosca service template to retrieve + * @param version the version of the tosca service template to get + * @return the specified tosca service template or section Json Schema + * @throws PfModelException on errors getting the Common or Instance Properties + * @throws AutomationCompositionException on error getting the Common or Instance Properties + */ + // @formatter:off + @GetMapping(value = "/commission/getCommonOrInstanceProperties", + produces = {MediaType.APPLICATION_JSON_VALUE, APPLICATION_YAML}) + @ApiOperation(value = "Query details of the requested tosca service template common or instance properties", + notes = "Queries details of the requested commissioned tosca service template json common" + + "or instance properties, returning all tosca service template common or instance property details", + response = ToscaServiceTemplate.class, + tags = {"Clamp Automation Composition Commissioning API"}, + authorizations = @Authorization(value = AUTHORIZATION_TYPE), + responseHeaders = { + @ResponseHeader( + name = VERSION_MINOR_NAME, description = VERSION_MINOR_DESCRIPTION, + response = String.class), + @ResponseHeader(name = VERSION_PATCH_NAME, description = VERSION_PATCH_DESCRIPTION, + response = String.class), + @ResponseHeader(name = VERSION_LATEST_NAME, description = VERSION_LATEST_DESCRIPTION, + response = String.class), + @ResponseHeader(name = REQUEST_ID_NAME, description = REQUEST_ID_HDR_DESCRIPTION, + response = UUID.class)}, + extensions = { + @Extension + ( + name = EXTENSION_NAME, + properties = { + @ExtensionProperty(name = API_VERSION_NAME, value = API_VERSION), + @ExtensionProperty(name = LAST_MOD_NAME, value = LAST_MOD_RELEASE) + } + ) + } + ) + @ApiResponses( + value = { + @ApiResponse(code = AUTHENTICATION_ERROR_CODE, message = AUTHENTICATION_ERROR_MESSAGE), + @ApiResponse(code = AUTHORIZATION_ERROR_CODE, message = AUTHORIZATION_ERROR_MESSAGE), + @ApiResponse(code = SERVER_ERROR_CODE, message = SERVER_ERROR_MESSAGE) + } + ) + // @formatter:on + public ResponseEntity> queryToscaServiceCommonOrInstanceProperties( + @RequestHeader(name = REQUEST_ID_NAME, required = false) @ApiParam(REQUEST_ID_PARAM_DESCRIPTION) UUID requestId, + @ApiParam( + value = "Flag, true for common properties, false for instance", + required = false) @RequestParam(value = "common", defaultValue = "false", required = false) boolean common, + @ApiParam(value = "Tosca service template name", required = false) @RequestParam( + value = "name", + required = false) String name, + @ApiParam(value = "Tosca service template version", required = false) @RequestParam( + value = "version", + required = false) String version) + throws PfModelException { + + return ResponseEntity.ok().body(provider.getNodeTemplatesWithCommonOrInstanceProperties(common, name, version)); + } + + /** + * Queries the elements of a specific automation composition. + * + * @param requestId request ID used in ONAP logging + * @param name the name of the automation composition definition to get + * @param version the version of the automation composition definition to get + * @return the automation composition element definitions + * @throws PfModelException on errors getting the elements of a specific automation composition + */ + // @formatter:off + @GetMapping(value = "/commission/elements", + produces = {MediaType.APPLICATION_JSON_VALUE, APPLICATION_YAML}) + @ApiOperation(value = "Query details of the requested commissioned automation composition element definitions", + notes = "Queries details of the requested commissioned automation composition element definitions, " + + "returning all automation composition elements' details", + response = ToscaNodeTemplate.class, + tags = {TAGS}, + authorizations = @Authorization(value = AUTHORIZATION_TYPE), + responseHeaders = { + @ResponseHeader( + name = VERSION_MINOR_NAME, description = VERSION_MINOR_DESCRIPTION, + response = String.class), + @ResponseHeader(name = VERSION_PATCH_NAME, description = VERSION_PATCH_DESCRIPTION, + response = String.class), + @ResponseHeader(name = VERSION_LATEST_NAME, description = VERSION_LATEST_DESCRIPTION, + response = String.class), + @ResponseHeader(name = REQUEST_ID_NAME, description = REQUEST_ID_HDR_DESCRIPTION, + response = UUID.class)}, + extensions = { + @Extension + ( + name = EXTENSION_NAME, + properties = { + @ExtensionProperty(name = API_VERSION_NAME, value = API_VERSION), + @ExtensionProperty(name = LAST_MOD_NAME, value = LAST_MOD_RELEASE) + } + ) + } + ) + @ApiResponses( + value = { + @ApiResponse(code = AUTHENTICATION_ERROR_CODE, message = AUTHENTICATION_ERROR_MESSAGE), + @ApiResponse(code = AUTHORIZATION_ERROR_CODE, message = AUTHORIZATION_ERROR_MESSAGE), + @ApiResponse(code = SERVER_ERROR_CODE, message = SERVER_ERROR_MESSAGE) + } + ) + // @formatter:on + public ResponseEntity> queryElements( + @RequestHeader(name = REQUEST_ID_NAME, required = false) @ApiParam(REQUEST_ID_PARAM_DESCRIPTION) UUID requestId, + @ApiParam(value = "Automation composition definition name", required = false) @RequestParam( + value = "name", + required = false) String name, + @ApiParam(value = "Automation composition definition version", required = false) @RequestParam( + value = "version", + required = false) String version) + throws PfModelException { + + List nodeTemplate = provider.getAutomationCompositionDefinitions(name, version); + // Prevent ambiguous queries with multiple returns + if (nodeTemplate.size() > 1) { + throw new PfModelException(Status.NOT_ACCEPTABLE, "Multiple automation compositions are not supported"); + } + + List response = provider.getAutomationCompositionElementDefinitions(nodeTemplate.get(0)); + return ResponseEntity.ok().body(response); + } +} diff --git a/runtime-acm/src/main/java/org/onap/policy/clamp/acm/runtime/main/rest/InstantiationController.java b/runtime-acm/src/main/java/org/onap/policy/clamp/acm/runtime/main/rest/InstantiationController.java new file mode 100644 index 000000000..dc56c77e7 --- /dev/null +++ b/runtime-acm/src/main/java/org/onap/policy/clamp/acm/runtime/main/rest/InstantiationController.java @@ -0,0 +1,623 @@ +/*- + * ============LICENSE_START======================================================= + * Copyright (C) 2021 Nordix Foundation. + * Modifications Copyright (C) 2021 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * SPDX-License-Identifier: Apache-2.0 + * ============LICENSE_END========================================================= + */ + +package org.onap.policy.clamp.acm.runtime.main.rest; + +import io.swagger.annotations.ApiOperation; +import io.swagger.annotations.ApiParam; +import io.swagger.annotations.ApiResponse; +import io.swagger.annotations.ApiResponses; +import io.swagger.annotations.Authorization; +import io.swagger.annotations.Extension; +import io.swagger.annotations.ExtensionProperty; +import io.swagger.annotations.ResponseHeader; +import java.util.UUID; +import lombok.RequiredArgsConstructor; +import org.onap.policy.clamp.acm.runtime.instantiation.AutomationCompositionInstantiationProvider; +import org.onap.policy.clamp.acm.runtime.main.web.AbstractRestController; +import org.onap.policy.clamp.common.acm.exception.AutomationCompositionException; +import org.onap.policy.clamp.models.acm.concepts.AutomationCompositions; +import org.onap.policy.clamp.models.acm.messages.rest.instantiation.AutomationCompositionOrderStateResponse; +import org.onap.policy.clamp.models.acm.messages.rest.instantiation.AutomationCompositionPrimedResponse; +import org.onap.policy.clamp.models.acm.messages.rest.instantiation.InstancePropertiesResponse; +import org.onap.policy.clamp.models.acm.messages.rest.instantiation.InstantiationCommand; +import org.onap.policy.clamp.models.acm.messages.rest.instantiation.InstantiationResponse; +import org.onap.policy.models.base.PfModelException; +import org.onap.policy.models.tosca.authorative.concepts.ToscaServiceTemplate; +import org.springframework.http.MediaType; +import org.springframework.http.ResponseEntity; +import org.springframework.web.bind.annotation.DeleteMapping; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.PostMapping; +import org.springframework.web.bind.annotation.PutMapping; +import org.springframework.web.bind.annotation.RequestBody; +import org.springframework.web.bind.annotation.RequestHeader; +import org.springframework.web.bind.annotation.RequestParam; +import org.springframework.web.bind.annotation.RestController; + +/** + * Class to provide REST end points for creating, deleting, query and commanding a automation composition definition. + */ +@RestController +@RequiredArgsConstructor +public class InstantiationController extends AbstractRestController { + + private static final String TAGS = "Clamp Automation Composition Instantiation API"; + + // The Automation Composition provider for instantiation requests + private final AutomationCompositionInstantiationProvider provider; + + /** + * Creates a automation composition. + * + * @param requestId request ID used in ONAP logging + * @param automationCompositions the automation compositions + * @return a response + * @throws PfModelException on errors creating a automation composition + */ + // @formatter:off + @PostMapping(value = "/instantiation", + produces = {MediaType.APPLICATION_JSON_VALUE, APPLICATION_YAML}, + consumes = {MediaType.APPLICATION_JSON_VALUE, APPLICATION_YAML}) + @ApiOperation( + value = "Commissions automation composition definitions", + notes = "Commissions automation composition definitions, returning the automation composition IDs", + response = InstantiationResponse.class, + tags = {TAGS}, + authorizations = @Authorization(value = AUTHORIZATION_TYPE), + responseHeaders = { + @ResponseHeader( + name = VERSION_MINOR_NAME, + description = VERSION_MINOR_DESCRIPTION, + response = String.class), + @ResponseHeader( + name = VERSION_PATCH_NAME, + description = VERSION_PATCH_DESCRIPTION, + response = String.class), + @ResponseHeader( + name = VERSION_LATEST_NAME, + description = VERSION_LATEST_DESCRIPTION, + response = String.class), + @ResponseHeader( + name = REQUEST_ID_NAME, + description = REQUEST_ID_HDR_DESCRIPTION, + response = UUID.class) + }, + extensions = { + @Extension + ( + name = EXTENSION_NAME, + properties = { + @ExtensionProperty(name = API_VERSION_NAME, value = API_VERSION), + @ExtensionProperty(name = LAST_MOD_NAME, value = LAST_MOD_RELEASE) + } + ) + } + ) + @ApiResponses( + value = { + @ApiResponse(code = AUTHENTICATION_ERROR_CODE, message = AUTHENTICATION_ERROR_MESSAGE), + @ApiResponse(code = AUTHORIZATION_ERROR_CODE, message = AUTHORIZATION_ERROR_MESSAGE), + @ApiResponse(code = SERVER_ERROR_CODE, message = SERVER_ERROR_MESSAGE) + } + ) + // @formatter:on + public ResponseEntity create( + @RequestHeader(name = REQUEST_ID_NAME, required = false) @ApiParam(REQUEST_ID_PARAM_DESCRIPTION) UUID requestId, + @ApiParam( + value = "Entity Body of automation composition", + required = true) @RequestBody AutomationCompositions automationCompositions) + throws PfModelException { + + return ResponseEntity.ok().body(provider.createAutomationCompositions(automationCompositions)); + } + + /** + * Saves instance properties. + * + * @param requestId request ID used in ONAP logging + * @param body the body of automation composition following TOSCA definition + * @return a response + */ + // @formatter:off + @PostMapping(value = "/instanceProperties", + consumes = {MediaType.APPLICATION_JSON_VALUE, APPLICATION_YAML}, + produces = {MediaType.APPLICATION_JSON_VALUE, APPLICATION_YAML}) + @ApiOperation( + value = "Saves instance properties", + notes = "Saves instance properties, returning the saved instances properties and it's version", + response = InstancePropertiesResponse.class, + tags = {TAGS}, + authorizations = @Authorization(value = AUTHORIZATION_TYPE), + responseHeaders = { + @ResponseHeader( + name = VERSION_MINOR_NAME, + description = VERSION_MINOR_DESCRIPTION, + response = String.class), + @ResponseHeader( + name = VERSION_PATCH_NAME, + description = VERSION_PATCH_DESCRIPTION, + response = String.class), + @ResponseHeader( + name = VERSION_LATEST_NAME, + description = VERSION_LATEST_DESCRIPTION, + response = String.class), + @ResponseHeader( + name = REQUEST_ID_NAME, + description = REQUEST_ID_HDR_DESCRIPTION, + response = UUID.class) + }, + extensions = { + @Extension + ( + name = EXTENSION_NAME, + properties = { + @ExtensionProperty(name = API_VERSION_NAME, value = API_VERSION), + @ExtensionProperty(name = LAST_MOD_NAME, value = LAST_MOD_RELEASE) + } + ) + } + ) + @ApiResponses( + value = { + @ApiResponse(code = AUTHENTICATION_ERROR_CODE, message = AUTHENTICATION_ERROR_MESSAGE), + @ApiResponse(code = AUTHORIZATION_ERROR_CODE, message = AUTHORIZATION_ERROR_MESSAGE), + @ApiResponse(code = SERVER_ERROR_CODE, message = SERVER_ERROR_MESSAGE) + } + ) + // @formatter:on + public ResponseEntity createInstanceProperties( + @RequestHeader(name = REQUEST_ID_NAME, required = false) @ApiParam(REQUEST_ID_PARAM_DESCRIPTION) UUID requestId, + @ApiParam(value = "Body of instance properties", required = true) @RequestBody ToscaServiceTemplate body) + throws PfModelException { + + return ResponseEntity.ok().body(provider.createInstanceProperties(body)); + } + + /** + * Deletes a automation composition definition and instance properties. + * + * @param requestId request ID used in ONAP logging + * @param name the name of the automation composition to delete + * @param version the version of the automation composition to delete + * @return a response + * @throws PfModelException on errors deleting of automation composition and instance properties + */ + // @formatter:off + @DeleteMapping(value = "/instanceProperties", + produces = {MediaType.APPLICATION_JSON_VALUE, APPLICATION_YAML}) + @ApiOperation(value = "Delete a automation composition and instance properties", + notes = "Deletes a automation composition and instance properties, returning optional error details", + response = InstantiationResponse.class, + tags = {TAGS}, + authorizations = @Authorization(value = AUTHORIZATION_TYPE), + responseHeaders = { + @ResponseHeader( + name = VERSION_MINOR_NAME, + description = VERSION_MINOR_DESCRIPTION, + response = String.class), + @ResponseHeader( + name = VERSION_PATCH_NAME, + description = VERSION_PATCH_DESCRIPTION, + response = String.class), + @ResponseHeader( + name = VERSION_LATEST_NAME, + description = VERSION_LATEST_DESCRIPTION, + response = String.class), + @ResponseHeader( + name = REQUEST_ID_NAME, + description = REQUEST_ID_HDR_DESCRIPTION, + response = UUID.class)}, + extensions = { + @Extension + ( + name = EXTENSION_NAME, + properties = { + @ExtensionProperty(name = API_VERSION_NAME, value = API_VERSION), + @ExtensionProperty(name = LAST_MOD_NAME, value = LAST_MOD_RELEASE) + } + ) + } + ) + @ApiResponses( + value = { + @ApiResponse(code = AUTHENTICATION_ERROR_CODE, message = AUTHENTICATION_ERROR_MESSAGE), + @ApiResponse(code = AUTHORIZATION_ERROR_CODE, message = AUTHORIZATION_ERROR_MESSAGE), + @ApiResponse(code = SERVER_ERROR_CODE, message = SERVER_ERROR_MESSAGE) + } + ) + // @formatter:on + + public ResponseEntity deleteInstanceProperties( + @RequestHeader(name = REQUEST_ID_NAME, required = false) @ApiParam(REQUEST_ID_PARAM_DESCRIPTION) UUID requestId, + @ApiParam(value = "Automation composition definition name", required = true) @RequestParam("name") String name, + @ApiParam(value = "Automation composition definition version") @RequestParam( + value = "version", + required = true) String version) + throws PfModelException { + + return ResponseEntity.ok().body(provider.deleteInstanceProperties(name, version)); + } + + /** + * Queries details of all automation compositions. + * + * @param requestId request ID used in ONAP logging + * @param name the name of the automation composition to get, null for all automation compositions + * @param version the version of the automation composition to get, null for all automation compositions + * @return the automation compositions + * @throws PfModelException on errors getting commissioning of automation composition + */ + // @formatter:off + @GetMapping(value = "/instantiation", + produces = {MediaType.APPLICATION_JSON_VALUE, APPLICATION_YAML}) + @ApiOperation(value = "Query details of the requested automation compositions", + notes = "Queries details of the requested automation compositions, returning all composition details", + response = AutomationCompositions.class, + tags = {TAGS}, + authorizations = @Authorization(value = AUTHORIZATION_TYPE), + responseHeaders = { + @ResponseHeader( + name = VERSION_MINOR_NAME, description = VERSION_MINOR_DESCRIPTION, + response = String.class), + @ResponseHeader(name = VERSION_PATCH_NAME, description = VERSION_PATCH_DESCRIPTION, + response = String.class), + @ResponseHeader(name = VERSION_LATEST_NAME, description = VERSION_LATEST_DESCRIPTION, + response = String.class), + @ResponseHeader(name = REQUEST_ID_NAME, description = REQUEST_ID_HDR_DESCRIPTION, + response = UUID.class)}, + extensions = { + @Extension + ( + name = EXTENSION_NAME, + properties = { + @ExtensionProperty(name = API_VERSION_NAME, value = API_VERSION), + @ExtensionProperty(name = LAST_MOD_NAME, value = LAST_MOD_RELEASE) + } + ) + } + ) + @ApiResponses( + value = { + @ApiResponse(code = AUTHENTICATION_ERROR_CODE, message = AUTHENTICATION_ERROR_MESSAGE), + @ApiResponse(code = AUTHORIZATION_ERROR_CODE, message = AUTHORIZATION_ERROR_MESSAGE), + @ApiResponse(code = SERVER_ERROR_CODE, message = SERVER_ERROR_MESSAGE) + } + ) + // @formatter:on + public ResponseEntity query( + @RequestHeader(name = REQUEST_ID_NAME, required = false) @ApiParam(REQUEST_ID_PARAM_DESCRIPTION) UUID requestId, + @ApiParam(value = "Automation composition definition name", required = false) @RequestParam( + value = "name", + required = false) String name, + @ApiParam(value = "Automation composition definition version", required = false) @RequestParam( + value = "version", + required = false) String version) + throws PfModelException { + + return ResponseEntity.ok().body(provider.getAutomationCompositions(name, version)); + } + + /** + * Updates a automation composition. + * + * @param requestId request ID used in ONAP logging + * @param automationCompositions the automation compositions + * @return a response + * @throws PfModelException on errors updating of automation compositions + */ + // @formatter:off + @PutMapping(value = "/instantiation", + produces = {MediaType.APPLICATION_JSON_VALUE, APPLICATION_YAML}, + consumes = {MediaType.APPLICATION_JSON_VALUE, APPLICATION_YAML}) + @ApiOperation( + value = "Updates automation composition definitions", + notes = "Updates automation composition definitions, returning the updated composition definition IDs", + response = InstantiationResponse.class, + tags = {TAGS}, + authorizations = @Authorization(value = AUTHORIZATION_TYPE), + responseHeaders = { + @ResponseHeader( + name = VERSION_MINOR_NAME, + description = VERSION_MINOR_DESCRIPTION, + response = String.class), + @ResponseHeader( + name = VERSION_PATCH_NAME, + description = VERSION_PATCH_DESCRIPTION, + response = String.class), + @ResponseHeader( + name = VERSION_LATEST_NAME, + description = VERSION_LATEST_DESCRIPTION, + response = String.class), + @ResponseHeader( + name = REQUEST_ID_NAME, + description = REQUEST_ID_HDR_DESCRIPTION, + response = UUID.class) + }, + extensions = { + @Extension + ( + name = EXTENSION_NAME, + properties = { + @ExtensionProperty(name = API_VERSION_NAME, value = API_VERSION), + @ExtensionProperty(name = LAST_MOD_NAME, value = LAST_MOD_RELEASE) + } + ) + } + ) + @ApiResponses( + value = { + @ApiResponse(code = AUTHENTICATION_ERROR_CODE, message = AUTHENTICATION_ERROR_MESSAGE), + @ApiResponse(code = AUTHORIZATION_ERROR_CODE, message = AUTHORIZATION_ERROR_MESSAGE), + @ApiResponse(code = SERVER_ERROR_CODE, message = SERVER_ERROR_MESSAGE) + } + ) + // @formatter:on + public ResponseEntity update( + @RequestHeader(name = REQUEST_ID_NAME, required = false) @ApiParam(REQUEST_ID_PARAM_DESCRIPTION) UUID requestId, + @ApiParam( + value = "Entity Body of Automation Composition", + required = true) @RequestBody AutomationCompositions automationCompositions) + throws PfModelException { + + return ResponseEntity.ok().body(provider.updateAutomationCompositions(automationCompositions)); + } + + /** + * Deletes a automation composition definition. + * + * @param requestId request ID used in ONAP logging + * @param name the name of the automation composition to delete + * @param version the version of the automation composition to delete + * @return a response + * @throws PfModelException on errors deleting of automation composition + */ + // @formatter:off + @DeleteMapping(value = "/instantiation", + produces = {MediaType.APPLICATION_JSON_VALUE, APPLICATION_YAML}) + @ApiOperation(value = "Delete a automation composition", + notes = "Deletes a automation composition, returning optional error details", + response = InstantiationResponse.class, + tags = {TAGS}, + authorizations = @Authorization(value = AUTHORIZATION_TYPE), + responseHeaders = { + @ResponseHeader( + name = VERSION_MINOR_NAME, + description = VERSION_MINOR_DESCRIPTION, + response = String.class), + @ResponseHeader( + name = VERSION_PATCH_NAME, + description = VERSION_PATCH_DESCRIPTION, + response = String.class), + @ResponseHeader( + name = VERSION_LATEST_NAME, + description = VERSION_LATEST_DESCRIPTION, + response = String.class), + @ResponseHeader( + name = REQUEST_ID_NAME, + description = REQUEST_ID_HDR_DESCRIPTION, + response = UUID.class)}, + extensions = { + @Extension + ( + name = EXTENSION_NAME, + properties = { + @ExtensionProperty(name = API_VERSION_NAME, value = API_VERSION), + @ExtensionProperty(name = LAST_MOD_NAME, value = LAST_MOD_RELEASE) + } + ) + } + ) + @ApiResponses( + value = { + @ApiResponse(code = AUTHENTICATION_ERROR_CODE, message = AUTHENTICATION_ERROR_MESSAGE), + @ApiResponse(code = AUTHORIZATION_ERROR_CODE, message = AUTHORIZATION_ERROR_MESSAGE), + @ApiResponse(code = SERVER_ERROR_CODE, message = SERVER_ERROR_MESSAGE) + } + ) + // @formatter:on + + public ResponseEntity delete( + @RequestHeader(name = REQUEST_ID_NAME, required = false) @ApiParam(REQUEST_ID_PARAM_DESCRIPTION) UUID requestId, + @ApiParam(value = "Automation composition definition name", required = true) @RequestParam("name") String name, + @ApiParam(value = "Automation composition definition version") @RequestParam( + value = "version", + required = true) String version) + throws PfModelException { + + return ResponseEntity.ok().body(provider.deleteAutomationComposition(name, version)); + } + + /** + * Issues automation composition commands to automation compositions. + * + * @param requestId request ID used in ONAP logging + * @param command the command to issue to automation compositions + * @return the automation composition definitions + * @throws PfModelException on errors issuing a command + * @throws AutomationCompositionException on errors issuing a command + */ + // @formatter:off + @PutMapping(value = "/instantiation/command", + produces = {MediaType.APPLICATION_JSON_VALUE, APPLICATION_YAML}, + consumes = {MediaType.APPLICATION_JSON_VALUE, APPLICATION_YAML}) + @ApiOperation(value = "Issue a command to the requested automation compositions", + notes = "Issues a command to an automation composition, ordering a state change on the composition", + response = InstantiationResponse.class, + tags = {TAGS}, + authorizations = @Authorization(value = AUTHORIZATION_TYPE), + responseHeaders = { + @ResponseHeader( + name = VERSION_MINOR_NAME, description = VERSION_MINOR_DESCRIPTION, + response = String.class), + @ResponseHeader(name = VERSION_PATCH_NAME, description = VERSION_PATCH_DESCRIPTION, + response = String.class), + @ResponseHeader(name = VERSION_LATEST_NAME, description = VERSION_LATEST_DESCRIPTION, + response = String.class), + @ResponseHeader(name = REQUEST_ID_NAME, description = REQUEST_ID_HDR_DESCRIPTION, + response = UUID.class)}, + extensions = { + @Extension + ( + name = EXTENSION_NAME, + properties = { + @ExtensionProperty(name = API_VERSION_NAME, value = API_VERSION), + @ExtensionProperty(name = LAST_MOD_NAME, value = LAST_MOD_RELEASE) + } + ) + } + ) + @ApiResponses( + value = { + @ApiResponse(code = AUTHENTICATION_ERROR_CODE, message = AUTHENTICATION_ERROR_MESSAGE), + @ApiResponse(code = AUTHORIZATION_ERROR_CODE, message = AUTHORIZATION_ERROR_MESSAGE), + @ApiResponse(code = SERVER_ERROR_CODE, message = SERVER_ERROR_MESSAGE) + } + ) + // @formatter:on + public ResponseEntity issueAutomationCompositionCommand( + @RequestHeader(name = REQUEST_ID_NAME, required = false) @ApiParam(REQUEST_ID_PARAM_DESCRIPTION) UUID requestId, + @ApiParam( + value = "Entity Body of automation composition command", + required = true) @RequestBody InstantiationCommand command) + throws AutomationCompositionException, PfModelException { + + return ResponseEntity.accepted().body(provider.issueAutomationCompositionCommand(command)); + } + + /** + * Queries details of all automation compositions. + * + * @param requestId request ID used in ONAP logging + * @param name the name of the automation composition to get, null for all automation compositions + * @param version the version of the automation composition to get, null for all automation compositions + * @return the automation compositions + * @throws PfModelException on errors getting commissioning of automation composition + */ + // @formatter:off + @GetMapping(value = "/instantiationState", + produces = {MediaType.APPLICATION_JSON_VALUE, APPLICATION_YAML}) + @ApiOperation(value = "Query details of the requested automation compositions", + notes = "Queries details of requested automation compositions, returning all automation composition details", + response = AutomationCompositions.class, + tags = {TAGS}, + authorizations = @Authorization(value = AUTHORIZATION_TYPE), + responseHeaders = { + @ResponseHeader( + name = VERSION_MINOR_NAME, description = VERSION_MINOR_DESCRIPTION, + response = String.class), + @ResponseHeader(name = VERSION_PATCH_NAME, description = VERSION_PATCH_DESCRIPTION, + response = String.class), + @ResponseHeader(name = VERSION_LATEST_NAME, description = VERSION_LATEST_DESCRIPTION, + response = String.class), + @ResponseHeader(name = REQUEST_ID_NAME, description = REQUEST_ID_HDR_DESCRIPTION, + response = UUID.class)}, + extensions = { + @Extension + ( + name = EXTENSION_NAME, + properties = { + @ExtensionProperty(name = API_VERSION_NAME, value = API_VERSION), + @ExtensionProperty(name = LAST_MOD_NAME, value = LAST_MOD_RELEASE) + } + ) + } + ) + @ApiResponses( + value = { + @ApiResponse(code = AUTHENTICATION_ERROR_CODE, message = AUTHENTICATION_ERROR_MESSAGE), + @ApiResponse(code = AUTHORIZATION_ERROR_CODE, message = AUTHORIZATION_ERROR_MESSAGE), + @ApiResponse(code = SERVER_ERROR_CODE, message = SERVER_ERROR_MESSAGE) + } + ) + // @formatter:on + public ResponseEntity getInstantiationOrderState( + @RequestHeader(name = REQUEST_ID_NAME, required = false) @ApiParam(REQUEST_ID_PARAM_DESCRIPTION) UUID requestId, + @ApiParam(value = "Automation composition name", required = false) @RequestParam( + value = "name", + required = false) String name, + @ApiParam(value = "Automation composition version", required = false) @RequestParam( + value = "version", + required = false) String version) + throws PfModelException { + + return ResponseEntity.ok().body(provider.getInstantiationOrderState(name, version)); + } + + /** + * Queries Primed/De-Primed status of a automation composition. + * + * @param requestId request ID used in ONAP logging + * @param name the name of the automation composition to get, null for all automation compositions + * @param version the version of the automation composition to get, null for all automation compositions + * @return the automation compositions + * @throws PfModelException on errors getting priming of automation composition + */ + // @formatter:off + @GetMapping(value = "/automationCompositionPriming", + produces = {MediaType.APPLICATION_JSON_VALUE, APPLICATION_YAML}) + @ApiOperation(value = "Query priming details of the requested automation compositions", + notes = "Queries priming details of requested automation compositions, returning primed/deprimed compositions", + response = AutomationCompositionPrimedResponse.class, + tags = {TAGS}, + authorizations = @Authorization(value = AUTHORIZATION_TYPE), + responseHeaders = { + @ResponseHeader( + name = VERSION_MINOR_NAME, description = VERSION_MINOR_DESCRIPTION, + response = String.class), + @ResponseHeader(name = VERSION_PATCH_NAME, description = VERSION_PATCH_DESCRIPTION, + response = String.class), + @ResponseHeader(name = VERSION_LATEST_NAME, description = VERSION_LATEST_DESCRIPTION, + response = String.class), + @ResponseHeader(name = REQUEST_ID_NAME, description = REQUEST_ID_HDR_DESCRIPTION, + response = UUID.class)}, + extensions = { + @Extension + ( + name = EXTENSION_NAME, + properties = { + @ExtensionProperty(name = API_VERSION_NAME, value = API_VERSION), + @ExtensionProperty(name = LAST_MOD_NAME, value = LAST_MOD_RELEASE) + } + ) + } + ) + @ApiResponses( + value = { + @ApiResponse(code = AUTHENTICATION_ERROR_CODE, message = AUTHENTICATION_ERROR_MESSAGE), + @ApiResponse(code = AUTHORIZATION_ERROR_CODE, message = AUTHORIZATION_ERROR_MESSAGE), + @ApiResponse(code = SERVER_ERROR_CODE, message = SERVER_ERROR_MESSAGE) + } + ) + // @formatter:on + public ResponseEntity getAutomationCompositionPriming( + @RequestHeader(name = REQUEST_ID_NAME, required = false) @ApiParam(REQUEST_ID_PARAM_DESCRIPTION) UUID requestId, + @ApiParam(value = "Automation composition definition name", required = false) @RequestParam( + value = "name", + required = false) String name, + @ApiParam(value = "Automation composition definition version", required = false) @RequestParam( + value = "version", + required = false) String version) + throws PfModelException { + + return ResponseEntity.ok().body(provider.getAutomationCompositionPriming(name, version)); + } +} diff --git a/runtime-acm/src/main/java/org/onap/policy/clamp/acm/runtime/main/rest/MonitoringQueryController.java b/runtime-acm/src/main/java/org/onap/policy/clamp/acm/runtime/main/rest/MonitoringQueryController.java new file mode 100644 index 000000000..30c1d5dc9 --- /dev/null +++ b/runtime-acm/src/main/java/org/onap/policy/clamp/acm/runtime/main/rest/MonitoringQueryController.java @@ -0,0 +1,334 @@ +/*- + * ============LICENSE_START======================================================= + * Copyright (C) 2021 Nordix Foundation. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * SPDX-License-Identifier: Apache-2.0 + * ============LICENSE_END========================================================= + */ + +package org.onap.policy.clamp.acm.runtime.main.rest; + +import io.swagger.annotations.ApiOperation; +import io.swagger.annotations.ApiParam; +import io.swagger.annotations.ApiResponse; +import io.swagger.annotations.ApiResponses; +import io.swagger.annotations.Authorization; +import io.swagger.annotations.Extension; +import io.swagger.annotations.ExtensionProperty; +import io.swagger.annotations.ResponseHeader; +import java.time.Instant; +import java.util.UUID; +import lombok.RequiredArgsConstructor; +import org.onap.policy.clamp.acm.runtime.main.web.AbstractRestController; +import org.onap.policy.clamp.acm.runtime.monitoring.MonitoringProvider; +import org.onap.policy.clamp.models.acm.concepts.AcElementStatisticsList; +import org.onap.policy.clamp.models.acm.concepts.ParticipantStatisticsList; +import org.onap.policy.models.base.PfModelException; +import org.springframework.http.MediaType; +import org.springframework.http.ResponseEntity; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.RequestHeader; +import org.springframework.web.bind.annotation.RequestParam; +import org.springframework.web.bind.annotation.RestController; + +/** + * This class handles REST endpoints for ACM Statistics monitoring. + */ +@RestController +@RequiredArgsConstructor +public class MonitoringQueryController extends AbstractRestController { + + private static final String TAGS = "Clamp Automation Composition Monitoring API"; + private final MonitoringProvider provider; + + /** + * Queries details of automation composition participants statistics. + * + * @param requestId request ID used in ONAP logging + * @param name the name of the participant to get, null for all participants statistics + * @param version the version of the participant to get, null for all participants with the given name + * @param recordCount the record count to be fetched + * @param startTime the time from which to get statistics + * @param endTime the time to which to get statistics + * @return the participant statistics + */ + // @formatter:off + @GetMapping(value = "/monitoring/participant", + produces = {MediaType.APPLICATION_JSON_VALUE, APPLICATION_YAML}) + @ApiOperation(value = "Query details of the requested participant stats", + notes = "Queries details of the requested participant stats, returning all participant stats", + response = ParticipantStatisticsList.class, + tags = {TAGS}, + authorizations = @Authorization(value = AUTHORIZATION_TYPE), + responseHeaders = { + @ResponseHeader( + name = VERSION_MINOR_NAME, description = VERSION_MINOR_DESCRIPTION, + response = String.class), + @ResponseHeader(name = VERSION_PATCH_NAME, description = VERSION_PATCH_DESCRIPTION, + response = String.class), + @ResponseHeader(name = VERSION_LATEST_NAME, description = VERSION_LATEST_DESCRIPTION, + response = String.class), + @ResponseHeader(name = REQUEST_ID_NAME, description = REQUEST_ID_HDR_DESCRIPTION, + response = UUID.class)}, + extensions = { + @Extension + ( + name = EXTENSION_NAME, + properties = { + @ExtensionProperty(name = API_VERSION_NAME, value = API_VERSION), + @ExtensionProperty(name = LAST_MOD_NAME, value = LAST_MOD_RELEASE) + } + ) + } + ) + @ApiResponses( + value = { + @ApiResponse(code = AUTHENTICATION_ERROR_CODE, message = AUTHENTICATION_ERROR_MESSAGE), + @ApiResponse(code = AUTHORIZATION_ERROR_CODE, message = AUTHORIZATION_ERROR_MESSAGE), + @ApiResponse(code = SERVER_ERROR_CODE, message = SERVER_ERROR_MESSAGE) + } + ) + // @formatter:on + public ResponseEntity queryParticipantStatistics( + @RequestHeader(name = REQUEST_ID_NAME, required = false) @ApiParam(REQUEST_ID_PARAM_DESCRIPTION) UUID requestId, + @ApiParam(value = "Automation composition participant name") @RequestParam( + value = "name", + required = false) final String name, + @ApiParam(value = "Automation composition participant version", required = false) @RequestParam( + value = "version", + required = false) final String version, + @ApiParam(value = "Record count", required = false) @RequestParam( + value = "recordCount", + required = false, + defaultValue = "0") final int recordCount, + @ApiParam(value = "start time", required = false) @RequestParam( + value = "startTime", + required = false) final String startTime, + @ApiParam(value = "end time", required = false) @RequestParam( + value = "endTime", + required = false) final String endTime) { + + Instant startTimestamp = null; + Instant endTimestamp = null; + + if (startTime != null) { + startTimestamp = Instant.parse(startTime); + } + if (endTime != null) { + endTimestamp = Instant.parse(endTime); + } + return ResponseEntity.ok().body( + provider.fetchFilteredParticipantStatistics(name, version, recordCount, startTimestamp, endTimestamp)); + } + + /** + * Queries details of all participant statistics per automation composition. + * + * @param requestId request ID used in ONAP logging + * @param name the name of the automation composition + * @param version version of the automation composition + * @return the automation composition element statistics + */ + // @formatter:off + @GetMapping(value = "/monitoring/participants/automationcomposition", + produces = {MediaType.APPLICATION_JSON_VALUE, APPLICATION_YAML}) + @ApiOperation(value = "Query details of all the participant stats in a automation composition", + notes = "Queries details of the participant stats, returning all participant stats", + response = AcElementStatisticsList.class, + tags = {TAGS}, + authorizations = @Authorization(value = AUTHORIZATION_TYPE), + responseHeaders = { + @ResponseHeader( + name = VERSION_MINOR_NAME, description = VERSION_MINOR_DESCRIPTION, + response = String.class), + @ResponseHeader(name = VERSION_PATCH_NAME, description = VERSION_PATCH_DESCRIPTION, + response = String.class), + @ResponseHeader(name = VERSION_LATEST_NAME, description = VERSION_LATEST_DESCRIPTION, + response = String.class), + @ResponseHeader(name = REQUEST_ID_NAME, description = REQUEST_ID_HDR_DESCRIPTION, + response = UUID.class)}, + extensions = { + @Extension + ( + name = EXTENSION_NAME, + properties = { + @ExtensionProperty(name = API_VERSION_NAME, value = API_VERSION), + @ExtensionProperty(name = LAST_MOD_NAME, value = LAST_MOD_RELEASE) + } + ) + }) + @ApiResponses( + value = { + @ApiResponse(code = AUTHENTICATION_ERROR_CODE, message = AUTHENTICATION_ERROR_MESSAGE), + @ApiResponse(code = AUTHORIZATION_ERROR_CODE, message = AUTHORIZATION_ERROR_MESSAGE), + @ApiResponse(code = SERVER_ERROR_CODE, message = SERVER_ERROR_MESSAGE) + } + ) + // @formatter:on + public ResponseEntity queryParticipantStatisticsPerAutomationComposition( + @RequestHeader(name = REQUEST_ID_NAME, required = false) @ApiParam(REQUEST_ID_PARAM_DESCRIPTION) UUID requestId, + @ApiParam(value = "Automation composition name", required = true) @RequestParam( + value = "name", + required = false) final String name, + @ApiParam(value = "Automation composition version", required = true) @RequestParam( + value = "version", + required = false) final String version) { + + return ResponseEntity.ok().body(provider.fetchParticipantStatsPerAutomationComposition(name, version)); + } + + /** + * Queries details of all automation composition element statistics per automation composition. + * + * @param requestId request ID used in ONAP logging + * @param name the name of the automation composition + * @param version version of the automation composition + * @return the automation composition element statistics + */ + // @formatter:off + @GetMapping(value = "/monitoring/acelements/automationcomposition", + produces = {MediaType.APPLICATION_JSON_VALUE, APPLICATION_YAML}) + @ApiOperation(value = "Query details of the requested acElement stats in a automation composition", + notes = "Queries details of the requested acElement stats, returning all acElement stats", + response = AcElementStatisticsList.class, + tags = {TAGS}, + authorizations = @Authorization(value = AUTHORIZATION_TYPE), + responseHeaders = { + @ResponseHeader( + name = VERSION_MINOR_NAME, description = VERSION_MINOR_DESCRIPTION, + response = String.class), + @ResponseHeader(name = VERSION_PATCH_NAME, description = VERSION_PATCH_DESCRIPTION, + response = String.class), + @ResponseHeader(name = VERSION_LATEST_NAME, description = VERSION_LATEST_DESCRIPTION, + response = String.class), + @ResponseHeader(name = REQUEST_ID_NAME, description = REQUEST_ID_HDR_DESCRIPTION, + response = UUID.class)}, + extensions = { + @Extension + ( + name = EXTENSION_NAME, + properties = { + @ExtensionProperty(name = API_VERSION_NAME, value = API_VERSION), + @ExtensionProperty(name = LAST_MOD_NAME, value = LAST_MOD_RELEASE) + } + ) + }) + @ApiResponses( + value = { + @ApiResponse(code = AUTHENTICATION_ERROR_CODE, message = AUTHENTICATION_ERROR_MESSAGE), + @ApiResponse(code = AUTHORIZATION_ERROR_CODE, message = AUTHORIZATION_ERROR_MESSAGE), + @ApiResponse(code = SERVER_ERROR_CODE, message = SERVER_ERROR_MESSAGE) + } + ) + // @formatter:on + public ResponseEntity queryElementStatisticsPerAutomationComposition( + @RequestHeader(name = REQUEST_ID_NAME, required = false) @ApiParam(REQUEST_ID_PARAM_DESCRIPTION) UUID requestId, + @ApiParam(value = "Automation composition name", required = true) @RequestParam( + value = "name", + required = false) final String name, + @ApiParam(value = "Automation composition version", required = true) @RequestParam( + value = "version", + required = false) final String version) { + + return ResponseEntity.ok().body(provider.fetchAcElementStatsPerAutomationComposition(name, version)); + } + + /** + * Queries details of all automation composition element statistics per automation composition. + * + * @param requestId request ID used in ONAP logging + * @param name the name of the automation composition + * @param version version of the automation composition + * @param id Id of the automation composition element + * @param recordCount the record count to be fetched + * @param startTime the time from which to get statistics + * @param endTime the time to which to get statistics + * @return the automation composition element statistics + * @throws PfModelException on errors getting details of all automation composition element statistics per + * automation composition + */ + // @formatter:off + @GetMapping(value = "/monitoring/acelement", + produces = {MediaType.APPLICATION_JSON_VALUE, APPLICATION_YAML}) + @ApiOperation(value = "Query details of the requested acElement stats", + notes = "Queries details of the requested acElement stats, returning all acElement stats", + response = AcElementStatisticsList.class, + tags = {TAGS}, + authorizations = @Authorization(value = AUTHORIZATION_TYPE), + responseHeaders = { + @ResponseHeader( + name = VERSION_MINOR_NAME, description = VERSION_MINOR_DESCRIPTION, + response = String.class), + @ResponseHeader(name = VERSION_PATCH_NAME, description = VERSION_PATCH_DESCRIPTION, + response = String.class), + @ResponseHeader(name = VERSION_LATEST_NAME, description = VERSION_LATEST_DESCRIPTION, + response = String.class), + @ResponseHeader(name = REQUEST_ID_NAME, description = REQUEST_ID_HDR_DESCRIPTION, + response = UUID.class)}, + extensions = { + @Extension + ( + name = EXTENSION_NAME, + properties = { + @ExtensionProperty(name = API_VERSION_NAME, value = API_VERSION), + @ExtensionProperty(name = LAST_MOD_NAME, value = LAST_MOD_RELEASE) + } + ) + }) + @ApiResponses( + value = { + @ApiResponse(code = AUTHENTICATION_ERROR_CODE, message = AUTHENTICATION_ERROR_MESSAGE), + @ApiResponse(code = AUTHORIZATION_ERROR_CODE, message = AUTHORIZATION_ERROR_MESSAGE), + @ApiResponse(code = SERVER_ERROR_CODE, message = SERVER_ERROR_MESSAGE) + } + ) + // @formatter:on + public ResponseEntity queryElementStatistics( + @RequestHeader(name = REQUEST_ID_NAME, required = false) @ApiParam(REQUEST_ID_PARAM_DESCRIPTION) UUID requestId, + @ApiParam(value = "Participant name", required = true) @RequestParam( + value = "name", + required = false) final String name, + @ApiParam(value = "Participant version", required = true) @RequestParam( + value = "version", + required = false) final String version, + @ApiParam(value = "Record count", required = false) @RequestParam( + value = "recordCount", + required = false, + defaultValue = "0") final int recordCount, + @ApiParam(value = "Automation composition element id", required = false) @RequestParam( + value = "id", + required = false) final String id, + @ApiParam(value = "start time", required = false) @RequestParam( + value = "startTime", + required = false) final String startTime, + @ApiParam(value = "end time", required = false) @RequestParam( + value = "endTime", + required = false) final String endTime) + throws PfModelException { + + Instant startTimestamp = null; + Instant endTimestamp = null; + + if (startTime != null) { + startTimestamp = Instant.parse(startTime); + } + if (endTime != null) { + endTimestamp = Instant.parse(endTime); + } + return ResponseEntity.ok().body( + provider.fetchFilteredAcElementStatistics(name, version, id, startTimestamp, endTimestamp, recordCount)); + } + +} diff --git a/runtime-acm/src/main/java/org/onap/policy/clamp/acm/runtime/main/web/AbstractRestController.java b/runtime-acm/src/main/java/org/onap/policy/clamp/acm/runtime/main/web/AbstractRestController.java new file mode 100644 index 000000000..7907de7be --- /dev/null +++ b/runtime-acm/src/main/java/org/onap/policy/clamp/acm/runtime/main/web/AbstractRestController.java @@ -0,0 +1,91 @@ +/*- + * ============LICENSE_START======================================================= + * Copyright (C) 2021 Nordix Foundation. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * SPDX-License-Identifier: Apache-2.0 + * ============LICENSE_END========================================================= + */ + +package org.onap.policy.clamp.acm.runtime.main.web; + +import io.swagger.annotations.Api; +import io.swagger.annotations.BasicAuthDefinition; +import io.swagger.annotations.Info; +import io.swagger.annotations.SecurityDefinition; +import io.swagger.annotations.SwaggerDefinition; +import io.swagger.annotations.Tag; +import java.net.HttpURLConnection; +import javax.ws.rs.core.MediaType; +import org.springframework.web.bind.annotation.RequestMapping; + +/** + * Common superclass to provide REST endpoints for the participant simulator. + */ +// @formatter:off +@RequestMapping(value = "/v2", produces = {MediaType.APPLICATION_JSON, AbstractRestController.APPLICATION_YAML}) +@Api(value = "Automation Composition Commissioning API") +@SwaggerDefinition( + info = @Info(description = + "Automation Composition Service", version = "v1.0", + title = "Automation Composition"), + consumes = {MediaType.APPLICATION_JSON, AbstractRestController.APPLICATION_YAML}, + produces = {MediaType.APPLICATION_JSON, AbstractRestController.APPLICATION_YAML}, + schemes = {SwaggerDefinition.Scheme.HTTP, SwaggerDefinition.Scheme.HTTPS}, + tags = {@Tag(name = "automationcomposition", description = "Automation Composition Service")}, + securityDefinition = @SecurityDefinition(basicAuthDefinitions = {@BasicAuthDefinition(key = "basicAuth")})) +// @formatter:on +public abstract class AbstractRestController { + public static final String APPLICATION_YAML = "application/yaml"; + + public static final String EXTENSION_NAME = "interface info"; + + public static final String API_VERSION_NAME = "api-version"; + public static final String API_VERSION = "1.0.0"; + + public static final String LAST_MOD_NAME = "last-mod-release"; + public static final String LAST_MOD_RELEASE = "Istanbul"; + + public static final String VERSION_MINOR_NAME = "X-MinorVersion"; + public static final String VERSION_MINOR_DESCRIPTION = + "Used to request or communicate a MINOR version back from the client" + + " to the server, and from the server back to the client"; + + public static final String VERSION_PATCH_NAME = "X-PatchVersion"; + public static final String VERSION_PATCH_DESCRIPTION = "Used only to communicate a PATCH version in a response for" + + " troubleshooting purposes only, and will not be provided by" + " the client on request"; + + public static final String VERSION_LATEST_NAME = "X-LatestVersion"; + public static final String VERSION_LATEST_DESCRIPTION = "Used only to communicate an API's latest version"; + + public static final String REQUEST_ID_NAME = "X-ONAP-RequestID"; + public static final String REQUEST_ID_HDR_DESCRIPTION = "Used to track REST transactions for logging purpose"; + public static final String REQUEST_ID_PARAM_DESCRIPTION = "RequestID for http transaction"; + + public static final String AUTHORIZATION_TYPE = "basicAuth"; + + public static final int AUTHENTICATION_ERROR_CODE = HttpURLConnection.HTTP_UNAUTHORIZED; + public static final int AUTHORIZATION_ERROR_CODE = HttpURLConnection.HTTP_FORBIDDEN; + public static final int SERVER_ERROR_CODE = HttpURLConnection.HTTP_INTERNAL_ERROR; + + public static final String AUTHENTICATION_ERROR_MESSAGE = "Authentication Error"; + public static final String AUTHORIZATION_ERROR_MESSAGE = "Authorization Error"; + public static final String SERVER_ERROR_MESSAGE = "Internal Server Error"; + + /** + * Constructor. + */ + protected AbstractRestController() { + } +} diff --git a/runtime-acm/src/main/java/org/onap/policy/clamp/acm/runtime/main/web/AutomationConfiguraitonAafFilter.java b/runtime-acm/src/main/java/org/onap/policy/clamp/acm/runtime/main/web/AutomationConfiguraitonAafFilter.java new file mode 100644 index 000000000..ed49e3b44 --- /dev/null +++ b/runtime-acm/src/main/java/org/onap/policy/clamp/acm/runtime/main/web/AutomationConfiguraitonAafFilter.java @@ -0,0 +1,38 @@ +/*- + * ============LICENSE_START======================================================= + * Copyright (C) 2021 Nordix Foundation. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * SPDX-License-Identifier: Apache-2.0 + * ============LICENSE_END========================================================= + */ + +package org.onap.policy.clamp.acm.runtime.main.web; + +import org.onap.policy.common.endpoints.http.server.aaf.AafGranularAuthFilter; +import org.onap.policy.common.utils.resources.MessageConstants; + +/** + * Class to manage AAF filters for the automation composition runtime component. + */ +public class AutomationConfiguraitonAafFilter extends AafGranularAuthFilter { + + public static final String AAF_NODETYPE = MessageConstants.POLICY_CLAMP; + public static final String AAF_ROOT_PERMISSION = DEFAULT_NAMESPACE + "." + AAF_NODETYPE; + + @Override + public String getPermissionTypeRoot() { + return AAF_ROOT_PERMISSION; + } +} diff --git a/runtime-acm/src/main/java/org/onap/policy/clamp/acm/runtime/main/web/GlobalControllerExceptionHandler.java b/runtime-acm/src/main/java/org/onap/policy/clamp/acm/runtime/main/web/GlobalControllerExceptionHandler.java new file mode 100644 index 000000000..fef358bb1 --- /dev/null +++ b/runtime-acm/src/main/java/org/onap/policy/clamp/acm/runtime/main/web/GlobalControllerExceptionHandler.java @@ -0,0 +1,67 @@ +/*- + * ============LICENSE_START======================================================= + * Copyright (C) 2021 Nordix Foundation. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * SPDX-License-Identifier: Apache-2.0 + * ============LICENSE_END========================================================= + */ + +package org.onap.policy.clamp.acm.runtime.main.web; + +import org.onap.policy.clamp.common.acm.exception.AutomationCompositionException; +import org.onap.policy.clamp.models.acm.messages.rest.SimpleResponse; +import org.onap.policy.clamp.models.acm.rest.RestUtils; +import org.onap.policy.models.base.PfModelException; +import org.onap.policy.models.base.PfModelRuntimeException; +import org.springframework.http.ResponseEntity; +import org.springframework.web.bind.annotation.ExceptionHandler; +import org.springframework.web.bind.annotation.RestControllerAdvice; + +@RestControllerAdvice +public class GlobalControllerExceptionHandler { + + /** + * Handle AutomationCompositionException. + * + * @param ex AutomationCompositionException + * @return ResponseEntity + */ + @ExceptionHandler(AutomationCompositionException.class) + public ResponseEntity handleBadRequest(AutomationCompositionException ex) { + return RestUtils.toSimpleResponse(ex); + } + + /** + * Handle PfModelRuntimeException. + * + * @param ex PfModelRuntimeException + * @return ResponseEntity + */ + @ExceptionHandler(PfModelRuntimeException.class) + public ResponseEntity handleBadRequest(PfModelRuntimeException ex) { + return RestUtils.toSimpleResponse(ex); + } + + /** + * Handle PfModelException. + * + * @param ex PfModelException + * @return ResponseEntity + */ + @ExceptionHandler(PfModelException.class) + public ResponseEntity handleBadRequest(PfModelException ex) { + return RestUtils.toSimpleResponse(ex); + } +} diff --git a/runtime-acm/src/main/java/org/onap/policy/clamp/acm/runtime/main/web/RuntimeErrorController.java b/runtime-acm/src/main/java/org/onap/policy/clamp/acm/runtime/main/web/RuntimeErrorController.java new file mode 100644 index 000000000..5eecb92dd --- /dev/null +++ b/runtime-acm/src/main/java/org/onap/policy/clamp/acm/runtime/main/web/RuntimeErrorController.java @@ -0,0 +1,104 @@ +/*- + * ============LICENSE_START======================================================= + * Copyright (C) 2021 Nordix Foundation. + * ================================================================================ + * Modifications Copyright (C) 2021 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * SPDX-License-Identifier: Apache-2.0 + * ============LICENSE_END========================================================= + */ + +package org.onap.policy.clamp.acm.runtime.main.web; + +import io.swagger.v3.oas.annotations.Hidden; +import java.util.Map; +import javax.servlet.RequestDispatcher; +import javax.servlet.http.HttpServletRequest; +import org.onap.policy.clamp.models.acm.messages.rest.SimpleResponse; +import org.onap.policy.clamp.models.acm.messages.rest.TypedSimpleResponse; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.beans.factory.annotation.Value; +import org.springframework.boot.web.error.ErrorAttributeOptions; +import org.springframework.boot.web.servlet.error.ErrorAttributes; +import org.springframework.boot.web.servlet.error.ErrorController; +import org.springframework.http.HttpStatus; +import org.springframework.http.MediaType; +import org.springframework.http.ResponseEntity; +import org.springframework.stereotype.Controller; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.context.request.ServletWebRequest; + +@Controller +@Hidden +public class RuntimeErrorController implements ErrorController { + + private static final Logger LOGGER = LoggerFactory.getLogger(RuntimeErrorController.class); + + private final ErrorAttributes errorAttributes; + + @Value("${server.error.path}") + private String path; + + /** + * Constructor. + * + * @param errorAttributes ErrorAttributes + */ + public RuntimeErrorController(ErrorAttributes errorAttributes) { + this.errorAttributes = errorAttributes; + } + + protected HttpStatus getStatus(HttpServletRequest request) { + Integer statusCode = (Integer) request.getAttribute(RequestDispatcher.ERROR_STATUS_CODE); + if (statusCode == null) { + return HttpStatus.INTERNAL_SERVER_ERROR; + } + try { + return HttpStatus.valueOf(statusCode); + } catch (Exception ex) { + LOGGER.error("statusCode {} Not Valid", statusCode, ex); + return HttpStatus.INTERNAL_SERVER_ERROR; + } + } + + /** + * Handle Errors not handled to GlobalControllerExceptionHandler. + * + * @param request HttpServletRequest + * @return ResponseEntity + */ + @RequestMapping(value = "${server.error.path}", produces = MediaType.APPLICATION_JSON_VALUE) + public ResponseEntity> handleError(HttpServletRequest request) { + Map map = this.errorAttributes.getErrorAttributes(new ServletWebRequest(request), + ErrorAttributeOptions.defaults()); + + var sb = new StringBuilder(); + final Object error = map.get("error"); + if (error != null) { + sb.append(error.toString()).append(" "); + } + final Object message = map.get("message"); + if (message != null) { + sb.append(message.toString()); + } + + TypedSimpleResponse resp = new TypedSimpleResponse<>(); + resp.setErrorDetails(sb.toString()); + + return ResponseEntity.status(getStatus(request)).body(resp); + + } +} diff --git a/runtime-acm/src/main/java/org/onap/policy/clamp/acm/runtime/monitoring/MonitoringProvider.java b/runtime-acm/src/main/java/org/onap/policy/clamp/acm/runtime/monitoring/MonitoringProvider.java new file mode 100644 index 000000000..2950ad9da --- /dev/null +++ b/runtime-acm/src/main/java/org/onap/policy/clamp/acm/runtime/monitoring/MonitoringProvider.java @@ -0,0 +1,247 @@ +/*- + * ============LICENSE_START======================================================= + * Copyright (C) 2021 Nordix Foundation. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * SPDX-License-Identifier: Apache-2.0 + * ============LICENSE_END========================================================= + */ + +package org.onap.policy.clamp.acm.runtime.monitoring; + +import java.time.Instant; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import lombok.AllArgsConstructor; +import lombok.NonNull; +import org.onap.policy.clamp.models.acm.concepts.AcElementStatistics; +import org.onap.policy.clamp.models.acm.concepts.AcElementStatisticsList; +import org.onap.policy.clamp.models.acm.concepts.AutomationCompositionElement; +import org.onap.policy.clamp.models.acm.concepts.ParticipantStatistics; +import org.onap.policy.clamp.models.acm.concepts.ParticipantStatisticsList; +import org.onap.policy.clamp.models.acm.persistence.provider.AcElementStatisticsProvider; +import org.onap.policy.clamp.models.acm.persistence.provider.AutomationCompositionProvider; +import org.onap.policy.clamp.models.acm.persistence.provider.ParticipantStatisticsProvider; +import org.onap.policy.models.base.PfModelException; +import org.onap.policy.models.base.PfModelRuntimeException; +import org.onap.policy.models.tosca.authorative.concepts.ToscaConceptIdentifier; +import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; + +/** + * This class provides information about statistics data of Automation Composition elements and Participants in database + * to callers. + */ +@Service +@Transactional +@AllArgsConstructor +public class MonitoringProvider { + + private static final String DESC_ORDER = "DESC"; + private final ParticipantStatisticsProvider participantStatisticsProvider; + private final AcElementStatisticsProvider acElementStatisticsProvider; + private final AutomationCompositionProvider automationCompositionProvider; + + /** + * Create participant statistics. + * + * @param participantStatistics the participant statistics + * @return the result of create operation + * @throws PfModelException on creation errors + */ + public ParticipantStatisticsList createParticipantStatistics(List participantStatistics) + throws PfModelException { + var participantStatisticsList = new ParticipantStatisticsList(); + participantStatisticsList + .setStatisticsList(participantStatisticsProvider.createParticipantStatistics(participantStatistics)); + + return participantStatisticsList; + } + + /** + * Create AcElement statistics. + * + * @param acElementStatisticsList the AcElement statistics + * @return the result of create operation + * @throws PfModelException on creation errors + */ + public AcElementStatisticsList createAcElementStatistics(List acElementStatisticsList) + throws PfModelException { + var elementStatisticsList = new AcElementStatisticsList(); + elementStatisticsList + .setAcElementStatistics(acElementStatisticsProvider.createAcElementStatistics(acElementStatisticsList)); + + return elementStatisticsList; + } + + /** + * Get participant statistics based on specific filters. + * + * @param name the name of the participant statistics to get, null to get all statistics + * @param version the version of the participant statistics to get, null to get all statistics + * @param recordCount number of records to be fetched. + * @param startTime start of the timestamp, from statistics to be filtered + * @param endTime end of the timestamp up to which statistics to be filtered + * @return the participant found + */ + @Transactional(readOnly = true) + public ParticipantStatisticsList fetchFilteredParticipantStatistics(@NonNull final String name, + final String version, int recordCount, Instant startTime, Instant endTime) { + var participantStatisticsList = new ParticipantStatisticsList(); + + // Additional parameters can be added in filterMap for filtering data. + Map filterMap = null; + participantStatisticsList.setStatisticsList(participantStatisticsProvider.getFilteredParticipantStatistics(name, + version, startTime, endTime, filterMap, DESC_ORDER, recordCount)); + + return participantStatisticsList; + } + + /** + * Get all participant statistics records found for a specific automation composition. + * + * @param automationCompositionName name of the automation composition + * @param automationCompositionVersion version of the automation composition + * @return All the participant statistics found + * @throws PfModelRuntimeException on errors getting participant statistics + */ + @Transactional(readOnly = true) + public ParticipantStatisticsList fetchParticipantStatsPerAutomationComposition( + @NonNull final String automationCompositionName, @NonNull final String automationCompositionVersion) { + var statisticsList = new ParticipantStatisticsList(); + List participantStatistics = new ArrayList<>(); + try { + // Fetch all participantIds for a specific automation composition + List participantIds = + getAllParticipantIdsPerAutomationComposition(automationCompositionName, automationCompositionVersion); + for (ToscaConceptIdentifier id : participantIds) { + participantStatistics.addAll(participantStatisticsProvider + .getFilteredParticipantStatistics(id.getName(), id.getVersion(), null, null, null, DESC_ORDER, 0)); + } + statisticsList.setStatisticsList(participantStatistics); + } catch (PfModelException e) { + throw new PfModelRuntimeException(e); + } + return statisticsList; + } + + /** + * Get AcElement statistics based on specific filters. + * + * @param name the name of the AcElement statistics to get, null to get all statistics + * @param version the version of the AcElement statistics to get, null to get all statistics + * @param id UUID of the automation composition element + * @param startTime start of the timestamp, from statistics to be filtered + * @param endTime end of the timestamp up to which statistics to be filtered + * @param recordCount number of records to be fetched. + * @return the participant found + * @throws PfModelException on errors getting automation composition statistics + */ + @Transactional(readOnly = true) + public AcElementStatisticsList fetchFilteredAcElementStatistics(@NonNull final String name, final String version, + final String id, Instant startTime, Instant endTime, int recordCount) throws PfModelException { + var acElementStatisticsList = new AcElementStatisticsList(); + Map filterMap = new HashMap<>(); + // Adding UUID in filter if present + if (id != null) { + filterMap.put("localName", id); + } + acElementStatisticsList.setAcElementStatistics(acElementStatisticsProvider.getFilteredAcElementStatistics(name, + version, startTime, endTime, filterMap, DESC_ORDER, recordCount)); + + return acElementStatisticsList; + } + + /** + * Get AcElement statistics per automation composition. + * + * @param name the name of the automation composition + * @param version the version of the automation composition + * @return the AcElement statistics found + * @throws PfModelRuntimeException on errors getting automation composition statistics + */ + @Transactional(readOnly = true) + public AcElementStatisticsList fetchAcElementStatsPerAutomationComposition(@NonNull final String name, + @NonNull final String version) { + var acElementStatisticsList = new AcElementStatisticsList(); + List acElementStats = new ArrayList<>(); + try { + List acElements = new ArrayList<>(); + // Fetch all automation composition elements for the automation composition + var automationCompositionOpt = + automationCompositionProvider.findAutomationComposition(new ToscaConceptIdentifier(name, version)); + if (automationCompositionOpt.isPresent()) { + acElements.addAll(automationCompositionOpt.get().getElements().values()); + // Collect automation composition element statistics for each acElement. + for (AutomationCompositionElement acElement : acElements) { + acElementStats.addAll(fetchFilteredAcElementStatistics(acElement.getParticipantId().getName(), + acElement.getParticipantId().getVersion(), acElement.getId().toString(), null, null, 0) + .getAcElementStatistics()); + } + } + acElementStatisticsList.setAcElementStatistics(acElementStats); + } catch (PfModelException e) { + throw new PfModelRuntimeException(e); + } + return acElementStatisticsList; + } + + /** + * If required, REST end point can be defined for this method to fetch associated participant Ids + * for a automation composition. + * + * @param name the name of the automation composition + * @param version the version of the automation composition + * @return List of participant Id + * @throws PfModelException on errors + */ + @Transactional(readOnly = true) + public List getAllParticipantIdsPerAutomationComposition(String name, String version) + throws PfModelException { + List participantIds = new ArrayList<>(); + var automationCompositionOpt = + automationCompositionProvider.findAutomationComposition(new ToscaConceptIdentifier(name, version)); + if (automationCompositionOpt.isPresent()) { + for (AutomationCompositionElement acElement : automationCompositionOpt.get().getElements().values()) { + participantIds.add(acElement.getParticipantId()); + } + } + return participantIds; + } + + /** + * If required, REST end point can be defined for this method to fetch associated automation composition element Ids + * for a automation composition. + * + * @param name the name of the automation composition + * @param version the version of the automation composition + * @return Map of automation composition Id and participant details + * @throws PfModelException on errors + */ + @Transactional(readOnly = true) + public Map getAllAcElementsIdPerAutomationComposition(String name, String version) + throws PfModelException { + Map acElementId = new HashMap<>(); + var automationCompositionOpt = + automationCompositionProvider.findAutomationComposition(new ToscaConceptIdentifier(name, version)); + if (automationCompositionOpt.isPresent()) { + for (AutomationCompositionElement acElement : automationCompositionOpt.get().getElements().values()) { + acElementId.put(acElement.getId().toString(), acElement.getParticipantId()); + } + } + return acElementId; + } +} diff --git a/runtime-acm/src/main/java/org/onap/policy/clamp/acm/runtime/supervision/HandleCounter.java b/runtime-acm/src/main/java/org/onap/policy/clamp/acm/runtime/supervision/HandleCounter.java new file mode 100644 index 000000000..9949f3c89 --- /dev/null +++ b/runtime-acm/src/main/java/org/onap/policy/clamp/acm/runtime/supervision/HandleCounter.java @@ -0,0 +1,106 @@ +/*- + * ============LICENSE_START======================================================= + * Copyright (C) 2021 Nordix Foundation. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * SPDX-License-Identifier: Apache-2.0 + * ============LICENSE_END========================================================= + */ + +package org.onap.policy.clamp.acm.runtime.supervision; + +import java.time.Instant; +import java.util.HashMap; +import java.util.HashSet; +import java.util.Map; +import java.util.Set; +import lombok.Getter; +import lombok.Setter; + +public class HandleCounter { + @Getter + @Setter + private long maxWaitMs; + + @Getter + @Setter + private int maxRetryCount; + + private Map mapCounter = new HashMap<>(); + private Set mapFault = new HashSet<>(); + private Map mapTimer = new HashMap<>(); + + public long getDuration(K id) { + mapTimer.putIfAbsent(id, getEpochMilli()); + return getEpochMilli() - mapTimer.get(id); + } + + /** + * Reset timer and clear counter and fault by id. + * + * @param id the id + */ + public void clear(K id) { + mapFault.remove(id); + mapCounter.put(id, 0); + mapTimer.put(id, getEpochMilli()); + } + + /** + * Remove counter, timer and fault by id. + * + * @param id the id + */ + public void remove(K id) { + mapFault.remove(id); + mapCounter.remove(id); + mapTimer.remove(id); + } + + public void setFault(K id) { + mapCounter.put(id, 0); + mapFault.add(id); + } + + /** + * Increment RetryCount by id e return true if minor or equal of maxRetryCount. + * + * @param id the identifier + * @return false if count is major of maxRetryCount + */ + public boolean count(K id) { + int counter = mapCounter.getOrDefault(id, 0) + 1; + if (counter <= maxRetryCount) { + mapCounter.put(id, counter); + return true; + } + return false; + } + + public boolean isFault(K id) { + return mapFault.contains(id); + } + + public int getCounter(K id) { + return mapCounter.getOrDefault(id, 0); + } + + protected long getEpochMilli() { + return Instant.now().toEpochMilli(); + } + + public Set keySet() { + return mapCounter.keySet(); + } +} diff --git a/runtime-acm/src/main/java/org/onap/policy/clamp/acm/runtime/supervision/MessageIntercept.java b/runtime-acm/src/main/java/org/onap/policy/clamp/acm/runtime/supervision/MessageIntercept.java new file mode 100644 index 000000000..5b861ce96 --- /dev/null +++ b/runtime-acm/src/main/java/org/onap/policy/clamp/acm/runtime/supervision/MessageIntercept.java @@ -0,0 +1,32 @@ +/*- + * ============LICENSE_START======================================================= + * Copyright (C) 2021 Nordix Foundation. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * SPDX-License-Identifier: Apache-2.0 + * ============LICENSE_END========================================================= + */ + +package org.onap.policy.clamp.acm.runtime.supervision; + +import java.lang.annotation.ElementType; +import java.lang.annotation.Retention; +import java.lang.annotation.RetentionPolicy; +import java.lang.annotation.Target; + +@Retention(RetentionPolicy.RUNTIME) +@Target(ElementType.METHOD) +public @interface MessageIntercept { + +} diff --git a/runtime-acm/src/main/java/org/onap/policy/clamp/acm/runtime/supervision/SupervisionAspect.java b/runtime-acm/src/main/java/org/onap/policy/clamp/acm/runtime/supervision/SupervisionAspect.java new file mode 100644 index 000000000..ea851da81 --- /dev/null +++ b/runtime-acm/src/main/java/org/onap/policy/clamp/acm/runtime/supervision/SupervisionAspect.java @@ -0,0 +1,105 @@ +/*- + * ============LICENSE_START======================================================= + * Copyright (C) 2021 Nordix Foundation. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * SPDX-License-Identifier: Apache-2.0 + * ============LICENSE_END========================================================= + */ + +package org.onap.policy.clamp.acm.runtime.supervision; + +import java.io.Closeable; +import java.io.IOException; +import java.util.concurrent.LinkedBlockingQueue; +import java.util.concurrent.ThreadPoolExecutor; +import java.util.concurrent.TimeUnit; +import lombok.RequiredArgsConstructor; +import org.apache.commons.lang3.tuple.ImmutablePair; +import org.aspectj.lang.annotation.After; +import org.aspectj.lang.annotation.AfterReturning; +import org.aspectj.lang.annotation.Aspect; +import org.aspectj.lang.annotation.Before; +import org.onap.policy.clamp.models.acm.messages.dmaap.participant.ParticipantRegister; +import org.onap.policy.clamp.models.acm.messages.dmaap.participant.ParticipantStatus; +import org.onap.policy.clamp.models.acm.messages.dmaap.participant.ParticipantUpdateAck; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.scheduling.annotation.Scheduled; +import org.springframework.stereotype.Component; + +@Aspect +@Component +@RequiredArgsConstructor +public class SupervisionAspect implements Closeable { + + private static final Logger LOGGER = LoggerFactory.getLogger(SupervisionAspect.class); + + private final SupervisionScanner supervisionScanner; + + private ThreadPoolExecutor executor = + new ThreadPoolExecutor(1, 1, 0L, TimeUnit.MILLISECONDS, new LinkedBlockingQueue<>()); + + @Scheduled( + fixedRateString = "${runtime.participantParameters.heartBeatMs}", + initialDelayString = "${runtime.participantParameters.heartBeatMs}") + public void schedule() { + LOGGER.info("Add scheduled scanning"); + executor.execute(() -> supervisionScanner.run(true)); + } + + /** + * Intercept Messages from participant and run Supervision Scan. + */ + @After("@annotation(MessageIntercept)") + public void doCheck() { + if (executor.getQueue().size() < 2) { + LOGGER.debug("Add scanning Message"); + executor.execute(() -> supervisionScanner.run(false)); + } + } + + @Before("@annotation(MessageIntercept) && args(participantStatusMessage,..)") + public void handleParticipantStatus(ParticipantStatus participantStatusMessage) { + executor.execute(() -> supervisionScanner.handleParticipantStatus(participantStatusMessage.getParticipantId())); + } + + /** + * Intercepts participant Register Message + * if there is a Commissioning starts an execution of handleParticipantRegister. + * + * @param participantRegisterMessage the ParticipantRegister message + * @param isCommissioning is Commissioning + */ + @AfterReturning( + value = "@annotation(MessageIntercept) && args(participantRegisterMessage,..)", + returning = "isCommissioning") + public void handleParticipantRegister(ParticipantRegister participantRegisterMessage, boolean isCommissioning) { + if (isCommissioning) { + executor.execute(() -> supervisionScanner.handleParticipantRegister(new ImmutablePair<>( + participantRegisterMessage.getParticipantId(), participantRegisterMessage.getParticipantType()))); + } + } + + @Before("@annotation(MessageIntercept) && args(participantUpdateAckMessage,..)") + public void handleParticipantUpdateAck(ParticipantUpdateAck participantUpdateAckMessage) { + executor.execute(() -> supervisionScanner.handleParticipantUpdateAck(new ImmutablePair<>( + participantUpdateAckMessage.getParticipantId(), participantUpdateAckMessage.getParticipantType()))); + } + + @Override + public void close() throws IOException { + executor.shutdown(); + } +} diff --git a/runtime-acm/src/main/java/org/onap/policy/clamp/acm/runtime/supervision/SupervisionHandler.java b/runtime-acm/src/main/java/org/onap/policy/clamp/acm/runtime/supervision/SupervisionHandler.java new file mode 100644 index 000000000..055acb28f --- /dev/null +++ b/runtime-acm/src/main/java/org/onap/policy/clamp/acm/runtime/supervision/SupervisionHandler.java @@ -0,0 +1,518 @@ +/*- + * ============LICENSE_START======================================================= + * Copyright (C) 2021 Nordix Foundation. + * Modifications Copyright (C) 2021 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * SPDX-License-Identifier: Apache-2.0 + * ============LICENSE_END========================================================= + */ + +package org.onap.policy.clamp.acm.runtime.supervision; + +import java.util.List; +import java.util.Map; +import java.util.Set; +import java.util.UUID; +import javax.ws.rs.core.Response; +import javax.ws.rs.core.Response.Status; +import lombok.AllArgsConstructor; +import org.apache.commons.collections4.CollectionUtils; +import org.onap.policy.clamp.acm.runtime.monitoring.MonitoringProvider; +import org.onap.policy.clamp.acm.runtime.supervision.comm.AutomationCompositionStateChangePublisher; +import org.onap.policy.clamp.acm.runtime.supervision.comm.AutomationCompositionUpdatePublisher; +import org.onap.policy.clamp.acm.runtime.supervision.comm.ParticipantDeregisterAckPublisher; +import org.onap.policy.clamp.acm.runtime.supervision.comm.ParticipantRegisterAckPublisher; +import org.onap.policy.clamp.acm.runtime.supervision.comm.ParticipantUpdatePublisher; +import org.onap.policy.clamp.common.acm.exception.AutomationCompositionException; +import org.onap.policy.clamp.models.acm.concepts.AutomationComposition; +import org.onap.policy.clamp.models.acm.concepts.AutomationCompositionElementAck; +import org.onap.policy.clamp.models.acm.concepts.AutomationCompositionInfo; +import org.onap.policy.clamp.models.acm.concepts.AutomationCompositionState; +import org.onap.policy.clamp.models.acm.concepts.Participant; +import org.onap.policy.clamp.models.acm.concepts.ParticipantHealthStatus; +import org.onap.policy.clamp.models.acm.concepts.ParticipantState; +import org.onap.policy.clamp.models.acm.concepts.ParticipantUtils; +import org.onap.policy.clamp.models.acm.messages.dmaap.participant.AutomationCompositionAck; +import org.onap.policy.clamp.models.acm.messages.dmaap.participant.ParticipantDeregister; +import org.onap.policy.clamp.models.acm.messages.dmaap.participant.ParticipantMessage; +import org.onap.policy.clamp.models.acm.messages.dmaap.participant.ParticipantRegister; +import org.onap.policy.clamp.models.acm.messages.dmaap.participant.ParticipantStatus; +import org.onap.policy.clamp.models.acm.messages.dmaap.participant.ParticipantUpdateAck; +import org.onap.policy.clamp.models.acm.persistence.provider.AutomationCompositionProvider; +import org.onap.policy.clamp.models.acm.persistence.provider.ParticipantProvider; +import org.onap.policy.clamp.models.acm.persistence.provider.ServiceTemplateProvider; +import org.onap.policy.models.base.PfModelException; +import org.onap.policy.models.base.PfModelRuntimeException; +import org.onap.policy.models.tosca.authorative.concepts.ToscaConceptIdentifier; +import org.onap.policy.models.tosca.authorative.concepts.ToscaServiceTemplate; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.stereotype.Component; + +/** + * This class handles supervision of automation composition instances, so only one object of this type should be built + * at a time. + * + *

+ * It is effectively a singleton that is started at system start. + */ +@Component +@AllArgsConstructor +public class SupervisionHandler { + private static final Logger LOGGER = LoggerFactory.getLogger(SupervisionHandler.class); + + private static final String AUTOMATION_COMPOSITION_CANNOT_TRANSITION_FROM_STATE = + "Automation composition can't transition from state "; + private static final String AUTOMATION_COMPOSITION_IS_ALREADY_IN_STATE = + "Automation composition is already in state "; + private static final String TO_STATE = " to state "; + private static final String AND_TRANSITIONING_TO_STATE = " and transitioning to state "; + + private final AutomationCompositionProvider automationCompositionProvider; + private final ParticipantProvider participantProvider; + private final MonitoringProvider monitoringProvider; + private final ServiceTemplateProvider serviceTemplateProvider; + + // Publishers for participant communication + private final AutomationCompositionUpdatePublisher automationCompositionUpdatePublisher; + private final AutomationCompositionStateChangePublisher automationCompositionStateChangePublisher; + private final ParticipantRegisterAckPublisher participantRegisterAckPublisher; + private final ParticipantDeregisterAckPublisher participantDeregisterAckPublisher; + private final ParticipantUpdatePublisher participantUpdatePublisher; + + /** + * Supervision trigger called when a command is issued on automation compositions. + * + *

+ * Causes supervision to start or continue supervision on the automation compositions in question. + * + * @param automationCompositionIdentifierList the automation compositions for which the supervision command has been + * issued + * @throws AutomationCompositionException on supervision triggering exceptions + */ + public void triggerAutomationCompositionSupervision( + List automationCompositionIdentifierList) throws AutomationCompositionException { + + LOGGER.debug("triggering automation composition supervision on automation compositions {}", + automationCompositionIdentifierList); + + if (CollectionUtils.isEmpty(automationCompositionIdentifierList)) { + // This is just to force throwing of the exception in certain circumstances. + exceptionOccured(Response.Status.NOT_ACCEPTABLE, + "The list of automation compositions for supervision is empty"); + } + + for (ToscaConceptIdentifier automationCompositionId : automationCompositionIdentifierList) { + try { + var automationComposition = + automationCompositionProvider.getAutomationComposition(automationCompositionId); + + superviseAutomationComposition(automationComposition); + + automationCompositionProvider.saveAutomationComposition(automationComposition); + } catch (PfModelException pfme) { + throw new AutomationCompositionException(pfme.getErrorResponse().getResponseCode(), pfme.getMessage(), + pfme); + } + } + } + + /** + * Handle a ParticipantStatus message from a participant. + * + * @param participantStatusMessage the ParticipantStatus message received from a participant + */ + @MessageIntercept + public void handleParticipantMessage(ParticipantStatus participantStatusMessage) { + LOGGER.debug("Participant Status received {}", participantStatusMessage); + try { + superviseParticipant(participantStatusMessage); + } catch (PfModelException | AutomationCompositionException svExc) { + LOGGER.warn("error supervising participant {}", participantStatusMessage.getParticipantId(), svExc); + return; + } + + try { + superviseAutomationCompositions(participantStatusMessage); + } catch (PfModelException | AutomationCompositionException svExc) { + LOGGER.warn("error supervising participant {}", participantStatusMessage.getParticipantId(), svExc); + } + } + + /** + * Handle a ParticipantRegister message from a participant. + * + * @param participantRegisterMessage the ParticipantRegister message received from a participant + */ + @MessageIntercept + public boolean handleParticipantMessage(ParticipantRegister participantRegisterMessage) { + LOGGER.debug("Participant Register received {}", participantRegisterMessage); + try { + checkParticipant(participantRegisterMessage, ParticipantState.UNKNOWN, ParticipantHealthStatus.UNKNOWN); + } catch (PfModelException | AutomationCompositionException svExc) { + LOGGER.warn("error saving participant {}", participantRegisterMessage.getParticipantId(), svExc); + } + + var isCommissioning = participantUpdatePublisher.sendCommissioning(null, null, + participantRegisterMessage.getParticipantId(), participantRegisterMessage.getParticipantType()); + + participantRegisterAckPublisher.send(participantRegisterMessage.getMessageId(), + participantRegisterMessage.getParticipantId(), participantRegisterMessage.getParticipantType()); + return isCommissioning; + } + + /** + * Handle a ParticipantDeregister message from a participant. + * + * @param participantDeregisterMessage the ParticipantDeregister message received from a participant + */ + @MessageIntercept + public void handleParticipantMessage(ParticipantDeregister participantDeregisterMessage) { + LOGGER.debug("Participant Deregister received {}", participantDeregisterMessage); + try { + var participantOpt = + participantProvider.findParticipant(participantDeregisterMessage.getParticipantId().getName(), + participantDeregisterMessage.getParticipantId().getVersion()); + + if (participantOpt.isPresent()) { + var participant = participantOpt.get(); + participant.setParticipantState(ParticipantState.TERMINATED); + participant.setHealthStatus(ParticipantHealthStatus.OFF_LINE); + participantProvider.saveParticipant(participant); + } + } catch (PfModelException pfme) { + LOGGER.warn("Model exception occured with participant id {}", + participantDeregisterMessage.getParticipantId()); + } + + participantDeregisterAckPublisher.send(participantDeregisterMessage.getMessageId()); + } + + /** + * Handle a ParticipantUpdateAck message from a participant. + * + * @param participantUpdateAckMessage the ParticipantUpdateAck message received from a participant + */ + @MessageIntercept + public void handleParticipantMessage(ParticipantUpdateAck participantUpdateAckMessage) { + LOGGER.debug("Participant Update Ack received {}", participantUpdateAckMessage); + try { + var participantOpt = + participantProvider.findParticipant(participantUpdateAckMessage.getParticipantId().getName(), + participantUpdateAckMessage.getParticipantId().getVersion()); + + if (participantOpt.isPresent()) { + var participant = participantOpt.get(); + participant.setParticipantState(participantUpdateAckMessage.getState()); + participantProvider.saveParticipant(participant); + } else { + LOGGER.warn("Participant not found in database {}", participantUpdateAckMessage.getParticipantId()); + } + } catch (PfModelException pfme) { + LOGGER.warn("Model exception occured with participant id {}", + participantUpdateAckMessage.getParticipantId()); + } + } + + /** + * Send commissioning update message to dmaap. + * + * @param name the ToscaServiceTemplate name + * @param version the ToscaServiceTemplate version + */ + public void handleSendCommissionMessage(String name, String version) { + LOGGER.debug("Participant update message with serviveTemplate {} {} being sent to all participants", name, + version); + participantUpdatePublisher.sendComissioningBroadcast(name, version); + } + + /** + * Send decommissioning update message to dmaap. + * + */ + public void handleSendDeCommissionMessage() { + LOGGER.debug("Participant update message being sent"); + participantUpdatePublisher.sendDecomisioning(); + } + + /** + * Handle a AutomationComposition update acknowledge message from a participant. + * + * @param automationCompositionAckMessage the AutomationCompositionAck message received from a participant + */ + @MessageIntercept + public void handleAutomationCompositionUpdateAckMessage(AutomationCompositionAck automationCompositionAckMessage) { + LOGGER.debug("AutomationComposition Update Ack message received {}", automationCompositionAckMessage); + setAcElementStateInDb(automationCompositionAckMessage); + } + + /** + * Handle a AutomationComposition statechange acknowledge message from a participant. + * + * @param automationCompositionAckMessage the AutomationCompositionAck message received from a participant + */ + @MessageIntercept + public void handleAutomationCompositionStateChangeAckMessage( + AutomationCompositionAck automationCompositionAckMessage) { + LOGGER.debug("AutomationComposition StateChange Ack message received {}", automationCompositionAckMessage); + setAcElementStateInDb(automationCompositionAckMessage); + } + + private void setAcElementStateInDb(AutomationCompositionAck automationCompositionAckMessage) { + if (automationCompositionAckMessage.getAutomationCompositionResultMap() != null) { + try { + var automationComposition = automationCompositionProvider + .getAutomationComposition(automationCompositionAckMessage.getAutomationCompositionId()); + if (automationComposition != null) { + var updated = updateState(automationComposition, + automationCompositionAckMessage.getAutomationCompositionResultMap().entrySet()); + updated |= setPrimed(automationComposition); + if (updated) { + automationCompositionProvider.saveAutomationComposition(automationComposition); + } + } else { + LOGGER.warn("AutomationComposition not found in database {}", + automationCompositionAckMessage.getAutomationCompositionId()); + } + } catch (PfModelException pfme) { + LOGGER.warn("Model exception occured with AutomationComposition Id {}", + automationCompositionAckMessage.getAutomationCompositionId()); + } + } + } + + private boolean updateState(AutomationComposition automationComposition, + Set> automationCompositionResultSet) { + var updated = false; + for (var acElementAck : automationCompositionResultSet) { + var element = automationComposition.getElements().get(acElementAck.getKey()); + if (element != null) { + element.setState(acElementAck.getValue().getState()); + updated = true; + } + } + return updated; + } + + private boolean setPrimed(AutomationComposition automationComposition) { + var acElements = automationComposition.getElements().values(); + if (acElements != null) { + Boolean primedFlag = true; + var checkOpt = automationComposition.getElements().values().stream() + .filter(acElement -> (!acElement.getState().equals(AutomationCompositionState.PASSIVE) + || !acElement.getState().equals(AutomationCompositionState.RUNNING))) + .findAny(); + if (checkOpt.isEmpty()) { + primedFlag = false; + } + automationComposition.setPrimed(primedFlag); + return true; + } + + return false; + } + + /** + * Supervise a automation composition, performing whatever actions need to be performed on the automation + * composition. + * + * @param automationComposition the automation composition to supervises + * @throws AutomationCompositionException on supervision errors + */ + private void superviseAutomationComposition(AutomationComposition automationComposition) + throws AutomationCompositionException { + switch (automationComposition.getOrderedState()) { + case UNINITIALISED: + superviseAutomationCompositionUninitialization(automationComposition); + break; + + case PASSIVE: + superviseAutomationCompositionPassivation(automationComposition); + break; + + case RUNNING: + superviseAutomationCompositionActivation(automationComposition); + break; + + default: + exceptionOccured(Response.Status.NOT_ACCEPTABLE, + "A automation composition cannot be commanded to go into state " + + automationComposition.getOrderedState().name()); + } + } + + /** + * Supervise a automation composition uninitialisation, performing whatever actions need to be performed on the + * automation composition, + * automation composition ordered state is UNINITIALIZED. + * + * @param automationComposition the automation composition to supervises + * @throws AutomationCompositionException on supervision errors + */ + private void superviseAutomationCompositionUninitialization(AutomationComposition automationComposition) + throws AutomationCompositionException { + switch (automationComposition.getState()) { + case UNINITIALISED: + exceptionOccured(Response.Status.NOT_ACCEPTABLE, + AUTOMATION_COMPOSITION_IS_ALREADY_IN_STATE + automationComposition.getState().name()); + break; + + case UNINITIALISED2PASSIVE: + case PASSIVE: + automationComposition.setState(AutomationCompositionState.PASSIVE2UNINITIALISED); + automationCompositionStateChangePublisher.send(automationComposition, + getFirstStartPhase(automationComposition)); + break; + + case PASSIVE2UNINITIALISED: + exceptionOccured(Response.Status.NOT_ACCEPTABLE, + AUTOMATION_COMPOSITION_IS_ALREADY_IN_STATE + automationComposition.getState().name() + + AND_TRANSITIONING_TO_STATE + automationComposition.getOrderedState()); + break; + + default: + exceptionOccured(Response.Status.NOT_ACCEPTABLE, AUTOMATION_COMPOSITION_CANNOT_TRANSITION_FROM_STATE + + automationComposition.getState().name() + TO_STATE + automationComposition.getOrderedState()); + break; + } + } + + private void superviseAutomationCompositionPassivation(AutomationComposition automationComposition) + throws AutomationCompositionException { + switch (automationComposition.getState()) { + case PASSIVE: + exceptionOccured(Response.Status.NOT_ACCEPTABLE, + AUTOMATION_COMPOSITION_IS_ALREADY_IN_STATE + automationComposition.getState().name()); + break; + case UNINITIALISED: + automationComposition.setState(AutomationCompositionState.UNINITIALISED2PASSIVE); + automationCompositionUpdatePublisher.send(automationComposition); + break; + + case UNINITIALISED2PASSIVE: + case RUNNING2PASSIVE: + exceptionOccured(Response.Status.NOT_ACCEPTABLE, + AUTOMATION_COMPOSITION_IS_ALREADY_IN_STATE + automationComposition.getState().name() + + AND_TRANSITIONING_TO_STATE + automationComposition.getOrderedState()); + break; + + case RUNNING: + automationComposition.setState(AutomationCompositionState.RUNNING2PASSIVE); + automationCompositionStateChangePublisher.send(automationComposition, + getFirstStartPhase(automationComposition)); + break; + + default: + exceptionOccured(Response.Status.NOT_ACCEPTABLE, AUTOMATION_COMPOSITION_CANNOT_TRANSITION_FROM_STATE + + automationComposition.getState().name() + TO_STATE + automationComposition.getOrderedState()); + break; + } + } + + private void superviseAutomationCompositionActivation(AutomationComposition automationComposition) + throws AutomationCompositionException { + switch (automationComposition.getState()) { + case RUNNING: + exceptionOccured(Response.Status.NOT_ACCEPTABLE, + AUTOMATION_COMPOSITION_IS_ALREADY_IN_STATE + automationComposition.getState().name()); + break; + + case PASSIVE2RUNNING: + exceptionOccured(Response.Status.NOT_ACCEPTABLE, + AUTOMATION_COMPOSITION_IS_ALREADY_IN_STATE + automationComposition.getState().name() + + AND_TRANSITIONING_TO_STATE + automationComposition.getOrderedState()); + break; + + case PASSIVE: + automationComposition.setState(AutomationCompositionState.PASSIVE2RUNNING); + automationCompositionStateChangePublisher.send(automationComposition, + getFirstStartPhase(automationComposition)); + break; + + default: + exceptionOccured(Response.Status.NOT_ACCEPTABLE, AUTOMATION_COMPOSITION_CANNOT_TRANSITION_FROM_STATE + + automationComposition.getState().name() + TO_STATE + automationComposition.getOrderedState()); + break; + } + } + + private int getFirstStartPhase(AutomationComposition automationComposition) { + ToscaServiceTemplate toscaServiceTemplate = null; + try { + toscaServiceTemplate = serviceTemplateProvider.getAllServiceTemplates().get(0); + } catch (PfModelException e) { + throw new PfModelRuntimeException(Status.BAD_REQUEST, "Canont load ToscaServiceTemplate from DB", e); + } + return ParticipantUtils.getFirstStartPhase(automationComposition, toscaServiceTemplate); + } + + private void checkParticipant(ParticipantMessage participantMessage, ParticipantState participantState, + ParticipantHealthStatus healthStatus) throws AutomationCompositionException, PfModelException { + if (participantMessage.getParticipantId() == null) { + exceptionOccured(Response.Status.NOT_FOUND, "Participant ID on PARTICIPANT_STATUS message is null"); + } + var participantOpt = participantProvider.findParticipant(participantMessage.getParticipantId().getName(), + participantMessage.getParticipantId().getVersion()); + + if (participantOpt.isEmpty()) { + var participant = new Participant(); + participant.setName(participantMessage.getParticipantId().getName()); + participant.setVersion(participantMessage.getParticipantId().getVersion()); + participant.setDefinition(participantMessage.getParticipantId()); + participant.setParticipantType(participantMessage.getParticipantType()); + participant.setParticipantState(participantState); + participant.setHealthStatus(healthStatus); + + participantProvider.saveParticipant(participant); + } else { + var participant = participantOpt.get(); + participant.setParticipantState(participantState); + participant.setHealthStatus(healthStatus); + + participantProvider.saveParticipant(participant); + } + } + + private void superviseParticipant(ParticipantStatus participantStatusMessage) + throws PfModelException, AutomationCompositionException { + + checkParticipant(participantStatusMessage, participantStatusMessage.getState(), + participantStatusMessage.getHealthStatus()); + + monitoringProvider.createParticipantStatistics(List.of(participantStatusMessage.getParticipantStatistics())); + } + + private void superviseAutomationCompositions(ParticipantStatus participantStatusMessage) + throws PfModelException, AutomationCompositionException { + if (participantStatusMessage.getAutomationCompositionInfoList() != null) { + for (AutomationCompositionInfo acEntry : participantStatusMessage.getAutomationCompositionInfoList()) { + var dbAutomationComposition = automationCompositionProvider + .getAutomationComposition(new ToscaConceptIdentifier(acEntry.getAutomationCompositionId())); + if (dbAutomationComposition == null) { + exceptionOccured(Response.Status.NOT_FOUND, + "PARTICIPANT_STATUS automation composition not found in database: " + + acEntry.getAutomationCompositionId()); + } + dbAutomationComposition.setState(acEntry.getState()); + monitoringProvider.createAcElementStatistics( + acEntry.getAutomationCompositionStatistics().getAcElementStatisticsList().getAcElementStatistics()); + } + } + } + + private void exceptionOccured(Response.Status status, String reason) throws AutomationCompositionException { + throw new AutomationCompositionException(status, reason); + } +} diff --git a/runtime-acm/src/main/java/org/onap/policy/clamp/acm/runtime/supervision/SupervisionScanner.java b/runtime-acm/src/main/java/org/onap/policy/clamp/acm/runtime/supervision/SupervisionScanner.java new file mode 100644 index 000000000..ce7195d93 --- /dev/null +++ b/runtime-acm/src/main/java/org/onap/policy/clamp/acm/runtime/supervision/SupervisionScanner.java @@ -0,0 +1,307 @@ +/*- + * ============LICENSE_START======================================================= + * Copyright (C) 2021 Nordix Foundation. + * ================================================================================ + * Modifications Copyright (C) 2021 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * SPDX-License-Identifier: Apache-2.0 + * ============LICENSE_END========================================================= + */ + +package org.onap.policy.clamp.acm.runtime.supervision; + +import java.util.HashMap; +import java.util.Map; +import org.apache.commons.lang3.tuple.Pair; +import org.onap.policy.clamp.acm.runtime.main.parameters.AcRuntimeParameterGroup; +import org.onap.policy.clamp.acm.runtime.supervision.comm.AutomationCompositionStateChangePublisher; +import org.onap.policy.clamp.acm.runtime.supervision.comm.AutomationCompositionUpdatePublisher; +import org.onap.policy.clamp.acm.runtime.supervision.comm.ParticipantStatusReqPublisher; +import org.onap.policy.clamp.acm.runtime.supervision.comm.ParticipantUpdatePublisher; +import org.onap.policy.clamp.models.acm.concepts.AutomationComposition; +import org.onap.policy.clamp.models.acm.concepts.AutomationCompositionElement; +import org.onap.policy.clamp.models.acm.concepts.AutomationCompositionState; +import org.onap.policy.clamp.models.acm.concepts.Participant; +import org.onap.policy.clamp.models.acm.concepts.ParticipantHealthStatus; +import org.onap.policy.clamp.models.acm.concepts.ParticipantUtils; +import org.onap.policy.clamp.models.acm.persistence.provider.AutomationCompositionProvider; +import org.onap.policy.clamp.models.acm.persistence.provider.ParticipantProvider; +import org.onap.policy.clamp.models.acm.persistence.provider.ServiceTemplateProvider; +import org.onap.policy.models.base.PfModelException; +import org.onap.policy.models.tosca.authorative.concepts.ToscaConceptIdentifier; +import org.onap.policy.models.tosca.authorative.concepts.ToscaNodeTemplate; +import org.onap.policy.models.tosca.authorative.concepts.ToscaServiceTemplate; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.stereotype.Component; + +/** + * This class is used to scan the automation compositions in the database and check if they are in the correct state. + */ +@Component +public class SupervisionScanner { + private static final Logger LOGGER = LoggerFactory.getLogger(SupervisionScanner.class); + + private final HandleCounter automationCompositionCounter = new HandleCounter<>(); + private final HandleCounter participantStatusCounter = new HandleCounter<>(); + private final HandleCounter> participantUpdateCounter = + new HandleCounter<>(); + + private final Map phaseMap = new HashMap<>(); + + private final AutomationCompositionProvider automationCompositionProvider; + private final ServiceTemplateProvider serviceTemplateProvider; + private final AutomationCompositionStateChangePublisher automationCompositionStateChangePublisher; + private final AutomationCompositionUpdatePublisher automationCompositionUpdatePublisher; + private final ParticipantProvider participantProvider; + private final ParticipantStatusReqPublisher participantStatusReqPublisher; + private final ParticipantUpdatePublisher participantUpdatePublisher; + + /** + * Constructor for instantiating SupervisionScanner. + * + * @param automationCompositionProvider the provider to use to read automation compositions from the database + * @param serviceTemplateProvider the Policy Models Provider + * @param automationCompositionStateChangePublisher the AutomationComposition StateChange Publisher + * @param automationCompositionUpdatePublisher the AutomationCompositionUpdate Publisher + * @param participantProvider the Participant Provider + * @param participantStatusReqPublisher the Participant StatusReq Publisher + * @param participantUpdatePublisher the Participant Update Publisher + * @param acRuntimeParameterGroup the parameters for the automation composition runtime + */ + public SupervisionScanner(final AutomationCompositionProvider automationCompositionProvider, + ServiceTemplateProvider serviceTemplateProvider, + final AutomationCompositionStateChangePublisher automationCompositionStateChangePublisher, + AutomationCompositionUpdatePublisher automationCompositionUpdatePublisher, + ParticipantProvider participantProvider, ParticipantStatusReqPublisher participantStatusReqPublisher, + ParticipantUpdatePublisher participantUpdatePublisher, final AcRuntimeParameterGroup acRuntimeParameterGroup) { + this.automationCompositionProvider = automationCompositionProvider; + this.serviceTemplateProvider = serviceTemplateProvider; + this.automationCompositionStateChangePublisher = automationCompositionStateChangePublisher; + this.automationCompositionUpdatePublisher = automationCompositionUpdatePublisher; + this.participantProvider = participantProvider; + this.participantStatusReqPublisher = participantStatusReqPublisher; + this.participantUpdatePublisher = participantUpdatePublisher; + + automationCompositionCounter.setMaxRetryCount( + acRuntimeParameterGroup.getParticipantParameters().getUpdateParameters().getMaxRetryCount()); + automationCompositionCounter + .setMaxWaitMs(acRuntimeParameterGroup.getParticipantParameters().getMaxStatusWaitMs()); + + participantUpdateCounter.setMaxRetryCount( + acRuntimeParameterGroup.getParticipantParameters().getUpdateParameters().getMaxRetryCount()); + participantUpdateCounter + .setMaxWaitMs(acRuntimeParameterGroup.getParticipantParameters().getUpdateParameters().getMaxWaitMs()); + + participantStatusCounter.setMaxRetryCount( + acRuntimeParameterGroup.getParticipantParameters().getUpdateParameters().getMaxRetryCount()); + participantStatusCounter.setMaxWaitMs(acRuntimeParameterGroup.getParticipantParameters().getMaxStatusWaitMs()); + } + + /** + * Run Scanning. + * + * @param counterCheck if true activate counter and retry + */ + public void run(boolean counterCheck) { + LOGGER.debug("Scanning automation compositions in the database . . ."); + + if (counterCheck) { + try { + for (var participant : participantProvider.getParticipants()) { + scanParticipantStatus(participant); + } + } catch (PfModelException pfme) { + LOGGER.warn("error reading participant from database", pfme); + return; + } + } + + try { + var list = serviceTemplateProvider.getAllServiceTemplates(); + if (list != null && !list.isEmpty()) { + ToscaServiceTemplate toscaServiceTemplate = list.get(0); + + for (AutomationComposition automationComposition : automationCompositionProvider + .getAutomationCompositions()) { + scanAutomationComposition(automationComposition, toscaServiceTemplate, counterCheck); + } + } + } catch (PfModelException pfme) { + LOGGER.warn("error reading automation compositions from database", pfme); + } + + if (counterCheck) { + scanParticipantUpdate(); + } + + LOGGER.debug("Automation composition scan complete . . ."); + } + + private void scanParticipantUpdate() { + LOGGER.debug("Scanning participants to update . . ."); + + for (var id : participantUpdateCounter.keySet()) { + if (participantUpdateCounter.isFault(id)) { + LOGGER.debug("report Participant Update fault"); + + } else if (participantUpdateCounter.getDuration(id) > participantUpdateCounter.getMaxWaitMs()) { + + if (participantUpdateCounter.count(id)) { + LOGGER.debug("retry message ParticipantUpdate"); + participantUpdatePublisher.sendCommissioning(null, null, id.getLeft(), id.getRight()); + } else { + LOGGER.debug("report Participant Update fault"); + participantUpdateCounter.setFault(id); + } + } + } + + LOGGER.debug("Participants to update scan complete . . ."); + } + + private void scanParticipantStatus(Participant participant) throws PfModelException { + ToscaConceptIdentifier id = participant.getKey().asIdentifier(); + if (participantStatusCounter.isFault(id)) { + LOGGER.debug("report Participant fault"); + return; + } + if (participantStatusCounter.getDuration(id) > participantStatusCounter.getMaxWaitMs()) { + if (participantStatusCounter.count(id)) { + LOGGER.debug("retry message ParticipantStatusReq"); + participantStatusReqPublisher.send(id); + participant.setHealthStatus(ParticipantHealthStatus.NOT_HEALTHY); + } else { + LOGGER.debug("report Participant fault"); + participantStatusCounter.setFault(id); + participant.setHealthStatus(ParticipantHealthStatus.OFF_LINE); + } + participantProvider.saveParticipant(participant); + } + } + + /** + * handle participant Status message. + */ + public void handleParticipantStatus(ToscaConceptIdentifier id) { + participantStatusCounter.clear(id); + } + + public void handleParticipantRegister(Pair id) { + participantUpdateCounter.clear(id); + } + + public void handleParticipantUpdateAck(Pair id) { + participantUpdateCounter.remove(id); + } + + private void scanAutomationComposition(final AutomationComposition automationComposition, + ToscaServiceTemplate toscaServiceTemplate, boolean counterCheck) throws PfModelException { + LOGGER.debug("scanning automation composition {} . . .", automationComposition.getKey().asIdentifier()); + + if (automationComposition.getState().equals(automationComposition.getOrderedState().asState())) { + LOGGER.debug("automation composition {} scanned, OK", automationComposition.getKey().asIdentifier()); + + // Clear missed report counter on automation composition + clearFaultAndCounter(automationComposition); + return; + } + + var completed = true; + var minSpNotCompleted = 1000; // min startPhase not completed + var maxSpNotCompleted = 0; // max startPhase not completed + var defaultMin = 1000; // min startPhase + var defaultMax = 0; // max startPhase + for (AutomationCompositionElement element : automationComposition.getElements().values()) { + ToscaNodeTemplate toscaNodeTemplate = toscaServiceTemplate.getToscaTopologyTemplate().getNodeTemplates() + .get(element.getDefinition().getName()); + int startPhase = ParticipantUtils.findStartPhase(toscaNodeTemplate.getProperties()); + defaultMin = Math.min(defaultMin, startPhase); + defaultMax = Math.max(defaultMax, startPhase); + if (!element.getState().equals(element.getOrderedState().asState())) { + completed = false; + minSpNotCompleted = Math.min(minSpNotCompleted, startPhase); + maxSpNotCompleted = Math.max(maxSpNotCompleted, startPhase); + } + } + + if (completed) { + LOGGER.debug("automation composition scan: transition from state {} to {} completed", + automationComposition.getState(), automationComposition.getOrderedState()); + + automationComposition.setState(automationComposition.getOrderedState().asState()); + automationCompositionProvider.saveAutomationComposition(automationComposition); + + // Clear missed report counter on automation composition + clearFaultAndCounter(automationComposition); + } else { + LOGGER.debug("automation composition scan: transition from state {} to {} not completed", + automationComposition.getState(), automationComposition.getOrderedState()); + + var nextSpNotCompleted = + AutomationCompositionState.UNINITIALISED2PASSIVE.equals(automationComposition.getState()) + || AutomationCompositionState.PASSIVE2RUNNING.equals(automationComposition.getState()) + ? minSpNotCompleted + : maxSpNotCompleted; + + var firstStartPhase = + AutomationCompositionState.UNINITIALISED2PASSIVE.equals(automationComposition.getState()) + || AutomationCompositionState.PASSIVE2RUNNING.equals(automationComposition.getState()) ? defaultMin + : defaultMax; + + if (nextSpNotCompleted != phaseMap.getOrDefault(automationComposition.getKey().asIdentifier(), + firstStartPhase)) { + phaseMap.put(automationComposition.getKey().asIdentifier(), nextSpNotCompleted); + sendAutomationCompositionMsg(automationComposition, nextSpNotCompleted); + } else if (counterCheck) { + phaseMap.put(automationComposition.getKey().asIdentifier(), nextSpNotCompleted); + handleCounter(automationComposition, nextSpNotCompleted); + } + } + } + + private void clearFaultAndCounter(AutomationComposition automationComposition) { + automationCompositionCounter.clear(automationComposition.getKey().asIdentifier()); + phaseMap.clear(); + } + + private void handleCounter(AutomationComposition automationComposition, int startPhase) { + ToscaConceptIdentifier id = automationComposition.getKey().asIdentifier(); + if (automationCompositionCounter.isFault(id)) { + LOGGER.debug("report AutomationComposition fault"); + return; + } + + if (automationCompositionCounter.getDuration(id) > automationCompositionCounter.getMaxWaitMs()) { + if (automationCompositionCounter.count(id)) { + phaseMap.put(id, startPhase); + sendAutomationCompositionMsg(automationComposition, startPhase); + } else { + LOGGER.debug("report AutomationComposition fault"); + automationCompositionCounter.setFault(id); + } + } + } + + private void sendAutomationCompositionMsg(AutomationComposition automationComposition, int startPhase) { + if (AutomationCompositionState.UNINITIALISED2PASSIVE.equals(automationComposition.getState())) { + LOGGER.debug("retry message AutomationCompositionUpdate"); + automationCompositionUpdatePublisher.send(automationComposition, startPhase); + } else { + LOGGER.debug("retry message AutomationCompositionStateChange"); + automationCompositionStateChangePublisher.send(automationComposition, startPhase); + } + } +} diff --git a/runtime-acm/src/main/java/org/onap/policy/clamp/acm/runtime/supervision/comm/AbstractParticipantAckPublisher.java b/runtime-acm/src/main/java/org/onap/policy/clamp/acm/runtime/supervision/comm/AbstractParticipantAckPublisher.java new file mode 100644 index 000000000..22284a4eb --- /dev/null +++ b/runtime-acm/src/main/java/org/onap/policy/clamp/acm/runtime/supervision/comm/AbstractParticipantAckPublisher.java @@ -0,0 +1,62 @@ +/*- + * ============LICENSE_START======================================================= + * Copyright (C) 2021 Nordix Foundation. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * SPDX-License-Identifier: Apache-2.0 + * ============LICENSE_END========================================================= + */ + +package org.onap.policy.clamp.acm.runtime.supervision.comm; + +import java.util.List; +import javax.ws.rs.core.Response.Status; +import org.onap.policy.clamp.acm.runtime.config.messaging.Publisher; +import org.onap.policy.clamp.common.acm.exception.AutomationCompositionRuntimeException; +import org.onap.policy.clamp.models.acm.messages.dmaap.participant.ParticipantAckMessage; +import org.onap.policy.common.endpoints.event.comm.TopicSink; +import org.onap.policy.common.endpoints.event.comm.client.TopicSinkClient; + +public abstract class AbstractParticipantAckPublisher implements Publisher { + + private TopicSinkClient topicSinkClient; + private boolean active = false; + + /** + * Method to send Participant message to participants on demand. + * + * @param participantMessage the Participant message + */ + public void send(final E participantMessage) { + if (!active) { + throw new AutomationCompositionRuntimeException(Status.NOT_ACCEPTABLE, "Not Active!"); + } + topicSinkClient.send(participantMessage); + } + + + @Override + public void active(List topicSinks) { + if (topicSinks.size() != 1) { + throw new IllegalArgumentException("Topic Sink must be one"); + } + this.topicSinkClient = new TopicSinkClient(topicSinks.get(0)); + active = true; + } + + @Override + public void stop() { + active = false; + } +} diff --git a/runtime-acm/src/main/java/org/onap/policy/clamp/acm/runtime/supervision/comm/AbstractParticipantPublisher.java b/runtime-acm/src/main/java/org/onap/policy/clamp/acm/runtime/supervision/comm/AbstractParticipantPublisher.java new file mode 100644 index 000000000..054eaf7b5 --- /dev/null +++ b/runtime-acm/src/main/java/org/onap/policy/clamp/acm/runtime/supervision/comm/AbstractParticipantPublisher.java @@ -0,0 +1,62 @@ +/*- + * ============LICENSE_START======================================================= + * Copyright (C) 2021 Nordix Foundation. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * SPDX-License-Identifier: Apache-2.0 + * ============LICENSE_END========================================================= + */ + +package org.onap.policy.clamp.acm.runtime.supervision.comm; + +import java.util.List; +import javax.ws.rs.core.Response.Status; +import org.onap.policy.clamp.acm.runtime.config.messaging.Publisher; +import org.onap.policy.clamp.common.acm.exception.AutomationCompositionRuntimeException; +import org.onap.policy.clamp.models.acm.messages.dmaap.participant.ParticipantMessage; +import org.onap.policy.common.endpoints.event.comm.TopicSink; +import org.onap.policy.common.endpoints.event.comm.client.TopicSinkClient; + +public abstract class AbstractParticipantPublisher implements Publisher { + + private TopicSinkClient topicSinkClient; + private boolean active = false; + + /** + * Method to send Participant message to participants on demand. + * + * @param participantMessage the Participant message + */ + public void send(final E participantMessage) { + if (!active) { + throw new AutomationCompositionRuntimeException(Status.NOT_ACCEPTABLE, "Not Active!"); + } + topicSinkClient.send(participantMessage); + } + + + @Override + public void active(List topicSinks) { + if (topicSinks.size() != 1) { + throw new IllegalArgumentException("Topic Sink must be one"); + } + this.topicSinkClient = new TopicSinkClient(topicSinks.get(0)); + active = true; + } + + @Override + public void stop() { + active = false; + } +} diff --git a/runtime-acm/src/main/java/org/onap/policy/clamp/acm/runtime/supervision/comm/AutomationCompositionStateChangeAckListener.java b/runtime-acm/src/main/java/org/onap/policy/clamp/acm/runtime/supervision/comm/AutomationCompositionStateChangeAckListener.java new file mode 100644 index 000000000..dd07be680 --- /dev/null +++ b/runtime-acm/src/main/java/org/onap/policy/clamp/acm/runtime/supervision/comm/AutomationCompositionStateChangeAckListener.java @@ -0,0 +1,70 @@ +/*- + * ============LICENSE_START======================================================= + * Copyright (C) 2021 Nordix Foundation. + * Modifications Copyright (C) 2021 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * SPDX-License-Identifier: Apache-2.0 + * ============LICENSE_END========================================================= + */ + +package org.onap.policy.clamp.acm.runtime.supervision.comm; + +import org.onap.policy.clamp.acm.runtime.config.messaging.Listener; +import org.onap.policy.clamp.acm.runtime.supervision.SupervisionHandler; +import org.onap.policy.clamp.models.acm.messages.dmaap.participant.AutomationCompositionAck; +import org.onap.policy.clamp.models.acm.messages.dmaap.participant.ParticipantMessageType; +import org.onap.policy.common.endpoints.event.comm.Topic.CommInfrastructure; +import org.onap.policy.common.endpoints.listeners.ScoListener; +import org.onap.policy.common.utils.coder.StandardCoderObject; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.stereotype.Component; + +/** + * Listener for AutomationCompositionStateChangeAck messages sent by participants. + */ +@Component +public class AutomationCompositionStateChangeAckListener extends ScoListener + implements Listener { + private static final Logger LOGGER = LoggerFactory.getLogger(AutomationCompositionStateChangeAckListener.class); + + private final SupervisionHandler supervisionHandler; + + /** + * Constructs the object. + */ + public AutomationCompositionStateChangeAckListener(SupervisionHandler supervisionHandler) { + super(AutomationCompositionAck.class); + this.supervisionHandler = supervisionHandler; + } + + @Override + public void onTopicEvent(final CommInfrastructure infra, final String topic, final StandardCoderObject sco, + final AutomationCompositionAck automationCompositionStateChangeAckMessage) { + LOGGER.debug("AutomationCompositionStateChangeAck received from participant - {}", + automationCompositionStateChangeAckMessage); + supervisionHandler.handleAutomationCompositionStateChangeAckMessage(automationCompositionStateChangeAckMessage); + } + + @Override + public ScoListener getScoListener() { + return this; + } + + @Override + public String getType() { + return ParticipantMessageType.AUTOMATION_COMPOSITION_STATECHANGE_ACK.name(); + } +} diff --git a/runtime-acm/src/main/java/org/onap/policy/clamp/acm/runtime/supervision/comm/AutomationCompositionStateChangePublisher.java b/runtime-acm/src/main/java/org/onap/policy/clamp/acm/runtime/supervision/comm/AutomationCompositionStateChangePublisher.java new file mode 100644 index 000000000..4e0d12bf6 --- /dev/null +++ b/runtime-acm/src/main/java/org/onap/policy/clamp/acm/runtime/supervision/comm/AutomationCompositionStateChangePublisher.java @@ -0,0 +1,50 @@ +/*- + * ============LICENSE_START======================================================= + * Copyright (C) 2021 Nordix Foundation. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * SPDX-License-Identifier: Apache-2.0 + * ============LICENSE_END========================================================= + */ + +package org.onap.policy.clamp.acm.runtime.supervision.comm; + +import java.util.UUID; +import org.onap.policy.clamp.models.acm.concepts.AutomationComposition; +import org.onap.policy.clamp.models.acm.messages.dmaap.participant.AutomationCompositionStateChange; +import org.springframework.stereotype.Component; + +/** + * This class is used to send AutomationCompositionStateChangePublisher messages to participants on DMaaP. + */ +@Component +public class AutomationCompositionStateChangePublisher + extends AbstractParticipantPublisher { + + /** + * Send AutomationCompositionStateChange to Participant. + * + * @param automationComposition the AutomationComposition + * @param startPhase the startPhase + */ + public void send(AutomationComposition automationComposition, int startPhase) { + var acsc = new AutomationCompositionStateChange(); + acsc.setAutomationCompositionId(automationComposition.getKey().asIdentifier()); + acsc.setMessageId(UUID.randomUUID()); + acsc.setOrderedState(automationComposition.getOrderedState()); + acsc.setStartPhase(startPhase); + + super.send(acsc); + } +} diff --git a/runtime-acm/src/main/java/org/onap/policy/clamp/acm/runtime/supervision/comm/AutomationCompositionUpdateAckListener.java b/runtime-acm/src/main/java/org/onap/policy/clamp/acm/runtime/supervision/comm/AutomationCompositionUpdateAckListener.java new file mode 100644 index 000000000..7a1d5294c --- /dev/null +++ b/runtime-acm/src/main/java/org/onap/policy/clamp/acm/runtime/supervision/comm/AutomationCompositionUpdateAckListener.java @@ -0,0 +1,70 @@ +/*- + * ============LICENSE_START======================================================= + * Copyright (C) 2021 Nordix Foundation. + * Modifications Copyright (C) 2021 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * SPDX-License-Identifier: Apache-2.0 + * ============LICENSE_END========================================================= + */ + +package org.onap.policy.clamp.acm.runtime.supervision.comm; + +import org.onap.policy.clamp.acm.runtime.config.messaging.Listener; +import org.onap.policy.clamp.acm.runtime.supervision.SupervisionHandler; +import org.onap.policy.clamp.models.acm.messages.dmaap.participant.AutomationCompositionAck; +import org.onap.policy.clamp.models.acm.messages.dmaap.participant.ParticipantMessageType; +import org.onap.policy.common.endpoints.event.comm.Topic.CommInfrastructure; +import org.onap.policy.common.endpoints.listeners.ScoListener; +import org.onap.policy.common.utils.coder.StandardCoderObject; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.stereotype.Component; + +/** + * Listener for AutomationCompositionUpdateAck messages sent by participants. + */ +@Component +public class AutomationCompositionUpdateAckListener extends ScoListener + implements Listener { + private static final Logger LOGGER = LoggerFactory.getLogger(AutomationCompositionUpdateAckListener.class); + + private final SupervisionHandler supervisionHandler; + + /** + * Constructs the object. + */ + public AutomationCompositionUpdateAckListener(SupervisionHandler supervisionHandler) { + super(AutomationCompositionAck.class); + this.supervisionHandler = supervisionHandler; + } + + @Override + public void onTopicEvent(final CommInfrastructure infra, final String topic, final StandardCoderObject sco, + final AutomationCompositionAck automationCompositionUpdateAckMessage) { + LOGGER.debug("AutomationCompositionUpdateAck message received from participant - {}", + automationCompositionUpdateAckMessage); + supervisionHandler.handleAutomationCompositionUpdateAckMessage(automationCompositionUpdateAckMessage); + } + + @Override + public ScoListener getScoListener() { + return this; + } + + @Override + public String getType() { + return ParticipantMessageType.AUTOMATION_COMPOSITION_UPDATE_ACK.name(); + } +} diff --git a/runtime-acm/src/main/java/org/onap/policy/clamp/acm/runtime/supervision/comm/AutomationCompositionUpdatePublisher.java b/runtime-acm/src/main/java/org/onap/policy/clamp/acm/runtime/supervision/comm/AutomationCompositionUpdatePublisher.java new file mode 100644 index 000000000..ac5a998b4 --- /dev/null +++ b/runtime-acm/src/main/java/org/onap/policy/clamp/acm/runtime/supervision/comm/AutomationCompositionUpdatePublisher.java @@ -0,0 +1,91 @@ +/*- + * ============LICENSE_START======================================================= + * Copyright (C) 2021 Nordix Foundation. + * ================================================================================ + * Modifications Copyright (C) 2021 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * SPDX-License-Identifier: Apache-2.0 + * ============LICENSE_END========================================================= + */ + +package org.onap.policy.clamp.acm.runtime.supervision.comm; + +import java.time.Instant; +import java.util.ArrayList; +import java.util.List; +import java.util.UUID; +import lombok.AllArgsConstructor; +import org.onap.policy.clamp.models.acm.concepts.AutomationComposition; +import org.onap.policy.clamp.models.acm.concepts.AutomationCompositionElement; +import org.onap.policy.clamp.models.acm.concepts.ParticipantUpdates; +import org.onap.policy.clamp.models.acm.messages.dmaap.participant.AutomationCompositionUpdate; +import org.onap.policy.clamp.models.acm.persistence.provider.ServiceTemplateProvider; +import org.onap.policy.clamp.models.acm.utils.AcmUtils; +import org.onap.policy.models.base.PfModelException; +import org.onap.policy.models.tosca.authorative.concepts.ToscaServiceTemplate; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.stereotype.Component; + +/** + * This class is used to send AutomationCompositionUpdate messages to participants on DMaaP. + */ +@Component +@AllArgsConstructor +public class AutomationCompositionUpdatePublisher extends AbstractParticipantPublisher { + + private static final Logger LOGGER = LoggerFactory.getLogger(AutomationCompositionUpdatePublisher.class); + private final ServiceTemplateProvider serviceTemplateProvider; + + /** + * Send AutomationCompositionUpdate to Participant. + * + * @param automationComposition the AutomationComposition + */ + public void send(AutomationComposition automationComposition) { + send(automationComposition, 0); + } + + /** + * Send AutomationCompositionUpdate to Participant. + * + * @param automationComposition the AutomationComposition + * @param startPhase the Start Phase + */ + public void send(AutomationComposition automationComposition, int startPhase) { + var automationCompositionUpdateMsg = new AutomationCompositionUpdate(); + automationCompositionUpdateMsg.setStartPhase(startPhase); + automationCompositionUpdateMsg.setAutomationCompositionId(automationComposition.getKey().asIdentifier()); + automationCompositionUpdateMsg.setMessageId(UUID.randomUUID()); + automationCompositionUpdateMsg.setTimestamp(Instant.now()); + ToscaServiceTemplate toscaServiceTemplate; + try { + toscaServiceTemplate = serviceTemplateProvider.getAllServiceTemplates().get(0); + } catch (PfModelException pfme) { + LOGGER.warn("Get of tosca service template failed, cannot send participantupdate", pfme); + return; + } + + List participantUpdates = new ArrayList<>(); + for (AutomationCompositionElement element : automationComposition.getElements().values()) { + AcmUtils.setServiceTemplatePolicyInfo(element, toscaServiceTemplate); + AcmUtils.prepareParticipantUpdate(element, participantUpdates); + } + automationCompositionUpdateMsg.setParticipantUpdatesList(participantUpdates); + + LOGGER.debug("AutomationCompositionUpdate message sent {}", automationCompositionUpdateMsg); + super.send(automationCompositionUpdateMsg); + } +} diff --git a/runtime-acm/src/main/java/org/onap/policy/clamp/acm/runtime/supervision/comm/ParticipantDeregisterAckPublisher.java b/runtime-acm/src/main/java/org/onap/policy/clamp/acm/runtime/supervision/comm/ParticipantDeregisterAckPublisher.java new file mode 100644 index 000000000..34881b557 --- /dev/null +++ b/runtime-acm/src/main/java/org/onap/policy/clamp/acm/runtime/supervision/comm/ParticipantDeregisterAckPublisher.java @@ -0,0 +1,45 @@ +/*- + * ============LICENSE_START======================================================= + * Copyright (C) 2021 Nordix Foundation. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * SPDX-License-Identifier: Apache-2.0 + * ============LICENSE_END========================================================= + */ + +package org.onap.policy.clamp.acm.runtime.supervision.comm; + +import java.util.UUID; +import org.onap.policy.clamp.models.acm.messages.dmaap.participant.ParticipantDeregisterAck; +import org.springframework.stereotype.Component; + +/** + * This class is used to send ParticipantDeregisterAck messages to participants on DMaaP. + */ +@Component +public class ParticipantDeregisterAckPublisher extends AbstractParticipantAckPublisher { + + /** + * Sent ParticipantDeregisterAck to Participant. + * + * @param responseTo the original request id in the request. + */ + public void send(UUID responseTo) { + var message = new ParticipantDeregisterAck(); + message.setResponseTo(responseTo); + message.setMessage("Participant Deregister Ack"); + message.setResult(true); + super.send(message); + } +} diff --git a/runtime-acm/src/main/java/org/onap/policy/clamp/acm/runtime/supervision/comm/ParticipantDeregisterListener.java b/runtime-acm/src/main/java/org/onap/policy/clamp/acm/runtime/supervision/comm/ParticipantDeregisterListener.java new file mode 100644 index 000000000..eec21235f --- /dev/null +++ b/runtime-acm/src/main/java/org/onap/policy/clamp/acm/runtime/supervision/comm/ParticipantDeregisterListener.java @@ -0,0 +1,69 @@ +/*- + * ============LICENSE_START======================================================= + * Copyright (C) 2021 Nordix Foundation. + * Modifications Copyright (C) 2021 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * SPDX-License-Identifier: Apache-2.0 + * ============LICENSE_END========================================================= + */ + +package org.onap.policy.clamp.acm.runtime.supervision.comm; + +import org.onap.policy.clamp.acm.runtime.config.messaging.Listener; +import org.onap.policy.clamp.acm.runtime.supervision.SupervisionHandler; +import org.onap.policy.clamp.models.acm.messages.dmaap.participant.ParticipantDeregister; +import org.onap.policy.clamp.models.acm.messages.dmaap.participant.ParticipantMessageType; +import org.onap.policy.common.endpoints.event.comm.Topic.CommInfrastructure; +import org.onap.policy.common.endpoints.listeners.ScoListener; +import org.onap.policy.common.utils.coder.StandardCoderObject; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.stereotype.Component; + +/** + * Listener for ParticipantDeregister messages sent by participants. + */ +@Component +public class ParticipantDeregisterListener extends ScoListener + implements Listener { + private static final Logger LOGGER = LoggerFactory.getLogger(ParticipantDeregisterListener.class); + + private final SupervisionHandler supervisionHandler; + + /** + * Constructs the object. + */ + public ParticipantDeregisterListener(SupervisionHandler supervisionHandler) { + super(ParticipantDeregister.class); + this.supervisionHandler = supervisionHandler; + } + + @Override + public void onTopicEvent(final CommInfrastructure infra, final String topic, final StandardCoderObject sco, + final ParticipantDeregister participantDeregisterMessage) { + LOGGER.debug("ParticipantDeregister message received from participant - {}", participantDeregisterMessage); + supervisionHandler.handleParticipantMessage(participantDeregisterMessage); + } + + @Override + public String getType() { + return ParticipantMessageType.PARTICIPANT_DEREGISTER.name(); + } + + @Override + public ScoListener getScoListener() { + return this; + } +} diff --git a/runtime-acm/src/main/java/org/onap/policy/clamp/acm/runtime/supervision/comm/ParticipantRegisterAckPublisher.java b/runtime-acm/src/main/java/org/onap/policy/clamp/acm/runtime/supervision/comm/ParticipantRegisterAckPublisher.java new file mode 100644 index 000000000..8344837c1 --- /dev/null +++ b/runtime-acm/src/main/java/org/onap/policy/clamp/acm/runtime/supervision/comm/ParticipantRegisterAckPublisher.java @@ -0,0 +1,50 @@ +/*- + * ============LICENSE_START======================================================= + * Copyright (C) 2021 Nordix Foundation. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * SPDX-License-Identifier: Apache-2.0 + * ============LICENSE_END========================================================= + */ + +package org.onap.policy.clamp.acm.runtime.supervision.comm; + +import java.util.UUID; +import org.onap.policy.clamp.models.acm.messages.dmaap.participant.ParticipantRegisterAck; +import org.onap.policy.models.tosca.authorative.concepts.ToscaConceptIdentifier; +import org.springframework.stereotype.Component; + +/** + * This class is used to send ParticipantRegisterAck messages to participants on DMaaP. + */ +@Component +public class ParticipantRegisterAckPublisher extends AbstractParticipantAckPublisher { + + /** + * Send ParticipantRegisterAck to Participant. + * + * @param responseTo the original request id in the request. + * @param participantId the participant Id + * @param participantType the participant Type + */ + public void send(UUID responseTo, ToscaConceptIdentifier participantId, ToscaConceptIdentifier participantType) { + var message = new ParticipantRegisterAck(); + message.setParticipantId(participantId); + message.setParticipantType(participantType); + message.setResponseTo(responseTo); + message.setMessage("Participant Register Ack"); + message.setResult(true); + super.send(message); + } +} diff --git a/runtime-acm/src/main/java/org/onap/policy/clamp/acm/runtime/supervision/comm/ParticipantRegisterListener.java b/runtime-acm/src/main/java/org/onap/policy/clamp/acm/runtime/supervision/comm/ParticipantRegisterListener.java new file mode 100644 index 000000000..852340000 --- /dev/null +++ b/runtime-acm/src/main/java/org/onap/policy/clamp/acm/runtime/supervision/comm/ParticipantRegisterListener.java @@ -0,0 +1,69 @@ +/*- + * ============LICENSE_START======================================================= + * Copyright (C) 2021 Nordix Foundation. + * Modifications Copyright (C) 2021 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * SPDX-License-Identifier: Apache-2.0 + * ============LICENSE_END========================================================= + */ + +package org.onap.policy.clamp.acm.runtime.supervision.comm; + +import org.onap.policy.clamp.acm.runtime.config.messaging.Listener; +import org.onap.policy.clamp.acm.runtime.supervision.SupervisionHandler; +import org.onap.policy.clamp.models.acm.messages.dmaap.participant.ParticipantMessageType; +import org.onap.policy.clamp.models.acm.messages.dmaap.participant.ParticipantRegister; +import org.onap.policy.common.endpoints.event.comm.Topic.CommInfrastructure; +import org.onap.policy.common.endpoints.listeners.ScoListener; +import org.onap.policy.common.utils.coder.StandardCoderObject; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.stereotype.Component; + +/** + * Listener for ParticipantRegister messages sent by participants. + */ +@Component +public class ParticipantRegisterListener extends ScoListener + implements Listener { + private static final Logger LOGGER = LoggerFactory.getLogger(ParticipantRegisterListener.class); + + private final SupervisionHandler supervisionHandler; + + /** + * Constructs the object. + */ + public ParticipantRegisterListener(SupervisionHandler supervisionHandler) { + super(ParticipantRegister.class); + this.supervisionHandler = supervisionHandler; + } + + @Override + public void onTopicEvent(final CommInfrastructure infra, final String topic, final StandardCoderObject sco, + final ParticipantRegister participantRegisterMessage) { + LOGGER.debug("ParticipantRegister message received from participant - {}", participantRegisterMessage); + supervisionHandler.handleParticipantMessage(participantRegisterMessage); + } + + @Override + public String getType() { + return ParticipantMessageType.PARTICIPANT_REGISTER.name(); + } + + @Override + public ScoListener getScoListener() { + return this; + } +} diff --git a/runtime-acm/src/main/java/org/onap/policy/clamp/acm/runtime/supervision/comm/ParticipantStatusListener.java b/runtime-acm/src/main/java/org/onap/policy/clamp/acm/runtime/supervision/comm/ParticipantStatusListener.java new file mode 100644 index 000000000..4ae1a1a2d --- /dev/null +++ b/runtime-acm/src/main/java/org/onap/policy/clamp/acm/runtime/supervision/comm/ParticipantStatusListener.java @@ -0,0 +1,68 @@ +/*- + * ============LICENSE_START======================================================= + * Copyright (C) 2021 Nordix Foundation. + * Modifications Copyright (C) 2021 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * SPDX-License-Identifier: Apache-2.0 + * ============LICENSE_END========================================================= + */ + +package org.onap.policy.clamp.acm.runtime.supervision.comm; + +import org.onap.policy.clamp.acm.runtime.config.messaging.Listener; +import org.onap.policy.clamp.acm.runtime.supervision.SupervisionHandler; +import org.onap.policy.clamp.models.acm.messages.dmaap.participant.ParticipantMessageType; +import org.onap.policy.clamp.models.acm.messages.dmaap.participant.ParticipantStatus; +import org.onap.policy.common.endpoints.event.comm.Topic.CommInfrastructure; +import org.onap.policy.common.endpoints.listeners.ScoListener; +import org.onap.policy.common.utils.coder.StandardCoderObject; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.stereotype.Component; + +/** + * Listener for ParticipantStatus messages sent by participants. + */ +@Component +public class ParticipantStatusListener extends ScoListener implements Listener { + private static final Logger LOGGER = LoggerFactory.getLogger(ParticipantStatusListener.class); + + private final SupervisionHandler supervisionHandler; + + /** + * Constructs the object. + */ + public ParticipantStatusListener(SupervisionHandler supervisionHandler) { + super(ParticipantStatus.class); + this.supervisionHandler = supervisionHandler; + } + + @Override + public void onTopicEvent(final CommInfrastructure infra, final String topic, final StandardCoderObject sco, + final ParticipantStatus participantStatusMessage) { + LOGGER.debug("ParticipantStatus message received from participant - {}", participantStatusMessage); + supervisionHandler.handleParticipantMessage(participantStatusMessage); + } + + @Override + public String getType() { + return ParticipantMessageType.PARTICIPANT_STATUS.name(); + } + + @Override + public ScoListener getScoListener() { + return this; + } +} diff --git a/runtime-acm/src/main/java/org/onap/policy/clamp/acm/runtime/supervision/comm/ParticipantStatusReqPublisher.java b/runtime-acm/src/main/java/org/onap/policy/clamp/acm/runtime/supervision/comm/ParticipantStatusReqPublisher.java new file mode 100644 index 000000000..0de8ff063 --- /dev/null +++ b/runtime-acm/src/main/java/org/onap/policy/clamp/acm/runtime/supervision/comm/ParticipantStatusReqPublisher.java @@ -0,0 +1,48 @@ +/*- + * ============LICENSE_START======================================================= + * Copyright (C) 2021 Nordix Foundation. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * SPDX-License-Identifier: Apache-2.0 + * ============LICENSE_END========================================================= + */ + +package org.onap.policy.clamp.acm.runtime.supervision.comm; + +import java.time.Instant; +import org.onap.policy.clamp.models.acm.messages.dmaap.participant.ParticipantStatusReq; +import org.onap.policy.models.tosca.authorative.concepts.ToscaConceptIdentifier; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.stereotype.Component; + +@Component +public class ParticipantStatusReqPublisher extends AbstractParticipantPublisher { + + private static final Logger LOGGER = LoggerFactory.getLogger(ParticipantStatusReqPublisher.class); + + /** + * Send ParticipantStatusReq to Participant. + * + * @param participantId the participant Id + */ + public void send(ToscaConceptIdentifier participantId) { + ParticipantStatusReq message = new ParticipantStatusReq(); + message.setParticipantId(participantId); + message.setTimestamp(Instant.now()); + + LOGGER.debug("Participant StatusReq sent {}", message); + super.send(message); + } +} diff --git a/runtime-acm/src/main/java/org/onap/policy/clamp/acm/runtime/supervision/comm/ParticipantUpdateAckListener.java b/runtime-acm/src/main/java/org/onap/policy/clamp/acm/runtime/supervision/comm/ParticipantUpdateAckListener.java new file mode 100644 index 000000000..d75de775b --- /dev/null +++ b/runtime-acm/src/main/java/org/onap/policy/clamp/acm/runtime/supervision/comm/ParticipantUpdateAckListener.java @@ -0,0 +1,69 @@ +/*- + * ============LICENSE_START======================================================= + * Copyright (C) 2021 Nordix Foundation. + * Modifications Copyright (C) 2021 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * SPDX-License-Identifier: Apache-2.0 + * ============LICENSE_END========================================================= + */ + +package org.onap.policy.clamp.acm.runtime.supervision.comm; + +import org.onap.policy.clamp.acm.runtime.config.messaging.Listener; +import org.onap.policy.clamp.acm.runtime.supervision.SupervisionHandler; +import org.onap.policy.clamp.models.acm.messages.dmaap.participant.ParticipantMessageType; +import org.onap.policy.clamp.models.acm.messages.dmaap.participant.ParticipantUpdateAck; +import org.onap.policy.common.endpoints.event.comm.Topic.CommInfrastructure; +import org.onap.policy.common.endpoints.listeners.ScoListener; +import org.onap.policy.common.utils.coder.StandardCoderObject; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.stereotype.Component; + +/** + * Listener for ParticipantUpdateAck messages sent by participants. + */ +@Component +public class ParticipantUpdateAckListener extends ScoListener + implements Listener { + private static final Logger LOGGER = LoggerFactory.getLogger(ParticipantUpdateAckListener.class); + + private final SupervisionHandler supervisionHandler; + + /** + * Constructs the object. + */ + public ParticipantUpdateAckListener(SupervisionHandler supervisionHandler) { + super(ParticipantUpdateAck.class); + this.supervisionHandler = supervisionHandler; + } + + @Override + public void onTopicEvent(final CommInfrastructure infra, final String topic, final StandardCoderObject sco, + final ParticipantUpdateAck participantUpdateAckMessage) { + LOGGER.debug("ParticipantUpdateAck message received from participant - {}", participantUpdateAckMessage); + supervisionHandler.handleParticipantMessage(participantUpdateAckMessage); + } + + @Override + public String getType() { + return ParticipantMessageType.PARTICIPANT_UPDATE_ACK.name(); + } + + @Override + public ScoListener getScoListener() { + return this; + } +} diff --git a/runtime-acm/src/main/java/org/onap/policy/clamp/acm/runtime/supervision/comm/ParticipantUpdatePublisher.java b/runtime-acm/src/main/java/org/onap/policy/clamp/acm/runtime/supervision/comm/ParticipantUpdatePublisher.java new file mode 100644 index 000000000..47a66c10e --- /dev/null +++ b/runtime-acm/src/main/java/org/onap/policy/clamp/acm/runtime/supervision/comm/ParticipantUpdatePublisher.java @@ -0,0 +1,127 @@ +/*- + * ============LICENSE_START======================================================= + * Copyright (C) 2021 Nordix Foundation. + * ================================================================================ + * Modifications Copyright (C) 2021 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * SPDX-License-Identifier: Apache-2.0 + * ============LICENSE_END========================================================= + */ + +package org.onap.policy.clamp.acm.runtime.supervision.comm; + +import java.time.Instant; +import java.util.ArrayList; +import java.util.List; +import java.util.Map; +import lombok.AllArgsConstructor; +import org.onap.policy.clamp.models.acm.concepts.ParticipantDefinition; +import org.onap.policy.clamp.models.acm.concepts.ParticipantUtils; +import org.onap.policy.clamp.models.acm.messages.dmaap.participant.ParticipantUpdate; +import org.onap.policy.clamp.models.acm.persistence.provider.ServiceTemplateProvider; +import org.onap.policy.clamp.models.acm.utils.AcmUtils; +import org.onap.policy.models.base.PfModelException; +import org.onap.policy.models.tosca.authorative.concepts.ToscaConceptIdentifier; +import org.onap.policy.models.tosca.authorative.concepts.ToscaNodeType; +import org.onap.policy.models.tosca.authorative.concepts.ToscaServiceTemplate; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.stereotype.Component; + +/** + * This class is used to send ParticipantUpdate messages to participants on DMaaP. + */ +@Component +@AllArgsConstructor +public class ParticipantUpdatePublisher extends AbstractParticipantPublisher { + + private static final Logger LOGGER = LoggerFactory.getLogger(ParticipantUpdatePublisher.class); + + private final ServiceTemplateProvider serviceTemplateProvider; + + /** + * Send ParticipantUpdate to all Participants. + * + * @param name the ToscaServiceTemplate name + * @param version the ToscaServiceTemplate version + */ + public void sendComissioningBroadcast(String name, String version) { + sendCommissioning(name, version, null, null); + } + + /** + * Send ParticipantUpdate to Participant + * if participantType and participantId are null then message is broadcast. + * + * @param name the ToscaServiceTemplate name + * @param version the ToscaServiceTemplate version + * @param participantType the ParticipantType + * @param participantId the ParticipantId + */ + public boolean sendCommissioning(String name, String version, ToscaConceptIdentifier participantType, + ToscaConceptIdentifier participantId) { + var message = new ParticipantUpdate(); + message.setParticipantType(participantType); + message.setParticipantId(participantId); + message.setTimestamp(Instant.now()); + + ToscaServiceTemplate toscaServiceTemplate = null; + Map commonPropertiesMap = null; + try { + var list = serviceTemplateProvider.getServiceTemplateList(name, version); + if (!list.isEmpty()) { + toscaServiceTemplate = list.get(0); + commonPropertiesMap = + serviceTemplateProvider.getCommonOrInstancePropertiesFromNodeTypes(true, toscaServiceTemplate); + } else { + LOGGER.warn("No tosca service template found, cannot send participantupdate {} {}", name, version); + return false; + } + } catch (PfModelException pfme) { + LOGGER.warn("Get of tosca service template failed, cannot send participantupdate", pfme); + return false; + } + + List participantDefinitionUpdates = new ArrayList<>(); + for (var toscaInputEntry : toscaServiceTemplate.getToscaTopologyTemplate().getNodeTemplates().entrySet()) { + if (ParticipantUtils.checkIfNodeTemplateIsAutomationCompositionElement(toscaInputEntry.getValue(), + toscaServiceTemplate)) { + AcmUtils.prepareParticipantDefinitionUpdate( + ParticipantUtils.findParticipantType(toscaInputEntry.getValue().getProperties()), + toscaInputEntry.getKey(), toscaInputEntry.getValue(), + participantDefinitionUpdates, commonPropertiesMap); + } + } + + // Commission the automation composition but sending participantdefinitions to participants + message.setParticipantDefinitionUpdates(participantDefinitionUpdates); + LOGGER.debug("Participant Update sent {}", message); + super.send(message); + return true; + } + + /** + * Send ParticipantUpdate to Participant after that commissioning has been removed. + */ + public void sendDecomisioning() { + var message = new ParticipantUpdate(); + message.setTimestamp(Instant.now()); + // DeCommission the automation composition but deleting participantdefinitions on participants + message.setParticipantDefinitionUpdates(null); + + LOGGER.debug("Participant Update sent {}", message); + super.send(message); + } +} diff --git a/runtime-acm/src/main/resources/application.yaml b/runtime-acm/src/main/resources/application.yaml new file mode 100644 index 000000000..9f60211c8 --- /dev/null +++ b/runtime-acm/src/main/resources/application.yaml @@ -0,0 +1,66 @@ +spring: + security: + user: + name: runtimeUser + password: zb!XztG34 + http: + converters: + preferred-json-mapper: gson + datasource: + url: jdbc:mariadb://${mariadb.host:localhost}:${mariadb.port:3306}/clamp-acm + driverClassName: org.mariadb.jdbc.Driver + username: policy + password: P01icY + hikari: + connectionTimeout: 30000 + idleTimeout: 600000 + maxLifetime: 1800000 + maximumPoolSize: 10 + jpa: + hibernate: + ddl-auto: update + naming: + physical-strategy: org.hibernate.boot.model.naming.PhysicalNamingStrategyStandardImpl + implicit-strategy: org.onap.policy.common.spring.utils.CustomImplicitNamingStrategy + properties: + hibernate: + dialect: org.hibernate.dialect.MariaDB103Dialect + format_sql: true + +security: + enable-csrf: false + +server: + port: 6969 + servlet: + context-path: /onap/policy/clamp/acm + error: + path: /error + +runtime: + participantParameters: + heartBeatMs: 20000 + maxStatusWaitMs: 100000 + updateParameters: + maxRetryCount: 4 + maxWaitMs: 20000 + topicParameterGroup: + topicSources: + - + topic: POLICY-ACRUNTIME-PARTICIPANT + servers: + - ${topicServer:localhost} + topicCommInfrastructure: dmaap + fetchTimeout: 15000 + topicSinks: + - + topic: POLICY-ACRUNTIME-PARTICIPANT + servers: + - ${topicServer:localhost} + topicCommInfrastructure: dmaap + +management: + endpoints: + web: + exposure: + include: health, metrics, prometheus diff --git a/runtime-acm/src/main/resources/version.txt b/runtime-acm/src/main/resources/version.txt new file mode 100644 index 000000000..46ff2c3a7 --- /dev/null +++ b/runtime-acm/src/main/resources/version.txt @@ -0,0 +1,4 @@ +ONAP Tosca defined automation composition +Version: ${project.version} +Built (UTC): ${maven.build.timestamp} +ONAP https://wiki.onap.org diff --git a/runtime-acm/src/test/java/org/onap/policy/clamp/acm/runtime/commissioning/CommissioningProviderTest.java b/runtime-acm/src/test/java/org/onap/policy/clamp/acm/runtime/commissioning/CommissioningProviderTest.java new file mode 100644 index 000000000..35731d0e0 --- /dev/null +++ b/runtime-acm/src/test/java/org/onap/policy/clamp/acm/runtime/commissioning/CommissioningProviderTest.java @@ -0,0 +1,221 @@ +/*- + * ============LICENSE_START======================================================= + * Copyright (C) 2021 Nordix Foundation. + * Modifications Copyright (C) 2021 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * SPDX-License-Identifier: Apache-2.0 + * ============LICENSE_END========================================================= + */ + +package org.onap.policy.clamp.acm.runtime.commissioning; + +import static org.assertj.core.api.Assertions.assertThat; +import static org.mockito.ArgumentMatchers.any; +import static org.mockito.ArgumentMatchers.eq; +import static org.mockito.Mockito.mock; +import static org.mockito.Mockito.verify; +import static org.mockito.Mockito.when; + +import com.fasterxml.jackson.databind.ObjectMapper; +import com.fasterxml.jackson.databind.PropertyNamingStrategies; +import com.fasterxml.jackson.module.jsonSchema.factories.SchemaFactoryWrapper; +import java.util.List; +import java.util.Map; +import org.junit.jupiter.api.Test; +import org.onap.policy.clamp.acm.runtime.instantiation.InstantiationUtils; +import org.onap.policy.clamp.models.acm.persistence.provider.AutomationCompositionProvider; +import org.onap.policy.clamp.models.acm.persistence.provider.ParticipantProvider; +import org.onap.policy.clamp.models.acm.persistence.provider.ServiceTemplateProvider; +import org.onap.policy.common.utils.coder.Coder; +import org.onap.policy.common.utils.coder.StandardCoder; +import org.onap.policy.models.tosca.authorative.concepts.ToscaCapabilityType; +import org.onap.policy.models.tosca.authorative.concepts.ToscaConceptIdentifier; +import org.onap.policy.models.tosca.authorative.concepts.ToscaDataType; +import org.onap.policy.models.tosca.authorative.concepts.ToscaNodeTemplate; +import org.onap.policy.models.tosca.authorative.concepts.ToscaNodeType; +import org.onap.policy.models.tosca.authorative.concepts.ToscaPolicyType; +import org.onap.policy.models.tosca.authorative.concepts.ToscaRelationshipType; +import org.onap.policy.models.tosca.authorative.concepts.ToscaServiceTemplate; +import org.onap.policy.models.tosca.authorative.concepts.ToscaTopologyTemplate; + +class CommissioningProviderTest { + private static final String TOSCA_SERVICE_TEMPLATE_YAML = + "src/test/resources/rest/servicetemplates/pmsh_multiple_ac_tosca.yaml"; + private static final String COMMON_TOSCA_SERVICE_TEMPLATE_YAML = + "src/test/resources/rest/servicetemplates/full-tosca-with-common-properties.yaml"; + + private static final Coder CODER = new StandardCoder(); + private final ObjectMapper mapper = new ObjectMapper(); + + /** + * Test the fetching of automation composition definitions (ToscaServiceTemplates). + * + * @throws Exception . + */ + @Test + void testGetAutomationCompositionDefinitions() throws Exception { + var acProvider = mock(AutomationCompositionProvider.class); + var participantProvider = mock(ParticipantProvider.class); + var serviceTemplateProvider = mock(ServiceTemplateProvider.class); + + CommissioningProvider provider = + new CommissioningProvider(serviceTemplateProvider, acProvider, null, participantProvider); + + List listOfTemplates = provider.getAutomationCompositionDefinitions(null, null); + assertThat(listOfTemplates).isEmpty(); + + when(acProvider.getFilteredNodeTemplates(any())) + .thenReturn(List.of(new ToscaNodeTemplate(), new ToscaNodeTemplate())); + listOfTemplates = provider.getAutomationCompositionDefinitions(null, null); + assertThat(listOfTemplates).hasSize(2); + } + + /** + * Test the creation of automation composition definitions (ToscaServiceTemplates). + * + * @throws Exception . + */ + @Test + void testCreateAutomationCompositionDefinitions() throws Exception { + var serviceTemplateProvider = mock(ServiceTemplateProvider.class); + var acProvider = mock(AutomationCompositionProvider.class); + var participantProvider = mock(ParticipantProvider.class); + + CommissioningProvider provider = + new CommissioningProvider(serviceTemplateProvider, acProvider, null, participantProvider); + + List listOfTemplates = provider.getAutomationCompositionDefinitions(null, null); + assertThat(listOfTemplates).isEmpty(); + + ToscaServiceTemplate serviceTemplate = InstantiationUtils.getToscaServiceTemplate(TOSCA_SERVICE_TEMPLATE_YAML); + when(serviceTemplateProvider.createServiceTemplate(serviceTemplate)).thenReturn(serviceTemplate); + + // Response should return the number of node templates present in the service template + List affectedDefinitions = provider + .createAutomationCompositionDefinitions(serviceTemplate).getAffectedAutomationCompositionDefinitions(); + assertThat(affectedDefinitions).hasSize(13); + + when(acProvider.getFilteredNodeTemplates(any())) + .thenReturn(List.of(new ToscaNodeTemplate(), new ToscaNodeTemplate())); + + listOfTemplates = provider.getAutomationCompositionDefinitions(null, null); + assertThat(listOfTemplates).hasSize(2); + } + + /** + * Test the fetching of a full ToscaServiceTemplate object - as opposed to the reduced template that is being + * tested in the testGetToscaServiceTemplateReduced() test. + * + */ + @Test + void testGetToscaServiceTemplate() throws Exception { + var serviceTemplateProvider = mock(ServiceTemplateProvider.class); + var acProvider = mock(AutomationCompositionProvider.class); + var participantProvider = mock(ParticipantProvider.class); + + CommissioningProvider provider = + new CommissioningProvider(serviceTemplateProvider, acProvider, null, participantProvider); + ToscaServiceTemplate serviceTemplate = + InstantiationUtils.getToscaServiceTemplate(COMMON_TOSCA_SERVICE_TEMPLATE_YAML); + when(serviceTemplateProvider.createServiceTemplate(serviceTemplate)).thenReturn(serviceTemplate); + + provider.createAutomationCompositionDefinitions(serviceTemplate); + verify(serviceTemplateProvider).createServiceTemplate(serviceTemplate); + + when(serviceTemplateProvider.getToscaServiceTemplate(eq(null), eq(null))).thenReturn(serviceTemplate); + + ToscaServiceTemplate returnedServiceTemplate = provider.getToscaServiceTemplate(null, null); + assertThat(returnedServiceTemplate).isNotNull(); + + Map nodeTemplates = + returnedServiceTemplate.getToscaTopologyTemplate().getNodeTemplates(); + + assertThat(nodeTemplates).hasSize(8); + } + + /** + * Test the fetching of a reduced ToscaServiceTemplate with only some of the objects from the full template. + * The reduced template does not contain: DataTypesAsMap or PolicyTypesAsMap. + * + */ + @Test + void testGetToscaServiceTemplateReduced() throws Exception { + var serviceTemplateProvider = mock(ServiceTemplateProvider.class); + var acProvider = mock(AutomationCompositionProvider.class); + var participantProvider = mock(ParticipantProvider.class); + + CommissioningProvider provider = + new CommissioningProvider(serviceTemplateProvider, acProvider, null, participantProvider); + ToscaServiceTemplate serviceTemplate = + InstantiationUtils.getToscaServiceTemplate(COMMON_TOSCA_SERVICE_TEMPLATE_YAML); + when(serviceTemplateProvider.createServiceTemplate(serviceTemplate)).thenReturn(serviceTemplate); + + provider.createAutomationCompositionDefinitions(serviceTemplate); + + when(serviceTemplateProvider.getServiceTemplateList(any(), any())).thenReturn(List.of(serviceTemplate)); + + String returnedServiceTemplate = provider.getToscaServiceTemplateReduced(null, null); + assertThat(returnedServiceTemplate).isNotNull(); + ToscaServiceTemplate parsedServiceTemplate = CODER.decode(returnedServiceTemplate, ToscaServiceTemplate.class); + + assertThat(parsedServiceTemplate.getToscaTopologyTemplate().getNodeTemplates()).hasSize(8); + } + + /** + * Tests the different schemas being returned from the schema endpoint. As schemas of the different + * sections of the Tosca Service Templates can be returned by the API, this test must cover all of the + * different sections. + * + */ + @Test + void testGetToscaServiceTemplateSchema() throws Exception { + var serviceTemplateProvider = mock(ServiceTemplateProvider.class); + var acProvider = mock(AutomationCompositionProvider.class); + var participantProvider = mock(ParticipantProvider.class); + + CommissioningProvider provider = + new CommissioningProvider(serviceTemplateProvider, acProvider, null, participantProvider); + ToscaServiceTemplate serviceTemplate = + InstantiationUtils.getToscaServiceTemplate(COMMON_TOSCA_SERVICE_TEMPLATE_YAML); + when(serviceTemplateProvider.createServiceTemplate(serviceTemplate)).thenReturn(serviceTemplate); + + provider.createAutomationCompositionDefinitions(serviceTemplate); + + mapper.setPropertyNamingStrategy(PropertyNamingStrategies.SNAKE_CASE); + + Map> sections = Map.of("all", ToscaServiceTemplate.class, "data_types", ToscaDataType.class, + "capability_types", ToscaCapabilityType.class, "node_types", ToscaNodeType.class, "relationship_types", + ToscaRelationshipType.class, "policy_types", ToscaPolicyType.class, "topology_template", + ToscaTopologyTemplate.class, "node_templates", List.class); + + for (Map.Entry> entry : sections.entrySet()) { + String returnedServiceTemplateSchema = provider.getToscaServiceTemplateSchema(entry.getKey()); + assertThat(returnedServiceTemplateSchema).isNotNull(); + + var visitor = new SchemaFactoryWrapper(); + + if (entry.getKey().equals("node_templates")) { + mapper.acceptJsonFormatVisitor( + mapper.getTypeFactory().constructCollectionType(List.class, ToscaNodeTemplate.class), visitor); + } else { + mapper.acceptJsonFormatVisitor(mapper.constructType(entry.getValue()), visitor); + } + + var jsonSchema = visitor.finalSchema(); + String localServiceTemplateSchema = mapper.writerWithDefaultPrettyPrinter().writeValueAsString(jsonSchema); + assertThat(localServiceTemplateSchema).isEqualTo(returnedServiceTemplateSchema); + } + } +} diff --git a/runtime-acm/src/test/java/org/onap/policy/clamp/acm/runtime/commissioning/rest/CommissioningControllerTest.java b/runtime-acm/src/test/java/org/onap/policy/clamp/acm/runtime/commissioning/rest/CommissioningControllerTest.java new file mode 100644 index 000000000..2a49e04c1 --- /dev/null +++ b/runtime-acm/src/test/java/org/onap/policy/clamp/acm/runtime/commissioning/rest/CommissioningControllerTest.java @@ -0,0 +1,303 @@ +/*- + * ============LICENSE_START======================================================= + * Copyright (C) 2021 Nordix Foundation. + * Modifications Copyright (C) 2021 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * SPDX-License-Identifier: Apache-2.0 + * ============LICENSE_END========================================================= + */ + +package org.onap.policy.clamp.acm.runtime.commissioning.rest; + +import static org.assertj.core.api.Assertions.assertThat; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertNotNull; +import static org.junit.jupiter.api.Assertions.assertNull; +import static org.junit.jupiter.api.Assertions.assertTrue; + +import java.util.List; +import java.util.Map; +import javax.ws.rs.client.Entity; +import javax.ws.rs.client.Invocation; +import javax.ws.rs.core.Response; +import org.junit.jupiter.api.AfterEach; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.ExtendWith; +import org.junit.jupiter.api.parallel.Execution; +import org.junit.jupiter.api.parallel.ExecutionMode; +import org.onap.policy.clamp.acm.runtime.instantiation.InstantiationUtils; +import org.onap.policy.clamp.acm.runtime.util.rest.CommonRestController; +import org.onap.policy.clamp.models.acm.messages.rest.commissioning.CommissioningResponse; +import org.onap.policy.clamp.models.acm.persistence.provider.ServiceTemplateProvider; +import org.onap.policy.models.tosca.authorative.concepts.ToscaNodeTemplate; +import org.onap.policy.models.tosca.authorative.concepts.ToscaServiceTemplate; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.boot.test.context.SpringBootTest; +import org.springframework.boot.test.context.SpringBootTest.WebEnvironment; +import org.springframework.boot.web.server.LocalServerPort; +import org.springframework.test.context.TestPropertySource; +import org.springframework.test.context.junit.jupiter.SpringExtension; + +@ExtendWith(SpringExtension.class) +@SpringBootTest(webEnvironment = WebEnvironment.RANDOM_PORT) +@TestPropertySource(locations = {"classpath:application_test.properties"}) +@Execution(ExecutionMode.SAME_THREAD) +class CommissioningControllerTest extends CommonRestController { + + private static final String TOSCA_SERVICE_TEMPLATE_YAML = + "src/test/resources/rest/servicetemplates/pmsh_multiple_ac_tosca.yaml"; + private static final String COMMON_TOSCA_SERVICE_TEMPLATE_YAML = + "src/test/resources/rest/servicetemplates/full-tosca-with-common-properties.yaml"; + + private static final String COMMISSIONING_ENDPOINT = "commission"; + private static ToscaServiceTemplate serviceTemplate = new ToscaServiceTemplate(); + private static ToscaServiceTemplate commonPropertiesServiceTemplate = new ToscaServiceTemplate(); + + @Autowired + private ServiceTemplateProvider serviceTemplateProvider; + + @LocalServerPort + private int randomServerPort; + + /** + * starts Main and inserts a commissioning template. + * + * @throws Exception if an error occurs + */ + @BeforeAll + public static void setUpBeforeClass() throws Exception { + + serviceTemplate = InstantiationUtils.getToscaServiceTemplate(TOSCA_SERVICE_TEMPLATE_YAML); + commonPropertiesServiceTemplate = + InstantiationUtils.getToscaServiceTemplate(COMMON_TOSCA_SERVICE_TEMPLATE_YAML); + } + + @BeforeEach + public void setUpPort() { + super.setHttpPrefix(randomServerPort); + } + + @AfterEach + public void cleanDatabase() throws Exception { + deleteEntryInDB(); + } + + @Test + void testSwagger() throws Exception { + super.testSwagger(COMMISSIONING_ENDPOINT); + } + + @Test + void testUnauthorizedCreate() throws Exception { + assertUnauthorizedPost(COMMISSIONING_ENDPOINT, Entity.json(serviceTemplate)); + } + + @Test + void testUnauthorizedQuery() throws Exception { + assertUnauthorizedGet(COMMISSIONING_ENDPOINT); + } + + @Test + void testUnauthorizedQueryElements() throws Exception { + assertUnauthorizedGet(COMMISSIONING_ENDPOINT + "/elements"); + } + + @Test + void testUnauthorizedDelete() throws Exception { + assertUnauthorizedDelete(COMMISSIONING_ENDPOINT); + } + + @Test + void testUnauthorizedQueryToscaServiceTemplate() throws Exception { + assertUnauthorizedGet(COMMISSIONING_ENDPOINT + "/toscaservicetemplate"); + } + + @Test + void testUnauthorizedQueryToscaServiceTemplateSchema() throws Exception { + assertUnauthorizedGet(COMMISSIONING_ENDPOINT + "/toscaServiceTemplateSchema"); + } + + @Test + void testUnauthorizedQueryToscaServiceCommonOrInstanceProperties() throws Exception { + assertUnauthorizedGet(COMMISSIONING_ENDPOINT + "/getCommonOrInstanceProperties"); + } + + @Test + void testQueryToscaServiceTemplate() throws Exception { + createFullEntryInDbWithCommonProps(); + + Invocation.Builder invocationBuilder = super.sendRequest(COMMISSIONING_ENDPOINT + "/toscaservicetemplate"); + Response rawresp = invocationBuilder.buildGet().invoke(); + assertEquals(Response.Status.OK.getStatusCode(), rawresp.getStatus()); + ToscaServiceTemplate template = rawresp.readEntity(ToscaServiceTemplate.class); + assertNotNull(template); + assertThat(template.getNodeTypes()).hasSize(8); + + } + + @Test + void testQueryToscaServiceTemplateSchema() throws Exception { + createFullEntryInDbWithCommonProps(); + + Invocation.Builder invocationBuilder = + super.sendRequest(COMMISSIONING_ENDPOINT + "/toscaServiceTemplateSchema"); + Response rawresp = invocationBuilder.buildGet().invoke(); + assertEquals(Response.Status.OK.getStatusCode(), rawresp.getStatus()); + String schema = rawresp.readEntity(String.class); + assertNotNull(schema); + + } + + @Test + void testQueryCommonOrInstanceProperties() throws Exception { + createFullEntryInDbWithCommonProps(); + + Invocation.Builder invocationBuilder = super.sendRequest(COMMISSIONING_ENDPOINT + + "/getCommonOrInstanceProperties" + "?common=true&name=ToscaServiceTemplateSimple&version=1.0.0"); + Response rawresp = invocationBuilder.buildGet().invoke(); + assertEquals(Response.Status.OK.getStatusCode(), rawresp.getStatus()); + + @SuppressWarnings("unchecked") + Map commonProperties = rawresp.readEntity(Map.class); + + assertNotNull(commonProperties); + assertThat(commonProperties).hasSize(6); + + } + + @Test + void testCreateBadRequest() throws Exception { + Invocation.Builder invocationBuilder = super.sendRequest(COMMISSIONING_ENDPOINT); + Response resp = invocationBuilder.post(Entity.json("NotToscaServiceTempalte")); + + assertThat(Response.Status.INTERNAL_SERVER_ERROR.getStatusCode()).isEqualTo(resp.getStatus()); + CommissioningResponse commissioningResponse = resp.readEntity(CommissioningResponse.class); + assertThat(commissioningResponse.getErrorDetails()).isNotNull(); + assertThat(commissioningResponse.getAffectedAutomationCompositionDefinitions()).isNull(); + } + + @Test + void testCreate() throws Exception { + Invocation.Builder invocationBuilder = super.sendRequest(COMMISSIONING_ENDPOINT); + Response resp = invocationBuilder.post(Entity.json(serviceTemplate)); + assertEquals(Response.Status.OK.getStatusCode(), resp.getStatus()); + CommissioningResponse commissioningResponse = resp.readEntity(CommissioningResponse.class); + + assertNotNull(commissioningResponse); + assertNull(commissioningResponse.getErrorDetails()); + // Response should return the number of node templates present in the service template + assertThat(commissioningResponse.getAffectedAutomationCompositionDefinitions()).hasSize(13); + for (String nodeTemplateName : serviceTemplate.getToscaTopologyTemplate().getNodeTemplates().keySet()) { + assertTrue(commissioningResponse.getAffectedAutomationCompositionDefinitions().stream() + .anyMatch(ac -> ac.getName().equals(nodeTemplateName))); + } + + } + + @Test + void testQuery_NoResultWithThisName() throws Exception { + createEntryInDB(); + + Invocation.Builder invocationBuilder = super.sendRequest(COMMISSIONING_ENDPOINT + "?name=noResultWithThisName"); + Response rawresp = invocationBuilder.buildGet().invoke(); + assertEquals(Response.Status.OK.getStatusCode(), rawresp.getStatus()); + List entityList = rawresp.readEntity(List.class); + assertThat(entityList).isEmpty(); + + } + + @Test + void testQuery() throws Exception { + createEntryInDB(); + + Invocation.Builder invocationBuilder = super.sendRequest(COMMISSIONING_ENDPOINT); + Response rawresp = invocationBuilder.buildGet().invoke(); + assertEquals(Response.Status.OK.getStatusCode(), rawresp.getStatus()); + List entityList = rawresp.readEntity(List.class); + assertNotNull(entityList); + assertThat(entityList).hasSize(2); + + } + + @Test + void testQueryElementsBadRequest() throws Exception { + createEntryInDB(); + + // Call get elements with no info + Invocation.Builder invocationBuilder = super.sendRequest(COMMISSIONING_ENDPOINT + "/elements"); + Response resp = invocationBuilder.buildGet().invoke(); + assertEquals(Response.Status.NOT_ACCEPTABLE.getStatusCode(), resp.getStatus()); + + } + + @Test + void testQueryElements() throws Exception { + createEntryInDB(); + + Invocation.Builder invocationBuilder = super.sendRequest( + COMMISSIONING_ENDPOINT + "/elements" + "?name=org.onap.domain.pmsh.PMSHAutomationCompositionDefinition"); + Response rawresp = invocationBuilder.buildGet().invoke(); + assertEquals(Response.Status.OK.getStatusCode(), rawresp.getStatus()); + List entityList = rawresp.readEntity(List.class); + assertNotNull(entityList); + assertThat(entityList).hasSize(4); + + } + + @Test + void testDeleteBadRequest() throws Exception { + createEntryInDB(); + + Invocation.Builder invocationBuilder = super.sendRequest(COMMISSIONING_ENDPOINT); + // Call delete with no info + Response resp = invocationBuilder.delete(); + assertEquals(Response.Status.BAD_REQUEST.getStatusCode(), resp.getStatus()); + + } + + @Test + void testDelete() throws Exception { + var serviceTemplateCreated = createEntryInDB(); + + Invocation.Builder invocationBuilder = super.sendRequest(COMMISSIONING_ENDPOINT + "?name=" + + serviceTemplateCreated.getName() + "&version=" + serviceTemplateCreated.getVersion()); + // Call delete with no info + Response resp = invocationBuilder.delete(); + assertEquals(Response.Status.OK.getStatusCode(), resp.getStatus()); + + List templatesInDB = serviceTemplateProvider.getAllServiceTemplates(); + assertThat(templatesInDB).isEmpty(); + } + + private synchronized ToscaServiceTemplate createEntryInDB() throws Exception { + deleteEntryInDB(); + return serviceTemplateProvider.createServiceTemplate(serviceTemplate); + } + + // Delete entries from the DB after relevant tests + private synchronized void deleteEntryInDB() throws Exception { + var list = serviceTemplateProvider.getAllServiceTemplates(); + if (!list.isEmpty()) { + serviceTemplateProvider.deleteServiceTemplate(list.get(0).getName(), list.get(0).getVersion()); + } + } + + private synchronized void createFullEntryInDbWithCommonProps() throws Exception { + deleteEntryInDB(); + serviceTemplateProvider.createServiceTemplate(commonPropertiesServiceTemplate); + } +} diff --git a/runtime-acm/src/test/java/org/onap/policy/clamp/acm/runtime/config/messaging/MessageDispatcherActivatorTest.java b/runtime-acm/src/test/java/org/onap/policy/clamp/acm/runtime/config/messaging/MessageDispatcherActivatorTest.java new file mode 100644 index 000000000..dd070fc0b --- /dev/null +++ b/runtime-acm/src/test/java/org/onap/policy/clamp/acm/runtime/config/messaging/MessageDispatcherActivatorTest.java @@ -0,0 +1,102 @@ +/*- + * ============LICENSE_START======================================================= + * Copyright (C) 2021 Nordix Foundation. + * Modifications Copyright (C) 2021 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * SPDX-License-Identifier: Apache-2.0 + * ============LICENSE_END========================================================= + */ + +package org.onap.policy.clamp.acm.runtime.config.messaging; + +import static org.assertj.core.api.Assertions.assertThatIllegalStateException; +import static org.junit.jupiter.api.Assertions.assertFalse; +import static org.junit.jupiter.api.Assertions.assertTrue; +import static org.mockito.ArgumentMatchers.any; +import static org.mockito.ArgumentMatchers.anyList; +import static org.mockito.Mockito.mock; +import static org.mockito.Mockito.spy; +import static org.mockito.Mockito.times; +import static org.mockito.Mockito.verify; +import static org.mockito.Mockito.when; + +import java.util.List; +import org.junit.jupiter.api.Test; +import org.onap.policy.clamp.acm.runtime.main.parameters.AcRuntimeParameterGroup; +import org.onap.policy.clamp.acm.runtime.supervision.comm.ParticipantStatusListener; +import org.onap.policy.clamp.acm.runtime.util.CommonTestData; +import org.onap.policy.clamp.models.acm.messages.dmaap.participant.ParticipantStatus; +import org.onap.policy.common.utils.coder.Coder; +import org.onap.policy.common.utils.coder.StandardCoder; +import org.onap.policy.common.utils.coder.StandardCoderObject; + +/** + * Class to perform unit test of {@link MessageDispatcherActivator}}. + * + */ +class MessageDispatcherActivatorTest { + + private static final Coder CODER = new StandardCoder(); + + private static final String TOPIC_FIRST = "TOPIC1"; + private static final String TOPIC_SECOND = "TOPIC2"; + + @Test + void testStartAndStop() throws Exception { + AcRuntimeParameterGroup parameterGroup = CommonTestData.geParameterGroup("dbtest"); + + var publisherFirst = spy(mock(Publisher.class)); + var publisherSecond = spy(mock(Publisher.class)); + var publishers = List.of(publisherFirst, publisherSecond); + + var listenerFirst = spy(mock(ParticipantStatusListener.class)); + when(listenerFirst.getType()).thenReturn(TOPIC_FIRST); + when(listenerFirst.getScoListener()).thenReturn(listenerFirst); + + var listenerSecond = spy(mock(ParticipantStatusListener.class)); + when(listenerSecond.getType()).thenReturn(TOPIC_SECOND); + when(listenerSecond.getScoListener()).thenReturn(listenerSecond); + + List> listeners = List.of(listenerFirst, listenerSecond); + + try (var activator = new MessageDispatcherActivator(parameterGroup, publishers, listeners)) { + + assertFalse(activator.isAlive()); + activator.start(); + assertTrue(activator.isAlive()); + + // repeat start - should throw an exception + assertThatIllegalStateException().isThrownBy(() -> activator.start()); + assertTrue(activator.isAlive()); + verify(publisherFirst, times(1)).active(anyList()); + verify(publisherSecond, times(1)).active(anyList()); + + StandardCoderObject sco = CODER.decode("{messageType:" + TOPIC_FIRST + "}", StandardCoderObject.class); + activator.getMsgDispatcher().onTopicEvent(null, "msg", sco); + verify(listenerFirst, times(1)).onTopicEvent(any(), any(), any()); + + sco = CODER.decode("{messageType:" + TOPIC_SECOND + "}", StandardCoderObject.class); + activator.getMsgDispatcher().onTopicEvent(null, "msg", sco); + verify(listenerSecond, times(1)).onTopicEvent(any(), any(), any()); + + activator.stop(); + assertFalse(activator.isAlive()); + + // repeat stop - should throw an exception + assertThatIllegalStateException().isThrownBy(() -> activator.stop()); + assertFalse(activator.isAlive()); + } + } +} diff --git a/runtime-acm/src/test/java/org/onap/policy/clamp/acm/runtime/instantiation/AutomationCompositionInstantiationProviderTest.java b/runtime-acm/src/test/java/org/onap/policy/clamp/acm/runtime/instantiation/AutomationCompositionInstantiationProviderTest.java new file mode 100644 index 000000000..30ed89eac --- /dev/null +++ b/runtime-acm/src/test/java/org/onap/policy/clamp/acm/runtime/instantiation/AutomationCompositionInstantiationProviderTest.java @@ -0,0 +1,394 @@ +/*- + * ============LICENSE_START======================================================= + * Copyright (C) 2021 Nordix Foundation. + * Modifications Copyright (C) 2021 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * SPDX-License-Identifier: Apache-2.0 + * ============LICENSE_END========================================================= + */ + +package org.onap.policy.clamp.acm.runtime.instantiation; + +import static org.assertj.core.api.Assertions.assertThat; +import static org.assertj.core.api.Assertions.assertThatThrownBy; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNull; +import static org.mockito.ArgumentMatchers.anyString; +import static org.mockito.Mockito.mock; +import static org.mockito.Mockito.verify; +import static org.mockito.Mockito.when; + +import java.io.IOException; +import java.util.List; +import java.util.Optional; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.Test; +import org.mockito.Mockito; +import org.onap.policy.clamp.acm.runtime.commissioning.CommissioningProvider; +import org.onap.policy.clamp.acm.runtime.supervision.SupervisionHandler; +import org.onap.policy.clamp.acm.runtime.util.CommonTestData; +import org.onap.policy.clamp.common.acm.exception.AutomationCompositionRuntimeException; +import org.onap.policy.clamp.models.acm.concepts.AutomationComposition; +import org.onap.policy.clamp.models.acm.concepts.AutomationCompositionOrderedState; +import org.onap.policy.clamp.models.acm.concepts.AutomationCompositionState; +import org.onap.policy.clamp.models.acm.concepts.AutomationCompositions; +import org.onap.policy.clamp.models.acm.messages.rest.instantiation.InstantiationCommand; +import org.onap.policy.clamp.models.acm.messages.rest.instantiation.InstantiationResponse; +import org.onap.policy.clamp.models.acm.persistence.provider.AutomationCompositionProvider; +import org.onap.policy.clamp.models.acm.persistence.provider.ParticipantProvider; +import org.onap.policy.models.tosca.authorative.concepts.ToscaConceptIdentifier; +import org.onap.policy.models.tosca.authorative.concepts.ToscaNodeTemplate; +import org.onap.policy.models.tosca.authorative.concepts.ToscaServiceTemplate; + +/** + * Class to perform unit test of {@link AutomationCompositionInstantiationProvider}}. + * + */ +class AutomationCompositionInstantiationProviderTest { + private static final String ID_NAME = "PMSH_Instance1"; + private static final String ID_VERSION = "1.2.3"; + private static final String AC_INSTANTIATION_CREATE_JSON = + "src/test/resources/rest/acm/AutomationCompositions.json"; + private static final String AC_INSTANTIATION_UPDATE_JSON = + "src/test/resources/rest/acm/AutomationCompositionsUpdate.json"; + private static final String AC_INSTANTIATION_CHANGE_STATE_JSON = "src/test/resources/rest/acm/PassiveCommand.json"; + private static final String AC_INSTANTIATION_DEFINITION_NAME_NOT_FOUND_JSON = + "src/test/resources/rest/acm/AutomationCompositionElementsNotFound.json"; + private static final String AC_INSTANTIATION_AC_DEFINITION_NOT_FOUND_JSON = + "src/test/resources/rest/acm/AutomationCompositionsNotFound.json"; + private static final String TOSCA_TEMPLATE_YAML = + "src/test/resources/rest/servicetemplates/pmsh_multiple_ac_tosca.yaml"; + private static final String AUTOMATION_COMPOSITION_NOT_FOUND = "Automation composition not found"; + private static final String DELETE_BAD_REQUEST = "Automation composition state is still %s"; + private static final String ORDERED_STATE_INVALID = "ordered state invalid or not specified on command"; + private static final String AC_ELEMENT_NAME_NOT_FOUND = + "\"AutomationCompositions\" INVALID, item has status INVALID\n" + + " \"entry org.onap.domain.pmsh.PMSHAutomationCompositionDefinition\" INVALID, item has status INVALID\n" + + " \"entry org.onap.domain.pmsh.DCAEMicroservice\" INVALID, Not found\n" + + " \"entry org.onap.domain.pmsh.PMSHAutomationCompositionDefinition\" INVALID, item has status INVALID\n" + + " \"entry org.onap.domain.pmsh.DCAEMicroservice\" INVALID, Not found\n"; + + private static final String AC_DEFINITION_NOT_FOUND = + "\"AutomationCompositions\" INVALID, item has status INVALID\n" + + " \"entry org.onap.domain.PMSHAutomationCompositionDefinition\" INVALID, item has status INVALID\n" + + " item \"AutomationComposition\" value \"org.onap.domain.PMSHAutomationCompositionDefinition\"" + + " INVALID, Commissioned automation composition definition not found\n" + + " \"entry org.onap.domain.PMSHAutomationCompositionDefinition\" INVALID, item has status INVALID\n" + + " item \"AutomationComposition\" value \"org.onap.domain.PMSHAutomationCompositionDefinition\"" + + " INVALID, Commissioned automation composition definition not found\n"; + + private static ToscaServiceTemplate serviceTemplate = new ToscaServiceTemplate(); + + @BeforeAll + public static void setUpBeforeClass() throws Exception { + serviceTemplate = InstantiationUtils.getToscaServiceTemplate(TOSCA_TEMPLATE_YAML); + } + + @Test + void testIntanceResponses() throws Exception { + var participantProvider = Mockito.mock(ParticipantProvider.class); + var acProvider = mock(AutomationCompositionProvider.class); + var supervisionHandler = mock(SupervisionHandler.class); + var commissioningProvider = mock(CommissioningProvider.class); + + when(commissioningProvider.getAllToscaServiceTemplate()).thenReturn(List.of(serviceTemplate)); + when(commissioningProvider.getToscaServiceTemplate(ID_NAME, ID_VERSION)).thenReturn(serviceTemplate); + + var instantiationProvider = new AutomationCompositionInstantiationProvider(acProvider, commissioningProvider, + supervisionHandler, participantProvider); + var instancePropertyList = instantiationProvider.createInstanceProperties(serviceTemplate); + assertNull(instancePropertyList.getErrorDetails()); + var id = new ToscaConceptIdentifier(ID_NAME, ID_VERSION); + assertEquals(id, instancePropertyList.getAffectedInstanceProperties().get(0)); + + AutomationCompositions automationCompositions = + InstantiationUtils.getAutomationCompositionsFromResource(AC_INSTANTIATION_CREATE_JSON, "Crud"); + var automationComposition = automationCompositions.getAutomationCompositionList().get(0); + automationComposition.setName(ID_NAME); + automationComposition.setVersion(ID_VERSION); + when(acProvider.getAutomationCompositions(ID_NAME, ID_VERSION)).thenReturn(List.of(automationComposition)); + + var instanceOrderState = instantiationProvider.getInstantiationOrderState(ID_NAME, ID_VERSION); + assertEquals(AutomationCompositionOrderedState.UNINITIALISED, instanceOrderState.getOrderedState()); + assertEquals(ID_NAME, instanceOrderState.getAutomationCompositionIdentifierList().get(0).getName()); + + when(acProvider.findAutomationComposition(ID_NAME, ID_VERSION)).thenReturn(Optional.of(automationComposition)); + when(acProvider.deleteAutomationComposition(ID_NAME, ID_VERSION)).thenReturn(automationComposition); + + var instanceResponse = instantiationProvider.deleteInstanceProperties(ID_NAME, ID_VERSION); + assertEquals(ID_NAME, instanceResponse.getAffectedAutomationCompositions().get(0).getName()); + + } + + @Test + void testInstantiationCrud() throws Exception { + var participantProvider = Mockito.mock(ParticipantProvider.class); + var participants = CommonTestData.createParticipants(); + when(participantProvider.getParticipants()).thenReturn(participants); + + var commissioningProvider = mock(CommissioningProvider.class); + var toscaNodeTemplate1 = new ToscaNodeTemplate(); + toscaNodeTemplate1.setName("org.onap.domain.pmsh.PMSH_MonitoringPolicyAutomationCompositionElement"); + toscaNodeTemplate1.setVersion("1.2.3"); + when(commissioningProvider.getAutomationCompositionDefinitions(anyString(), anyString())) + .thenReturn(List.of(toscaNodeTemplate1)); + + var toscaNodeTemplate2 = new ToscaNodeTemplate(); + toscaNodeTemplate2.setName("org.onap.domain.pmsh.PMSH_OperationalPolicyAutomationCompositionElement"); + toscaNodeTemplate2.setVersion("1.2.3"); + var toscaNodeTemplate3 = new ToscaNodeTemplate(); + toscaNodeTemplate3.setName("org.onap.domain.pmsh.PMSH_CDS_AutomationCompositionElement"); + toscaNodeTemplate3.setVersion("1.2.3"); + var toscaNodeTemplate4 = new ToscaNodeTemplate(); + toscaNodeTemplate4.setName("org.onap.domain.pmsh.PMSH_DCAEMicroservice"); + toscaNodeTemplate4.setVersion("1.2.3"); + + when(commissioningProvider.getAutomationCompositionElementDefinitions(toscaNodeTemplate1)) + .thenReturn(List.of(toscaNodeTemplate1, toscaNodeTemplate2, toscaNodeTemplate3, toscaNodeTemplate4)); + + var supervisionHandler = mock(SupervisionHandler.class); + var acProvider = mock(AutomationCompositionProvider.class); + var instantiationProvider = new AutomationCompositionInstantiationProvider(acProvider, commissioningProvider, + supervisionHandler, participantProvider); + AutomationCompositions automationCompositionsCreate = + InstantiationUtils.getAutomationCompositionsFromResource(AC_INSTANTIATION_CREATE_JSON, "Crud"); + InstantiationResponse instantiationResponse = + instantiationProvider.createAutomationCompositions(automationCompositionsCreate); + InstantiationUtils.assertInstantiationResponse(instantiationResponse, automationCompositionsCreate); + + verify(acProvider).saveAutomationCompositions(automationCompositionsCreate.getAutomationCompositionList()); + + for (var automationComposition : automationCompositionsCreate.getAutomationCompositionList()) { + when(acProvider.getAutomationCompositions(automationComposition.getName(), + automationComposition.getVersion())).thenReturn(List.of(automationComposition)); + + AutomationCompositions automationCompositionsGet = instantiationProvider + .getAutomationCompositions(automationComposition.getName(), automationComposition.getVersion()); + assertThat(automationCompositionsGet.getAutomationCompositionList()).hasSize(1); + assertThat(automationComposition) + .isEqualTo(automationCompositionsGet.getAutomationCompositionList().get(0)); + } + + AutomationCompositions automationCompositionsUpdate = + InstantiationUtils.getAutomationCompositionsFromResource(AC_INSTANTIATION_UPDATE_JSON, "Crud"); + + instantiationResponse = instantiationProvider.updateAutomationCompositions(automationCompositionsUpdate); + InstantiationUtils.assertInstantiationResponse(instantiationResponse, automationCompositionsUpdate); + + verify(acProvider).saveAutomationCompositions(automationCompositionsUpdate.getAutomationCompositionList()); + + for (var automationComposition : automationCompositionsUpdate.getAutomationCompositionList()) { + when(acProvider.findAutomationComposition(automationComposition.getKey().asIdentifier())) + .thenReturn(Optional.of(automationComposition)); + when(acProvider.findAutomationComposition(automationComposition.getName(), + automationComposition.getVersion())).thenReturn(Optional.of(automationComposition)); + when(acProvider.deleteAutomationComposition(automationComposition.getName(), + automationComposition.getVersion())).thenReturn(automationComposition); + } + + InstantiationCommand instantiationCommand = + InstantiationUtils.getInstantiationCommandFromResource(AC_INSTANTIATION_CHANGE_STATE_JSON, "Crud"); + instantiationResponse = instantiationProvider.issueAutomationCompositionCommand(instantiationCommand); + InstantiationUtils.assertInstantiationResponse(instantiationResponse, instantiationCommand); + + verify(supervisionHandler) + .triggerAutomationCompositionSupervision(instantiationCommand.getAutomationCompositionIdentifierList()); + + // in order to delete a automationComposition the state must be UNINITIALISED + automationCompositionsCreate.getAutomationCompositionList() + .forEach(ac -> ac.setState(AutomationCompositionState.UNINITIALISED)); + instantiationProvider.updateAutomationCompositions(automationCompositionsCreate); + + for (AutomationComposition automationComposition : automationCompositionsCreate + .getAutomationCompositionList()) { + instantiationProvider.deleteAutomationComposition(automationComposition.getName(), + automationComposition.getVersion()); + + verify(acProvider).deleteAutomationComposition(automationComposition.getName(), + automationComposition.getVersion()); + } + } + + @Test + void testInstantiationDelete() throws Exception { + + AutomationCompositions automationCompositions = + InstantiationUtils.getAutomationCompositionsFromResource(AC_INSTANTIATION_CREATE_JSON, "Delete"); + + AutomationComposition automationComposition0 = automationCompositions.getAutomationCompositionList().get(0); + var participantProvider = Mockito.mock(ParticipantProvider.class); + var acProvider = mock(AutomationCompositionProvider.class); + var supervisionHandler = mock(SupervisionHandler.class); + var commissioningProvider = mock(CommissioningProvider.class); + + var instantiationProvider = new AutomationCompositionInstantiationProvider(acProvider, commissioningProvider, + supervisionHandler, participantProvider); + + assertThatThrownBy(() -> instantiationProvider.deleteAutomationComposition(automationComposition0.getName(), + automationComposition0.getVersion())).hasMessageMatching(AUTOMATION_COMPOSITION_NOT_FOUND); + + for (AutomationCompositionState state : AutomationCompositionState.values()) { + if (!AutomationCompositionState.UNINITIALISED.equals(state)) { + assertThatDeleteThrownBy(automationCompositions, state); + } + } + automationComposition0.setState(AutomationCompositionState.UNINITIALISED); + + for (AutomationComposition automationComposition : automationCompositions.getAutomationCompositionList()) { + when(acProvider.findAutomationComposition(automationComposition.getName(), + automationComposition.getVersion())).thenReturn(Optional.of(automationComposition)); + when(acProvider.deleteAutomationComposition(automationComposition.getName(), + automationComposition.getVersion())).thenReturn(automationComposition); + + instantiationProvider.deleteAutomationComposition(automationComposition.getName(), + automationComposition.getVersion()); + } + } + + private void assertThatDeleteThrownBy(AutomationCompositions automationCompositions, + AutomationCompositionState state) throws Exception { + AutomationComposition automationComposition = automationCompositions.getAutomationCompositionList().get(0); + automationComposition.setState(state); + var participantProvider = Mockito.mock(ParticipantProvider.class); + var acProvider = mock(AutomationCompositionProvider.class); + var supervisionHandler = mock(SupervisionHandler.class); + var commissioningProvider = mock(CommissioningProvider.class); + + var instantiationProvider = new AutomationCompositionInstantiationProvider(acProvider, commissioningProvider, + supervisionHandler, participantProvider); + + when(acProvider.findAutomationComposition(automationComposition.getName(), automationComposition.getVersion())) + .thenReturn(Optional.of(automationComposition)); + + assertThatThrownBy(() -> instantiationProvider.deleteAutomationComposition(automationComposition.getName(), + automationComposition.getVersion())).hasMessageMatching(String.format(DELETE_BAD_REQUEST, state)); + } + + @Test + void testCreateAutomationCompositions_NoDuplicates() throws Exception { + var commissioningProvider = mock(CommissioningProvider.class); + + var toscaNodeTemplate1 = new ToscaNodeTemplate(); + toscaNodeTemplate1.setName("org.onap.domain.pmsh.PMSH_MonitoringPolicyAutomationCompositionElement"); + toscaNodeTemplate1.setVersion("1.2.3"); + when(commissioningProvider.getAutomationCompositionDefinitions(anyString(), anyString())) + .thenReturn(List.of(toscaNodeTemplate1)); + + var toscaNodeTemplate2 = new ToscaNodeTemplate(); + toscaNodeTemplate2.setName("org.onap.domain.pmsh.PMSH_OperationalPolicyAutomationCompositionElement"); + toscaNodeTemplate2.setVersion("1.2.3"); + var toscaNodeTemplate3 = new ToscaNodeTemplate(); + toscaNodeTemplate3.setName("org.onap.domain.pmsh.PMSH_CDS_AutomationCompositionElement"); + toscaNodeTemplate3.setVersion("1.2.3"); + var toscaNodeTemplate4 = new ToscaNodeTemplate(); + toscaNodeTemplate4.setName("org.onap.domain.pmsh.PMSH_DCAEMicroservice"); + toscaNodeTemplate4.setVersion("1.2.3"); + + when(commissioningProvider.getAutomationCompositionElementDefinitions(toscaNodeTemplate1)) + .thenReturn(List.of(toscaNodeTemplate1, toscaNodeTemplate2, toscaNodeTemplate3, toscaNodeTemplate4)); + + AutomationCompositions automationCompositionsCreate = + InstantiationUtils.getAutomationCompositionsFromResource(AC_INSTANTIATION_CREATE_JSON, "NoDuplicates"); + + var acProvider = mock(AutomationCompositionProvider.class); + var participantProvider = Mockito.mock(ParticipantProvider.class); + var supervisionHandler = mock(SupervisionHandler.class); + + var instantiationProvider = new AutomationCompositionInstantiationProvider(acProvider, commissioningProvider, + supervisionHandler, participantProvider); + + InstantiationResponse instantiationResponse = + instantiationProvider.createAutomationCompositions(automationCompositionsCreate); + InstantiationUtils.assertInstantiationResponse(instantiationResponse, automationCompositionsCreate); + + when(acProvider.findAutomationComposition( + automationCompositionsCreate.getAutomationCompositionList().get(0).getKey().asIdentifier())) + .thenReturn(Optional.of(automationCompositionsCreate.getAutomationCompositionList().get(0))); + + assertThatThrownBy(() -> instantiationProvider.createAutomationCompositions(automationCompositionsCreate)) + .hasMessageMatching( + automationCompositionsCreate.getAutomationCompositionList().get(0).getKey().asIdentifier() + + " already defined"); + } + + @Test + void testCreateAutomationCompositions_CommissionedAcElementNotFound() throws Exception { + var toscaNodeTemplate1 = new ToscaNodeTemplate(); + toscaNodeTemplate1.setName("org.onap.domain.pmsh.PMSH_MonitoringPolicyAutomationCompositionElement"); + toscaNodeTemplate1.setVersion("1.2.3"); + + var toscaNodeTemplate2 = new ToscaNodeTemplate(); + toscaNodeTemplate2.setName("org.onap.domain.pmsh.PMSH_OperationalPolicyAutomationCompositionElement"); + toscaNodeTemplate2.setVersion("1.2.3"); + var toscaNodeTemplate3 = new ToscaNodeTemplate(); + toscaNodeTemplate3.setName("org.onap.domain.pmsh.PMSH_CDS_AutomationCompositionElement"); + toscaNodeTemplate3.setVersion("1.2.3"); + var commissioningProvider = mock(CommissioningProvider.class); + AutomationCompositions automationCompositions = InstantiationUtils.getAutomationCompositionsFromResource( + AC_INSTANTIATION_DEFINITION_NAME_NOT_FOUND_JSON, "AcElementNotFound"); + + when(commissioningProvider.getAutomationCompositionDefinitions( + automationCompositions.getAutomationCompositionList().get(0).getDefinition().getName(), + automationCompositions.getAutomationCompositionList().get(0).getDefinition().getVersion())) + .thenReturn(List.of(toscaNodeTemplate1)); + + when(commissioningProvider.getAutomationCompositionElementDefinitions(toscaNodeTemplate1)) + .thenReturn(List.of(toscaNodeTemplate1, toscaNodeTemplate2, toscaNodeTemplate3)); + + var acProvider = mock(AutomationCompositionProvider.class); + var participantProvider = mock(ParticipantProvider.class); + var supervisionHandler = mock(SupervisionHandler.class); + var provider = new AutomationCompositionInstantiationProvider(acProvider, commissioningProvider, + supervisionHandler, participantProvider); + + assertThatThrownBy(() -> provider.createAutomationCompositions(automationCompositions)) + .hasMessageMatching(AC_ELEMENT_NAME_NOT_FOUND); + + assertThatThrownBy(() -> provider.updateAutomationCompositions(automationCompositions)) + .hasMessageMatching(AC_ELEMENT_NAME_NOT_FOUND); + } + + @Test + void testCreateAutomationCompositions_CommissionedAcNotFound() throws Exception { + AutomationCompositions automationCompositions = InstantiationUtils + .getAutomationCompositionsFromResource(AC_INSTANTIATION_AC_DEFINITION_NOT_FOUND_JSON, "AcNotFound"); + + var participantProvider = Mockito.mock(ParticipantProvider.class); + var acProvider = mock(AutomationCompositionProvider.class); + var supervisionHandler = mock(SupervisionHandler.class); + var commissioningProvider = mock(CommissioningProvider.class); + var provider = new AutomationCompositionInstantiationProvider(acProvider, commissioningProvider, + supervisionHandler, participantProvider); + + assertThatThrownBy(() -> provider.createAutomationCompositions(automationCompositions)) + .hasMessageMatching(AC_DEFINITION_NOT_FOUND); + + assertThatThrownBy(() -> provider.updateAutomationCompositions(automationCompositions)) + .hasMessageMatching(AC_DEFINITION_NOT_FOUND); + } + + @Test + void testIssueAutomationCompositionCommand_OrderedStateInvalid() + throws AutomationCompositionRuntimeException, IOException { + var participantProvider = Mockito.mock(ParticipantProvider.class); + var acProvider = mock(AutomationCompositionProvider.class); + var supervisionHandler = mock(SupervisionHandler.class); + var commissioningProvider = mock(CommissioningProvider.class); + var instantiationProvider = new AutomationCompositionInstantiationProvider(acProvider, commissioningProvider, + supervisionHandler, participantProvider); + assertThatThrownBy(() -> instantiationProvider.issueAutomationCompositionCommand(new InstantiationCommand())) + .hasMessageMatching(ORDERED_STATE_INVALID); + } +} diff --git a/runtime-acm/src/test/java/org/onap/policy/clamp/acm/runtime/instantiation/InstantiationUtils.java b/runtime-acm/src/test/java/org/onap/policy/clamp/acm/runtime/instantiation/InstantiationUtils.java new file mode 100644 index 000000000..759685ad9 --- /dev/null +++ b/runtime-acm/src/test/java/org/onap/policy/clamp/acm/runtime/instantiation/InstantiationUtils.java @@ -0,0 +1,147 @@ +/*- + * ============LICENSE_START======================================================= + * Copyright (C) 2021 Nordix Foundation. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * SPDX-License-Identifier: Apache-2.0 + * ============LICENSE_END========================================================= + */ + +package org.onap.policy.clamp.acm.runtime.instantiation; + +import static org.assertj.core.api.Assertions.assertThat; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertTrue; +import static org.junit.jupiter.api.Assertions.fail; + +import java.io.File; +import org.onap.policy.clamp.models.acm.concepts.AutomationComposition; +import org.onap.policy.clamp.models.acm.concepts.AutomationCompositions; +import org.onap.policy.clamp.models.acm.messages.rest.instantiation.InstantiationCommand; +import org.onap.policy.clamp.models.acm.messages.rest.instantiation.InstantiationResponse; +import org.onap.policy.common.utils.coder.Coder; +import org.onap.policy.common.utils.coder.CoderException; +import org.onap.policy.common.utils.coder.StandardCoder; +import org.onap.policy.common.utils.coder.StandardYamlCoder; +import org.onap.policy.common.utils.resources.ResourceUtils; +import org.onap.policy.models.tosca.authorative.concepts.ToscaConceptIdentifier; +import org.onap.policy.models.tosca.authorative.concepts.ToscaServiceTemplate; + +/** + * Utility methods supporting tests for Instantiation. + */ +public class InstantiationUtils { + + private static final Coder CODER = new StandardCoder(); + private static final StandardYamlCoder YAML_TRANSLATOR = new StandardYamlCoder(); + + /** + * Gets the AutomationCompositions from Resource. + * + * @param path path of the resource + * @param suffix suffix to add to all names in AutomationCompositions + * @return the AutomationCompositions from Resource + * @throws CoderException if an error occurs + */ + public static AutomationCompositions getAutomationCompositionsFromResource(final String path, final String suffix) + throws CoderException { + AutomationCompositions automationCompositions = CODER.decode(new File(path), AutomationCompositions.class); + + // add suffix to all names + automationCompositions.getAutomationCompositionList() + .forEach(automationComposition -> automationComposition.setName(automationComposition.getName() + suffix)); + return automationCompositions; + } + + /** + * Gets InstantiationCommand from Resource. + * + * @param path path of the resource + * @param suffix suffix to add to all names in AutomationCompositions + * @return the InstantiationCommand + * @throws CoderException if an error occurs + */ + public static InstantiationCommand getInstantiationCommandFromResource(final String path, final String suffix) + throws CoderException { + InstantiationCommand instantiationCommand = CODER.decode(new File(path), InstantiationCommand.class); + + // add suffix to all names + instantiationCommand.getAutomationCompositionIdentifierList().forEach(ac -> ac.setName(ac.getName() + suffix)); + return instantiationCommand; + } + + /** + * Assert that Instantiation Response contains proper AutomationCompositions. + * + * @param response InstantiationResponse + * @param automationCompositions AutomationCompositions + */ + public static void assertInstantiationResponse(InstantiationResponse response, + AutomationCompositions automationCompositions) { + assertThat(response).isNotNull(); + assertThat(response.getErrorDetails()).isNull(); + assertThat(response.getAffectedAutomationCompositions().size()) + .isEqualTo(automationCompositions.getAutomationCompositionList().size()); + for (AutomationComposition automationComposition : automationCompositions.getAutomationCompositionList()) { + assertTrue(response.getAffectedAutomationCompositions().stream() + .filter(ac -> ac.equals(automationComposition.getKey().asIdentifier())).findAny().isPresent()); + } + } + + /** + * Assert that Instantiation Response contains proper AutomationCompositions. + * + * @param response InstantiationResponse + * @param command InstantiationCommand + */ + public static void assertInstantiationResponse(InstantiationResponse response, InstantiationCommand command) { + assertThat(response).isNotNull(); + assertEquals(response.getAffectedAutomationCompositions().size(), + command.getAutomationCompositionIdentifierList().size()); + for (ToscaConceptIdentifier toscaConceptIdentifier : command.getAutomationCompositionIdentifierList()) { + assertTrue(response.getAffectedAutomationCompositions().stream() + .filter(ac -> ac.compareTo(toscaConceptIdentifier) == 0).findAny().isPresent()); + } + } + + /** + * Assert that Instantiation Response contains AutomationComposition equals to automationComposition. + * + * @param response InstantiationResponse + * @param automationComposition AutomationComposition + */ + public static void assertInstantiationResponse(InstantiationResponse response, + AutomationComposition automationComposition) { + assertThat(response).isNotNull(); + assertThat(response.getErrorDetails()).isNull(); + assertEquals(1, response.getAffectedAutomationCompositions().size()); + assertEquals(0, response.getAffectedAutomationCompositions().get(0) + .compareTo(automationComposition.getKey().asIdentifier())); + } + + /** + * Get ToscaServiceTemplate from resource. + * + * @param path path of the resource + */ + public static ToscaServiceTemplate getToscaServiceTemplate(String path) { + + try { + return YAML_TRANSLATOR.decode(ResourceUtils.getResourceAsStream(path), ToscaServiceTemplate.class); + } catch (CoderException e) { + fail("Cannot read or decode " + path); + return null; + } + } +} diff --git a/runtime-acm/src/test/java/org/onap/policy/clamp/acm/runtime/instantiation/rest/InstantiationControllerTest.java b/runtime-acm/src/test/java/org/onap/policy/clamp/acm/runtime/instantiation/rest/InstantiationControllerTest.java new file mode 100644 index 000000000..2ad15bd48 --- /dev/null +++ b/runtime-acm/src/test/java/org/onap/policy/clamp/acm/runtime/instantiation/rest/InstantiationControllerTest.java @@ -0,0 +1,543 @@ +/*- + * ============LICENSE_START======================================================= + * Copyright (C) 2021 Nordix Foundation. + * Modifications Copyright (C) 2021 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * SPDX-License-Identifier: Apache-2.0 + * ============LICENSE_END========================================================= + */ + +package org.onap.policy.clamp.acm.runtime.instantiation.rest; + +import static org.assertj.core.api.Assertions.assertThat; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertNotNull; +import static org.junit.jupiter.api.Assertions.assertNull; + +import javax.ws.rs.client.Entity; +import javax.ws.rs.client.Invocation; +import javax.ws.rs.core.Response; +import org.junit.jupiter.api.AfterEach; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.ExtendWith; +import org.onap.policy.clamp.acm.runtime.instantiation.AutomationCompositionInstantiationProvider; +import org.onap.policy.clamp.acm.runtime.instantiation.InstantiationUtils; +import org.onap.policy.clamp.acm.runtime.main.rest.InstantiationController; +import org.onap.policy.clamp.acm.runtime.util.CommonTestData; +import org.onap.policy.clamp.acm.runtime.util.rest.CommonRestController; +import org.onap.policy.clamp.models.acm.concepts.AutomationComposition; +import org.onap.policy.clamp.models.acm.concepts.AutomationCompositionOrderedState; +import org.onap.policy.clamp.models.acm.concepts.AutomationCompositions; +import org.onap.policy.clamp.models.acm.messages.rest.instantiation.AutomationCompositionOrderStateResponse; +import org.onap.policy.clamp.models.acm.messages.rest.instantiation.AutomationCompositionPrimedResponse; +import org.onap.policy.clamp.models.acm.messages.rest.instantiation.InstancePropertiesResponse; +import org.onap.policy.clamp.models.acm.messages.rest.instantiation.InstantiationCommand; +import org.onap.policy.clamp.models.acm.messages.rest.instantiation.InstantiationResponse; +import org.onap.policy.clamp.models.acm.persistence.provider.ParticipantProvider; +import org.onap.policy.clamp.models.acm.persistence.provider.ServiceTemplateProvider; +import org.onap.policy.clamp.models.acm.persistence.repository.AutomationCompositionRepository; +import org.onap.policy.models.tosca.authorative.concepts.ToscaConceptIdentifier; +import org.onap.policy.models.tosca.authorative.concepts.ToscaServiceTemplate; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.boot.test.context.SpringBootTest; +import org.springframework.boot.test.context.SpringBootTest.WebEnvironment; +import org.springframework.boot.web.server.LocalServerPort; +import org.springframework.test.context.TestPropertySource; +import org.springframework.test.context.junit.jupiter.SpringExtension; + +/** + * Class to perform unit test of {@link InstantiationController}}. + * + */ +@ExtendWith(SpringExtension.class) +@SpringBootTest(webEnvironment = WebEnvironment.RANDOM_PORT) +@TestPropertySource(locations = {"classpath:application_test.properties"}) +class InstantiationControllerTest extends CommonRestController { + + private static final String ID_NAME = "PMSH_Instance1"; + private static final String ID_VERSION = "1.2.3"; + + private static final String AC_INSTANTIATION_CREATE_JSON = + "src/test/resources/rest/acm/AutomationCompositions.json"; + + private static final String AC_INSTANTIATION_UPDATE_JSON = + "src/test/resources/rest/acm/AutomationCompositionsUpdate.json"; + + private static final String AC_INSTANTIATION_CHANGE_STATE_JSON = "src/test/resources/rest/acm/PassiveCommand.json"; + + private static final String TOSCA_TEMPLATE_YAML = + "src/test/resources/rest/servicetemplates/pmsh_multiple_ac_tosca.yaml"; + + private static final String INSTANTIATION_ENDPOINT = "instantiation"; + private static final String INSTANTIATION_COMMAND_ENDPOINT = "instantiation/command"; + private static final String PRIMING_ENDPOINT = "automationCompositionPriming"; + private static final String INSTANTIATION_PROPERTIES = "instanceProperties"; + private static final String INSTANTIATION_STATE = "instantiationState"; + + private static ToscaServiceTemplate serviceTemplate = new ToscaServiceTemplate(); + + @Autowired + private AutomationCompositionRepository automationCompositionRepository; + + @Autowired + private ServiceTemplateProvider serviceTemplateProvider; + + @Autowired + private AutomationCompositionInstantiationProvider instantiationProvider; + + @Autowired + private ParticipantProvider participantProvider; + + @LocalServerPort + private int randomServerPort; + + @BeforeAll + public static void setUpBeforeClass() throws Exception { + serviceTemplate = InstantiationUtils.getToscaServiceTemplate(TOSCA_TEMPLATE_YAML); + } + + @BeforeEach + public void populateDb() throws Exception { + createEntryInDB(); + } + + @BeforeEach + public void setUpPort() { + super.setHttpPrefix(randomServerPort); + } + + @AfterEach + public void cleanDatabase() throws Exception { + deleteEntryInDB(); + } + + @Test + void testSwagger() throws Exception { + super.testSwagger(INSTANTIATION_ENDPOINT); + } + + @Test + void testCreate_Unauthorized() throws Exception { + AutomationCompositions automationCompositions = + InstantiationUtils.getAutomationCompositionsFromResource(AC_INSTANTIATION_CREATE_JSON, "Unauthorized"); + + assertUnauthorizedPost(INSTANTIATION_ENDPOINT, Entity.json(automationCompositions)); + } + + @Test + void testQuery_Unauthorized() throws Exception { + assertUnauthorizedGet(INSTANTIATION_ENDPOINT); + } + + @Test + void testUpdate_Unauthorized() throws Exception { + AutomationCompositions automationCompositions = + InstantiationUtils.getAutomationCompositionsFromResource(AC_INSTANTIATION_UPDATE_JSON, "Unauthorized"); + + assertUnauthorizedPut(INSTANTIATION_ENDPOINT, Entity.json(automationCompositions)); + } + + @Test + void testDelete_Unauthorized() throws Exception { + assertUnauthorizedDelete(INSTANTIATION_ENDPOINT); + } + + @Test + void testCommand_Unauthorized() throws Exception { + InstantiationCommand instantiationCommand = + InstantiationUtils.getInstantiationCommandFromResource(AC_INSTANTIATION_CHANGE_STATE_JSON, "Unauthorized"); + + assertUnauthorizedPut(INSTANTIATION_COMMAND_ENDPOINT, Entity.json(instantiationCommand)); + } + + @Test + void testCreate() throws Exception { + + AutomationCompositions automationCompositionsFromRsc = + InstantiationUtils.getAutomationCompositionsFromResource(AC_INSTANTIATION_CREATE_JSON, "Create"); + + Invocation.Builder invocationBuilder = super.sendRequest(INSTANTIATION_ENDPOINT); + Response resp = invocationBuilder.post(Entity.json(automationCompositionsFromRsc)); + assertEquals(Response.Status.OK.getStatusCode(), resp.getStatus()); + InstantiationResponse instResponse = resp.readEntity(InstantiationResponse.class); + InstantiationUtils.assertInstantiationResponse(instResponse, automationCompositionsFromRsc); + + for (AutomationComposition automationCompositionFromRsc : automationCompositionsFromRsc + .getAutomationCompositionList()) { + AutomationCompositions automationCompositionsFromDb = instantiationProvider.getAutomationCompositions( + automationCompositionFromRsc.getKey().getName(), automationCompositionFromRsc.getKey().getVersion()); + + assertNotNull(automationCompositionsFromDb); + assertThat(automationCompositionsFromDb.getAutomationCompositionList()).hasSize(1); + assertEquals(automationCompositionFromRsc, + automationCompositionsFromDb.getAutomationCompositionList().get(0)); + } + + invocationBuilder = + super.sendRequest(PRIMING_ENDPOINT + "?name=" + "PMSHInstance0Create" + "&version=" + "1.0.1"); + Response rawresp = invocationBuilder.buildGet().invoke(); + assertEquals(Response.Status.OK.getStatusCode(), rawresp.getStatus()); + AutomationCompositionPrimedResponse primResponse = + rawresp.readEntity(AutomationCompositionPrimedResponse.class); + assertEquals(false, primResponse.getPrimedAutomationCompositionsList().get(0).isPrimed()); + } + + @Test + void testCreateBadRequest() throws Exception { + + AutomationCompositions automationCompositionsFromRsc = + InstantiationUtils.getAutomationCompositionsFromResource(AC_INSTANTIATION_CREATE_JSON, "CreateBadRequest"); + + Invocation.Builder invocationBuilder = super.sendRequest(INSTANTIATION_ENDPOINT); + Response resp = invocationBuilder.post(Entity.json(automationCompositionsFromRsc)); + assertEquals(Response.Status.OK.getStatusCode(), resp.getStatus()); + + // testing Bad Request: AC already defined + resp = invocationBuilder.post(Entity.json(automationCompositionsFromRsc)); + assertEquals(Response.Status.BAD_REQUEST.getStatusCode(), resp.getStatus()); + InstantiationResponse instResponse = resp.readEntity(InstantiationResponse.class); + assertNotNull(instResponse.getErrorDetails()); + assertNull(instResponse.getAffectedAutomationCompositions()); + } + + @Test + void testQuery_NoResultWithThisName() throws Exception { + Invocation.Builder invocationBuilder = super.sendRequest(INSTANTIATION_ENDPOINT + "?name=noResultWithThisName"); + Response rawresp = invocationBuilder.buildGet().invoke(); + assertEquals(Response.Status.OK.getStatusCode(), rawresp.getStatus()); + AutomationCompositions resp = rawresp.readEntity(AutomationCompositions.class); + assertThat(resp.getAutomationCompositionList()).isEmpty(); + } + + @Test + void testQuery() throws Exception { + + var automationCompositions = + InstantiationUtils.getAutomationCompositionsFromResource(AC_INSTANTIATION_CREATE_JSON, "Query"); + instantiationProvider.createAutomationCompositions(automationCompositions); + + for (AutomationComposition automationCompositionFromRsc : automationCompositions + .getAutomationCompositionList()) { + Invocation.Builder invocationBuilder = + super.sendRequest(INSTANTIATION_ENDPOINT + "?name=" + automationCompositionFromRsc.getKey().getName()); + Response rawresp = invocationBuilder.buildGet().invoke(); + assertEquals(Response.Status.OK.getStatusCode(), rawresp.getStatus()); + AutomationCompositions automationCompositionsQuery = rawresp.readEntity(AutomationCompositions.class); + assertNotNull(automationCompositionsQuery); + assertThat(automationCompositionsQuery.getAutomationCompositionList()).hasSize(1); + assertEquals(automationCompositionFromRsc, + automationCompositionsQuery.getAutomationCompositionList().get(0)); + } + } + + @Test + void testUpdate() throws Exception { + + AutomationCompositions automationCompositionsCreate = + InstantiationUtils.getAutomationCompositionsFromResource(AC_INSTANTIATION_CREATE_JSON, "Update"); + + var automationCompositions = + InstantiationUtils.getAutomationCompositionsFromResource(AC_INSTANTIATION_UPDATE_JSON, "Update"); + instantiationProvider.createAutomationCompositions(automationCompositionsCreate); + + Invocation.Builder invocationBuilder = super.sendRequest(INSTANTIATION_ENDPOINT); + Response resp = invocationBuilder.put(Entity.json(automationCompositions)); + assertEquals(Response.Status.OK.getStatusCode(), resp.getStatus()); + + InstantiationResponse instResponse = resp.readEntity(InstantiationResponse.class); + InstantiationUtils.assertInstantiationResponse(instResponse, automationCompositions); + + for (AutomationComposition automationCompositionUpdate : automationCompositions + .getAutomationCompositionList()) { + AutomationCompositions automationCompositionsFromDb = instantiationProvider.getAutomationCompositions( + automationCompositionUpdate.getKey().getName(), automationCompositionUpdate.getKey().getVersion()); + + assertNotNull(automationCompositionsFromDb); + assertThat(automationCompositionsFromDb.getAutomationCompositionList()).hasSize(1); + assertEquals(automationCompositionUpdate, + automationCompositionsFromDb.getAutomationCompositionList().get(0)); + } + } + + @Test + void testDelete_NoResultWithThisName() throws Exception { + Invocation.Builder invocationBuilder = + super.sendRequest(INSTANTIATION_ENDPOINT + "?name=noResultWithThisName&version=1.0.1"); + Response resp = invocationBuilder.delete(); + assertEquals(Response.Status.NOT_FOUND.getStatusCode(), resp.getStatus()); + InstantiationResponse instResponse = resp.readEntity(InstantiationResponse.class); + assertNotNull(instResponse.getErrorDetails()); + assertNull(instResponse.getAffectedAutomationCompositions()); + } + + @Test + void testDelete() throws Exception { + + AutomationCompositions automationCompositionsFromRsc = + InstantiationUtils.getAutomationCompositionsFromResource(AC_INSTANTIATION_CREATE_JSON, "Delete"); + + instantiationProvider.createAutomationCompositions(automationCompositionsFromRsc); + + for (AutomationComposition automationCompositionFromRsc : automationCompositionsFromRsc + .getAutomationCompositionList()) { + Invocation.Builder invocationBuilder = + super.sendRequest(INSTANTIATION_ENDPOINT + "?name=" + automationCompositionFromRsc.getKey().getName() + + "&version=" + automationCompositionFromRsc.getKey().getVersion()); + Response resp = invocationBuilder.delete(); + assertEquals(Response.Status.OK.getStatusCode(), resp.getStatus()); + InstantiationResponse instResponse = resp.readEntity(InstantiationResponse.class); + InstantiationUtils.assertInstantiationResponse(instResponse, automationCompositionFromRsc); + + AutomationCompositions automationCompositionsFromDb = instantiationProvider.getAutomationCompositions( + automationCompositionFromRsc.getKey().getName(), automationCompositionFromRsc.getKey().getVersion()); + assertThat(automationCompositionsFromDb.getAutomationCompositionList()).isEmpty(); + } + } + + @Test + void testDeleteBadRequest() throws Exception { + + AutomationCompositions automationCompositionsFromRsc = + InstantiationUtils.getAutomationCompositionsFromResource(AC_INSTANTIATION_CREATE_JSON, "DelBadRequest"); + + instantiationProvider.createAutomationCompositions(automationCompositionsFromRsc); + + for (AutomationComposition automationCompositionFromRsc : automationCompositionsFromRsc + .getAutomationCompositionList()) { + Invocation.Builder invocationBuilder = + super.sendRequest(INSTANTIATION_ENDPOINT + "?name=" + automationCompositionFromRsc.getKey().getName()); + Response resp = invocationBuilder.delete(); + assertEquals(Response.Status.BAD_REQUEST.getStatusCode(), resp.getStatus()); + } + } + + @Test + void testCreateInstanceProperties() throws Exception { + Invocation.Builder invocationBuilder = super.sendRequest(INSTANTIATION_PROPERTIES); + Response resp = invocationBuilder.post(Entity.json(serviceTemplate)); + assertEquals(Response.Status.OK.getStatusCode(), resp.getStatus()); + var instancePropertyList = resp.readEntity(InstancePropertiesResponse.class); + assertNull(instancePropertyList.getErrorDetails()); + var id = new ToscaConceptIdentifier(ID_NAME, ID_VERSION); + assertEquals(id, instancePropertyList.getAffectedInstanceProperties().get(0)); + + invocationBuilder = super.sendRequest(INSTANTIATION_ENDPOINT); + resp = invocationBuilder.get(); + assertEquals(Response.Status.OK.getStatusCode(), resp.getStatus()); + var automationCompositionsGet = resp.readEntity(AutomationCompositions.class); + assertThat(automationCompositionsGet.getAutomationCompositionList()).hasSize(1); + } + + @Test + void testDeleteInstanceProperties() throws Exception { + Invocation.Builder invocationBuilder = super.sendRequest(INSTANTIATION_PROPERTIES); + Response resp = invocationBuilder.post(Entity.json(serviceTemplate)); + assertEquals(Response.Status.OK.getStatusCode(), resp.getStatus()); + + invocationBuilder = super.sendRequest(INSTANTIATION_PROPERTIES + "?name=" + ID_NAME + "&version=" + ID_VERSION); + resp = invocationBuilder.delete(); + assertEquals(Response.Status.OK.getStatusCode(), resp.getStatus()); + var instanceResponse = resp.readEntity(InstantiationResponse.class); + assertEquals(ID_NAME, instanceResponse.getAffectedAutomationCompositions().get(0).getName()); + AutomationCompositions automationCompositionsGet = + instantiationProvider.getAutomationCompositions(ID_NAME, ID_VERSION); + assertThat(automationCompositionsGet.getAutomationCompositionList()).isEmpty(); + } + + @Test + void testDeleteInstancePropertiesBadRequest() throws Exception { + Invocation.Builder invocationBuilder = super.sendRequest(INSTANTIATION_PROPERTIES); + Response resp = invocationBuilder.post(Entity.json(serviceTemplate)); + assertEquals(Response.Status.OK.getStatusCode(), resp.getStatus()); + + invocationBuilder = super.sendRequest(INSTANTIATION_PROPERTIES + "?name=" + ID_NAME); + resp = invocationBuilder.delete(); + assertEquals(Response.Status.BAD_REQUEST.getStatusCode(), resp.getStatus()); + } + + @Test + void testDeleteInstancePropertiesPassiveMode() throws Exception { + Invocation.Builder invocationBuilder = super.sendRequest(INSTANTIATION_PROPERTIES); + Response resp = invocationBuilder.post(Entity.json(serviceTemplate)); + assertEquals(Response.Status.OK.getStatusCode(), resp.getStatus()); + + var automationCompositions = + InstantiationUtils.getAutomationCompositionsFromResource(AC_INSTANTIATION_CREATE_JSON, "Command"); + instantiationProvider.createAutomationCompositions(automationCompositions); + + var participants = CommonTestData.createParticipants(); + for (var participant : participants) { + participantProvider.saveParticipant(participant); + } + + InstantiationCommand command = + InstantiationUtils.getInstantiationCommandFromResource(AC_INSTANTIATION_CHANGE_STATE_JSON, "Command"); + + invocationBuilder = super.sendRequest(INSTANTIATION_COMMAND_ENDPOINT); + resp = invocationBuilder.put(Entity.json(command)); + assertEquals(Response.Status.ACCEPTED.getStatusCode(), resp.getStatus()); + InstantiationResponse instResponse = resp.readEntity(InstantiationResponse.class); + InstantiationUtils.assertInstantiationResponse(instResponse, command); + + // check passive state on DB and delete properties + for (ToscaConceptIdentifier toscaConceptIdentifier : command.getAutomationCompositionIdentifierList()) { + AutomationCompositions automationCompositionsGet = instantiationProvider + .getAutomationCompositions(toscaConceptIdentifier.getName(), toscaConceptIdentifier.getVersion()); + assertThat(automationCompositionsGet.getAutomationCompositionList()).hasSize(1); + assertEquals(command.getOrderedState(), + automationCompositionsGet.getAutomationCompositionList().get(0).getOrderedState()); + + invocationBuilder = super.sendRequest(INSTANTIATION_PROPERTIES + "?name=" + toscaConceptIdentifier.getName() + + "&version=" + toscaConceptIdentifier.getVersion()); + resp = invocationBuilder.delete(); + assertEquals(Response.Status.BAD_REQUEST.getStatusCode(), resp.getStatus()); + } + } + + @Test + void testCommand_NotFound1() throws Exception { + Invocation.Builder invocationBuilder = super.sendRequest(INSTANTIATION_COMMAND_ENDPOINT); + Response resp = invocationBuilder.put(Entity.json(new InstantiationCommand())); + assertEquals(Response.Status.BAD_REQUEST.getStatusCode(), resp.getStatus()); + } + + @Test + void testCommand_NotFound2() throws Exception { + InstantiationCommand command = + InstantiationUtils.getInstantiationCommandFromResource(AC_INSTANTIATION_CHANGE_STATE_JSON, "Command"); + command.setOrderedState(null); + + Invocation.Builder invocationBuilder = super.sendRequest(INSTANTIATION_COMMAND_ENDPOINT); + Response resp = invocationBuilder.put(Entity.json(command)); + assertEquals(Response.Status.BAD_REQUEST.getStatusCode(), resp.getStatus()); + } + + @Test + void testCommand() throws Exception { + var automationCompositions = + InstantiationUtils.getAutomationCompositionsFromResource(AC_INSTANTIATION_CREATE_JSON, "Command"); + instantiationProvider.createAutomationCompositions(automationCompositions); + + var participants = CommonTestData.createParticipants(); + for (var participant : participants) { + participantProvider.saveParticipant(participant); + } + + InstantiationCommand command = + InstantiationUtils.getInstantiationCommandFromResource(AC_INSTANTIATION_CHANGE_STATE_JSON, "Command"); + + Invocation.Builder invocationBuilder = super.sendRequest(INSTANTIATION_COMMAND_ENDPOINT); + Response resp = invocationBuilder.put(Entity.json(command)); + assertEquals(Response.Status.ACCEPTED.getStatusCode(), resp.getStatus()); + InstantiationResponse instResponse = resp.readEntity(InstantiationResponse.class); + InstantiationUtils.assertInstantiationResponse(instResponse, command); + + // check passive state on DB + for (ToscaConceptIdentifier toscaConceptIdentifier : command.getAutomationCompositionIdentifierList()) { + AutomationCompositions automationCompositionsGet = instantiationProvider + .getAutomationCompositions(toscaConceptIdentifier.getName(), toscaConceptIdentifier.getVersion()); + assertThat(automationCompositionsGet.getAutomationCompositionList()).hasSize(1); + assertEquals(command.getOrderedState(), + automationCompositionsGet.getAutomationCompositionList().get(0).getOrderedState()); + } + } + + @Test + void testIntanceProperties() throws Exception { + Invocation.Builder invocationBuilder = super.sendRequest(INSTANTIATION_PROPERTIES); + Response resp = invocationBuilder.post(Entity.json(serviceTemplate)); + assertEquals(Response.Status.OK.getStatusCode(), resp.getStatus()); + var instancePropertyList = resp.readEntity(InstancePropertiesResponse.class); + assertNull(instancePropertyList.getErrorDetails()); + var id = new ToscaConceptIdentifier(ID_NAME, ID_VERSION); + assertEquals(id, instancePropertyList.getAffectedInstanceProperties().get(0)); + + invocationBuilder = super.sendRequest(INSTANTIATION_STATE + "?name=" + ID_NAME + "&version=" + ID_VERSION); + resp = invocationBuilder.buildGet().invoke(); + assertEquals(Response.Status.OK.getStatusCode(), resp.getStatus()); + var instanceOrderState = resp.readEntity(AutomationCompositionOrderStateResponse.class); + assertEquals(AutomationCompositionOrderedState.UNINITIALISED, instanceOrderState.getOrderedState()); + assertEquals(ID_NAME, instanceOrderState.getAutomationCompositionIdentifierList().get(0).getName()); + AutomationCompositions automationCompositionsGet = + instantiationProvider.getAutomationCompositions(ID_NAME, ID_VERSION); + assertThat(automationCompositionsGet.getAutomationCompositionList()).hasSize(1); + + invocationBuilder = super.sendRequest(INSTANTIATION_PROPERTIES + "?name=" + ID_NAME + "&version=" + ID_VERSION); + resp = invocationBuilder.delete(); + assertEquals(Response.Status.OK.getStatusCode(), resp.getStatus()); + var instanceResponse = resp.readEntity(InstantiationResponse.class); + assertEquals(ID_NAME, instanceResponse.getAffectedAutomationCompositions().get(0).getName()); + automationCompositionsGet = instantiationProvider.getAutomationCompositions(ID_NAME, ID_VERSION); + assertThat(automationCompositionsGet.getAutomationCompositionList()).isEmpty(); + } + + @Test + void testChangeOrderStateFromUninitializedPassiveMode() throws Exception { + Invocation.Builder invocationBuilder = super.sendRequest(INSTANTIATION_PROPERTIES); + Response resp = invocationBuilder.post(Entity.json(serviceTemplate)); + assertEquals(Response.Status.OK.getStatusCode(), resp.getStatus()); + + var automationCompositions = + InstantiationUtils.getAutomationCompositionsFromResource(AC_INSTANTIATION_CREATE_JSON, "CommandPassive"); + instantiationProvider.createAutomationCompositions(automationCompositions); + + var participants = CommonTestData.createParticipants(); + for (var participant : participants) { + participantProvider.saveParticipant(participant); + } + + InstantiationCommand command = InstantiationUtils + .getInstantiationCommandFromResource(AC_INSTANTIATION_CHANGE_STATE_JSON, "CommandPassive"); + + invocationBuilder = super.sendRequest(INSTANTIATION_COMMAND_ENDPOINT); + resp = invocationBuilder.put(Entity.json(command)); + assertEquals(Response.Status.ACCEPTED.getStatusCode(), resp.getStatus()); + InstantiationResponse instResponse = resp.readEntity(InstantiationResponse.class); + InstantiationUtils.assertInstantiationResponse(instResponse, command); + } + + @Test + void testChangeOrderStateWithoutRegisteredParticipants() throws Exception { + Invocation.Builder invocationBuilder = super.sendRequest(INSTANTIATION_PROPERTIES); + Response resp = invocationBuilder.post(Entity.json(serviceTemplate)); + assertEquals(Response.Status.OK.getStatusCode(), resp.getStatus()); + + var automationCompositions = + InstantiationUtils.getAutomationCompositionsFromResource(AC_INSTANTIATION_CREATE_JSON, "CommandPassive"); + instantiationProvider.createAutomationCompositions(automationCompositions); + + InstantiationCommand command = InstantiationUtils + .getInstantiationCommandFromResource(AC_INSTANTIATION_CHANGE_STATE_JSON, "CommandPassive"); + + invocationBuilder = super.sendRequest(INSTANTIATION_COMMAND_ENDPOINT); + resp = invocationBuilder.put(Entity.json(command)); + assertEquals(Response.Status.BAD_REQUEST.getStatusCode(), resp.getStatus()); + } + + private synchronized void deleteEntryInDB() throws Exception { + automationCompositionRepository.deleteAll(); + var list = serviceTemplateProvider.getAllServiceTemplates(); + if (!list.isEmpty()) { + serviceTemplateProvider.deleteServiceTemplate(list.get(0).getName(), list.get(0).getVersion()); + } + } + + private synchronized void createEntryInDB() throws Exception { + deleteEntryInDB(); + serviceTemplateProvider.createServiceTemplate(serviceTemplate); + } +} diff --git a/runtime-acm/src/test/java/org/onap/policy/clamp/acm/runtime/main/rest/ActuatorControllerTest.java b/runtime-acm/src/test/java/org/onap/policy/clamp/acm/runtime/main/rest/ActuatorControllerTest.java new file mode 100644 index 000000000..553a4721b --- /dev/null +++ b/runtime-acm/src/test/java/org/onap/policy/clamp/acm/runtime/main/rest/ActuatorControllerTest.java @@ -0,0 +1,91 @@ +/*- + * ============LICENSE_START======================================================= + * Copyright (C) 2021 Nordix Foundation. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * SPDX-License-Identifier: Apache-2.0 + * ============LICENSE_END========================================================= + */ + +package org.onap.policy.clamp.acm.runtime.main.rest; + +import static org.junit.jupiter.api.Assertions.assertEquals; + +import javax.ws.rs.client.Invocation; +import javax.ws.rs.core.Response; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.ExtendWith; +import org.onap.policy.clamp.acm.runtime.util.rest.CommonRestController; +import org.springframework.boot.test.autoconfigure.actuate.metrics.AutoConfigureMetrics; +import org.springframework.boot.test.context.SpringBootTest; +import org.springframework.boot.test.context.SpringBootTest.WebEnvironment; +import org.springframework.boot.web.server.LocalServerPort; +import org.springframework.test.context.TestPropertySource; +import org.springframework.test.context.junit.jupiter.SpringExtension; + +@AutoConfigureMetrics +@ExtendWith(SpringExtension.class) +@SpringBootTest(webEnvironment = WebEnvironment.RANDOM_PORT) +@TestPropertySource(locations = {"classpath:application_test.properties"}) +class ActuatorControllerTest extends CommonRestController { + + private static final String HEALTH_ENDPOINT = "health"; + private static final String METRICS_ENDPOINT = "metrics"; + private static final String PROMETHEUS_ENDPOINT = "prometheus"; + + @LocalServerPort + private int randomServerPort; + + @BeforeEach + public void setUpPort() { + super.setHttpPrefix(randomServerPort); + } + + @Test + void testGetHealth_Unauthorized() throws Exception { + assertUnauthorizedActGet(HEALTH_ENDPOINT); + } + + @Test + void testGetMetrics_Unauthorized() throws Exception { + assertUnauthorizedActGet(METRICS_ENDPOINT); + } + + @Test + void testGetPrometheus_Unauthorized() throws Exception { + assertUnauthorizedActGet(PROMETHEUS_ENDPOINT); + } + + @Test + void testGetHealth() throws Exception { + Invocation.Builder invocationBuilder = super.sendActRequest(HEALTH_ENDPOINT); + Response rawresp = invocationBuilder.buildGet().invoke(); + assertEquals(Response.Status.OK.getStatusCode(), rawresp.getStatus()); + } + + @Test + void testGetMetrics() throws Exception { + Invocation.Builder invocationBuilder = super.sendActRequest(METRICS_ENDPOINT); + Response rawresp = invocationBuilder.buildGet().invoke(); + assertEquals(Response.Status.OK.getStatusCode(), rawresp.getStatus()); + } + + @Test + void testGePrometheus() throws Exception { + Invocation.Builder invocationBuilder = super.sendActRequest(PROMETHEUS_ENDPOINT); + Response rawresp = invocationBuilder.buildGet().invoke(); + assertEquals(Response.Status.OK.getStatusCode(), rawresp.getStatus()); + } +} diff --git a/runtime-acm/src/test/java/org/onap/policy/clamp/acm/runtime/monitoring/TestMonitoringProvider.java b/runtime-acm/src/test/java/org/onap/policy/clamp/acm/runtime/monitoring/TestMonitoringProvider.java new file mode 100644 index 000000000..aabc254c1 --- /dev/null +++ b/runtime-acm/src/test/java/org/onap/policy/clamp/acm/runtime/monitoring/TestMonitoringProvider.java @@ -0,0 +1,321 @@ +/*- + * ============LICENSE_START======================================================= + * Copyright (C) 2021 Nordix Foundation. + * Modifications Copyright (C) 2021 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * SPDX-License-Identifier: Apache-2.0 + * ============LICENSE_END========================================================= + */ + +package org.onap.policy.clamp.acm.runtime.monitoring; + +import static org.assertj.core.api.Assertions.assertThat; +import static org.assertj.core.api.Assertions.assertThatThrownBy; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.mockito.ArgumentMatchers.any; +import static org.mockito.ArgumentMatchers.anyMap; +import static org.mockito.ArgumentMatchers.eq; +import static org.mockito.Mockito.mock; +import static org.mockito.Mockito.when; + +import java.io.File; +import java.time.Instant; +import java.util.LinkedHashMap; +import java.util.List; +import java.util.Map; +import java.util.Optional; +import java.util.UUID; +import javax.ws.rs.core.Response; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.Test; +import org.mockito.Mockito; +import org.onap.policy.clamp.models.acm.concepts.AcElementStatisticsList; +import org.onap.policy.clamp.models.acm.concepts.AutomationComposition; +import org.onap.policy.clamp.models.acm.concepts.AutomationCompositionElement; +import org.onap.policy.clamp.models.acm.concepts.ParticipantStatisticsList; +import org.onap.policy.clamp.models.acm.persistence.provider.AcElementStatisticsProvider; +import org.onap.policy.clamp.models.acm.persistence.provider.AutomationCompositionProvider; +import org.onap.policy.clamp.models.acm.persistence.provider.ParticipantStatisticsProvider; +import org.onap.policy.common.utils.coder.Coder; +import org.onap.policy.common.utils.coder.CoderException; +import org.onap.policy.common.utils.coder.StandardCoder; +import org.onap.policy.models.base.PfModelRuntimeException; +import org.onap.policy.models.tosca.authorative.concepts.ToscaConceptIdentifier; + +class TestMonitoringProvider { + + private static final String AC_PARTICIPANT_STATISTICS_JSON = + "src/test/resources/rest/monitoring/TestParticipantStatistics.json"; + private static final String INVALID_PARTICIPANT_JSON_INPUT = + "src/test/resources/rest/monitoring/TestParticipantStatistics_Invalid.json"; + private static final String AC_ELEMENT_STATISTICS_JSON = + "src/test/resources/rest/monitoring/TestAcElementStatistics.json"; + private static final String INVALID_AC_ELEMENT_JSON_INPUT = + "src/test/resources/rest/monitoring/TestAcElementStatistics_Invalid.json"; + private static final Coder CODER = new StandardCoder(); + + private static final String STAT_LIST_IS_NULL = ".*StatisticsList is marked .*ull but is null"; + private static final String PARTICIPANT_STAT_LIST_IS_NULL = + "participantStatisticsList is marked .*null but is null"; + private static final String NAME_IS_NULL = "name is marked .*null but is null"; + private static final String AC_LIST_IS_NULL = "acElementStatisticsList is marked .*null but is null"; + private static final String ID_VERSION1 = "1.001"; + private static final String ID_VERSION2 = "1.002"; + private static final String ID_NAME1 = "name1"; + private static final String ID_NAME2 = "name2"; + private static final String SORT_DESC = "DESC"; + private static final String ID_NAME3 = "testACName"; + private static final String ID_INVALID_NAME = "invalidACName"; + private static ParticipantStatisticsList inputParticipantStatistics; + private static ParticipantStatisticsList invalidParticipantInput; + private static AcElementStatisticsList inputAcElementStatistics; + private static AcElementStatisticsList invalidAcElementInput; + + @BeforeAll + public static void beforeSetupStatistics() throws CoderException { + // Reading input json for statistics data + inputParticipantStatistics = + CODER.decode(new File(AC_PARTICIPANT_STATISTICS_JSON), ParticipantStatisticsList.class); + invalidParticipantInput = + CODER.decode(new File(INVALID_PARTICIPANT_JSON_INPUT), ParticipantStatisticsList.class); + inputAcElementStatistics = CODER.decode(new File(AC_ELEMENT_STATISTICS_JSON), AcElementStatisticsList.class); + invalidAcElementInput = CODER.decode(new File(INVALID_AC_ELEMENT_JSON_INPUT), AcElementStatisticsList.class); + } + + @Test + void testCreateParticipantStatistics() throws Exception { + var participantStatisticsProvider = mock(ParticipantStatisticsProvider.class); + var acElementStatisticsProvider = mock(AcElementStatisticsProvider.class); + var acProvider = mock(AutomationCompositionProvider.class); + MonitoringProvider provider = + new MonitoringProvider(participantStatisticsProvider, acElementStatisticsProvider, acProvider); + + when(participantStatisticsProvider.createParticipantStatistics(any())) + .thenReturn(inputParticipantStatistics.getStatisticsList()); + + when(participantStatisticsProvider.createParticipantStatistics(eq(null))) + .thenThrow(new PfModelRuntimeException(Response.Status.BAD_REQUEST, PARTICIPANT_STAT_LIST_IS_NULL)); + + // Creating statistics data in db with null input + + assertThatThrownBy(() -> { + provider.createParticipantStatistics(null); + }).hasMessageMatching(STAT_LIST_IS_NULL); + + assertThatThrownBy(() -> { + provider.createParticipantStatistics(invalidParticipantInput.getStatisticsList()); + }).hasMessageMatching(PARTICIPANT_STAT_LIST_IS_NULL); + + // Creating statistics data from input json + ParticipantStatisticsList createResponse = + provider.createParticipantStatistics(inputParticipantStatistics.getStatisticsList()); + + assertThat(createResponse.getStatisticsList()).hasSize(3); + assertEquals(createResponse.getStatisticsList().toString().replaceAll("\\s+", ""), + inputParticipantStatistics.getStatisticsList().toString().replaceAll("\\s+", "")); + } + + @Test + void testGetParticipantStatistics() throws Exception { + var participantStatisticsProvider = mock(ParticipantStatisticsProvider.class); + when(participantStatisticsProvider.getFilteredParticipantStatistics(eq(ID_NAME1), any(), any(), any(), eq(null), + eq(SORT_DESC), eq(0))).thenReturn(List.of(inputParticipantStatistics.getStatisticsList().get(0))); + + when(participantStatisticsProvider.getFilteredParticipantStatistics(eq(ID_NAME1), any(), + eq(Instant.parse("2021-01-11T12:00:00.000Z")), eq(Instant.parse("2021-01-11T16:00:00.000Z")), eq(null), + eq(SORT_DESC), eq(0))).thenReturn(List.of()); + + when(participantStatisticsProvider.getFilteredParticipantStatistics(eq(ID_NAME2), any(), any(), any(), eq(null), + eq(SORT_DESC), eq(1))).thenReturn(List.of(inputParticipantStatistics.getStatisticsList().get(2))); + + var acProvider = mock(AutomationCompositionProvider.class); + var acElementStatisticsProvider = mock(AcElementStatisticsProvider.class); + MonitoringProvider provider = + new MonitoringProvider(participantStatisticsProvider, acElementStatisticsProvider, acProvider); + provider.createParticipantStatistics(inputParticipantStatistics.getStatisticsList()); + + assertThatThrownBy(() -> { + provider.fetchFilteredParticipantStatistics(null, null, 0, null, null); + }).hasMessageMatching(NAME_IS_NULL); + + // Fetch specific statistics record with name, version and record count + ParticipantStatisticsList getResponse = + provider.fetchFilteredParticipantStatistics(ID_NAME2, ID_VERSION1, 1, null, null); + assertThat(getResponse.getStatisticsList()).hasSize(1); + assertEquals(getResponse.getStatisticsList().get(0).toString().replaceAll("\\s+", ""), + inputParticipantStatistics.getStatisticsList().get(2).toString().replaceAll("\\s+", "")); + + // Fetch statistics using timestamp + getResponse = provider.fetchFilteredParticipantStatistics(ID_NAME1, ID_VERSION1, 0, null, + Instant.parse("2021-01-10T15:00:00.000Z")); + assertThat(getResponse.getStatisticsList()).hasSize(1); + + getResponse = provider.fetchFilteredParticipantStatistics(ID_NAME1, ID_VERSION1, 0, + Instant.parse("2021-01-11T12:00:00.000Z"), Instant.parse("2021-01-11T16:00:00.000Z")); + + assertThat(getResponse.getStatisticsList()).isEmpty(); + } + + @Test + void testCreateAcElementStatistics() throws Exception { + var acElementStatisticsProvider = mock(AcElementStatisticsProvider.class); + when(acElementStatisticsProvider.createAcElementStatistics(any())) + .thenReturn(inputAcElementStatistics.getAcElementStatistics()); + + when(acElementStatisticsProvider.createAcElementStatistics(eq(null))) + .thenThrow(new PfModelRuntimeException(Response.Status.BAD_REQUEST, AC_LIST_IS_NULL)); + + var acProvider = mock(AutomationCompositionProvider.class); + + var participantStatisticsProvider = mock(ParticipantStatisticsProvider.class); + MonitoringProvider provider = + new MonitoringProvider(participantStatisticsProvider, acElementStatisticsProvider, acProvider); + // Creating statistics data in db with null input + assertThatThrownBy(() -> { + provider.createAcElementStatistics(null); + }).hasMessageMatching(STAT_LIST_IS_NULL); + + assertThatThrownBy(() -> { + provider.createAcElementStatistics(invalidAcElementInput.getAcElementStatistics()); + }).hasMessageMatching(AC_LIST_IS_NULL); + + // Creating acElement statistics data from input json + AcElementStatisticsList createResponse = + provider.createAcElementStatistics(inputAcElementStatistics.getAcElementStatistics()); + + assertThat(createResponse.getAcElementStatistics()).hasSize(4); + assertEquals(createResponse.getAcElementStatistics().toString().replaceAll("\\s+", ""), + inputAcElementStatistics.getAcElementStatistics().toString().replaceAll("\\s+", "")); + } + + @Test + void testGetAcElementStatistics() throws Exception { + var participantStatisticsProvider = mock(ParticipantStatisticsProvider.class); + var acElementStatisticsProvider = mock(AcElementStatisticsProvider.class); + var acProvider = mock(AutomationCompositionProvider.class); + + when(acElementStatisticsProvider.getFilteredAcElementStatistics(eq(ID_NAME1), any(), any(), any(), anyMap(), + eq(SORT_DESC), eq(0))) + .thenReturn(List.of(inputAcElementStatistics.getAcElementStatistics().get(0), + inputAcElementStatistics.getAcElementStatistics().get(1))); + + when(acElementStatisticsProvider.getFilteredAcElementStatistics(eq(ID_NAME1), any(), any(), any(), anyMap(), + eq(SORT_DESC), eq(0))) + .thenReturn(List.of(inputAcElementStatistics.getAcElementStatistics().get(0), + inputAcElementStatistics.getAcElementStatistics().get(1))); + + MonitoringProvider provider = + new MonitoringProvider(participantStatisticsProvider, acElementStatisticsProvider, acProvider); + assertThatThrownBy(() -> { + provider.fetchFilteredAcElementStatistics(null, null, null, null, null, 0); + }).hasMessageMatching(NAME_IS_NULL); + + provider.createAcElementStatistics(inputAcElementStatistics.getAcElementStatistics()); + + AcElementStatisticsList getResponse = + provider.fetchFilteredAcElementStatistics(ID_NAME1, null, null, null, null, 0); + + assertThat(getResponse.getAcElementStatistics()).hasSize(2); + assertEquals(getResponse.getAcElementStatistics().get(0).toString().replaceAll("\\s+", ""), + inputAcElementStatistics.getAcElementStatistics().get(0).toString().replaceAll("\\s+", "")); + + // Fetch specific statistics record with name, id and record count + getResponse = provider.fetchFilteredAcElementStatistics(ID_NAME1, ID_VERSION1, + "709c62b3-8918-41b9-a747-d21eb79c6c20", null, null, 0); + assertThat(getResponse.getAcElementStatistics()).hasSize(2); + + // Fetch statistics using timestamp + getResponse = provider.fetchFilteredAcElementStatistics(ID_NAME1, ID_VERSION1, null, + Instant.parse("2021-01-10T13:45:00.000Z"), null, 0); + assertThat(getResponse.getAcElementStatistics()).hasSize(2); + } + + @Test + void testGetParticipantStatsPerAc() throws Exception { + var participantStatisticsProvider = mock(ParticipantStatisticsProvider.class); + var acElementStatisticsProvider = mock(AcElementStatisticsProvider.class); + var mockAcProvider = Mockito.mock(AutomationCompositionProvider.class); + var provider = + new MonitoringProvider(participantStatisticsProvider, acElementStatisticsProvider, mockAcProvider); + + provider.createParticipantStatistics(inputParticipantStatistics.getStatisticsList()); + + var automationComposition = new AutomationComposition(); + var element = new AutomationCompositionElement(); + element.setParticipantId(new ToscaConceptIdentifier(ID_NAME1, ID_VERSION1)); + automationComposition.setElements(Map.of(UUID.randomUUID(), element)); + when(mockAcProvider.findAutomationComposition(new ToscaConceptIdentifier(ID_NAME2, ID_VERSION1))) + .thenReturn(Optional.of(automationComposition)); + + when(participantStatisticsProvider.getFilteredParticipantStatistics(eq(ID_NAME1), eq(ID_VERSION1), any(), any(), + eq(null), eq(SORT_DESC), eq(0))) + .thenReturn(List.of(inputParticipantStatistics.getStatisticsList().get(0), + inputParticipantStatistics.getStatisticsList().get(1))); + + ParticipantStatisticsList getResponse = + provider.fetchParticipantStatsPerAutomationComposition(ID_NAME2, ID_VERSION1); + assertThat(getResponse.getStatisticsList()).hasSize(2); + assertEquals(getResponse.getStatisticsList().get(0).toString().replaceAll("\\s+", ""), + inputParticipantStatistics.getStatisticsList().get(0).toString().replaceAll("\\s+", "")); + assertThat( + provider.fetchParticipantStatsPerAutomationComposition(ID_INVALID_NAME, ID_VERSION2).getStatisticsList()) + .isEmpty(); + } + + @Test + void testAcElementStatsPerAc() throws Exception { + // Setup a dummy automation composition data + var mockAcElement = new AutomationCompositionElement(); + mockAcElement.setId(inputAcElementStatistics.getAcElementStatistics().get(0).getId()); + mockAcElement.setParticipantId(new ToscaConceptIdentifier( + inputAcElementStatistics.getAcElementStatistics().get(0).getParticipantId().getName(), + inputAcElementStatistics.getAcElementStatistics().get(0).getParticipantId().getVersion())); + var mockAc = new AutomationComposition(); + mockAc.setElements(new LinkedHashMap<>()); + mockAc.getElements().put(mockAcElement.getId(), mockAcElement); + + var participantStatisticsProvider = mock(ParticipantStatisticsProvider.class); + var acElementStatisticsProvider = mock(AcElementStatisticsProvider.class); + var mockAcProvider = Mockito.mock(AutomationCompositionProvider.class); + var monitoringProvider = + new MonitoringProvider(participantStatisticsProvider, acElementStatisticsProvider, mockAcProvider); + + // Mock automation composition data to be returned for the given AC Id + when(mockAcProvider.findAutomationComposition(new ToscaConceptIdentifier(ID_NAME3, ID_VERSION1))) + .thenReturn(Optional.of(mockAc)); + + when(acElementStatisticsProvider.getFilteredAcElementStatistics(eq(ID_NAME1), eq(ID_VERSION1), any(), any(), + anyMap(), eq(SORT_DESC), eq(0))) + .thenReturn(List.of(inputAcElementStatistics.getAcElementStatistics().get(0), + inputAcElementStatistics.getAcElementStatistics().get(1))); + + monitoringProvider.createAcElementStatistics(inputAcElementStatistics.getAcElementStatistics()); + + AcElementStatisticsList getResponse = + monitoringProvider.fetchAcElementStatsPerAutomationComposition(ID_NAME3, ID_VERSION1); + + assertThat(getResponse.getAcElementStatistics()).hasSize(2); + assertEquals(getResponse.getAcElementStatistics().get(1).toString().replaceAll("\\s+", ""), + inputAcElementStatistics.getAcElementStatistics().get(1).toString().replaceAll("\\s+", "")); + + assertThat(monitoringProvider.fetchAcElementStatsPerAutomationComposition(ID_INVALID_NAME, ID_VERSION2) + .getAcElementStatistics()).isEmpty(); + + Map acElementIds = + monitoringProvider.getAllAcElementsIdPerAutomationComposition(ID_NAME3, ID_VERSION1); + assertThat(acElementIds) + .containsKey(inputAcElementStatistics.getAcElementStatistics().get(0).getId().toString()); + } +} diff --git a/runtime-acm/src/test/java/org/onap/policy/clamp/acm/runtime/monitoring/rest/MonitoringQueryControllerTest.java b/runtime-acm/src/test/java/org/onap/policy/clamp/acm/runtime/monitoring/rest/MonitoringQueryControllerTest.java new file mode 100644 index 000000000..7630e42d2 --- /dev/null +++ b/runtime-acm/src/test/java/org/onap/policy/clamp/acm/runtime/monitoring/rest/MonitoringQueryControllerTest.java @@ -0,0 +1,242 @@ +/*- + * ============LICENSE_START======================================================= + * Copyright (C) 2021 Nordix Foundation. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * SPDX-License-Identifier: Apache-2.0 + * ============LICENSE_END========================================================= + */ + +package org.onap.policy.clamp.acm.runtime.monitoring.rest; + +import static org.assertj.core.api.Assertions.assertThat; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertNotNull; + +import java.io.File; +import java.time.Instant; +import javax.ws.rs.client.Invocation; +import javax.ws.rs.core.Response; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.ExtendWith; +import org.onap.policy.clamp.acm.runtime.monitoring.MonitoringProvider; +import org.onap.policy.clamp.acm.runtime.util.rest.CommonRestController; +import org.onap.policy.clamp.models.acm.concepts.AcElementStatisticsList; +import org.onap.policy.clamp.models.acm.concepts.ParticipantStatisticsList; +import org.onap.policy.common.utils.coder.Coder; +import org.onap.policy.common.utils.coder.StandardCoder; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.boot.test.context.SpringBootTest; +import org.springframework.boot.test.context.SpringBootTest.WebEnvironment; +import org.springframework.boot.web.server.LocalServerPort; +import org.springframework.test.context.TestPropertySource; +import org.springframework.test.context.junit.jupiter.SpringExtension; + +@ExtendWith(SpringExtension.class) +@SpringBootTest(webEnvironment = WebEnvironment.RANDOM_PORT) +@TestPropertySource(locations = {"classpath:application_test.properties"}) +class MonitoringQueryControllerTest extends CommonRestController { + + private static final String AC_PARTICIPANT_STATISTICS_JSON = + "src/test/resources/rest/monitoring/TestParticipantStatistics.json"; + private static final String AC_ELEMENT_STATISTICS_JSON = + "src/test/resources/rest/monitoring/TestAcElementStatistics.json"; + + private static final Coder CODER = new StandardCoder(); + + private static ParticipantStatisticsList inputParticipantStatistics; + private static AcElementStatisticsList inputAcElementStatistics; + + private static ParticipantStatisticsList participantStatisticsList; + private static AcElementStatisticsList acElementStatisticsList; + + private static final String AC_ELEMENT_STATS_ENDPOINT = "monitoring/acelement"; + private static final String PARTICIPANT_STATS_ENDPOINT = "monitoring/participant"; + private static final String PARTICIPANT_STATS_PER_AC_ENDPOINT = "monitoring/participants/automationcomposition"; + private static final String AC_ELEMENT_STATS_PER_AC_ENDPOINT = "monitoring/acelements/automationcomposition"; + + @Autowired + private MonitoringProvider monitoringProvider; + + @LocalServerPort + private int randomServerPort; + + /** + * starts Main. + * + * @throws Exception if an error occurs + */ + @BeforeAll + public static void setUpBeforeAll() throws Exception { + + inputParticipantStatistics = + CODER.decode(new File(AC_PARTICIPANT_STATISTICS_JSON), ParticipantStatisticsList.class); + inputAcElementStatistics = CODER.decode(new File(AC_ELEMENT_STATISTICS_JSON), AcElementStatisticsList.class); + } + + @BeforeEach + public void setUpBeforeEach() throws Exception { + super.setHttpPrefix(randomServerPort); + + // Insert Participant statistics to DB + participantStatisticsList = + monitoringProvider.createParticipantStatistics(inputParticipantStatistics.getStatisticsList()); + // Insert AC Element statistics to DB + acElementStatisticsList = + monitoringProvider.createAcElementStatistics(inputAcElementStatistics.getAcElementStatistics()); + } + + @Test + void testQuery_Unauthorized_for_AcElementStats() throws Exception { + assertUnauthorizedGet(AC_ELEMENT_STATS_ENDPOINT); + } + + @Test + void testQuery_Unauthorized_for_AcParticipantStats() throws Exception { + assertUnauthorizedGet(PARTICIPANT_STATS_ENDPOINT); + } + + @Test + void testQuery_Unauthorized_for_ParticipantStatsPerAc() throws Exception { + assertUnauthorizedGet(PARTICIPANT_STATS_PER_AC_ENDPOINT); + } + + @Test + void testQuery_Unauthorized_for_AcElementStatsPerAc() throws Exception { + assertUnauthorizedGet(AC_ELEMENT_STATS_PER_AC_ENDPOINT); + } + + @Test + void testSwagger_AcStats() throws Exception { + super.testSwagger(AC_ELEMENT_STATS_ENDPOINT); + super.testSwagger(PARTICIPANT_STATS_ENDPOINT); + super.testSwagger(AC_ELEMENT_STATS_PER_AC_ENDPOINT); + super.testSwagger(PARTICIPANT_STATS_PER_AC_ENDPOINT); + } + + @Test + void testAcElementStatisticsEndpoint() throws Exception { + // Filter statistics only based on participant Id and UUID + Invocation.Builder invokeRequest1 = super.sendRequest(AC_ELEMENT_STATS_ENDPOINT + "?name=" + + acElementStatisticsList.getAcElementStatistics().get(0).getParticipantId().getName() + "&version=" + + acElementStatisticsList.getAcElementStatistics().get(0).getParticipantId().getVersion() + "&id=" + + acElementStatisticsList.getAcElementStatistics().get(0).getId().toString()); + Response response1 = invokeRequest1.buildGet().invoke(); + assertEquals(Response.Status.OK.getStatusCode(), response1.getStatus()); + + AcElementStatisticsList result1 = response1.readEntity(AcElementStatisticsList.class); + + assertNotNull(result1); + assertThat(result1.getAcElementStatistics()).hasSize(2); + + var acElementStat0 = acElementStatisticsList.getAcElementStatistics().get(0); + for (var acElement : result1.getAcElementStatistics()) { + assertEquals(acElement.getParticipantId().asConceptKey(), acElementStat0.getParticipantId().asConceptKey()); + assertEquals(acElement.getId(), acElementStat0.getId()); + } + + // Filter statistics based on timestamp + Invocation.Builder invokeRequest2 = super.sendRequest(AC_ELEMENT_STATS_ENDPOINT + "?name=" + + acElementStatisticsList.getAcElementStatistics().get(1).getParticipantId().getName() + "&version=" + + acElementStatisticsList.getAcElementStatistics().get(1).getParticipantId().getVersion() + + "&startTime=" + Instant.parse("2021-01-10T13:00:00.000Z") + "&endTime=" + + Instant.parse("2021-01-10T14:00:00.000Z")); + Response response2 = invokeRequest2.buildGet().invoke(); + assertEquals(Response.Status.OK.getStatusCode(), response2.getStatus()); + AcElementStatisticsList result2 = response2.readEntity(AcElementStatisticsList.class); + + assertNotNull(result2); + assertThat(result2.getAcElementStatistics()).hasSize(1); + assertEquals(result2.getAcElementStatistics().get(0), acElementStat0); + } + + @Test + void testAcElementStats_BadRequest() throws Exception { + Invocation.Builder invokeRequest1 = super.sendRequest(AC_ELEMENT_STATS_ENDPOINT + "?version=1.0.0"); + Response response1 = invokeRequest1.buildGet().invoke(); + assertEquals(Response.Status.INTERNAL_SERVER_ERROR.getStatusCode(), response1.getStatus()); + } + + @Test + void testParticipantStatisticsEndpoint() throws Exception { + + // Filter statistics only based on participant Id + Invocation.Builder invokeRequest1 = super.sendRequest(PARTICIPANT_STATS_ENDPOINT + "?name=" + + participantStatisticsList.getStatisticsList().get(0).getParticipantId().getName() + "&version=" + + participantStatisticsList.getStatisticsList().get(0).getParticipantId().getVersion()); + Response response1 = invokeRequest1.buildGet().invoke(); + assertEquals(Response.Status.OK.getStatusCode(), response1.getStatus()); + ParticipantStatisticsList result1 = response1.readEntity(ParticipantStatisticsList.class); + + assertNotNull(result1); + assertThat(result1.getStatisticsList()).hasSize(2); + assertThat(result1.getStatisticsList()).contains(participantStatisticsList.getStatisticsList().get(0)); + + // Filter statistics based on timestamp + Invocation.Builder invokeRequest2 = super.sendRequest(PARTICIPANT_STATS_ENDPOINT + "?name=" + + participantStatisticsList.getStatisticsList().get(1).getParticipantId().getName() + "&version=" + + participantStatisticsList.getStatisticsList().get(1).getParticipantId().getVersion() + "&startTime=" + + Instant.parse("2021-01-10T13:00:00.000Z") + "&endTime=" + Instant.parse("2021-01-10T14:00:00.000Z")); + Response response2 = invokeRequest2.buildGet().invoke(); + assertEquals(Response.Status.OK.getStatusCode(), response2.getStatus()); + ParticipantStatisticsList result2 = response2.readEntity(ParticipantStatisticsList.class); + + assertNotNull(result2); + assertThat(result2.getStatisticsList()).hasSize(1); + assertEquals(result2.getStatisticsList().get(0), participantStatisticsList.getStatisticsList().get(0)); + } + + @Test + void testParticipantStats_BadRequest() throws Exception { + Invocation.Builder invokeRequest1 = super.sendRequest(PARTICIPANT_STATS_ENDPOINT + "?version=0.0"); + Response response1 = invokeRequest1.buildGet().invoke(); + assertEquals(Response.Status.INTERNAL_SERVER_ERROR.getStatusCode(), response1.getStatus()); + } + + @Test + void testParticipantStatsPerAcEndpoint() throws Exception { + Invocation.Builder invokeRequest1 = + super.sendRequest(PARTICIPANT_STATS_PER_AC_ENDPOINT + "?name=dummyName&version=1.001"); + Response response1 = invokeRequest1.buildGet().invoke(); + assertEquals(Response.Status.OK.getStatusCode(), response1.getStatus()); + ParticipantStatisticsList result1 = response1.readEntity(ParticipantStatisticsList.class); + assertThat(result1.getStatisticsList()).isEmpty(); + } + + @Test + void testParticipantStatsPerAc_BadRequest() throws Exception { + Invocation.Builder invokeRequest1 = super.sendRequest(PARTICIPANT_STATS_PER_AC_ENDPOINT); + Response response1 = invokeRequest1.buildGet().invoke(); + assertEquals(Response.Status.INTERNAL_SERVER_ERROR.getStatusCode(), response1.getStatus()); + } + + @Test + void testAcElementStatisticsPerAcEndpoint() throws Exception { + Invocation.Builder invokeRequest1 = + super.sendRequest(AC_ELEMENT_STATS_PER_AC_ENDPOINT + "?name=dummyName&version=1.001"); + Response response1 = invokeRequest1.buildGet().invoke(); + assertEquals(Response.Status.OK.getStatusCode(), response1.getStatus()); + AcElementStatisticsList result1 = response1.readEntity(AcElementStatisticsList.class); + assertThat(result1.getAcElementStatistics()).isEmpty(); + } + + @Test + void testAcElementStatsPerAc_BadRequest() throws Exception { + Invocation.Builder invokeRequest1 = super.sendRequest(AC_ELEMENT_STATS_PER_AC_ENDPOINT); + Response response1 = invokeRequest1.buildGet().invoke(); + assertEquals(Response.Status.INTERNAL_SERVER_ERROR.getStatusCode(), response1.getStatus()); + } +} diff --git a/runtime-acm/src/test/java/org/onap/policy/clamp/acm/runtime/supervision/HandleCounterTest.java b/runtime-acm/src/test/java/org/onap/policy/clamp/acm/runtime/supervision/HandleCounterTest.java new file mode 100644 index 000000000..a6474c9e3 --- /dev/null +++ b/runtime-acm/src/test/java/org/onap/policy/clamp/acm/runtime/supervision/HandleCounterTest.java @@ -0,0 +1,84 @@ +/*- + * ============LICENSE_START======================================================= + * Copyright (C) 2021 Nordix Foundation. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * SPDX-License-Identifier: Apache-2.0 + * ============LICENSE_END========================================================= + */ + +package org.onap.policy.clamp.acm.runtime.supervision; + +import static org.assertj.core.api.Assertions.assertThat; + +import org.junit.jupiter.api.Test; + +class HandleCounterTest { + + private static final int ID = 1; + + @Test + void testCount() { + var handleCounter = new HandleCounter(); + handleCounter.setMaxRetryCount(2); + assertThat(handleCounter.count(ID)).isTrue(); + assertThat(handleCounter.getCounter(ID)).isEqualTo(1); + assertThat(handleCounter.count(ID)).isTrue(); + assertThat(handleCounter.getCounter(ID)).isEqualTo(2); + assertThat(handleCounter.count(ID)).isFalse(); + assertThat(handleCounter.getCounter(ID)).isEqualTo(2); + + handleCounter.clear(ID); + assertThat(handleCounter.count(ID)).isTrue(); + assertThat(handleCounter.getCounter(ID)).isEqualTo(1); + } + + @Test + void testFault() { + var handleCounter = new HandleCounter(); + handleCounter.setFault(ID); + assertThat(handleCounter.isFault(ID)).isTrue(); + handleCounter.clear(ID); + assertThat(handleCounter.isFault(ID)).isFalse(); + } + + @Test + void testDuration() throws InterruptedException { + + var handleCounter = new HandleCounter() { + long epochMilli = 0; + + @Override + protected long getEpochMilli() { + return epochMilli; + } + }; + handleCounter.epochMilli = 100; + var result = handleCounter.getDuration(ID); + assertThat(result).isZero(); + + handleCounter.epochMilli += 100; + result = handleCounter.getDuration(ID); + assertThat(result).isEqualTo(100); + + handleCounter.epochMilli += 100; + result = handleCounter.getDuration(ID); + assertThat(result).isEqualTo(200); + + handleCounter.epochMilli += 100; + handleCounter.clear(ID); + result = handleCounter.getDuration(ID); + assertThat(result).isZero(); + } +} diff --git a/runtime-acm/src/test/java/org/onap/policy/clamp/acm/runtime/supervision/SupervisionAspectTest.java b/runtime-acm/src/test/java/org/onap/policy/clamp/acm/runtime/supervision/SupervisionAspectTest.java new file mode 100644 index 000000000..487d41139 --- /dev/null +++ b/runtime-acm/src/test/java/org/onap/policy/clamp/acm/runtime/supervision/SupervisionAspectTest.java @@ -0,0 +1,66 @@ +/*- + * ============LICENSE_START======================================================= + * Copyright (C) 2021 Nordix Foundation. + * Modifications Copyright (C) 2021 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * SPDX-License-Identifier: Apache-2.0 + * ============LICENSE_END========================================================= + */ + +package org.onap.policy.clamp.acm.runtime.supervision; + +import static org.mockito.Mockito.mock; +import static org.mockito.Mockito.spy; +import static org.mockito.Mockito.timeout; +import static org.mockito.Mockito.verify; + +import org.junit.jupiter.api.Test; +import org.onap.policy.clamp.models.acm.messages.dmaap.participant.ParticipantStatus; +import org.onap.policy.models.tosca.authorative.concepts.ToscaConceptIdentifier; + +class SupervisionAspectTest { + + @Test + void testSchedule() throws Exception { + var supervisionScanner = spy(mock(SupervisionScanner.class)); + try (var supervisionAspect = new SupervisionAspect(supervisionScanner)) { + supervisionAspect.schedule(); + verify(supervisionScanner, timeout(500)).run(true); + } + } + + @Test + void testDoCheck() throws Exception { + var supervisionScanner = spy(mock(SupervisionScanner.class)); + try (var supervisionAspect = new SupervisionAspect(supervisionScanner)) { + supervisionAspect.doCheck(); + supervisionAspect.doCheck(); + verify(supervisionScanner, timeout(500).times(2)).run(false); + } + } + + @Test + void testHandleParticipantStatus() throws Exception { + var supervisionScanner = spy(mock(SupervisionScanner.class)); + var participantStatusMessage = new ParticipantStatus(); + var identifier = new ToscaConceptIdentifier("abc", "1.0.0"); + participantStatusMessage.setParticipantId(identifier); + + try (var supervisionAspect = new SupervisionAspect(supervisionScanner)) { + supervisionAspect.handleParticipantStatus(participantStatusMessage); + verify(supervisionScanner, timeout(500)).handleParticipantStatus(identifier); + } + } +} diff --git a/runtime-acm/src/test/java/org/onap/policy/clamp/acm/runtime/supervision/SupervisionHandlerTest.java b/runtime-acm/src/test/java/org/onap/policy/clamp/acm/runtime/supervision/SupervisionHandlerTest.java new file mode 100644 index 000000000..99e509c0e --- /dev/null +++ b/runtime-acm/src/test/java/org/onap/policy/clamp/acm/runtime/supervision/SupervisionHandlerTest.java @@ -0,0 +1,319 @@ +/*- + * ============LICENSE_START======================================================= + * Copyright (C) 2021 Nordix Foundation. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * SPDX-License-Identifier: Apache-2.0 + * ============LICENSE_END========================================================= + */ + +package org.onap.policy.clamp.acm.runtime.supervision; + +import static org.assertj.core.api.Assertions.assertThatThrownBy; +import static org.mockito.ArgumentMatchers.any; +import static org.mockito.ArgumentMatchers.anyList; +import static org.mockito.Mockito.mock; +import static org.mockito.Mockito.verify; +import static org.mockito.Mockito.when; + +import java.util.List; +import java.util.Map; +import java.util.Optional; +import java.util.UUID; +import org.junit.jupiter.api.Test; +import org.mockito.Mockito; +import org.onap.policy.clamp.acm.runtime.instantiation.InstantiationUtils; +import org.onap.policy.clamp.acm.runtime.monitoring.MonitoringProvider; +import org.onap.policy.clamp.acm.runtime.supervision.comm.AutomationCompositionStateChangePublisher; +import org.onap.policy.clamp.acm.runtime.supervision.comm.AutomationCompositionUpdatePublisher; +import org.onap.policy.clamp.acm.runtime.supervision.comm.ParticipantDeregisterAckPublisher; +import org.onap.policy.clamp.acm.runtime.supervision.comm.ParticipantRegisterAckPublisher; +import org.onap.policy.clamp.acm.runtime.supervision.comm.ParticipantUpdatePublisher; +import org.onap.policy.clamp.common.acm.exception.AutomationCompositionException; +import org.onap.policy.clamp.models.acm.concepts.AutomationComposition; +import org.onap.policy.clamp.models.acm.concepts.AutomationCompositionOrderedState; +import org.onap.policy.clamp.models.acm.concepts.Participant; +import org.onap.policy.clamp.models.acm.concepts.ParticipantHealthStatus; +import org.onap.policy.clamp.models.acm.concepts.ParticipantState; +import org.onap.policy.clamp.models.acm.concepts.ParticipantStatistics; +import org.onap.policy.clamp.models.acm.messages.dmaap.participant.AutomationCompositionAck; +import org.onap.policy.clamp.models.acm.messages.dmaap.participant.ParticipantDeregister; +import org.onap.policy.clamp.models.acm.messages.dmaap.participant.ParticipantMessageType; +import org.onap.policy.clamp.models.acm.messages.dmaap.participant.ParticipantRegister; +import org.onap.policy.clamp.models.acm.messages.dmaap.participant.ParticipantStatus; +import org.onap.policy.clamp.models.acm.messages.dmaap.participant.ParticipantUpdateAck; +import org.onap.policy.clamp.models.acm.persistence.provider.AutomationCompositionProvider; +import org.onap.policy.clamp.models.acm.persistence.provider.ParticipantProvider; +import org.onap.policy.clamp.models.acm.persistence.provider.ServiceTemplateProvider; +import org.onap.policy.common.utils.coder.CoderException; +import org.onap.policy.models.base.PfModelException; +import org.onap.policy.models.tosca.authorative.concepts.ToscaConceptIdentifier; + +class SupervisionHandlerTest { + private static final String TOSCA_TEMPLATE_YAML = + "src/test/resources/rest/servicetemplates/tosca-for-smoke-testing.yaml"; + private static final String AC_INSTANTIATION_CREATE_JSON = + "src/test/resources/rest/acm/AutomationCompositions.json"; + private static final ToscaConceptIdentifier identifier = new ToscaConceptIdentifier("PMSHInstance0Crud", "1.0.1"); + private static final ToscaConceptIdentifier participantId = new ToscaConceptIdentifier("ParticipantId", "1.0.0"); + private static final ToscaConceptIdentifier participantType = + new ToscaConceptIdentifier("ParticipantType", "1.0.0"); + + @Test + void testTriggerAutomationCompositionSupervisionEmpty() + throws AutomationCompositionException, PfModelException, CoderException { + var handler = + createSupervisionHandler(mock(AutomationCompositionProvider.class), mock(ParticipantProvider.class), + mock(MonitoringProvider.class), mock(ParticipantRegisterAckPublisher.class), + mock(ParticipantDeregisterAckPublisher.class), mock(AutomationCompositionUpdatePublisher.class), + mock(ParticipantUpdatePublisher.class), AutomationCompositionOrderedState.PASSIVE); + + assertThatThrownBy(() -> handler.triggerAutomationCompositionSupervision(List.of())) + .hasMessageMatching("The list of automation compositions for supervision is empty"); + } + + @Test + void testTriggerAutomationCompositionSupervision() + throws AutomationCompositionException, PfModelException, CoderException { + var automationCompositionProvider = mock(AutomationCompositionProvider.class); + var automationCompositionUpdatePublisher = mock(AutomationCompositionUpdatePublisher.class); + var handler = createSupervisionHandler(automationCompositionProvider, mock(ParticipantProvider.class), + mock(MonitoringProvider.class), mock(ParticipantRegisterAckPublisher.class), + mock(ParticipantDeregisterAckPublisher.class), automationCompositionUpdatePublisher, + mock(ParticipantUpdatePublisher.class), AutomationCompositionOrderedState.PASSIVE); + + handler.triggerAutomationCompositionSupervision(List.of(identifier)); + + verify(automationCompositionUpdatePublisher).send(any(AutomationComposition.class)); + verify(automationCompositionProvider).saveAutomationComposition(any(AutomationComposition.class)); + } + + @Test + void testTriggerAutomationCompositionUninitialised() + throws AutomationCompositionException, PfModelException, CoderException { + var automationCompositionProvider = mock(AutomationCompositionProvider.class); + var automationCompositionUpdatePublisher = mock(AutomationCompositionUpdatePublisher.class); + var handler = createSupervisionHandler(automationCompositionProvider, mock(ParticipantProvider.class), + mock(MonitoringProvider.class), mock(ParticipantRegisterAckPublisher.class), + mock(ParticipantDeregisterAckPublisher.class), automationCompositionUpdatePublisher, + mock(ParticipantUpdatePublisher.class), AutomationCompositionOrderedState.UNINITIALISED); + + assertThatThrownBy(() -> handler.triggerAutomationCompositionSupervision(List.of(identifier))) + .hasMessageMatching("Automation composition is already in state UNINITIALISED"); + } + + @Test + void testTriggerAutomationCompositionRunning() + throws AutomationCompositionException, PfModelException, CoderException { + var automationCompositionProvider = mock(AutomationCompositionProvider.class); + var automationCompositionUpdatePublisher = mock(AutomationCompositionUpdatePublisher.class); + var handler = createSupervisionHandler(automationCompositionProvider, mock(ParticipantProvider.class), + mock(MonitoringProvider.class), mock(ParticipantRegisterAckPublisher.class), + mock(ParticipantDeregisterAckPublisher.class), automationCompositionUpdatePublisher, + mock(ParticipantUpdatePublisher.class), AutomationCompositionOrderedState.RUNNING); + + assertThatThrownBy(() -> handler.triggerAutomationCompositionSupervision(List.of(identifier))) + .hasMessageMatching("Automation composition can't transition from state UNINITIALISED to state RUNNING"); + } + + @Test + void testHandleAutomationCompositionStateChangeAckMessage() throws PfModelException, CoderException { + var automationCompositionProvider = mock(AutomationCompositionProvider.class); + var handler = createSupervisionHandler(automationCompositionProvider, mock(ParticipantProvider.class), + mock(MonitoringProvider.class), mock(ParticipantRegisterAckPublisher.class), + mock(ParticipantDeregisterAckPublisher.class), mock(AutomationCompositionUpdatePublisher.class), + mock(ParticipantUpdatePublisher.class), AutomationCompositionOrderedState.PASSIVE); + var automationCompositionAckMessage = + new AutomationCompositionAck(ParticipantMessageType.AUTOMATION_COMPOSITION_STATECHANGE_ACK); + automationCompositionAckMessage.setAutomationCompositionResultMap(Map.of()); + automationCompositionAckMessage.setAutomationCompositionId(identifier); + + handler.handleAutomationCompositionStateChangeAckMessage(automationCompositionAckMessage); + + verify(automationCompositionProvider).saveAutomationComposition(any(AutomationComposition.class)); + } + + @Test + void testHandleAutomationCompositionUpdateAckMessage() throws PfModelException, CoderException { + var automationCompositionAckMessage = + new AutomationCompositionAck(ParticipantMessageType.AUTOMATION_COMPOSITION_UPDATE_ACK); + automationCompositionAckMessage.setParticipantId(participantId); + automationCompositionAckMessage.setParticipantType(participantType); + automationCompositionAckMessage.setAutomationCompositionResultMap(Map.of()); + automationCompositionAckMessage.setAutomationCompositionId(identifier); + var automationCompositionProvider = mock(AutomationCompositionProvider.class); + var handler = createSupervisionHandler(automationCompositionProvider, mock(ParticipantProvider.class), + mock(MonitoringProvider.class), mock(ParticipantRegisterAckPublisher.class), + mock(ParticipantDeregisterAckPublisher.class), mock(AutomationCompositionUpdatePublisher.class), + mock(ParticipantUpdatePublisher.class), AutomationCompositionOrderedState.PASSIVE); + + handler.handleAutomationCompositionUpdateAckMessage(automationCompositionAckMessage); + + verify(automationCompositionProvider).saveAutomationComposition(any(AutomationComposition.class)); + } + + @Test + void testHandleParticipantDeregister() throws PfModelException, CoderException { + var participant = new Participant(); + participant.setName(participantId.getName()); + participant.setVersion(participantId.getVersion()); + participant.setParticipantType(participantType); + + var participantProvider = mock(ParticipantProvider.class); + when(participantProvider.findParticipant(participantId.getName(), participantId.getVersion())) + .thenReturn(Optional.of(participant)); + + var participantDeregisterMessage = new ParticipantDeregister(); + participantDeregisterMessage.setMessageId(UUID.randomUUID()); + participantDeregisterMessage.setParticipantId(participantId); + participantDeregisterMessage.setParticipantType(participantType); + var participantDeregisterAckPublisher = mock(ParticipantDeregisterAckPublisher.class); + var handler = createSupervisionHandler(mock(AutomationCompositionProvider.class), participantProvider, + mock(MonitoringProvider.class), mock(ParticipantRegisterAckPublisher.class), + participantDeregisterAckPublisher, mock(AutomationCompositionUpdatePublisher.class), + mock(ParticipantUpdatePublisher.class), AutomationCompositionOrderedState.PASSIVE); + + handler.handleParticipantMessage(participantDeregisterMessage); + + verify(participantProvider).saveParticipant(any()); + verify(participantDeregisterAckPublisher).send(participantDeregisterMessage.getMessageId()); + } + + @Test + void testHandleParticipantRegister() throws PfModelException, CoderException { + var participant = new Participant(); + participant.setName(participantId.getName()); + participant.setVersion(participantId.getVersion()); + participant.setParticipantType(participantType); + + var participantRegisterMessage = new ParticipantRegister(); + participantRegisterMessage.setMessageId(UUID.randomUUID()); + participantRegisterMessage.setParticipantId(participantId); + participantRegisterMessage.setParticipantType(participantType); + var participantProvider = mock(ParticipantProvider.class); + var participantRegisterAckPublisher = mock(ParticipantRegisterAckPublisher.class); + var handler = createSupervisionHandler(mock(AutomationCompositionProvider.class), participantProvider, + mock(MonitoringProvider.class), participantRegisterAckPublisher, + mock(ParticipantDeregisterAckPublisher.class), mock(AutomationCompositionUpdatePublisher.class), + mock(ParticipantUpdatePublisher.class), AutomationCompositionOrderedState.PASSIVE); + + handler.handleParticipantMessage(participantRegisterMessage); + + verify(participantProvider).saveParticipant(any()); + verify(participantRegisterAckPublisher).send(participantRegisterMessage.getMessageId(), participantId, + participantType); + } + + @Test + void testParticipantUpdateAck() throws PfModelException, CoderException { + var participant = new Participant(); + participant.setName(participantId.getName()); + participant.setVersion(participantId.getVersion()); + participant.setParticipantType(participantType); + + var participantProvider = mock(ParticipantProvider.class); + when(participantProvider.findParticipant(participantId.getName(), participantId.getVersion())) + .thenReturn(Optional.of(participant)); + + var participantUpdateAckMessage = new ParticipantUpdateAck(); + participantUpdateAckMessage.setParticipantId(participantId); + participantUpdateAckMessage.setParticipantType(participantType); + participantUpdateAckMessage.setState(ParticipantState.PASSIVE); + var handler = createSupervisionHandler(mock(AutomationCompositionProvider.class), participantProvider, + mock(MonitoringProvider.class), mock(ParticipantRegisterAckPublisher.class), + mock(ParticipantDeregisterAckPublisher.class), mock(AutomationCompositionUpdatePublisher.class), + mock(ParticipantUpdatePublisher.class), AutomationCompositionOrderedState.PASSIVE); + + handler.handleParticipantMessage(participantUpdateAckMessage); + + verify(participantProvider).saveParticipant(any()); + } + + @Test + void testHandleParticipantStatus() throws PfModelException, CoderException { + var participantStatusMessage = new ParticipantStatus(); + participantStatusMessage.setParticipantId(participantId); + participantStatusMessage.setParticipantType(participantType); + participantStatusMessage.setState(ParticipantState.PASSIVE); + participantStatusMessage.setHealthStatus(ParticipantHealthStatus.HEALTHY); + participantStatusMessage.setParticipantStatistics(new ParticipantStatistics()); + + var participantProvider = mock(ParticipantProvider.class); + var monitoringProvider = mock(MonitoringProvider.class); + var handler = createSupervisionHandler(mock(AutomationCompositionProvider.class), participantProvider, + monitoringProvider, mock(ParticipantRegisterAckPublisher.class), + mock(ParticipantDeregisterAckPublisher.class), mock(AutomationCompositionUpdatePublisher.class), + mock(ParticipantUpdatePublisher.class), AutomationCompositionOrderedState.PASSIVE); + handler.handleParticipantMessage(participantStatusMessage); + + verify(participantProvider).saveParticipant(any()); + verify(monitoringProvider).createParticipantStatistics(anyList()); + } + + @Test + void testHandleSendCommissionMessage() throws PfModelException, CoderException { + var participantUpdatePublisher = mock(ParticipantUpdatePublisher.class); + var handler = + createSupervisionHandler(mock(AutomationCompositionProvider.class), mock(ParticipantProvider.class), + mock(MonitoringProvider.class), mock(ParticipantRegisterAckPublisher.class), + mock(ParticipantDeregisterAckPublisher.class), mock(AutomationCompositionUpdatePublisher.class), + participantUpdatePublisher, AutomationCompositionOrderedState.PASSIVE); + handler.handleSendCommissionMessage(participantId.getName(), participantId.getVersion()); + + verify(participantUpdatePublisher).sendComissioningBroadcast(participantId.getName(), + participantId.getVersion()); + } + + @Test + void testHandleSendDeCommissionMessage() throws PfModelException, CoderException { + var participantUpdatePublisher = mock(ParticipantUpdatePublisher.class); + var handler = + createSupervisionHandler(mock(AutomationCompositionProvider.class), mock(ParticipantProvider.class), + mock(MonitoringProvider.class), mock(ParticipantRegisterAckPublisher.class), + mock(ParticipantDeregisterAckPublisher.class), mock(AutomationCompositionUpdatePublisher.class), + participantUpdatePublisher, AutomationCompositionOrderedState.PASSIVE); + handler.handleSendDeCommissionMessage(); + + verify(participantUpdatePublisher).sendDecomisioning(); + } + + private SupervisionHandler createSupervisionHandler(AutomationCompositionProvider automationCompositionProvider, + ParticipantProvider participantProvider, MonitoringProvider monitoringProvider, + ParticipantRegisterAckPublisher participantRegisterAckPublisher, + ParticipantDeregisterAckPublisher participantDeregisterAckPublisher, + AutomationCompositionUpdatePublisher automationCompositionUpdatePublisher, + ParticipantUpdatePublisher participantUpdatePublisher, AutomationCompositionOrderedState orderedState) + throws PfModelException, CoderException { + var automationCompositionsCreate = + InstantiationUtils.getAutomationCompositionsFromResource(AC_INSTANTIATION_CREATE_JSON, "Crud"); + + var automationComposition = automationCompositionsCreate.getAutomationCompositionList().get(0); + automationComposition.setOrderedState(orderedState); + + when(automationCompositionProvider.findAutomationComposition(identifier)) + .thenReturn(Optional.of(automationComposition)); + when(automationCompositionProvider.getAutomationComposition(identifier)).thenReturn(automationComposition); + + var serviceTemplateProvider = Mockito.mock(ServiceTemplateProvider.class); + when(serviceTemplateProvider.getServiceTemplateList(any(), any())) + .thenReturn(List.of(InstantiationUtils.getToscaServiceTemplate(TOSCA_TEMPLATE_YAML))); + + var automationCompositionStateChangePublisher = mock(AutomationCompositionStateChangePublisher.class); + + return new SupervisionHandler(automationCompositionProvider, participantProvider, monitoringProvider, + serviceTemplateProvider, automationCompositionUpdatePublisher, automationCompositionStateChangePublisher, + participantRegisterAckPublisher, participantDeregisterAckPublisher, participantUpdatePublisher); + + } +} diff --git a/runtime-acm/src/test/java/org/onap/policy/clamp/acm/runtime/supervision/SupervisionScannerTest.java b/runtime-acm/src/test/java/org/onap/policy/clamp/acm/runtime/supervision/SupervisionScannerTest.java new file mode 100644 index 000000000..cd1a49b46 --- /dev/null +++ b/runtime-acm/src/test/java/org/onap/policy/clamp/acm/runtime/supervision/SupervisionScannerTest.java @@ -0,0 +1,214 @@ +/*- + * ============LICENSE_START======================================================= + * Copyright (C) 2021 Nordix Foundation. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * SPDX-License-Identifier: Apache-2.0 + * ============LICENSE_END========================================================= + */ + +package org.onap.policy.clamp.acm.runtime.supervision; + +import static org.mockito.ArgumentMatchers.any; +import static org.mockito.ArgumentMatchers.anyInt; +import static org.mockito.Mockito.mock; +import static org.mockito.Mockito.times; +import static org.mockito.Mockito.verify; +import static org.mockito.Mockito.when; + +import java.util.List; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.Test; +import org.onap.policy.clamp.acm.runtime.instantiation.InstantiationUtils; +import org.onap.policy.clamp.acm.runtime.supervision.comm.AutomationCompositionStateChangePublisher; +import org.onap.policy.clamp.acm.runtime.supervision.comm.AutomationCompositionUpdatePublisher; +import org.onap.policy.clamp.acm.runtime.supervision.comm.ParticipantStatusReqPublisher; +import org.onap.policy.clamp.acm.runtime.supervision.comm.ParticipantUpdatePublisher; +import org.onap.policy.clamp.acm.runtime.util.CommonTestData; +import org.onap.policy.clamp.models.acm.concepts.AutomationComposition; +import org.onap.policy.clamp.models.acm.concepts.AutomationCompositionOrderedState; +import org.onap.policy.clamp.models.acm.concepts.AutomationCompositionState; +import org.onap.policy.clamp.models.acm.concepts.Participant; +import org.onap.policy.clamp.models.acm.concepts.ParticipantHealthStatus; +import org.onap.policy.clamp.models.acm.concepts.ParticipantState; +import org.onap.policy.clamp.models.acm.persistence.provider.AutomationCompositionProvider; +import org.onap.policy.clamp.models.acm.persistence.provider.ParticipantProvider; +import org.onap.policy.clamp.models.acm.persistence.provider.ServiceTemplateProvider; +import org.onap.policy.common.utils.coder.CoderException; +import org.onap.policy.models.base.PfModelException; +import org.onap.policy.models.tosca.authorative.concepts.ToscaConceptIdentifier; +import org.onap.policy.models.tosca.authorative.concepts.ToscaServiceTemplate; + +class SupervisionScannerTest { + + private static final String TOSCA_SERVICE_TEMPLATE_YAML = + "src/test/resources/rest/servicetemplates/tosca-for-smoke-testing.yaml"; + private static final String AC_JSON = "src/test/resources/rest/acm/AutomationCompositionsSmoke.json"; + + private static ServiceTemplateProvider serviceTemplateProvider = mock(ServiceTemplateProvider.class); + + @BeforeAll + public static void setUpBeforeAll() throws Exception { + ToscaServiceTemplate serviceTemplate = InstantiationUtils.getToscaServiceTemplate(TOSCA_SERVICE_TEMPLATE_YAML); + when(serviceTemplateProvider.getAllServiceTemplates()).thenReturn(List.of(serviceTemplate)); + } + + @Test + void testScannerOrderedStateEqualsToState() throws PfModelException, CoderException { + var automationCompositionProvider = mock(AutomationCompositionProvider.class); + var automationCompositionStateChangePublisher = mock(AutomationCompositionStateChangePublisher.class); + var automationCompositionUpdatePublisher = mock(AutomationCompositionUpdatePublisher.class); + var participantProvider = mock(ParticipantProvider.class); + var participantStatusReqPublisher = mock(ParticipantStatusReqPublisher.class); + var participantUpdatePublisher = mock(ParticipantUpdatePublisher.class); + var acRuntimeParameterGroup = CommonTestData.geParameterGroup("dbScanner"); + + var automationCompositions = + InstantiationUtils.getAutomationCompositionsFromResource(AC_JSON, "Crud").getAutomationCompositionList(); + when(automationCompositionProvider.getAutomationCompositions()).thenReturn(automationCompositions); + + var supervisionScanner = new SupervisionScanner(automationCompositionProvider, serviceTemplateProvider, + automationCompositionStateChangePublisher, automationCompositionUpdatePublisher, participantProvider, + participantStatusReqPublisher, participantUpdatePublisher, acRuntimeParameterGroup); + supervisionScanner.run(false); + + verify(automationCompositionProvider, times(0)).saveAutomationComposition(any(AutomationComposition.class)); + } + + @Test + void testScannerOrderedStateDifferentToState() throws PfModelException, CoderException { + var automationCompositions = + InstantiationUtils.getAutomationCompositionsFromResource(AC_JSON, "Crud").getAutomationCompositionList(); + automationCompositions.get(0).setState(AutomationCompositionState.UNINITIALISED2PASSIVE); + automationCompositions.get(0).setOrderedState(AutomationCompositionOrderedState.UNINITIALISED); + var automationCompositionProvider = mock(AutomationCompositionProvider.class); + when(automationCompositionProvider.getAutomationCompositions()).thenReturn(automationCompositions); + + var automationCompositionUpdatePublisher = mock(AutomationCompositionUpdatePublisher.class); + var automationCompositionStateChangePublisher = mock(AutomationCompositionStateChangePublisher.class); + var participantProvider = mock(ParticipantProvider.class); + var participantStatusReqPublisher = mock(ParticipantStatusReqPublisher.class); + var participantUpdatePublisher = mock(ParticipantUpdatePublisher.class); + var acRuntimeParameterGroup = CommonTestData.geParameterGroup("dbScanner"); + + var supervisionScanner = new SupervisionScanner(automationCompositionProvider, serviceTemplateProvider, + automationCompositionStateChangePublisher, automationCompositionUpdatePublisher, participantProvider, + participantStatusReqPublisher, participantUpdatePublisher, acRuntimeParameterGroup); + supervisionScanner.run(false); + + verify(automationCompositionProvider, times(1)).saveAutomationComposition(any(AutomationComposition.class)); + } + + @Test + void testScanner() throws PfModelException { + var automationCompositionProvider = mock(AutomationCompositionProvider.class); + var automationComposition = new AutomationComposition(); + when(automationCompositionProvider.getAutomationCompositions()).thenReturn(List.of(automationComposition)); + + var participantProvider = mock(ParticipantProvider.class); + var participant = new Participant(); + participant.setName("Participant0"); + participant.setVersion("1.0.0"); + when(participantProvider.getParticipants(null, null)).thenReturn(List.of(participant)); + + var automationCompositionUpdatePublisher = mock(AutomationCompositionUpdatePublisher.class); + var participantStatusReqPublisher = mock(ParticipantStatusReqPublisher.class); + var automationCompositionStateChangePublisher = mock(AutomationCompositionStateChangePublisher.class); + var participantUpdatePublisher = mock(ParticipantUpdatePublisher.class); + var acRuntimeParameterGroup = CommonTestData.geParameterGroup("dbScanner"); + + var supervisionScanner = new SupervisionScanner(automationCompositionProvider, serviceTemplateProvider, + automationCompositionStateChangePublisher, automationCompositionUpdatePublisher, participantProvider, + participantStatusReqPublisher, participantUpdatePublisher, acRuntimeParameterGroup); + + supervisionScanner.handleParticipantStatus(participant.getKey().asIdentifier()); + supervisionScanner.run(true); + verify(automationCompositionProvider, times(0)).saveAutomationComposition(any(AutomationComposition.class)); + verify(participantStatusReqPublisher, times(0)).send(any(ToscaConceptIdentifier.class)); + } + + @Test + void testSendAutomationCompositionMsgUpdate() throws PfModelException, CoderException { + var automationCompositions = + InstantiationUtils.getAutomationCompositionsFromResource(AC_JSON, "Crud").getAutomationCompositionList(); + automationCompositions.get(0).setState(AutomationCompositionState.UNINITIALISED2PASSIVE); + automationCompositions.get(0).setOrderedState(AutomationCompositionOrderedState.PASSIVE); + for (var element : automationCompositions.get(0).getElements().values()) { + if ("org.onap.domain.database.Http_PMSHMicroserviceAutomationCompositionElement" + .equals(element.getDefinition().getName())) { + element.setOrderedState(AutomationCompositionOrderedState.PASSIVE); + element.setState(AutomationCompositionState.UNINITIALISED); + } else { + element.setOrderedState(AutomationCompositionOrderedState.PASSIVE); + element.setState(AutomationCompositionState.PASSIVE); + } + } + + var automationCompositionProvider = mock(AutomationCompositionProvider.class); + when(automationCompositionProvider.getAutomationCompositions()).thenReturn(automationCompositions); + + var participantProvider = mock(ParticipantProvider.class); + var automationCompositionUpdatePublisher = mock(AutomationCompositionUpdatePublisher.class); + var participantStatusReqPublisher = mock(ParticipantStatusReqPublisher.class); + var automationCompositionStateChangePublisher = mock(AutomationCompositionStateChangePublisher.class); + var participantUpdatePublisher = mock(ParticipantUpdatePublisher.class); + var acRuntimeParameterGroup = CommonTestData.geParameterGroup("dbScanner"); + + var supervisionScanner = new SupervisionScanner(automationCompositionProvider, serviceTemplateProvider, + automationCompositionStateChangePublisher, automationCompositionUpdatePublisher, participantProvider, + participantStatusReqPublisher, participantUpdatePublisher, acRuntimeParameterGroup); + + supervisionScanner.run(false); + + verify(automationCompositionUpdatePublisher).send(any(AutomationComposition.class), anyInt()); + } + + @Test + void testScanParticipant() throws PfModelException { + var automationCompositionProvider = mock(AutomationCompositionProvider.class); + var automationComposition = new AutomationComposition(); + when(automationCompositionProvider.getAutomationCompositions()).thenReturn(List.of(automationComposition)); + + var acRuntimeParameterGroup = CommonTestData.geParameterGroup("dbScanParticipant"); + acRuntimeParameterGroup.getParticipantParameters().getUpdateParameters().setMaxWaitMs(-1); + acRuntimeParameterGroup.getParticipantParameters().setMaxStatusWaitMs(-1); + + var participant = new Participant(); + participant.setName("Participant0"); + participant.setVersion("1.0.0"); + participant.setHealthStatus(ParticipantHealthStatus.HEALTHY); + participant.setParticipantState(ParticipantState.ACTIVE); + participant.setDefinition(new ToscaConceptIdentifier("unknown", "0.0.0")); + participant.setParticipantType(new ToscaConceptIdentifier("ParticipantType1", "1.0.0")); + var participantProvider = mock(ParticipantProvider.class); + when(participantProvider.getParticipants()).thenReturn(List.of(participant)); + + var automationCompositionUpdatePublisher = mock(AutomationCompositionUpdatePublisher.class); + var participantStatusReqPublisher = mock(ParticipantStatusReqPublisher.class); + var automationCompositionStateChangePublisher = mock(AutomationCompositionStateChangePublisher.class); + var participantUpdatePublisher = mock(ParticipantUpdatePublisher.class); + + var supervisionScanner = new SupervisionScanner(automationCompositionProvider, serviceTemplateProvider, + automationCompositionStateChangePublisher, automationCompositionUpdatePublisher, participantProvider, + participantStatusReqPublisher, participantUpdatePublisher, acRuntimeParameterGroup); + + supervisionScanner.handleParticipantStatus(participant.getKey().asIdentifier()); + supervisionScanner.run(true); + verify(participantStatusReqPublisher).send(any(ToscaConceptIdentifier.class)); + verify(participantProvider).saveParticipant(any()); + + supervisionScanner.run(true); + verify(participantProvider, times(2)).saveParticipant(any()); + } +} diff --git a/runtime-acm/src/test/java/org/onap/policy/clamp/acm/runtime/supervision/comm/SupervisionMessagesTest.java b/runtime-acm/src/test/java/org/onap/policy/clamp/acm/runtime/supervision/comm/SupervisionMessagesTest.java new file mode 100644 index 000000000..6545fe395 --- /dev/null +++ b/runtime-acm/src/test/java/org/onap/policy/clamp/acm/runtime/supervision/comm/SupervisionMessagesTest.java @@ -0,0 +1,225 @@ +/*- + * ============LICENSE_START======================================================= + * Copyright (C) 2021 Nordix Foundation. + * Modifications Copyright (C) 2021 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * SPDX-License-Identifier: Apache-2.0 + * ============LICENSE_END========================================================= + */ + +package org.onap.policy.clamp.acm.runtime.supervision.comm; + +import static org.assertj.core.api.Assertions.assertThatCode; +import static org.assertj.core.api.Assertions.assertThatThrownBy; +import static org.mockito.ArgumentMatchers.anyString; +import static org.mockito.Mockito.mock; +import static org.mockito.Mockito.times; +import static org.mockito.Mockito.verify; + +import java.time.Instant; +import java.util.Collections; +import java.util.List; +import java.util.UUID; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.Test; +import org.mockito.Mockito; +import org.onap.policy.clamp.acm.runtime.monitoring.MonitoringProvider; +import org.onap.policy.clamp.acm.runtime.supervision.SupervisionHandler; +import org.onap.policy.clamp.acm.runtime.util.rest.CommonRestController; +import org.onap.policy.clamp.models.acm.concepts.AutomationComposition; +import org.onap.policy.clamp.models.acm.concepts.AutomationCompositionState; +import org.onap.policy.clamp.models.acm.messages.dmaap.participant.ParticipantDeregister; +import org.onap.policy.clamp.models.acm.messages.dmaap.participant.ParticipantDeregisterAck; +import org.onap.policy.clamp.models.acm.messages.dmaap.participant.ParticipantRegisterAck; +import org.onap.policy.clamp.models.acm.messages.dmaap.participant.ParticipantUpdateAck; +import org.onap.policy.clamp.models.acm.persistence.provider.AcElementStatisticsProvider; +import org.onap.policy.clamp.models.acm.persistence.provider.AutomationCompositionProvider; +import org.onap.policy.clamp.models.acm.persistence.provider.ParticipantProvider; +import org.onap.policy.clamp.models.acm.persistence.provider.ParticipantStatisticsProvider; +import org.onap.policy.clamp.models.acm.persistence.provider.ServiceTemplateProvider; +import org.onap.policy.common.endpoints.event.comm.Topic.CommInfrastructure; +import org.onap.policy.common.endpoints.event.comm.TopicSink; +import org.onap.policy.models.base.PfModelException; +import org.onap.policy.models.tosca.authorative.concepts.ToscaConceptIdentifier; + +class SupervisionMessagesTest extends CommonRestController { + + private static final String NOT_ACTIVE = "Not Active!"; + private static final Object lockit = new Object(); + private static final CommInfrastructure INFRA = CommInfrastructure.NOOP; + private static final String TOPIC = "my-topic"; + private static SupervisionHandler supervisionHandler; + + /** + * setup Db Provider Parameters. + * + * @throws PfModelException if an error occurs + */ + @BeforeAll + public static void setupDbProviderParameters() throws PfModelException { + var acProvider = mock(AutomationCompositionProvider.class); + var participantStatisticsProvider = mock(ParticipantStatisticsProvider.class); + var acElementStatisticsProvider = mock(AcElementStatisticsProvider.class); + var monitoringProvider = + new MonitoringProvider(participantStatisticsProvider, acElementStatisticsProvider, acProvider); + var participantProvider = mock(ParticipantProvider.class); + var serviceTemplateProvider = Mockito.mock(ServiceTemplateProvider.class); + var automationCompositionUpdatePublisher = Mockito.mock(AutomationCompositionUpdatePublisher.class); + var automationCompositionStateChangePublisher = Mockito.mock(AutomationCompositionStateChangePublisher.class); + var participantRegisterAckPublisher = Mockito.mock(ParticipantRegisterAckPublisher.class); + var participantDeregisterAckPublisher = Mockito.mock(ParticipantDeregisterAckPublisher.class); + var participantUpdatePublisher = Mockito.mock(ParticipantUpdatePublisher.class); + supervisionHandler = new SupervisionHandler(acProvider, participantProvider, monitoringProvider, + serviceTemplateProvider, automationCompositionUpdatePublisher, automationCompositionStateChangePublisher, + participantRegisterAckPublisher, participantDeregisterAckPublisher, participantUpdatePublisher); + } + + @Test + void testSendParticipantRegisterAck() throws Exception { + final ParticipantRegisterAck participantRegisterAckMsg = new ParticipantRegisterAck(); + participantRegisterAckMsg.setMessage("ParticipantRegisterAck message"); + participantRegisterAckMsg.setResponseTo(UUID.randomUUID()); + participantRegisterAckMsg.setResult(true); + + synchronized (lockit) { + ParticipantRegisterAckPublisher acRegisterAckPublisher = new ParticipantRegisterAckPublisher(); + acRegisterAckPublisher.active(List.of(Mockito.mock(TopicSink.class))); + assertThatCode(() -> acRegisterAckPublisher.send(participantRegisterAckMsg)).doesNotThrowAnyException(); + } + } + + @Test + void testReceiveParticipantDeregister() throws Exception { + final ParticipantDeregister participantDeregisterMsg = new ParticipantDeregister(); + participantDeregisterMsg.setParticipantId(getParticipantId()); + participantDeregisterMsg.setTimestamp(Instant.now()); + participantDeregisterMsg.setParticipantType(getParticipantType()); + + synchronized (lockit) { + ParticipantDeregisterListener participantDeregisterListener = + new ParticipantDeregisterListener(supervisionHandler); + assertThatCode( + () -> participantDeregisterListener.onTopicEvent(INFRA, TOPIC, null, participantDeregisterMsg)) + .doesNotThrowAnyException(); + } + } + + @Test + void testSendParticipantDeregisterAck() throws Exception { + final ParticipantDeregisterAck participantDeregisterAckMsg = new ParticipantDeregisterAck(); + participantDeregisterAckMsg.setMessage("ParticipantDeregisterAck message"); + participantDeregisterAckMsg.setResponseTo(UUID.randomUUID()); + participantDeregisterAckMsg.setResult(true); + + synchronized (lockit) { + ParticipantDeregisterAckPublisher acDeregisterAckPublisher = new ParticipantDeregisterAckPublisher(); + acDeregisterAckPublisher.active(Collections.singletonList(Mockito.mock(TopicSink.class))); + assertThatCode(() -> acDeregisterAckPublisher.send(participantDeregisterAckMsg)).doesNotThrowAnyException(); + } + } + + @Test + void testReceiveParticipantUpdateAckMessage() throws Exception { + final ParticipantUpdateAck participantUpdateAckMsg = new ParticipantUpdateAck(); + participantUpdateAckMsg.setMessage("ParticipantUpdateAck message"); + participantUpdateAckMsg.setResponseTo(UUID.randomUUID()); + participantUpdateAckMsg.setResult(true); + participantUpdateAckMsg.setParticipantId(getParticipantId()); + participantUpdateAckMsg.setParticipantType(getParticipantType()); + + synchronized (lockit) { + ParticipantUpdateAckListener participantUpdateAckListener = + new ParticipantUpdateAckListener(supervisionHandler); + assertThatCode(() -> participantUpdateAckListener.onTopicEvent(INFRA, TOPIC, null, participantUpdateAckMsg)) + .doesNotThrowAnyException(); + } + } + + @Test + void testSendAutomationCompositionStateChangePublisherNotActive() { + var publisher = new AutomationCompositionStateChangePublisher(); + assertThatThrownBy(() -> publisher.send(getAutomationComposition(), 0)).hasMessage(NOT_ACTIVE); + } + + @Test + void testSendAutomationCompositionStateChangePublisher() { + var publisher = new AutomationCompositionStateChangePublisher(); + var topicSink = mock(TopicSink.class); + publisher.active(List.of(topicSink)); + publisher.send(getAutomationComposition(), 0); + verify(topicSink).send(anyString()); + } + + @Test + void testParticipantUpdatePublisherDecomisioning() { + var publisher = new ParticipantUpdatePublisher(mock(ServiceTemplateProvider.class)); + var topicSink = mock(TopicSink.class); + publisher.active(List.of(topicSink)); + publisher.sendDecomisioning(); + verify(topicSink).send(anyString()); + } + + @Test + void testParticipantUpdatePublisherComissioning() { + var publisher = new ParticipantUpdatePublisher(mock(ServiceTemplateProvider.class)); + var topicSink = mock(TopicSink.class); + publisher.active(List.of(topicSink)); + publisher.sendComissioningBroadcast("NAME", "1.0.0"); + verify(topicSink, times(0)).send(anyString()); + } + + @Test + void testParticipantStatusReqPublisher() { + var publisher = new ParticipantStatusReqPublisher(); + var topicSink = mock(TopicSink.class); + publisher.active(List.of(topicSink)); + publisher.send(getParticipantId()); + verify(topicSink).send(anyString()); + } + + @Test + void testParticipantRegisterAckPublisher() { + var publisher = new ParticipantRegisterAckPublisher(); + var topicSink = mock(TopicSink.class); + publisher.active(List.of(topicSink)); + publisher.send(UUID.randomUUID(), getParticipantId(), getParticipantType()); + verify(topicSink).send(anyString()); + } + + @Test + void testParticipantDeregisterAckPublisher() { + var publisher = new ParticipantDeregisterAckPublisher(); + var topicSink = mock(TopicSink.class); + publisher.active(List.of(topicSink)); + publisher.send(UUID.randomUUID()); + verify(topicSink).send(anyString()); + } + + private AutomationComposition getAutomationComposition() { + var automationComposition = new AutomationComposition(); + automationComposition.setName("NAME"); + automationComposition.setVersion("0.0.1"); + automationComposition.setState(AutomationCompositionState.UNINITIALISED); + return automationComposition; + } + + private ToscaConceptIdentifier getParticipantId() { + return new ToscaConceptIdentifier("org.onap.PM_Policy", "1.0.0"); + } + + private ToscaConceptIdentifier getParticipantType() { + return new ToscaConceptIdentifier("org.onap.policy.acm.PolicyAutomationCompositionParticipant", "2.3.1"); + } +} diff --git a/runtime-acm/src/test/java/org/onap/policy/clamp/acm/runtime/util/CommonTestData.java b/runtime-acm/src/test/java/org/onap/policy/clamp/acm/runtime/util/CommonTestData.java new file mode 100644 index 000000000..33a00c21b --- /dev/null +++ b/runtime-acm/src/test/java/org/onap/policy/clamp/acm/runtime/util/CommonTestData.java @@ -0,0 +1,125 @@ +/*- + * ============LICENSE_START======================================================= + * Copyright (C) 2021 Nordix Foundation. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * SPDX-License-Identifier: Apache-2.0 + * ============LICENSE_END========================================================= + */ + +package org.onap.policy.clamp.acm.runtime.util; + +import java.util.List; +import javax.ws.rs.core.Response.Status; +import org.onap.policy.clamp.acm.runtime.main.parameters.AcRuntimeParameterGroup; +import org.onap.policy.clamp.common.acm.exception.AutomationCompositionRuntimeException; +import org.onap.policy.clamp.models.acm.concepts.Participant; +import org.onap.policy.common.utils.coder.Coder; +import org.onap.policy.common.utils.coder.CoderException; +import org.onap.policy.common.utils.coder.StandardCoder; +import org.onap.policy.common.utils.resources.ResourceUtils; +import org.onap.policy.models.base.PfModelException; +import org.onap.policy.models.base.PfModelRuntimeException; +import org.onap.policy.models.provider.PolicyModelsProvider; +import org.onap.policy.models.provider.PolicyModelsProviderFactory; +import org.onap.policy.models.provider.PolicyModelsProviderParameters; +import org.onap.policy.models.tosca.authorative.concepts.ToscaConceptIdentifier; + +/** + * Class to hold/create all parameters for test cases. + * + */ +public class CommonTestData { + private static final Coder CODER = new StandardCoder(); + + /** + * Gets the standard automation composition parameters. + * + * @param dbName the database name + * @return the standard automation composition parameters + * @throws AutomationCompositionRuntimeException on errors reading the automation composition parameters + */ + public static AcRuntimeParameterGroup geParameterGroup(final String dbName) { + try { + return CODER.convert(getParameterGroupAsString(dbName), AcRuntimeParameterGroup.class); + + } catch (CoderException e) { + throw new AutomationCompositionRuntimeException(Status.NOT_ACCEPTABLE, + "cannot read automation composition parameters", e); + } + } + + /** + * Gets the standard automation composition parameters, as a String. + * + * @param dbName the database name + * @return the standard automation composition parameters as string + */ + public static String getParameterGroupAsString(final String dbName) { + return ResourceUtils.getResourceAsString("src/test/resources/parameters/TestParameters.json") + .replace("${dbName}", "jdbc:h2:mem:" + dbName); + } + + /** + * Create a new PolicyModelsProvider. + * + * @param databaseProviderParameters the database Provider Parameters + * @return a new PolicyModelsProvider + */ + public static PolicyModelsProvider getPolicyModelsProvider( + PolicyModelsProviderParameters databaseProviderParameters) { + try { + return new PolicyModelsProviderFactory().createPolicyModelsProvider(databaseProviderParameters); + } catch (PfModelException e) { + throw new PfModelRuntimeException(e); + } + } + + /** + * Create a List of Participants. + * + * @return a List of Participants + */ + public static List createParticipants() { + var participant1 = createParticipant( + new ToscaConceptIdentifier("org.onap.dcae.acm.DCAEMicroserviceAutomationCompositionParticipant", + "2.3.4"), + new ToscaConceptIdentifier("org.onap.dcae.acm.DCAEMicroserviceAutomationCompositionParticipant", + "2.3.4")); + var participant2 = createParticipant( + new ToscaConceptIdentifier("org.onap.policy.acm.PolicyAutomationCompositionParticipant", "2.3.1"), + new ToscaConceptIdentifier("org.onap.policy.acm.PolicyAutomationCompositionParticipant", "2.3.1")); + var participant3 = createParticipant( + new ToscaConceptIdentifier("org.onap.ccsdk.cds.acm.CdsAutomationCompositionParticipant", "2.2.1"), + new ToscaConceptIdentifier("org.onap.ccsdk.cds.acm.CdsAutomationCompositionParticipant", "2.2.1")); + return List.of(participant1, participant2, participant3); + } + + /** + * Create a new Participant. + * + * @param participantType the participant Type + * @param participantId the participant id + * @return a new Participant + */ + public static Participant createParticipant(ToscaConceptIdentifier participantType, + ToscaConceptIdentifier participantId) { + var participant = new Participant(); + participant.setDefinition(participantId); + participant.setParticipantType(participantType); + participant.setName(participantId.getName()); + participant.setVersion(participantId.getVersion()); + return participant; + } +} diff --git a/runtime-acm/src/test/java/org/onap/policy/clamp/acm/runtime/util/rest/CommonRestController.java b/runtime-acm/src/test/java/org/onap/policy/clamp/acm/runtime/util/rest/CommonRestController.java new file mode 100644 index 000000000..0fc0a6e9f --- /dev/null +++ b/runtime-acm/src/test/java/org/onap/policy/clamp/acm/runtime/util/rest/CommonRestController.java @@ -0,0 +1,201 @@ +/*- + * ============LICENSE_START======================================================= + * Copyright (C) 2021 Nordix Foundation. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * SPDX-License-Identifier: Apache-2.0 + * ============LICENSE_END========================================================= + */ + +package org.onap.policy.clamp.acm.runtime.util.rest; + +import static org.assertj.core.api.Assertions.assertThat; +import static org.junit.Assert.assertEquals; + +import javax.ws.rs.client.Client; +import javax.ws.rs.client.ClientBuilder; +import javax.ws.rs.client.Entity; +import javax.ws.rs.client.Invocation; +import javax.ws.rs.client.WebTarget; +import javax.ws.rs.core.MediaType; +import javax.ws.rs.core.Response; +import org.glassfish.jersey.client.ClientProperties; +import org.glassfish.jersey.client.authentication.HttpAuthenticationFeature; +import org.onap.policy.common.gson.GsonMessageBodyHandler; +import org.onap.policy.common.utils.network.NetworkUtil; + +/** + * Class to perform Rest unit tests. + * + */ +public class CommonRestController { + + public static final String SELF = NetworkUtil.getHostname(); + public static final String CONTEXT_PATH = "onap/automationcomposition"; + public static final String ENDPOINT_PREFIX = CONTEXT_PATH + "/v2/"; + public static final String ACTUATOR_ENDPOINT = CONTEXT_PATH + "/actuator/"; + + private static String httpPrefix; + + /** + * Verifies that an endpoint appears within the swagger response. + * + * @param endpoint the endpoint of interest + * @throws Exception if an error occurs + */ + protected void testSwagger(final String endpoint) throws Exception { + final Invocation.Builder invocationBuilder = sendRequest("api-docs"); + final String resp = invocationBuilder.get(String.class); + + assertThat(resp).contains(endpoint); + } + + /** + * Sends a request to an endpoint. + * + * @param endpoint the target endpoint + * @return a request builder + * @throws Exception if an error occurs + */ + protected Invocation.Builder sendRequest(final String endpoint) throws Exception { + return sendFqeRequest(httpPrefix + ENDPOINT_PREFIX + endpoint, true); + } + + /** + * Sends a request to an actuator endpoint. + * + * @param endpoint the target endpoint + * @return a request builder + * @throws Exception if an error occurs + */ + protected Invocation.Builder sendActRequest(final String endpoint) throws Exception { + return sendFqeRequest(httpPrefix + ACTUATOR_ENDPOINT + endpoint, true); + } + + /** + * Sends a request to an Rest Api endpoint, without any authorization header. + * + * @param endpoint the target endpoint + * @return a request builder + * @throws Exception if an error occurs + */ + protected Invocation.Builder sendNoAuthRequest(final String endpoint) throws Exception { + return sendFqeRequest(httpPrefix + ENDPOINT_PREFIX + endpoint, false); + } + + /** + * Sends a request to an actuator endpoint, without any authorization header. + * + * @param endpoint the target endpoint + * @return a request builder + * @throws Exception if an error occurs + */ + protected Invocation.Builder sendNoAuthActRequest(final String endpoint) throws Exception { + return sendFqeRequest(httpPrefix + ACTUATOR_ENDPOINT + endpoint, false); + } + + /** + * Sends a request to a fully qualified endpoint. + * + * @param fullyQualifiedEndpoint the fully qualified target endpoint + * @param includeAuth if authorization header should be included + * @return a request builder + * @throws Exception if an error occurs + */ + protected Invocation.Builder sendFqeRequest(final String fullyQualifiedEndpoint, boolean includeAuth) + throws Exception { + final Client client = ClientBuilder.newBuilder().build(); + + client.property(ClientProperties.METAINF_SERVICES_LOOKUP_DISABLE, "true"); + client.register(GsonMessageBodyHandler.class); + + if (includeAuth) { + client.register(HttpAuthenticationFeature.basic("runtimeUser", "zb!XztG34")); + } + + final WebTarget webTarget = client.target(fullyQualifiedEndpoint); + + return webTarget.request(MediaType.APPLICATION_JSON, MediaType.TEXT_PLAIN); + } + + /** + * Assert that POST call is Unauthorized. + * + * @param endPoint the endpoint + * @param entity the entity ofthe body + * @throws Exception if an error occurs + */ + protected void assertUnauthorizedPost(final String endPoint, final Entity entity) throws Exception { + Response rawresp = sendNoAuthRequest(endPoint).post(entity); + assertEquals(Response.Status.UNAUTHORIZED.getStatusCode(), rawresp.getStatus()); + } + + /** + * Assert that PUT call is Unauthorized. + * + * @param endPoint the endpoint + * @param entity the entity ofthe body + * @throws Exception if an error occurs + */ + protected void assertUnauthorizedPut(final String endPoint, final Entity entity) throws Exception { + Response rawresp = sendNoAuthRequest(endPoint).put(entity); + assertEquals(Response.Status.UNAUTHORIZED.getStatusCode(), rawresp.getStatus()); + } + + /** + * Assert that GET call is Unauthorized. + * + * @param endPoint the endpoint + * @throws Exception if an error occurs + */ + protected void assertUnauthorizedGet(final String endPoint) throws Exception { + Response rawresp = sendNoAuthRequest(endPoint).buildGet().invoke(); + assertEquals(Response.Status.UNAUTHORIZED.getStatusCode(), rawresp.getStatus()); + } + + /** + * Assert that GET call to actuator endpoint is Unauthorized. + * + * @param endPoint the endpoint + * @throws Exception if an error occurs + */ + protected void assertUnauthorizedActGet(final String endPoint) throws Exception { + Response rawresp = sendNoAuthActRequest(endPoint).buildGet().invoke(); + assertEquals(Response.Status.UNAUTHORIZED.getStatusCode(), rawresp.getStatus()); + } + + /** + * Assert that DELETE call is Unauthorized. + * + * @param endPoint the endpoint + * @throws Exception if an error occurs + */ + protected void assertUnauthorizedDelete(final String endPoint) throws Exception { + Response rawresp = sendNoAuthRequest(endPoint).delete(); + assertEquals(Response.Status.UNAUTHORIZED.getStatusCode(), rawresp.getStatus()); + } + + /** + * Set Up httpPrefix. + * + * @param port the port + */ + protected void setHttpPrefix(int port) { + httpPrefix = "http://" + SELF + ":" + port + "/"; + } + + protected String getHttpPrefix() { + return httpPrefix; + } +} diff --git a/runtime-acm/src/test/resources/application_test.properties b/runtime-acm/src/test/resources/application_test.properties new file mode 100644 index 000000000..a9060e65c --- /dev/null +++ b/runtime-acm/src/test/resources/application_test.properties @@ -0,0 +1,37 @@ +spring.security.user.name=runtimeUser +spring.security.user.password=zb!XztG34 +security.enable-csrf=false + +spring.datasource.url=jdbc:h2:mem:testdb +spring.datasource.driverClassName=org.h2.Driver +spring.datasource.username=policy +spring.datasource.password=P01icY + +spring.datasource.hikari.connectionTimeout=30000 +spring.datasource.hikari.idleTimeout=600000 +spring.datasource.hikari.maxLifetime=1800000 +spring.datasource.hikari.maximumPoolSize=3 + +spring.jpa.hibernate.naming.physical-strategy=org.hibernate.boot.model.naming.PhysicalNamingStrategyStandardImpl +spring.jpa.hibernate.naming.implicit-strategy=org.onap.policy.common.spring.utils.CustomImplicitNamingStrategy +spring.jpa.hibernate.ddl-auto=create +spring.jpa.properties.hibernate.dialect=org.hibernate.dialect.HSQLDialect +spring.jpa.properties.hibernate.format_sql=true + +server.port=6969 +server.servlet.context-path=/onap/automationcomposition +server.error.path=/error + +runtime.participantParameters.heartBeatMs=20000 +runtime.participantParameters.maxStatusWaitMs=100000 +runtime.participantParameters.updateParameters.maxRetryCount=3 +runtime.participantParameters.updateParameters.maxWaitMs=20000 +runtime.topicParameterGroup.topicSources[0].topic=POLICY-ACRUNTIME-PARTICIPANT +runtime.topicParameterGroup.topicSources[0].servers[0]=localhost +runtime.topicParameterGroup.topicSources[0].topicCommInfrastructure=dmaap +runtime.topicParameterGroup.topicSources[0].fetchTimeout=15000 +runtime.topicParameterGroup.topicSinks[0].topic=POLICY-ACRUNTIME-PARTICIPANT +runtime.topicParameterGroup.topicSinks[0].servers[0]=localhost +runtime.topicParameterGroup.topicSinks[0].topicCommInfrastructure=dmaap + +management.endpoints.web.exposure.include=health,metrics,prometheus diff --git a/runtime-acm/src/test/resources/parameters/TestParameters.json b/runtime-acm/src/test/resources/parameters/TestParameters.json new file mode 100644 index 000000000..c44e92e4d --- /dev/null +++ b/runtime-acm/src/test/resources/parameters/TestParameters.json @@ -0,0 +1,44 @@ +{ + "name": "AutomationCompositionRuntimeGroup", + "supervisionScannerIntervalSec": 1000, + "participantAcUpdateIntervalSec": 1000, + "participantAcStateChangeIntervalSec": 1000, + "participantParameters": { + "heartBeatMs": 120000, + "maxStatusWaitMs": 100000, + "updateParameters": { + "maxRetryCount": 1, + "maxWaitMs": 30000 + } + }, + "databaseProviderParameters": { + "name": "PolicyProviderParameterGroup", + "implementation": "org.onap.policy.models.provider.impl.DatabasePolicyModelsProviderImpl", + "databaseDriver": "org.h2.Driver", + "databaseUrl": "${dbName}", + "databaseUser": "policy", + "databasePassword": "P01icY", + "persistenceUnit": "InstantiationTests" + }, + "topicParameterGroup": { + "topicSources": [ + { + "topic": "POLICY-ACRUNTIME-PARTICIPANT", + "servers": [ + "localhost" + ], + "topicCommInfrastructure": "dmaap", + "fetchTimeout": 15000 + } + ], + "topicSinks": [ + { + "topic": "POLICY-ACRUNTIME-PARTICIPANT", + "servers": [ + "localhost" + ], + "topicCommInfrastructure": "dmaap" + } + ] + } +} diff --git a/runtime-acm/src/test/resources/parameters/logback-test.xml b/runtime-acm/src/test/resources/parameters/logback-test.xml new file mode 100644 index 000000000..ad1e35624 --- /dev/null +++ b/runtime-acm/src/test/resources/parameters/logback-test.xml @@ -0,0 +1,42 @@ + + + + + + Apex + + + + + + + %d %contextName [%t] %level %logger{36} - %msg%n + + + + + + + + + + + diff --git a/runtime-acm/src/test/resources/rest/acm/AutomationCompositionElementsNotFound.json b/runtime-acm/src/test/resources/rest/acm/AutomationCompositionElementsNotFound.json new file mode 100644 index 000000000..7e1107c0a --- /dev/null +++ b/runtime-acm/src/test/resources/rest/acm/AutomationCompositionElementsNotFound.json @@ -0,0 +1,142 @@ +{ + "automationCompositionList": [ + { + "name": "PMSHInstance0", + "version": "1.0.1", + "definition": { + "name": "org.onap.domain.pmsh.PMSHAutomationCompositionDefinition", + "version": "1.2.3" + }, + "state": "UNINITIALISED", + "orderedState": "UNINITIALISED", + "description": "PMSH automation composition instance 0", + "elements": { + "709c62b3-8918-41b9-a747-d21eb79c6c20": { + "id": "709c62b3-8918-41b9-a747-d21eb79c6c20", + "definition": { + "name": "org.onap.domain.pmsh.DCAEMicroservice", + "version": "1.2.3" + }, + "participantType": { + "name": "org.onap.dcae.acm.DCAEMicroserviceAutomationCompositionParticipant", + "version": "2.3.4" + }, + "state": "UNINITIALISED", + "orderedState": "UNINITIALISED", + "description": "DCAE Automation Composition Element for the PMSH instance 0 automation composition" + }, + "709c62b3-8918-41b9-a747-d21eb79c6c21": { + "id": "709c62b3-8918-41b9-a747-d21eb79c6c21", + "definition": { + "name": "org.onap.domain.pmsh.PMSH_MonitoringPolicyAutomationCompositionElement", + "version": "1.2.3" + }, + "participantType": { + "name": "org.onap.policy.acm.PolicyAutomationCompositionParticipant", + "version": "2.3.1" + }, + "state": "UNINITIALISED", + "orderedState": "UNINITIALISED", + "description": "Monitoring Policy Automation Composition Element for the PMSH instance 0 automation composition" + }, + "709c62b3-8918-41b9-a747-d21eb79c6c22": { + "id": "709c62b3-8918-41b9-a747-d21eb79c6c22", + "definition": { + "name": "org.onap.domain.pmsh.PMSH_OperationalPolicyAutomationCompositionElement", + "version": "1.2.3" + }, + "participantType": { + "name": "org.onap.policy.acm.PolicyAutomationCompositionParticipant", + "version": "2.3.1" + }, + "state": "UNINITIALISED", + "orderedState": "UNINITIALISED", + "description": "Operational Policy Automation Composition Element for the PMSH instance 0 automation composition" + }, + "709c62b3-8918-41b9-a747-d21eb79c6c23": { + "id": "709c62b3-8918-41b9-a747-d21eb79c6c23", + "definition": { + "name": "org.onap.domain.pmsh.PMSH_CDS_AutomationCompositionElement", + "version": "1.2.3" + }, + "participantType": { + "name": "org.onap.ccsdk.cds.acm.CdsAutomationCompositionParticipant", + "version": "2.2.1" + }, + "state": "UNINITIALISED", + "orderedState": "UNINITIALISED", + "description": "CDS Automation Composition Element for the PMSH instance 0 automation composition" + } + } + }, + { + "name": "PMSHInstance1", + "version": "1.0.1", + "definition": { + "name": "org.onap.domain.pmsh.PMSHAutomationCompositionDefinition", + "version": "1.2.3" + }, + "state": "UNINITIALISED", + "orderedState": "UNINITIALISED", + "description": "PMSH automation composition instance 1", + "elements": { + "709c62b3-8918-41b9-a747-d21eb79c6c24": { + "id": "709c62b3-8918-41b9-a747-e21eb79c6c24", + "definition": { + "name": "org.onap.domain.pmsh.DCAEMicroservice", + "version": "1.2.3" + }, + "participantType": { + "name": "org.onap.dcae.acm.DCAEMicroserviceAutomationCompositionParticipant", + "version": "2.3.4" + }, + "state": "UNINITIALISED", + "orderedState": "UNINITIALISED", + "description": "DCAE Automation Composition Element for the PMSH instance 1 automation composition" + }, + "709c62b3-8918-41b9-a747-d21eb79c6c25": { + "id": "709c62b3-8918-41b9-a747-e21eb79c6c25", + "definition": { + "name": "org.onap.domain.pmsh.PMSH_MonitoringPolicyAutomationCompositionElement", + "version": "1.2.3" + }, + "participantType": { + "name": "org.onap.policy.acm.PolicyAutomationCompositionParticipant", + "version": "2.3.1" + }, + "state": "UNINITIALISED", + "orderedState": "UNINITIALISED", + "description": "Monitoring Policy Automation Composition Element for the PMSH instance 1 automation composition" + }, + "709c62b3-8918-41b9-a747-d21eb79c6c26": { + "id": "709c62b3-8918-41b9-a747-e21eb79c6c26", + "definition": { + "name": "org.onap.domain.pmsh.PMSH_OperationalPolicyAutomationCompositionElement", + "version": "1.2.3" + }, + "participantType": { + "name": "org.onap.policy.acm.PolicyAutomationCompositionParticipant", + "version": "2.3.1" + }, + "state": "UNINITIALISED", + "orderedState": "UNINITIALISED", + "description": "Operational Policy Automation Composition Element for the PMSH instance 1 automation composition" + }, + "709c62b3-8918-41b9-a747-d21eb79c6c27": { + "id": "709c62b3-8918-41b9-a747-e21eb79c6c27", + "definition": { + "name": "org.onap.domain.pmsh.PMSH_CDS_AutomationCompositionElement", + "version": "1.2.3" + }, + "participantType": { + "name": "org.onap.ccsdk.cds.acm.CdsAutomationCompositionParticipant", + "version": "2.2.1" + }, + "state": "UNINITIALISED", + "orderedState": "UNINITIALISED", + "description": "CDS Automation Composition Element for the PMSH instance 1 automation composition" + } + } + } + ] +} diff --git a/runtime-acm/src/test/resources/rest/acm/AutomationCompositionVersionNotMatches.json b/runtime-acm/src/test/resources/rest/acm/AutomationCompositionVersionNotMatches.json new file mode 100644 index 000000000..d29444a09 --- /dev/null +++ b/runtime-acm/src/test/resources/rest/acm/AutomationCompositionVersionNotMatches.json @@ -0,0 +1,142 @@ +{ + "automationCompositionList": [ + { + "name": "PMSHInstance0", + "version": "1.0.1", + "definition": { + "name": "org.onap.domain.pmsh.PMSHAutomationCompositionDefinition", + "version": "1.2.3" + }, + "state": "UNINITIALISED", + "orderedState": "UNINITIALISED", + "description": "PMSH automation composition instance 0", + "elements": { + "709c62b3-8918-41b9-a747-d21eb79c6c20": { + "id": "709c62b3-8918-41b9-a747-d21eb79c6c20", + "definition": { + "name": "org.onap.domain.pmsh.PMSH_DCAEMicroservice", + "version": "1.0.0" + }, + "participantType": { + "name": "org.onap.dcae.acm.DCAEMicroserviceAutomationCompositionParticipant", + "version": "2.3.4" + }, + "state": "UNINITIALISED", + "orderedState": "UNINITIALISED", + "description": "DCAE Automation Composition Element for the PMSH instance 0 automation composition" + }, + "709c62b3-8918-41b9-a747-d21eb79c6c21": { + "id": "709c62b3-8918-41b9-a747-d21eb79c6c21", + "definition": { + "name": "org.onap.domain.pmsh.PMSH_MonitoringPolicyAutomationCompositionElement", + "version": "1.2.3" + }, + "participantType": { + "name": "org.onap.policy.acm.PolicyAutomationCompositionParticipant", + "version": "2.3.1" + }, + "state": "UNINITIALISED", + "orderedState": "UNINITIALISED", + "description": "Monitoring Policy Automation Composition Element for the PMSH instance 0 automation composition" + }, + "709c62b3-8918-41b9-a747-d21eb79c6c22": { + "id": "709c62b3-8918-41b9-a747-d21eb79c6c22", + "definition": { + "name": "org.onap.domain.pmsh.PMSH_OperationalPolicyAutomationCompositionElement", + "version": "1.2.3" + }, + "participantType": { + "name": "org.onap.policy.acm.PolicyAutomationCompositionParticipant", + "version": "2.3.1" + }, + "state": "UNINITIALISED", + "orderedState": "UNINITIALISED", + "description": "Operational Policy Automation Composition Element for the PMSH instance 0 automation composition" + }, + "709c62b3-8918-41b9-a747-d21eb79c6c23": { + "id": "709c62b3-8918-41b9-a747-d21eb79c6c23", + "definition": { + "name": "org.onap.domain.pmsh.PMSH_CDS_AutomationCompositionElement", + "version": "1.2.3" + }, + "participantType": { + "name": "org.onap.ccsdk.cds.acm.CdsAutomationCompositionParticipant", + "version": "2.2.1" + }, + "state": "UNINITIALISED", + "orderedState": "UNINITIALISED", + "description": "CDS Automation Composition Element for the PMSH instance 0 automation composition" + } + } + }, + { + "name": "PMSHInstance1", + "version": "1.0.1", + "definition": { + "name": "org.onap.domain.pmsh.PMSHAutomationCompositionDefinition", + "version": "1.2.3" + }, + "state": "UNINITIALISED", + "orderedState": "UNINITIALISED", + "description": "PMSH automation composition instance 1", + "elements": { + "709c62b3-8918-41b9-a747-d21eb79c6c24": { + "id": "709c62b3-8918-41b9-a747-e21eb79c6c24", + "definition": { + "name": "org.onap.domain.pmsh.PMSH_DCAEMicroservice", + "version": "1.0.0" + }, + "participantType": { + "name": "org.onap.dcae.acm.DCAEMicroserviceAutomationCompositionParticipant", + "version": "2.3.4" + }, + "state": "UNINITIALISED", + "orderedState": "UNINITIALISED", + "description": "DCAE Automation Composition Element for the PMSH instance 1 automation composition" + }, + "709c62b3-8918-41b9-a747-d21eb79c6c25": { + "id": "709c62b3-8918-41b9-a747-e21eb79c6c25", + "definition": { + "name": "org.onap.domain.pmsh.PMSH_MonitoringPolicyAutomationCompositionElement", + "version": "1.2.3" + }, + "participantType": { + "name": "org.onap.policy.acm.PolicyAutomationCompositionParticipant", + "version": "2.3.1" + }, + "state": "UNINITIALISED", + "orderedState": "UNINITIALISED", + "description": "Monitoring Policy Automation Composition Element for the PMSH instance 1 automation composition" + }, + "709c62b3-8918-41b9-a747-d21eb79c6c26": { + "id": "709c62b3-8918-41b9-a747-e21eb79c6c26", + "definition": { + "name": "org.onap.domain.pmsh.PMSH_OperationalPolicyAutomationCompositionElement", + "version": "1.2.3" + }, + "participantType": { + "name": "org.onap.policy.acm.PolicyAutomationCompositionParticipant", + "version": "2.3.1" + }, + "state": "UNINITIALISED", + "orderedState": "UNINITIALISED", + "description": "Operational Policy Automation Composition Element for the PMSH instance 1 automation composition" + }, + "709c62b3-8918-41b9-a747-d21eb79c6c27": { + "id": "709c62b3-8918-41b9-a747-e21eb79c6c27", + "definition": { + "name": "org.onap.domain.pmsh.PMSH_CDS_AutomationCompositionElement", + "version": "1.2.3" + }, + "participantType": { + "name": "org.onap.ccsdk.cds.acm.CdsAutomationCompositionParticipant", + "version": "2.2.1" + }, + "state": "UNINITIALISED", + "orderedState": "UNINITIALISED", + "description": "CDS Automation Composition Element for the PMSH instance 1 automation composition" + } + } + } + ] +} diff --git a/runtime-acm/src/test/resources/rest/acm/AutomationCompositions.json b/runtime-acm/src/test/resources/rest/acm/AutomationCompositions.json new file mode 100644 index 000000000..f368cd69d --- /dev/null +++ b/runtime-acm/src/test/resources/rest/acm/AutomationCompositions.json @@ -0,0 +1,174 @@ +{ + "automationCompositionList": [ + { + "name": "PMSHInstance0", + "version": "1.0.1", + "definition": { + "name": "org.onap.domain.pmsh.PMSHAutomationCompositionDefinition", + "version": "1.2.3" + }, + "state": "UNINITIALISED", + "orderedState": "UNINITIALISED", + "description": "PMSH automation composition instance 0", + "elements": { + "709c62b3-8918-41b9-a747-d21eb79c6c20": { + "id": "709c62b3-8918-41b9-a747-d21eb79c6c20", + "definition": { + "name": "org.onap.domain.pmsh.PMSH_DCAEMicroservice", + "version": "1.2.3" + }, + "participantId": { + "name": "org.onap.dcae.acm.DCAEMicroserviceAutomationCompositionParticipant", + "version": "2.3.4" + }, + "participantType": { + "name": "org.onap.dcae.acm.DCAEMicroserviceAutomationCompositionParticipant", + "version": "2.3.4" + }, + "state": "UNINITIALISED", + "orderedState": "UNINITIALISED", + "description": "DCAE Automation Composition Element for the PMSH instance 0 automation composition" + }, + "709c62b3-8918-41b9-a747-d21eb79c6c21": { + "id": "709c62b3-8918-41b9-a747-d21eb79c6c21", + "definition": { + "name": "org.onap.domain.pmsh.PMSH_MonitoringPolicyAutomationCompositionElement", + "version": "1.2.3" + }, + "participantId": { + "name": "org.onap.policy.acm.PolicyAutomationCompositionParticipant", + "version": "2.3.1" + }, + "participantType": { + "name": "org.onap.policy.acm.PolicyAutomationCompositionParticipant", + "version": "2.3.1" + }, + "state": "UNINITIALISED", + "orderedState": "UNINITIALISED", + "description": "Monitoring Policy Automation Composition Element for the PMSH instance 0 automation composition" + }, + "709c62b3-8918-41b9-a747-d21eb79c6c22": { + "id": "709c62b3-8918-41b9-a747-d21eb79c6c22", + "definition": { + "name": "org.onap.domain.pmsh.PMSH_OperationalPolicyAutomationCompositionElement", + "version": "1.2.3" + }, + "participantId": { + "name": "org.onap.policy.acm.PolicyAutomationCompositionParticipant", + "version": "2.3.1" + }, + "participantType": { + "name": "org.onap.policy.acm.PolicyAutomationCompositionParticipant", + "version": "2.3.1" + }, + "state": "UNINITIALISED", + "orderedState": "UNINITIALISED", + "description": "Operational Policy Automation Composition Element for the PMSH instance 0 automation composition" + }, + "709c62b3-8918-41b9-a747-d21eb79c6c23": { + "id": "709c62b3-8918-41b9-a747-d21eb79c6c23", + "definition": { + "name": "org.onap.domain.pmsh.PMSH_CDS_AutomationCompositionElement", + "version": "1.2.3" + }, + "participantId": { + "name": "org.onap.ccsdk.cds.acm.CdsAutomationCompositionParticipant", + "version": "2.2.1" + }, + "participantType": { + "name": "org.onap.ccsdk.cds.acm.CdsAutomationCompositionParticipant", + "version": "2.2.1" + }, + "state": "UNINITIALISED", + "orderedState": "UNINITIALISED", + "description": "CDS Automation Composition Element for the PMSH instance 0 automation composition" + } + } + }, + { + "name": "PMSHInstance1", + "version": "1.0.1", + "definition": { + "name": "org.onap.domain.pmsh.PMSHAutomationCompositionDefinition", + "version": "1.2.3" + }, + "state": "UNINITIALISED", + "orderedState": "UNINITIALISED", + "description": "PMSH automation composition instance 1", + "elements": { + "709c62b3-8918-41b9-a747-d21eb79c6c24": { + "id": "709c62b3-8918-41b9-a747-e21eb79c6c24", + "definition": { + "name": "org.onap.domain.pmsh.PMSH_DCAEMicroservice", + "version": "1.2.3" + }, + "participantId": { + "name": "org.onap.dcae.acm.DCAEMicroserviceAutomationCompositionParticipant", + "version": "2.3.4" + }, + "participantType": { + "name": "org.onap.dcae.acm.DCAEMicroserviceAutomationCompositionParticipant", + "version": "2.3.4" + }, + "state": "UNINITIALISED", + "orderedState": "UNINITIALISED", + "description": "DCAE Automation Composition Element for the PMSH instance 1 automation composition" + }, + "709c62b3-8918-41b9-a747-d21eb79c6c25": { + "id": "709c62b3-8918-41b9-a747-e21eb79c6c25", + "definition": { + "name": "org.onap.domain.pmsh.PMSH_MonitoringPolicyAutomationCompositionElement", + "version": "1.2.3" + }, + "participantId": { + "name": "org.onap.policy.acm.PolicyAutomationCompositionParticipant", + "version": "2.3.1" + }, + "participantType": { + "name": "org.onap.policy.acm.PolicyAutomationCompositionParticipant", + "version": "2.3.1" + }, + "state": "UNINITIALISED", + "orderedState": "UNINITIALISED", + "description": "Monitoring Policy Automation Composition Element for the PMSH instance 1 automation composition" + }, + "709c62b3-8918-41b9-a747-d21eb79c6c26": { + "id": "709c62b3-8918-41b9-a747-e21eb79c6c26", + "definition": { + "name": "org.onap.domain.pmsh.PMSH_OperationalPolicyAutomationCompositionElement", + "version": "1.2.3" + }, + "participantId": { + "name": "org.onap.policy.acm.PolicyAutomationCompositionParticipant", + "version": "2.3.1" + }, + "participantType": { + "name": "org.onap.policy.acm.PolicyAutomationCompositionParticipant", + "version": "2.3.1" + }, + "state": "UNINITIALISED", + "orderedState": "UNINITIALISED", + "description": "Operational Policy Automation Composition Element for the PMSH instance 1 automation composition" + }, + "709c62b3-8918-41b9-a747-d21eb79c6c27": { + "id": "709c62b3-8918-41b9-a747-e21eb79c6c27", + "definition": { + "name": "org.onap.domain.pmsh.PMSH_CDS_AutomationCompositionElement", + "version": "1.2.3" + }, + "participantId": { + "name": "org.onap.ccsdk.cds.acm.CdsAutomationCompositionParticipant", + "version": "2.2.1" + }, + "participantType": { + "name": "org.onap.ccsdk.cds.acm.CdsAutomationCompositionParticipant", + "version": "2.2.1" + }, + "state": "UNINITIALISED", + "orderedState": "UNINITIALISED", + "description": "CDS Automation Composition Element for the PMSH instance 1 automation composition" + } + } + } + ] +} diff --git a/runtime-acm/src/test/resources/rest/acm/AutomationCompositionsNotFound.json b/runtime-acm/src/test/resources/rest/acm/AutomationCompositionsNotFound.json new file mode 100644 index 000000000..5a859fbca --- /dev/null +++ b/runtime-acm/src/test/resources/rest/acm/AutomationCompositionsNotFound.json @@ -0,0 +1,142 @@ +{ + "automationCompositionList": [ + { + "name": "PMSHInstance0", + "version": "1.0.1", + "definition": { + "name": "org.onap.domain.PMSHAutomationCompositionDefinition", + "version": "1.2.3" + }, + "state": "UNINITIALISED", + "orderedState": "UNINITIALISED", + "description": "PMSH automation composition instance 0", + "elements": { + "709c62b3-8918-41b9-a747-d21eb79c6c20": { + "id": "709c62b3-8918-41b9-a747-d21eb79c6c20", + "definition": { + "name": "org.onap.domain.pmsh.PMSH_DCAEMicroservice", + "version": "1.2.3" + }, + "participantType": { + "name": "org.onap.dcae.acm.DCAEMicroserviceAutomationCompositionParticipant", + "version": "2.3.4" + }, + "state": "UNINITIALISED", + "orderedState": "UNINITIALISED", + "description": "DCAE Automation Composition Element for the PMSH instance 0 automation composition" + }, + "709c62b3-8918-41b9-a747-d21eb79c6c21": { + "id": "709c62b3-8918-41b9-a747-d21eb79c6c21", + "definition": { + "name": "org.onap.domain.pmsh.PMSH_MonitoringPolicyAutomationCompositionElement", + "version": "1.2.3" + }, + "participantType": { + "name": "org.onap.policy.acm.PolicyAutomationCompositionParticipant", + "version": "2.3.1" + }, + "state": "UNINITIALISED", + "orderedState": "UNINITIALISED", + "description": "Monitoring Policy Automation Composition Element for the PMSH instance 0 automation composition" + }, + "709c62b3-8918-41b9-a747-d21eb79c6c22": { + "id": "709c62b3-8918-41b9-a747-d21eb79c6c22", + "definition": { + "name": "org.onap.domain.pmsh.PMSH_OperationalPolicyAutomationCompositionElement", + "version": "1.2.3" + }, + "participantType": { + "name": "org.onap.policy.acm.PolicyAutomationCompositionParticipant", + "version": "2.3.1" + }, + "state": "UNINITIALISED", + "orderedState": "UNINITIALISED", + "description": "Operational Policy Automation Composition Element for the PMSH instance 0 automation composition" + }, + "709c62b3-8918-41b9-a747-d21eb79c6c23": { + "id": "709c62b3-8918-41b9-a747-d21eb79c6c23", + "definition": { + "name": "org.onap.domain.pmsh.PMSH_CDS_AutomationCompositionElement", + "version": "1.2.3" + }, + "participantType": { + "name": "org.onap.ccsdk.cds.acm.CdsAutomationCompositionParticipant", + "version": "2.2.1" + }, + "state": "UNINITIALISED", + "orderedState": "UNINITIALISED", + "description": "CDS Automation Composition Element for the PMSH instance 0 automation composition" + } + } + }, + { + "name": "PMSHInstance1", + "version": "1.0.1", + "definition": { + "name": "org.onap.domain.PMSHAutomationCompositionDefinition", + "version": "1.2.3" + }, + "state": "UNINITIALISED", + "orderedState": "UNINITIALISED", + "description": "PMSH automation composition instance 1", + "elements": { + "709c62b3-8918-41b9-a747-d21eb79c6c24": { + "id": "709c62b3-8918-41b9-a747-e21eb79c6c24", + "definition": { + "name": "org.onap.domain.pmsh.PMSH_DCAEMicroservice", + "version": "1.2.3" + }, + "participantType": { + "name": "org.onap.dcae.acm.DCAEMicroserviceAutomationCompositionParticipant", + "version": "2.3.4" + }, + "state": "UNINITIALISED", + "orderedState": "UNINITIALISED", + "description": "DCAE Automation Composition Element for the PMSH instance 1 automation composition" + }, + "709c62b3-8918-41b9-a747-d21eb79c6c25": { + "id": "709c62b3-8918-41b9-a747-e21eb79c6c25", + "definition": { + "name": "org.onap.domain.pmsh.PMSH_MonitoringPolicyAutomationCompositionElement", + "version": "1.2.3" + }, + "participantType": { + "name": "org.onap.policy.acm.PolicyAutomationCompositionParticipant", + "version": "2.3.1" + }, + "state": "UNINITIALISED", + "orderedState": "UNINITIALISED", + "description": "Monitoring Policy Automation Composition Element for the PMSH instance 1 automation composition" + }, + "709c62b3-8918-41b9-a747-d21eb79c6c26": { + "id": "709c62b3-8918-41b9-a747-e21eb79c6c26", + "definition": { + "name": "org.onap.domain.pmsh.PMSH_OperationalPolicyAutomationCompositionElement", + "version": "1.2.3" + }, + "participantType": { + "name": "org.onap.policy.acm.PolicyAutomationCompositionParticipant", + "version": "2.3.1" + }, + "state": "UNINITIALISED", + "orderedState": "UNINITIALISED", + "description": "Operational Policy Automation Composition Element for the PMSH instance 1 automation composition" + }, + "709c62b3-8918-41b9-a747-d21eb79c6c27": { + "id": "709c62b3-8918-41b9-a747-e21eb79c6c27", + "definition": { + "name": "org.onap.domain.pmsh.PMSH_CDS_AutomationCompositionElement", + "version": "1.2.3" + }, + "participantType": { + "name": "org.onap.ccsdk.cds.acm.CdsAutomationCompositionParticipant", + "version": "2.2.1" + }, + "state": "UNINITIALISED", + "orderedState": "UNINITIALISED", + "description": "CDS Automation Composition Element for the PMSH instance 1 automation composition" + } + } + } + ] +} diff --git a/runtime-acm/src/test/resources/rest/acm/AutomationCompositionsSmoke.json b/runtime-acm/src/test/resources/rest/acm/AutomationCompositionsSmoke.json new file mode 100644 index 000000000..72bdead66 --- /dev/null +++ b/runtime-acm/src/test/resources/rest/acm/AutomationCompositionsSmoke.json @@ -0,0 +1,174 @@ +{ + "automationCompositionList": [ + { + "name": "PMSHInstance0", + "version": "1.0.1", + "definition": { + "name": "org.onap.domain.pmsh.PMSHAutomationCompositionDefinition", + "version": "1.2.3" + }, + "state": "UNINITIALISED", + "orderedState": "UNINITIALISED", + "description": "PMSH automation composition instance 0", + "elements": { + "709c62b3-8918-41b9-a747-d21eb79c6c20": { + "id": "709c62b3-8918-41b9-a747-d21eb79c6c20", + "definition": { + "name": "org.onap.domain.database.Http_PMSHMicroserviceAutomationCompositionElement", + "version": "1.2.3" + }, + "participantId": { + "name": "org.onap.dcae.acm.DCAEMicroserviceAutomationCompositionParticipant", + "version": "2.3.4" + }, + "participantType": { + "name": "org.onap.dcae.acm.DCAEMicroserviceAutomationCompositionParticipant", + "version": "2.3.4" + }, + "state": "UNINITIALISED", + "orderedState": "UNINITIALISED", + "description": "DCAE Automation Composition Element for the PMSH instance 0 automation composition" + }, + "709c62b3-8918-41b9-a747-d21eb79c6c21": { + "id": "709c62b3-8918-41b9-a747-d21eb79c6c21", + "definition": { + "name": "org.onap.domain.pmsh.PMSH_MonitoringPolicyAutomationCompositionElement", + "version": "1.2.3" + }, + "participantId": { + "name": "org.onap.policy.acm.PolicyAutomationCompositionParticipant", + "version": "2.3.1" + }, + "participantType": { + "name": "org.onap.policy.acm.PolicyAutomationCompositionParticipant", + "version": "2.3.1" + }, + "state": "UNINITIALISED", + "orderedState": "UNINITIALISED", + "description": "Monitoring Policy Automation Composition Element for the PMSH instance 0 automation composition" + }, + "709c62b3-8918-41b9-a747-d21eb79c6c22": { + "id": "709c62b3-8918-41b9-a747-d21eb79c6c22", + "definition": { + "name": "org.onap.domain.pmsh.PMSH_OperationalPolicyAutomationCompositionElement", + "version": "1.2.3" + }, + "participantId": { + "name": "org.onap.policy.acm.PolicyAutomationCompositionParticipant", + "version": "2.3.1" + }, + "participantType": { + "name": "org.onap.policy.acm.PolicyAutomationCompositionParticipant", + "version": "2.3.1" + }, + "state": "UNINITIALISED", + "orderedState": "UNINITIALISED", + "description": "Operational Policy Automation Composition Element for the PMSH instance 0 automation composition" + }, + "709c62b3-8918-41b9-a747-d21eb79c6c23": { + "id": "709c62b3-8918-41b9-a747-d21eb79c6c23", + "definition": { + "name": "org.onap.domain.database.PMSH_K8SMicroserviceAutomationCompositionElement", + "version": "1.2.3" + }, + "participantId": { + "name": "org.onap.ccsdk.cds.acm.CdsAutomationCompositionParticipant", + "version": "2.2.1" + }, + "participantType": { + "name": "org.onap.ccsdk.cds.acm.CdsAutomationCompositionParticipant", + "version": "2.2.1" + }, + "state": "UNINITIALISED", + "orderedState": "UNINITIALISED", + "description": "CDS Automation Composition Element for the PMSH instance 0 automation composition" + } + } + }, + { + "name": "PMSHInstance1", + "version": "1.0.1", + "definition": { + "name": "org.onap.domain.pmsh.PMSHAutomationCompositionDefinition", + "version": "1.2.3" + }, + "state": "UNINITIALISED", + "orderedState": "UNINITIALISED", + "description": "PMSH automation composition instance 1", + "elements": { + "709c62b3-8918-41b9-a747-d21eb79c6c24": { + "id": "709c62b3-8918-41b9-a747-e21eb79c6c24", + "definition": { + "name": "org.onap.domain.pmsh.PMSH_DCAEMicroservice", + "version": "1.2.3" + }, + "participantId": { + "name": "org.onap.dcae.acm.DCAEMicroserviceAutomationCompositionParticipant", + "version": "2.3.4" + }, + "participantType": { + "name": "org.onap.dcae.acm.DCAEMicroserviceAutomationCompositionParticipant", + "version": "2.3.4" + }, + "state": "UNINITIALISED", + "orderedState": "UNINITIALISED", + "description": "DCAE Automation Composition Element for the PMSH instance 1 automation composition" + }, + "709c62b3-8918-41b9-a747-d21eb79c6c25": { + "id": "709c62b3-8918-41b9-a747-e21eb79c6c25", + "definition": { + "name": "org.onap.domain.pmsh.PMSH_MonitoringPolicyAutomationCompositionElement", + "version": "1.2.3" + }, + "participantId": { + "name": "org.onap.policy.acm.PolicyAutomationCompositionParticipant", + "version": "2.3.1" + }, + "participantType": { + "name": "org.onap.policy.acm.PolicyAutomationCompositionParticipant", + "version": "2.3.1" + }, + "state": "UNINITIALISED", + "orderedState": "UNINITIALISED", + "description": "Monitoring Policy Automation Composition Element for the PMSH instance 1 automation composition" + }, + "709c62b3-8918-41b9-a747-d21eb79c6c26": { + "id": "709c62b3-8918-41b9-a747-e21eb79c6c26", + "definition": { + "name": "org.onap.domain.pmsh.PMSH_OperationalPolicyAutomationCompositionElement", + "version": "1.2.3" + }, + "participantId": { + "name": "org.onap.policy.acm.PolicyAutomationCompositionParticipant", + "version": "2.3.1" + }, + "participantType": { + "name": "org.onap.policy.acm.PolicyAutomationCompositionParticipant", + "version": "2.3.1" + }, + "state": "UNINITIALISED", + "orderedState": "UNINITIALISED", + "description": "Operational Policy Automation Composition Element for the PMSH instance 1 automation composition" + }, + "709c62b3-8918-41b9-a747-d21eb79c6c27": { + "id": "709c62b3-8918-41b9-a747-e21eb79c6c27", + "definition": { + "name": "org.onap.domain.pmsh.PMSH_CDS_AutomationCompositionElement", + "version": "1.2.3" + }, + "participantId": { + "name": "org.onap.ccsdk.cds.acm.CdsAutomationCompositionParticipant", + "version": "2.2.1" + }, + "participantType": { + "name": "org.onap.ccsdk.cds.acm.CdsAutomationCompositionParticipant", + "version": "2.2.1" + }, + "state": "UNINITIALISED", + "orderedState": "UNINITIALISED", + "description": "CDS Automation Composition Element for the PMSH instance 1 automation composition" + } + } + } + ] +} diff --git a/runtime-acm/src/test/resources/rest/acm/AutomationCompositionsUpdate.json b/runtime-acm/src/test/resources/rest/acm/AutomationCompositionsUpdate.json new file mode 100644 index 000000000..f0c45b5b2 --- /dev/null +++ b/runtime-acm/src/test/resources/rest/acm/AutomationCompositionsUpdate.json @@ -0,0 +1,174 @@ +{ + "automationCompositionList": [ + { + "name": "PMSHInstance0", + "version": "1.0.1", + "definition": { + "name": "org.onap.domain.pmsh.PMSHAutomationCompositionDefinition", + "version": "1.2.3" + }, + "state": "UNINITIALISED", + "orderedState": "UNINITIALISED", + "description": "PMSH automation composition instance 1", + "elements": { + "709c62b3-8918-41b9-a747-d21eb79c6c21": { + "id": "709c62b3-8918-41b9-a747-d21eb79c6c21", + "definition": { + "name": "org.onap.domain.pmsh.PMSH_DCAEMicroservice", + "version": "1.2.3" + }, + "participantId": { + "name": "org.onap.dcae.acm.DCAEMicroserviceAutomationCompositionParticipant", + "version": "2.3.4" + }, + "participantType": { + "name": "org.onap.dcae.acm.DCAEMicroserviceAutomationCompositionParticipant", + "version": "2.3.4" + }, + "state": "UNINITIALISED", + "orderedState": "UNINITIALISED", + "description": "DCAE Automation Composition Element for the PMSH instance 0 automation composition" + }, + "709c62b3-8918-41b9-a747-d21eb79c6c22": { + "id": "709c62b3-8918-41b9-a747-d21eb79c6c22", + "definition": { + "name": "org.onap.domain.pmsh.PMSH_MonitoringPolicyAutomationCompositionElement", + "version": "1.2.3" + }, + "participantId": { + "name": "org.onap.policy.acm.PolicyAutomationCompositionParticipant", + "version": "2.3.1" + }, + "participantType": { + "name": "org.onap.policy.acm.PolicyAutomationCompositionParticipant", + "version": "2.3.1" + }, + "state": "UNINITIALISED", + "orderedState": "UNINITIALISED", + "description": "Monitoring Policy Automation Composition Element for the PMSH instance 0 automation composition" + }, + "709c62b3-8918-41b9-a747-d21eb79c6c23": { + "id": "709c62b3-8918-41b9-a747-d21eb79c6c23", + "definition": { + "name": "org.onap.domain.pmsh.PMSH_MonitoringPolicyAutomationCompositionElement", + "version": "1.2.3" + }, + "participantId": { + "name": "org.onap.policy.acm.PolicyAutomationCompositionParticipant", + "version": "2.3.1" + }, + "participantType": { + "name": "org.onap.policy.acm.PolicyAutomationCompositionParticipant", + "version": "2.3.1" + }, + "state": "UNINITIALISED", + "orderedState": "UNINITIALISED", + "description": "Operational Policy Automation Composition Element for the PMSH instance 0 automation composition" + }, + "709c62b3-8918-41b9-a747-d21eb79c6c24": { + "id": "709c62b3-8918-41b9-a747-d21eb79c6c24", + "definition": { + "name": "org.onap.domain.pmsh.PMSH_CDS_AutomationCompositionElement", + "version": "1.2.3" + }, + "participantId": { + "name": "org.onap.ccsdk.cds.acm.CdsAutomationCompositionParticipant", + "version": "2.2.1" + }, + "participantType": { + "name": "org.onap.ccsdk.cds.acm.CdsAutomationCompositionParticipant", + "version": "2.2.1" + }, + "state": "UNINITIALISED", + "orderedState": "UNINITIALISED", + "description": "CDS Automation Composition Element for the PMSH instance 0 automation composition" + } + } + }, + { + "name": "PMSHInstance1", + "version": "1.0.1", + "definition": { + "name": "org.onap.domain.pmsh.PMSHAutomationCompositionDefinition", + "version": "1.2.3" + }, + "state": "UNINITIALISED", + "orderedState": "UNINITIALISED", + "description": "PMSH automation composition instance 1", + "elements": { + "709c62b3-8918-41b9-a747-d21eb79c6c25": { + "id": "709c62b3-8918-41b9-a747-e21eb79c6c25", + "definition": { + "name": "org.onap.domain.pmsh.PMSH_DCAEMicroservice", + "version": "1.2.3" + }, + "participantId": { + "name": "org.onap.dcae.acm.DCAEMicroserviceAutomationCompositionParticipant", + "version": "2.3.4" + }, + "participantType": { + "name": "org.onap.dcae.acm.DCAEMicroserviceAutomationCompositionParticipant", + "version": "2.3.4" + }, + "state": "UNINITIALISED", + "orderedState": "UNINITIALISED", + "description": "DCAE Automation Composition Element for the PMSH instance 1 automation composition" + }, + "709c62b3-8918-41b9-a747-d21eb79c6c26": { + "id": "709c62b3-8918-41b9-a747-e21eb79c6c26", + "definition": { + "name": "org.onap.domain.pmsh.PMSH_MonitoringPolicyAutomationCompositionElement", + "version": "1.2.3" + }, + "participantId": { + "name": "org.onap.policy.acm.PolicyAutomationCompositionParticipant", + "version": "2.3.1" + }, + "participantType": { + "name": "org.onap.policy.acm.PolicyAutomationCompositionParticipant", + "version": "2.3.1" + }, + "state": "UNINITIALISED", + "orderedState": "UNINITIALISED", + "description": "Monitoring Policy Automation Composition Element for the PMSH instance 1 automation composition" + }, + "709c62b3-8918-41b9-a747-d21eb79c6c27": { + "id": "709c62b3-8918-41b9-a747-e21eb79c6c27", + "definition": { + "name": "org.onap.domain.pmsh.PMSH_MonitoringPolicyAutomationCompositionElement", + "version": "1.2.3" + }, + "participantId": { + "name": "org.onap.policy.acm.PolicyAutomationCompositionParticipant", + "version": "2.3.1" + }, + "participantType": { + "name": "org.onap.policy.acm.PolicyAutomationCompositionParticipant", + "version": "2.3.1" + }, + "state": "UNINITIALISED", + "orderedState": "UNINITIALISED", + "description": "Operational Policy Automation Composition Element for the PMSH instance 1 automation composition" + }, + "709c62b3-8918-41b9-a747-d21eb79c6c28": { + "id": "709c62b3-8918-41b9-a747-e21eb79c6c28", + "definition": { + "name": "org.onap.domain.pmsh.PMSH_CDS_AutomationCompositionElement", + "version": "1.2.3" + }, + "participantId": { + "name": "org.onap.ccsdk.cds.acm.CdsAutomationCompositionParticipant", + "version": "2.2.1" + }, + "participantType": { + "name": "org.onap.ccsdk.cds.acm.CdsAutomationCompositionParticipant", + "version": "2.2.1" + }, + "state": "UNINITIALISED", + "orderedState": "UNINITIALISED", + "description": "CDS Automation Composition Element for the PMSH instance 1 automation composition" + } + } + } + ] +} diff --git a/runtime-acm/src/test/resources/rest/acm/PassiveCommand.json b/runtime-acm/src/test/resources/rest/acm/PassiveCommand.json new file mode 100644 index 000000000..5bb9eb336 --- /dev/null +++ b/runtime-acm/src/test/resources/rest/acm/PassiveCommand.json @@ -0,0 +1,13 @@ +{ + "orderedState": "PASSIVE", + "automationCompositionIdentifierList": [ + { + "name": "PMSHInstance0", + "version": "1.0.1" + }, + { + "name": "PMSHInstance1", + "version": "1.0.1" + } + ] +} diff --git a/runtime-acm/src/test/resources/rest/monitoring/TestAcElementStatistics.json b/runtime-acm/src/test/resources/rest/monitoring/TestAcElementStatistics.json new file mode 100644 index 000000000..c63c3ea1d --- /dev/null +++ b/runtime-acm/src/test/resources/rest/monitoring/TestAcElementStatistics.json @@ -0,0 +1,44 @@ +{ + "acElementStatistics":[ + { + "participantId":{ + "name":"name1", + "version":"1.001" + }, + "id": "709c62b3-8918-41b9-a747-d21eb79c6c20", + "timeStamp": "2021-01-10T13:45:00.000Z", + "state": "UNINITIALISED", + "acElementUptime":250 + }, + { + "participantId":{ + "name":"name1", + "version":"1.001" + }, + "id": "709c62b3-8918-41b9-a747-d21eb79c6c20", + "timeStamp": "2021-01-10T15:45:00.000Z", + "state": "UNINITIALISED", + "acElementUptime":450 + }, + { + "participantId":{ + "name":"name2", + "version":"1.001" + }, + "id": "709c62b3-8918-41b9-a747-d21eb79c6c21", + "timeStamp": "2021-01-10T14:25:00.000Z", + "state": "UNINITIALISED", + "acElementUptime":330 + }, + { + "participantId":{ + "name":"name2", + "version":"1.001" + }, + "id": "709c62b3-8918-41b9-a747-d21eb79c6c21", + "timeStamp": "2021-01-10T16:35:00.000Z", + "state": "UNINITIALISED", + "acElementUptime":650 + } + ] +} \ No newline at end of file diff --git a/runtime-acm/src/test/resources/rest/monitoring/TestAcElementStatistics_Invalid.json b/runtime-acm/src/test/resources/rest/monitoring/TestAcElementStatistics_Invalid.json new file mode 100644 index 000000000..59af47828 --- /dev/null +++ b/runtime-acm/src/test/resources/rest/monitoring/TestAcElementStatistics_Invalid.json @@ -0,0 +1,13 @@ +{ + "acElementStatisticsList":[ + { + "participantId":{ + "name":"name1", + "version":"1.001" + }, + "id": "709c62b3-8918-41b9-a747-d21eb79c6c20", + "state": "UNINITIALISED", + "acElementUptime":250 + } + ] +} \ No newline at end of file diff --git a/runtime-acm/src/test/resources/rest/monitoring/TestParticipantStatistics.json b/runtime-acm/src/test/resources/rest/monitoring/TestParticipantStatistics.json new file mode 100644 index 000000000..acd88e24b --- /dev/null +++ b/runtime-acm/src/test/resources/rest/monitoring/TestParticipantStatistics.json @@ -0,0 +1,46 @@ +{ + "statisticsList":[ + { + "participantId":{ + "name":"name1", + "version":"1.001" + }, + "timeStamp": "2021-01-10T13:45:00.000Z", + "state": "PASSIVE", + "healthStatus": "HEALTHY", + "eventCount":250, + "lastExecutionTime":100, + "averageExecutionTime":90, + "upTime":1000, + "lastStart":3000 + }, + { + "participantId":{ + "name":"name1", + "version":"1.001" + }, + "timeStamp": "2021-01-10T15:45:00.000Z", + "state": "PASSIVE", + "healthStatus": "HEALTHY", + "eventCount":262, + "lastExecutionTime":100, + "averageExecutionTime":90, + "upTime":2000, + "lastStart":3000 + }, + { + "participantId":{ + "name":"name2", + "version":"1.001" + }, + "timeStamp": "2021-01-27T14:25:00.000Z", + "state": "PASSIVE", + "healthStatus": "HEALTHY", + "eventCount":245, + "lastExecutionTime":1020, + "averageExecutionTime":85, + "upTime":1050, + "lastStart":3100 + } + ] +} \ No newline at end of file diff --git a/runtime-acm/src/test/resources/rest/monitoring/TestParticipantStatistics_Invalid.json b/runtime-acm/src/test/resources/rest/monitoring/TestParticipantStatistics_Invalid.json new file mode 100644 index 000000000..7281822f0 --- /dev/null +++ b/runtime-acm/src/test/resources/rest/monitoring/TestParticipantStatistics_Invalid.json @@ -0,0 +1,16 @@ +{ + "participantStatisticsList":[ + { + "participantId":{ + "name":"name3", + "version":"1.001" + }, + "state": "PASSIVE", + "eventCount":250, + "lastExecutionTime":100, + "averageExecutionTime":90, + "upTime":1000, + "lastStart":3000 + } + ] +} \ No newline at end of file diff --git a/runtime-acm/src/test/resources/rest/servicetemplates/PMSHMultipleACTosca.yaml b/runtime-acm/src/test/resources/rest/servicetemplates/PMSHMultipleACTosca.yaml new file mode 100644 index 000000000..4cbebc413 --- /dev/null +++ b/runtime-acm/src/test/resources/rest/servicetemplates/PMSHMultipleACTosca.yaml @@ -0,0 +1,232 @@ +tosca_definitions_version: tosca_simple_yaml_1_3 +data_types: + onap.datatypes.ToscaConceptIdentifier: + derived_from: tosca.datatypes.Root + properties: + name: + type: string + required: true + version: + type: string + required: true +node_types: + org.onap.policy.clamp.acm.Participant: + version: 1.0.1 + derived_from: tosca.nodetypes.Root + properties: + provider: + type: string + requred: false + org.onap.policy.clamp.acm.AutomationCompositionElement: + version: 1.0.1 + derived_from: tosca.nodetypes.Root + properties: + provider: + type: string + requred: false + participantType: + type: onap.datatypes.ToscaConceptIdentifier + requred: true + startPhase: + type: integer + required: false + constraints: + - greater-or-equal: 0 + metadata: + common: true + description: A value indicating the start phase in which this automation composition element will be started, the + first start phase is zero. Automation Composition Elements are started in their start_phase order and stopped + in reverse start phase order. Automation Composition Elements with the same start phase are started and + stopped simultaneously + org.onap.policy.clamp.acm.AutomationComposition: + version: 1.0.1 + derived_from: tosca.nodetypes.Root + properties: + provider: + type: string + requred: false + elements: + type: list + required: true + entry_schema: + type: onap.datatypes.ToscaConceptIdentifier + org.onap.policy.clamp.acm.DCAEMicroserviceAutomationCompositionElement: + version: 1.0.1 + derived_from: org.onap.policy.clamp.acm.AutomationCompositionElement + properties: + dcae_blueprint_id: + type: onap.datatypes.ToscaConceptIdentifier + requred: true + org.onap.policy.clamp.acm.PolicyTypeAutomationCompositionElement: + version: 1.0.1 + derived_from: org.onap.policy.clamp.acm.AutomationCompositionElement + properties: + policy_type_id: + type: onap.datatypes.ToscaConceptIdentifier + requred: true + org.onap.policy.clamp.acm.CDSAutomationCompositionElement: + version: 1.0.1 + derived_from: org.onap.policy.clamp.acm.AutomationCompositionElement + properties: + cds_blueprint_id: + type: onap.datatypes.ToscaConceptIdentifier + requred: true +topology_template: + node_templates: + org.onap.dcae.acm.DCAEMicroserviceAutomationCompositionParticipant: + version: 2.3.4 + type: org.onap.policy.clamp.acm.Participant + type_version: 1.0.1 + description: Participant for DCAE microservices + properties: + provider: ONAP + org.onap.policy.acm.PolicyAutomationCompositionParticipant: + version: 2.2.1 + type: org.onap.policy.clamp.acm.Participant + type_version: 1.0.1 + description: Participant for DCAE microservices + properties: + provider: ONAP + org.onap.ccsdk.cds.acm.CdsAutomationCompositionParticipant: + version: 2.2.1 + type: org.onap.policy.clamp.acm.Participant + type_version: 1.0.1 + description: Participant for DCAE microservices + properties: + provider: ONAP + org.onap.domain.pmsh.PMSH_DCAEMicroservice: + version: 1.2.3 + type: org.onap.policy.clamp.acm.DCAEMicroserviceAutomationCompositionElement + type_version: 1.0.0 + description: Automation composition element for the DCAE microservice for Performance Management Subscription Handling + properties: + provider: Ericsson + participantType: + name: org.onap.dcae.acm.DCAEMicroserviceAutomationCompositionParticipant + version: 2.3.4 + dcae_blueprint_id: + name: org.onap.dcae.blueprints.PMSHBlueprint + version: 1.0.0 + org.onap.domain.pmsh.PMSH_MonitoringPolicyAutomationCompositionElement: + version: 1.2.3 + type: org.onap.policy.clamp.acm.PolicyTypeAutomationCompositionElement + type_version: 1.0.0 + description: Automation composition element for the monitoring policy for Performance Management Subscription Handling + properties: + provider: Ericsson + participantType: + name: org.onap.policy.acm.PolicyAutomationCompositionParticipant + version: 2.2.1 + policy_type_id: + name: onap.policies.monitoring.pm-subscription-handler + version: 1.0.0 + org.onap.domain.pmsh.PMSH_OperationalPolicyAutomationCompositionElement: + version: 1.2.3 + type: org.onap.policy.clamp.acm.PolicyTypeAutomationCompositionElement + type_version: 1.0.0 + description: Automation composition element for the operational policy for Performance Management Subscription Handling + properties: + provider: Ericsson + participantType: + name: org.onap.policy.acm.PolicyAutomationCompositionParticipant + version: 2.2.1 + policy_type_id: + name: onap.policies.operational.pm-subscription-handler + version: 1.0.0 + org.onap.domain.pmsh.PMSH_CDS_AutomationCompositionElement: + version: 1.2.3 + type: org.onap.policy.clamp.acm.AutomationCompositionElement + type_version: 1.0.0 + description: Automation composition element for CDS for Performance Management Subscription Handling + properties: + provider: Ericsson + participantType: + name: org.onap.ccsdk.cds.acm.CdsAutomationCompositionParticipant + version: 3.2.1 + cds_blueprint_id: + name: org.onap.ccsdk.cds.PMSHCdsBlueprint + version: 1.0.0 + org.onap.domain.pmsh.PMSHAutomationCompositionDefinition: + version: 1.2.3 + type: org.onap.policy.clamp.acm.AutomationComposition + type_version: 1.0.0 + description: Automation composition for Performance Management Subscription Handling + properties: + provider: Ericsson + elements: + - name: org.onap.domain.pmsh.PMSH_DCAEMicroservice + version: 1.2.3 + - name: org.onap.domain.pmsh.PMSH_MonitoringPolicyAutomationCompositionElement + version: 1.2.3 + - name: org.onap.domain.pmsh.PMSH_OperationalPolicyAutomationCompositionElement + version: 1.2.3 + - name: org.onap.domain.pmsh.PMSH_CDS_AutomationCompositionElement + version: 1.2.3 + org.onap.domain.pmsh.PMSD_DCAEMicroservice: + version: 1.2.3 + type: org.onap.policy.clamp.acm.DCAEMicroserviceAutomationCompositionElement + type_version: 1.0.0 + description: Automation composition element for the DCAE microservice for Performance Management Subscription Handling + properties: + provider: Ericsson + participantType: + name: org.onap.dcae.acm.DCAEMicroserviceAutomationCompositionParticipant + version: 2.3.4 + dcae_blueprint_id: + name: org.onap.dcae.blueprints.PMSDBlueprint + version: 1.0.0 + org.onap.domain.pmsh.PMSD_MonitoringPolicyAutomationCompositionElement: + version: 1.2.3 + type: org.onap.policy.clamp.acm.PolicyTypeAutomationCompositionElement + type_version: 1.0.0 + description: Automation composition element for the monitoring policy for Performance Management Subscription Handling + properties: + provider: Ericsson + participantType: + name: org.onap.policy.acm.PolicyAutomationCompositionParticipant + version: 2.2.1 + policy_type_id: + name: onap.policies.monitoring.pm-subscription-handler + version: 1.0.0 + org.onap.domain.pmsh.PMSD_OperationalPolicyAutomationCompositionElement: + version: 1.2.3 + type: org.onap.policy.clamp.acm.PolicyTypeAutomationCompositionElement + type_version: 1.0.0 + description: Automation composition element for the operational policy for Performance Management Subscription Handling + properties: + provider: Ericsson + participantType: + name: org.onap.policy.acm.PolicyAutomationCompositionParticipant + version: 2.2.1 + policy_type_id: + name: onap.policies.operational.pm-subscription-handler + version: 1.0.0 + org.onap.domain.pmsh.PMSD_CDS_AutomationCompositionElement: + version: 1.2.3 + type: org.onap.policy.clamp.acm.AutomationCompositionElement + type_version: 1.0.0 + description: Automation composition element for CDS for Performance Management Subscription Handling + properties: + provider: Ericsson + participantType: + name: org.onap.ccsdk.cds.acm.CdsAutomationCompositionParticipant + version: 3.2.1 + cds_blueprint_id: + name: org.onap.ccsdk.cds.PMSDCdsBlueprint + version: 1.0.0 + org.onap.domain.pmsh.PMSDAutomationCompositionDefinition: + version: 1.2.3 + type: org.onap.policy.clamp.acm.AutomationComposition + type_version: 1.0.0 + description: Automation composition for Performance Management Subscription Handling + properties: + provider: Ericsson + elements: + - name: org.onap.domain.pmsh.PMSD_DCAEMicroservice + version: 1.2.3 + - name: org.onap.domain.pmsh.PMSD_MonitoringPolicyAutomationCompositionElement + version: 1.2.3 + - name: org.onap.domain.pmsh.PMSD_OperationalPolicyAutomationCompositionElement + version: 1.2.3 + - name: org.onap.domain.pmsh.PMSD_CDS_AutomationCompositionElement + version: 1.2.3 diff --git a/runtime-acm/src/test/resources/rest/servicetemplates/full-tosca-with-common-properties.yaml b/runtime-acm/src/test/resources/rest/servicetemplates/full-tosca-with-common-properties.yaml new file mode 100644 index 000000000..30d53b4aa --- /dev/null +++ b/runtime-acm/src/test/resources/rest/servicetemplates/full-tosca-with-common-properties.yaml @@ -0,0 +1,3546 @@ +tosca_definitions_version: tosca_simple_yaml_1_1_0 +data_types: + onap.datatypes.ToscaConceptIdentifier: + derived_from: tosca.datatypes.Root + properties: + name: + type: string + required: true + version: + type: string + required: true + org.onap.datatypes.policy.clamp.acm.DCAEMicroserviceAutomationCompositionElementConsulInfo: + name: org.onap.datatypes.policy.clamp.acm.DCAEMicroserviceAutomationCompositionElementConsulInfo + version: 0.0.0 + derived_from: tosca.datatypes.Root + properties: + consulUrl: + name: consulUrl + type: string + typeVersion: 0.0.0 + description: Consul url for this entry + required: true + consul_body: + name: consulBody + type: string + typeVersion: 0.0.0 + description: Body of Consul entry + required: true + onap.datatype.acm.Target: + derived_from: tosca.datatypes.Root + description: Definition for a entity in A&AI to perform a control loop operation on + properties: + targetType: + type: string + description: Category for the target type + required: true + constraints: + - valid_values: + - VNF + - VM + - VFMODULE + - PNF + entityIds: + type: map + description: | + Map of values that identify the resource. If none are provided, it is assumed that the + entity that generated the ONSET event will be the target. + required: false + metadata: + clamp_possible_values: ClampExecution:CSAR_RESOURCES + entry_schema: + type: string + onap.datatype.acm.Actor: + derived_from: tosca.datatypes.Root + description: An actor/operation/target definition + properties: + actor: + type: string + description: The actor performing the operation. + required: true + metadata: + clamp_possible_values: Dictionary:DefaultActors,ClampExecution:CDS/actor + operation: + type: string + description: The operation the actor is performing. + metadata: + clamp_possible_values: Dictionary:DefaultOperations,ClampExecution:CDS/operation + required: true + target: + type: onap.datatype.acm.Target + description: The resource the operation should be performed on. + required: true + payload: + type: map + description: Name/value pairs of payload information passed by Policy to the actor + required: false + metadata: + clamp_possible_values: ClampExecution:CDS/payload + entry_schema: + type: string + onap.datatype.acm.Operation: + derived_from: tosca.datatypes.Root + description: An operation supported by an actor + properties: + id: + type: string + description: Unique identifier for the operation + required: true + description: + type: string + description: A user-friendly description of the intent for the operation + required: false + operation: + type: onap.datatype.acm.Actor + description: The definition of the operation to be performed. + required: true + timeout: + type: integer + description: The amount of time for the actor to perform the operation. + required: true + retries: + type: integer + description: The number of retries the actor should attempt to perform the operation. + required: true + default: 0 + success: + type: string + description: Points to the operation to invoke on success. A value of "final_success" indicates and end to the operation. + required: false + default: final_success + failure: + type: string + description: Points to the operation to invoke on Actor operation failure. + required: false + default: final_failure + failure_timeout: + type: string + description: Points to the operation to invoke when the time out for the operation occurs. + required: false + default: final_failure_timeout + failure_retries: + type: string + description: Points to the operation to invoke when the current operation has exceeded its max retries. + required: false + default: final_failure_retries + failure_exception: + type: string + description: Points to the operation to invoke when the current operation causes an exception. + required: false + default: final_failure_exception + failure_guard: + type: string + description: Points to the operation to invoke when the current operation is blocked due to guard policy enforcement. + required: false + default: final_failure_guard + onap.datatypes.monitoring.managedObjectDNsBasic: + constraints: [] + properties: + DN: + name: DN + type: string + typeVersion: 0.0.0 + description: Managed object distinguished name + required: true + constraints: [] + metadata: {} + name: onap.datatypes.monitoring.managedObjectDNsBasic + version: 0.0.0 + derived_from: tosca.datatypes.Root + metadata: {} + onap.datatypes.monitoring.managedObjectDNsBasics: + constraints: [] + properties: + managedObjectDNsBasic: + name: managedObjectDNsBasic + type: map + typeVersion: 0.0.0 + description: Managed object distinguished name object + required: true + constraints: [] + entry_schema: + type: onap.datatypes.monitoring.managedObjectDNsBasic + typeVersion: 0.0.0 + constraints: [] + metadata: {} + name: onap.datatypes.monitoring.managedObjectDNsBasics + version: 0.0.0 + derived_from: tosca.datatypes.Root + metadata: {} + onap.datatypes.monitoring.measurementGroup: + constraints: [] + properties: + measurementTypes: + name: measurementTypes + type: list + typeVersion: 0.0.0 + description: List of measurement types + required: true + constraints: [] + entry_schema: + type: onap.datatypes.monitoring.measurementTypes + typeVersion: 0.0.0 + constraints: [] + metadata: {} + managedObjectDNsBasic: + name: managedObjectDNsBasic + type: list + typeVersion: 0.0.0 + description: List of managed object distinguished names + required: true + constraints: [] + entry_schema: + type: onap.datatypes.monitoring.managedObjectDNsBasics + typeVersion: 0.0.0 + constraints: [] + metadata: {} + name: onap.datatypes.monitoring.measurementGroup + version: 0.0.0 + derived_from: tosca.datatypes.Root + metadata: {} + onap.datatypes.monitoring.measurementGroups: + constraints: [] + properties: + measurementGroup: + name: measurementGroup + type: map + typeVersion: 0.0.0 + description: Measurement Group + required: true + constraints: [] + entry_schema: + type: onap.datatypes.monitoring.measurementGroup + typeVersion: 0.0.0 + constraints: [] + metadata: {} + name: onap.datatypes.monitoring.measurementGroups + version: 0.0.0 + derived_from: tosca.datatypes.Root + metadata: {} + onap.datatypes.monitoring.measurementType: + constraints: [] + properties: + measurementType: + name: measurementType + type: string + typeVersion: 0.0.0 + description: Measurement type + required: true + constraints: [] + metadata: {} + name: onap.datatypes.monitoring.measurementType + version: 0.0.0 + derived_from: tosca.datatypes.Root + metadata: {} + onap.datatypes.monitoring.measurementTypes: + constraints: [] + properties: + measurementType: + name: measurementType + type: map + typeVersion: 0.0.0 + description: Measurement type object + required: true + constraints: [] + entry_schema: + type: onap.datatypes.monitoring.measurementType + typeVersion: 0.0.0 + constraints: [] + metadata: {} + name: onap.datatypes.monitoring.measurementTypes + version: 0.0.0 + derived_from: tosca.datatypes.Root + metadata: {} + onap.datatypes.monitoring.nfFilter: + constraints: [] + properties: + modelNames: + name: modelNames + type: list + typeVersion: 0.0.0 + description: List of model names + required: true + constraints: [] + entry_schema: + type: string + typeVersion: 0.0.0 + constraints: [] + metadata: {} + modelInvariantIDs: + name: modelInvariantIDs + type: list + typeVersion: 0.0.0 + description: List of model invariant IDs + required: true + constraints: [] + entry_schema: + type: string + typeVersion: 0.0.0 + constraints: [] + metadata: {} + modelVersionIDs: + name: modelVersionIDs + type: list + typeVersion: 0.0.0 + description: List of model version IDs + required: true + constraints: [] + entry_schema: + type: string + typeVersion: 0.0.0 + constraints: [] + metadata: {} + nfNames: + name: nfNames + type: list + typeVersion: 0.0.0 + description: List of network functions + required: true + constraints: [] + entry_schema: + type: string + typeVersion: 0.0.0 + constraints: [] + metadata: {} + name: onap.datatypes.monitoring.nfFilter + version: 0.0.0 + derived_from: tosca.datatypes.Root + metadata: {} + onap.datatypes.monitoring.subscription: + constraints: [] + properties: + measurementGroups: + name: measurementGroups + type: list + typeVersion: 0.0.0 + description: Measurement Groups + required: true + constraints: [] + entry_schema: + type: onap.datatypes.monitoring.measurementGroups + typeVersion: 0.0.0 + constraints: [] + metadata: {} + fileBasedGP: + name: fileBasedGP + type: integer + typeVersion: 0.0.0 + description: File based granularity period + required: true + constraints: [] + metadata: {} + fileLocation: + name: fileLocation + type: string + typeVersion: 0.0.0 + description: ROP file location + required: true + constraints: [] + metadata: {} + subscriptionName: + name: subscriptionName + type: string + typeVersion: 0.0.0 + description: Name of the subscription + required: true + constraints: [] + metadata: {} + administrativeState: + name: administrativeState + type: string + typeVersion: 0.0.0 + description: State of the subscription + required: true + constraints: + - valid_values: + - LOCKED + - UNLOCKED + metadata: {} + nfFilter: + name: nfFilter + type: map + typeVersion: 0.0.0 + description: Network function filter + required: true + constraints: [] + entry_schema: + type: onap.datatypes.monitoring.nfFilter + typeVersion: 0.0.0 + constraints: [] + metadata: {} + name: onap.datatypes.monitoring.subscription + version: 0.0.0 + derived_from: tosca.datatypes.Root + metadata: {} +policy_types: + onap.policies.Monitoring: + derived_from: tosca.policies.Root + description: a base policy type for all policies that govern monitoring provisioning + version: 1.0.0 + name: onap.policies.Monitoring + onap.policies.Sirisha: + derived_from: tosca.policies.Root + description: a base policy type for all policies that govern monitoring provisioning + version: 1.0.0 + name: onap.policies.Sirisha + onap.policies.monitoring.dcae-pm-subscription-handler: + properties: + pmsh_policy: + name: pmsh_policy + type: onap.datatypes.monitoring.subscription + typeVersion: 0.0.0 + description: PMSH Policy JSON + required: false + constraints: [] + metadata: {} + name: onap.policies.monitoring.dcae-pm-subscription-handler + version: 1.0.0 + derived_from: onap.policies.Monitoring + metadata: {} + onap.policies.acm.operational.Common: + derived_from: tosca.policies.Root + version: 1.0.0 + name: onap.policies.acm.operational.Common + description: | + Operational Policy for Automation Composition execution. Originated in Frankfurt to support TOSCA Compliant + Policy Types. This does NOT support the legacy Policy YAML policy type. + properties: + id: + type: string + description: The unique automation composition id. + required: true + timeout: + type: integer + description: | + Overall timeout for executing all the operations. This timeout should equal or exceed the total + timeout for each operation listed. + required: true + abatement: + type: boolean + description: Whether an abatement event message will be expected for the automation composition from DCAE. + required: true + default: false + trigger: + type: string + description: Initial operation to execute upon receiving an Onset event message for the Automation Composition. + required: true + operations: + type: list + description: List of operations to be performed when Automation Composition is triggered. + required: true + entry_schema: + type: onap.datatype.acm.Operation + onap.policies.acm.operational.common.Apex: + derived_from: onap.policies.acm.operational.Common + type_version: 1.0.0 + version: 1.0.0 + name: onap.policies.acm.operational.common.Apex + description: Operational policies for Apex PDP + properties: + engineServiceParameters: + type: string + description: The engine parameters like name, instanceCount, policy implementation, parameters etc. + required: true + eventInputParameters: + type: string + description: The event input parameters. + required: true + eventOutputParameters: + type: string + description: The event output parameters. + required: true + javaProperties: + type: string + description: Name/value pairs of properties to be set for APEX if needed. + required: false +node_types: + org.onap.policy.clamp.acm.Participant: + version: 1.0.1 + derived_from: tosca.nodetypes.Root + properties: + provider: + type: string + requred: false + org.onap.policy.clamp.acm.AutomationCompositionElement: + version: 1.0.1 + derived_from: tosca.nodetypes.Root + properties: + provider: + type: string + required: false + metadata: + common: true + description: Specifies the organization that provides the automation composition element + participantType: + type: onap.datatypes.ToscaConceptIdentifier + required: true + metadata: + common: true + description: The identity of the participant type that hosts this type of Automation Composition Element + startPhase: + type: integer + required: false + constraints: + - greater_or_equal: 0 + metadata: + common: true + description: A value indicating the start phase in which this automation composition element will be started, the + first start phase is zero. Automation Composition Elements are started in their start_phase order and stopped + in reverse start phase order. Automation Composition Elements with the same start phase are started and + stopped simultaneously + uninitializedToPassiveTimeout: + type: integer + required: false + constraints: + - greater_or_equal: 0 + default: 60 + metadata: + common: true + description: The maximum time in seconds to wait for a state chage from uninitialized to passive + passiveToRunningTimeout: + type: integer + required: false + constraints: + - greater_or_equal: 0 + default: 60 + metadata: + common: true + description: The maximum time in seconds to wait for a state chage from passive to running + runningToPassiveTimeout: + type: integer + required: false + constraints: + - greater_or_equal: 0 + default: 60 + metadata: + common: true + description: The maximum time in seconds to wait for a state chage from running to passive + passiveToUninitializedTimeout: + type: integer + required: false + constraints: + - greater_or_equal: 0 + default: 60 + metadata: + common: true + description: The maximum time in seconds to wait for a state chage from passive to uninitialized + org.onap.policy.clamp.acm.AutomationComposition: + version: 1.0.1 + derived_from: tosca.nodetypes.Root + properties: + provider: + type: string + required: false + metadata: + common: true + description: Specifies the organization that provides the automation composition element + elements: + type: list + required: true + metadata: + common: true + entry_schema: + type: onap.datatypes.ToscaConceptIdentifier + description: Specifies a list of automation composition element definitions that make up this automation composition definition + org.onap.policy.clamp.acm.DCAEMicroserviceAutomationCompositionElement: + version: 1.0.1 + derived_from: org.onap.policy.clamp.acm.AutomationCompositionElement + properties: + dcae_blueprint_id: + type: onap.datatypes.ToscaConceptIdentifier + requred: false + dcae_blueprint: + type: onap.dcae.cloudify_blueprint + requred: false + consul_info: + type: list + required: false + entry_schema: + type: org.onap.datatypes.policy.clamp.acm.DCAEMicroserviceAutomationCompositionElementConsulInfo + org.onap.policy.clamp.acm.PolicyAutomationCompositionElement: + version: 1.0.1 + derived_from: org.onap.policy.clamp.acm.AutomationCompositionElement + properties: + policy_type_id: + type: onap.datatypes.ToscaConceptIdentifier + requred: true + policy_id: + type: onap.datatypes.ToscaConceptIdentifier + requred: false + org.onap.policy.clamp.acm.DerivedPolicyAutomationCompositionElement: + version: 1.0.1 + derived_from: org.onap.policy.clamp.acm.PolicyAutomationCompositionElement + properties: + policy_type_id: + type: onap.datatypes.ToscaConceptIdentifier + requred: true + policy_id: + type: onap.datatypes.ToscaConceptIdentifier + requred: false + org.onap.policy.clamp.acm.DerivedDerivedPolicyAutomationCompositionElement: + version: 1.0.1 + derived_from: org.onap.policy.clamp.acm.DerivedPolicyAutomationCompositionElement + properties: + policy_type_id: + type: onap.datatypes.ToscaConceptIdentifier + requred: true + policy_id: + type: onap.datatypes.ToscaConceptIdentifier + requred: false + org.onap.policy.clamp.acm.CDSAutomationCompositionElement: + version: 1.0.1 + derived_from: org.onap.policy.clamp.acm.AutomationCompositionElement + properties: + cds_blueprint_id: + type: onap.datatypes.ToscaConceptIdentifier + requred: true +topology_template: + inputs: + pmsh_monitoring_policy: + type: onap.datatypes.ToscaConceptIdentifier + description: The ID of the PMSH monitoring policy to use + default: + name: MICROSERVICE_vLoadBalancerMS_v1_0_dcae-pm-subscription-handler_1_0_0test + version: 1.0.0 + pmsh_operational_policy: + type: onap.datatypes.ToscaConceptIdentifier + description: The ID of the PMSH operational policy to use + default: + name: operational.apex.pmcontrol + version: 1.0.0 + node_templates: + org.onap.dcae.acm.DCAEMicroserviceAutomationCompositionParticipant: + version: 2.3.4 + type: org.onap.policy.clamp.acm.Participant + type_version: 1.0.1 + description: Participant for DCAE microservices + properties: + provider: ONAP + org.onap.policy.acm.PolicyAutomationCompositionParticipant: + version: 2.3.1 + type: org.onap.policy.clamp.acm.Participant + type_version: 1.0.1 + description: Participant for DCAE microservices + properties: + provider: ONAP + org.onap.domain.pmsh.PMSH_DCAEMicroservice: + version: 1.2.3 + type: org.onap.policy.clamp.acm.DCAEMicroserviceAutomationCompositionElement + type_version: 1.0.0 + description: Automation composition element for the DCAE microservice for Performance Management Subscription Handling + properties: + provider: Ericsson + participantType: + name: org.onap.dcae.acm.DCAEMicroserviceAutomationCompositionParticipant + version: 2.3.4 + dcae_blueprint: + tosca_definitions_version: cloudify_dsl_1_3 + imports: + - https://www.getcloudify.org/spec/cloudify/4.5.5/types.yaml + - plugin:k8splugin?version=3.7.0 + - plugin:pgaas?version=1.3.0 + - plugin:clamppolicyplugin?version=1.1.0 + inputs: + tag_version: + type: string + description: Docker image to be used + default: nexus3.onap.org:10001/onap/org.onap.dcaegen2.services.pmsh:1.1.2 + replicas: + type: integer + description: Number of instances + default: 1 + operational_policy_name: + type: string + default: operational.apex.pmcontrol + control_loop_name: + type: string + default: pmsh-control-loop + pmsh_publish_topic_name: + type: string + default: unauthenticated.DCAE_CL_OUTPUT + policy_feedback_topic_name: + type: string + default: unauthenticated.PMSH_CL_INPUT + aai_notification_topic_name: + type: string + default: AAI-EVENT + publisher_client_role: + type: string + description: Client role to request secure access to topic + default: org.onap.dcae.pmPublisher + subscriber_client_role: + type: string + description: Client role to request secure access to topic + default: org.onap.dcae.pmSubscriber + dcae_location: + type: string + description: DCAE location for the subscriber, used to set up routing + default: san-francisco + cpu_limit: + type: string + default: 1000m + cpu_request: + type: string + default: 1000m + memory_limit: + type: string + default: 1024Mi + memory_request: + type: string + default: 1024Mi + pgaas_cluster_name: + type: string + default: dcae-pg-primary.onap + enable_tls: + type: boolean + default: true + protocol: + type: string + description: PMSH protocol. If enable_tls is false, set to http + default: https + policy_model_id: + type: string + default: onap.policies.monitoring.dcae-pm-subscription-handler + policy_id: + type: string + default: MICROSERVICE_vLoadBalancerMS_v1_0_dcae-pm-subscription-handler_1_0_0test + node_templates: + pgaasvm: + type: dcae.nodes.pgaas.database + properties: + writerfqdn: + get_input: pgaas_cluster_name + name: pmsh + pmsh: + type: dcae.nodes.ContainerizedServiceComponentUsingDmaap + interfaces: + cloudify.interfaces.lifecycle: + create: + inputs: + ports: + - '8443:0' + envs: + PMSH_PG_URL: + get_attribute: + - pgaasvm + - admin + - host + PMSH_PG_PASSWORD: + get_attribute: + - pgaasvm + - admin + - password + PMSH_PG_USERNAME: + get_attribute: + - pgaasvm + - admin + - user + PMSH_DB_NAME: + get_attribute: + - pgaasvm + - admin + - database + relationships: + - target: pmsh-policy + type: cloudify.relationships.depends_on + properties: + service_component_type: dcae-pmsh + service_component_name_override: dcae-pmsh + application_config: + enable_tls: + get_input: enable_tls + aaf_identity: dcae@dcae.onap.org + aaf_password: demo123456! + operational_policy_name: + get_input: operational_policy_name + control_loop_name: + get_input: control_loop_name + cert_path: /opt/app/pmsh/etc/certs/cert.pem + key_path: /opt/app/pmsh/etc/certs/key.pem + ca_cert_path: /opt/app/pmsh/etc/certs/cacert.pem + streams_publishes: + policy_pm_publisher: + type: message_router + dmaap_info: + topic_url: + concat: + - http://message-router:3904/events/ + - get_input: pmsh_publish_topic_name + streams_subscribes: + policy_pm_subscriber: + type: message_router + dmaap_info: + topic_url: + concat: + - http://message-router:3904/events/ + - get_input: policy_feedback_topic_name + aai_subscriber: + type: message_router + dmaap_info: + topic_url: + concat: + - http://message-router:3904/events/ + - get_input: aai_notification_topic_name + resource_config: + limits: + cpu: + get_input: cpu_limit + memory: + get_input: memory_limit + requests: + cpu: + get_input: cpu_request + memory: + get_input: memory_request + docker_config: + healthcheck: + endpoint: /healthcheck + interval: 15s + timeout: 1s + type: + get_input: protocol + image: + get_input: tag_version + replicas: + get_input: replicas + log_info: + log_directory: /var/log/ONAP/dcaegen2/services/pmsh + tls_info: + cert_directory: /opt/app/pmsh/etc/certs + use_tls: + get_input: enable_tls + pmsh-policy: + type: clamp.nodes.policy + properties: + policy_model_id: + get_input: policy_model_id + policy_id: + get_input: policy_id + consul_info: + - consulUrl: http://consul:31321/v1/kv/dcae-pmsh:policy + consulBody: + subscription: + subscriptionName: subscriptiona + administrativeState: UNLOCKED + fileBasedGP: 15 + fileLocation: /pm/pm.xml + nfFilter: + nfNames: + - ^pnf1.* + modelInvariantIDs: + - 5845y423-g654-6fju-po78-8n53154532k6 + - 7129e420-d396-4efb-af02-6b83499b12f8 + modelVersionIDs: + - e80a6ae3-cafd-4d24-850d-e14c084a5ca9 + measurementGroups: + - measurementGroup: + measurementTypes: + - measurementType: countera + - measurementType: counterb + managedObjectDNsBasic: + - DN: dna + - DN: dnb + - measurementGroup: + measurementTypes: + - measurementType: counterc + - measurementType: counterd + managedObjectDNsBasic: + - DN: dnc + - DN: dnd + org.onap.domain.pmsh.PMSH_MonitoringPolicyAutomationCompositionElement: + version: 1.2.3 + type: org.onap.policy.clamp.acm.PolicyAutomationCompositionElement + type_version: 1.0.0 + description: Automation composition element for the monitoring policy for Performance Management Subscription Handling + properties: + provider: Ericsson + participantType: + name: org.onap.policy.acm.PolicyAutomationCompositionParticipant + version: 2.3.1 + policy_type_id: + name: onap.policies.monitoring.pm-subscription-handler + version: 1.0.0 + policy_id: + get_input: pmsh_monitoring_policy + org.onap.domain.pmsh.PMSH_OperationalPolicyAutomationCompositionElement: + version: 1.2.3 + type: org.onap.policy.clamp.acm.PolicyAutomationCompositionElement + type_version: 1.0.0 + description: Automation composition element for the operational policy for Performance Management Subscription Handling + properties: + provider: Ericsson + participantType: + name: org.onap.policy.acm.PolicyAutomationCompositionParticipant + version: 2.3.1 + policy_type_id: + name: onap.policies.operational.pm-subscription-handler + version: 1.0.0 + policy_id: + get_input: pmsh_operational_policy + org.onap.domain.pmsh.DerivedPolicyAutomationCompositionElement: + version: 1.2.3 + type: org.onap.policy.clamp.acm.DerivedPolicyAutomationCompositionElement + type_version: 1.0.0 + description: Automation composition for Performance Management Subscription Handling + properties: + provider: Ericsson + elements: + - name: org.onap.domain.pmsh.PMSH_DCAEMicroservice + version: 1.2.3 + - name: org.onap.domain.pmsh.PMSH_MonitoringPolicyAutomationCompositionElement + version: 1.2.3 + - name: org.onap.domain.pmsh.PMSH_OperationalPolicyAutomationCompositionElement + version: 1.2.3 + org.onap.domain.pmsh.DerivedDerivedPolicyAutomationCompositionElement: + version: 1.2.3 + type: org.onap.policy.clamp.acm.DerivedDerivedPolicyAutomationCompositionElement + type_version: 1.0.0 + description: Automation composition for Performance Management Subscription Handling + properties: + provider: Ericsson Software Technologies + elements: + - name: org.onap.domain.pmsh.PMSH_DerivedTestMicroservice + version: 1.2.3 + org.onap.domain.pmsh.PMSHAutomationCompositionDefinition: + version: 1.2.3 + type: org.onap.policy.clamp.acm.AutomationComposition + type_version: 1.0.0 + description: Automation composition for Performance Management Subscription Handling + properties: + provider: Ericsson + elements: + - name: org.onap.domain.pmsh.PMSH_DCAEMicroservice + version: 1.2.3 + - name: org.onap.domain.pmsh.PMSH_MonitoringPolicyAutomationCompositionElement + version: 1.2.3 + - name: org.onap.domain.pmsh.PMSH_OperationalPolicyAutomationCompositionElement + version: 1.2.3 + policies: + - MICROSERVICE_vLoadBalancerMS_v1_0_dcae-pm-subscription-handler_1_0_0test: + type: onap.policies.monitoring.dcae-pm-subscription-handler + type_version: 1.0.0 + name: MICROSERVICE_vLoadBalancerMS_v1_0_dcae-pm-subscription-handler_1_0_0test + version: 1.0.0 + metadata: + policy-id: MICROSERVICE_vLoadBalancerMS_v1_0_dcae-pm-subscription-handler_1_0_0test + policy-version: 1.0.0 + properties: + pmsh_policy: + fileBasedGP: 15 + fileLocation: /pm/pm.xml + subscriptionName: subscriptiona + administrativeState: UNLOCKED + nfFilter: + onap.datatypes.monitoring.nfFilter: + modelVersionIDs: + - e80a6ae3-cafd-4d24-850d-e14c084a5ca9 + modelInvariantIDs: + - 5845y423-g654-6fju-po78-8n53154532k6 + - 7129e420-d396-4efb-af02-6b83499b12f8 + modelNames: [] + nfNames: + - '"^pnf1.*"' + measurementGroups: + - measurementGroup: + onap.datatypes.monitoring.measurementGroup: + measurementTypes: + - measurementType: + onap.datatypes.monitoring.measurementType: + measurementType: countera + - measurementType: + onap.datatypes.monitoring.measurementType: + measurementType: counterb + managedObjectDNsBasic: + - managedObjectDNsBasic: + onap.datatypes.monitoring.managedObjectDNsBasic: + DN: dna + - managedObjectDNsBasic: + onap.datatypes.monitoring.managedObjectDNsBasic: + DN: dnb + - measurementGroup: + onap.datatypes.monitoring.measurementGroup: + measurementTypes: + - measurementType: + onap.datatypes.monitoring.measurementType: + measurementType: counterc + - measurementType: + onap.datatypes.monitoring.measurementType: + measurementType: counterd + managedObjectDNsBasic: + - managedObjectDNsBasic: + onap.datatypes.monitoring.managedObjectDNsBasic: + DN: dnc + - managedObjectDNsBasic: + onap.datatypes.monitoring.managedObjectDNsBasic: + DN: dnd + - operational.apex.pmcontrol: + type: onap.policies.acm.operational.common.Apex + type_version: 1.0.0 + version: 1.0.0 + metadata: + policy-id: operational.apex.pmcontrol + policy-version: 1 + properties: + engineServiceParameters: + name: MyApexEngine + version: 0.0.1 + id: 45 + instanceCount: 2 + deploymentPort: 12561 + policy_type_impl: + apexPolicyModel: + key: + name: PMControlPolicy + version: 0.0.1 + keyInformation: + key: + name: PMControlPolicy_KeyInfo + version: 0.0.1 + keyInfoMap: + entry: + - key: + name: CDSActionIdentifiersType + version: 0.0.1 + value: + key: + name: CDSActionIdentifiersType + version: 0.0.1 + UUID: 6e5fa19b-14df-37e3-a4ae-8c537e861a82 + description: Generated description for concept referred to by key "CDSActionIdentifiersType:0.0.1" + - key: + name: CDSCreateResponseEvent + version: 0.0.1 + value: + key: + name: CDSCreateResponseEvent + version: 0.0.1 + UUID: 14b29e38-ac75-3273-aa4e-8583c0aa7dad + description: Generated description for concept referred to by key "CDSCreateResponseEvent:0.0.1" + - key: + name: CDSCreateResponsePayloadType + version: 0.0.1 + value: + key: + name: CDSCreateResponsePayloadType + version: 0.0.1 + UUID: 04573f8f-e772-30a5-b1d9-d7318d4a1e13 + description: Generated description for concept referred to by key "CDSCreateResponsePayloadType:0.0.1" + - key: + name: CDSCreateResponsePolicy + version: 0.0.1 + value: + key: + name: CDSCreateResponsePolicy + version: 0.0.1 + UUID: e126c965-fc09-3bfe-8f55-70f380a4a49c + description: Generated description for concept referred to by key "CDSCreateResponsePolicy:0.0.1" + - key: + name: CDSCreateResponseTask + version: 0.0.1 + value: + key: + name: CDSCreateResponseTask + version: 0.0.1 + UUID: 6165ee82-afd2-3aab-a517-f00b3f2461d2 + description: Generated description for concept referred to by key "CDSCreateResponseTask:0.0.1" + - key: + name: CDSCreateSubscriptionPayloadType + version: 0.0.1 + value: + key: + name: CDSCreateSubscriptionPayloadType + version: 0.0.1 + UUID: 8350ac5e-c157-38b9-9614-a0f93a830e60 + description: Generated description for concept referred to by key "CDSCreateSubscriptionPayloadType:0.0.1" + - key: + name: CDSCreateSubscriptionRequestEvent + version: 0.0.1 + value: + key: + name: CDSCreateSubscriptionRequestEvent + version: 0.0.1 + UUID: cfa325ba-226b-3a31-9183-ec43e2b6e9a2 + description: Generated description for concept referred to by key "CDSCreateSubscriptionRequestEvent:0.0.1" + - key: + name: CDSDeleteResponseEvent + version: 0.0.1 + value: + key: + name: CDSDeleteResponseEvent + version: 0.0.1 + UUID: 8be9c0fa-7437-3841-aff2-b3cec6ae3bd8 + description: Generated description for concept referred to by key "CDSDeleteResponseEvent:0.0.1" + - key: + name: CDSDeleteResponsePayloadType + version: 0.0.1 + value: + key: + name: CDSDeleteResponsePayloadType + version: 0.0.1 + UUID: 3fbfe0c9-152e-34d3-a504-09cd13c058d0 + description: Generated description for concept referred to by key "CDSDeleteResponsePayloadType:0.0.1" + - key: + name: CDSDeleteResponsePolicy + version: 0.0.1 + value: + key: + name: CDSDeleteResponsePolicy + version: 0.0.1 + UUID: a780251c-edd5-3132-b865-04313246b43c + description: Generated description for concept referred to by key "CDSDeleteResponsePolicy:0.0.1" + - key: + name: CDSDeleteResponseTask + version: 0.0.1 + value: + key: + name: CDSDeleteResponseTask + version: 0.0.1 + UUID: afce4555-3aa3-3521-a7d8-ee8cdf0d3efc + description: Generated description for concept referred to by key "CDSDeleteResponseTask:0.0.1" + - key: + name: CDSDeleteSubscriptionPayloadType + version: 0.0.1 + value: + key: + name: CDSDeleteSubscriptionPayloadType + version: 0.0.1 + UUID: 12658406-9147-3c9d-a38c-5ad5e30b092b + description: Generated description for concept referred to by key "CDSDeleteSubscriptionPayloadType:0.0.1" + - key: + name: CDSDeleteSubscriptionRequestEvent + version: 0.0.1 + value: + key: + name: CDSDeleteSubscriptionRequestEvent + version: 0.0.1 + UUID: 24380c95-9289-36e6-8cbf-0edefa15ccd9 + description: Generated description for concept referred to by key "CDSDeleteSubscriptionRequestEvent:0.0.1" + - key: + name: CDSRequestCommonHeaderType + version: 0.0.1 + value: + key: + name: CDSRequestCommonHeaderType + version: 0.0.1 + UUID: 35590ac0-062c-39f1-8786-b4ff716e30b1 + description: Generated description for concept referred to by key "CDSRequestCommonHeaderType:0.0.1" + - key: + name: CDSResponseCommonHeaderType + version: 0.0.1 + value: + key: + name: CDSResponseCommonHeaderType + version: 0.0.1 + UUID: dd7e1805-885a-350b-aaf9-ed541321ae3c + description: Generated description for concept referred to by key "CDSResponseCommonHeaderType:0.0.1" + - key: + name: CDSResponseStatusEvent + version: 0.0.1 + value: + key: + name: CDSResponseStatusEvent + version: 0.0.1 + UUID: 7986e21b-32f7-302e-9554-31f21b673493 + description: Generated description for concept referred to by key "CDSResponseStatusEvent:0.0.1" + - key: + name: CDSResponseStatusType + version: 0.0.1 + value: + key: + name: CDSResponseStatusType + version: 0.0.1 + UUID: 92b8a2cf-344e-3ce1-8cc0-2b7d3cb695fa + description: Generated description for concept referred to by key "CDSResponseStatusType:0.0.1" + - key: + name: CreateSubscriptionPayloadEvent + version: 0.0.1 + value: + key: + name: CreateSubscriptionPayloadEvent + version: 0.0.1 + UUID: 92162397-1a8e-3a3f-a469-d2af7700af4a + description: Generated description for concept referred to by key "CreateSubscriptionPayloadEvent:0.0.1" + - key: + name: CreateSubscriptionPayloadTask + version: 0.0.1 + value: + key: + name: CreateSubscriptionPayloadTask + version: 0.0.1 + UUID: bc0c69f0-52ed-38ea-b468-ae4a6fd1730d + description: Generated description for concept referred to by key "CreateSubscriptionPayloadTask:0.0.1" + - key: + name: CreateSubscriptionRequestTask + version: 0.0.1 + value: + key: + name: CreateSubscriptionRequestTask + version: 0.0.1 + UUID: 89cb75e9-f06c-30d3-b4ff-698d45f63869 + description: Generated description for concept referred to by key "CreateSubscriptionRequestTask:0.0.1" + - key: + name: DeleteSubscriptionPayloadEvent + version: 0.0.1 + value: + key: + name: DeleteSubscriptionPayloadEvent + version: 0.0.1 + UUID: 994fa441-04ab-33bb-832d-1cd12ab5d074 + description: Generated description for concept referred to by key "DeleteSubscriptionPayloadEvent:0.0.1" + - key: + name: DeleteSubscriptionPayloadTask + version: 0.0.1 + value: + key: + name: DeleteSubscriptionPayloadTask + version: 0.0.1 + UUID: 0f519117-5fea-3e4b-941f-8f778100465f + description: Generated description for concept referred to by key "DeleteSubscriptionPayloadTask:0.0.1" + - key: + name: DeleteSubscriptionRequestTask + version: 0.0.1 + value: + key: + name: DeleteSubscriptionRequestTask + version: 0.0.1 + UUID: acb772fe-d442-39e3-98f9-b1080caf4150 + description: Generated description for concept referred to by key "DeleteSubscriptionRequestTask:0.0.1" + - key: + name: MRResponseEvent + version: 0.0.1 + value: + key: + name: MRResponseEvent + version: 0.0.1 + UUID: 13c747a3-6bae-3bcf-9c80-b152e01dc194 + description: Generated description for concept referred to by key "MRResponseEvent:0.0.1" + - key: + name: PMControlPolicy + version: 0.0.1 + value: + key: + name: PMControlPolicy + version: 0.0.1 + UUID: acf1e55c-7bc5-3bd5-975a-0ca54afcd8a4 + description: Generated description for concept referred to by key "PMControlPolicy:0.0.1" + - key: + name: PMControlPolicy_Albums + version: 0.0.1 + value: + key: + name: PMControlPolicy_Albums + version: 0.0.1 + UUID: b38ad204-c2c8-32f4-9b5a-dda0aeb0145b + description: Generated description for concept referred to by key "PMControlPolicy_Albums:0.0.1" + - key: + name: PMControlPolicy_Events + version: 0.0.1 + value: + key: + name: PMControlPolicy_Events + version: 0.0.1 + UUID: be3871a0-c42a-3113-a066-82d192840eca + description: Generated description for concept referred to by key "PMControlPolicy_Events:0.0.1" + - key: + name: PMControlPolicy_KeyInfo + version: 0.0.1 + value: + key: + name: PMControlPolicy_KeyInfo + version: 0.0.1 + UUID: ced37634-28a4-3178-b7f6-2980794927b0 + description: Generated description for concept referred to by key "PMControlPolicy_KeyInfo:0.0.1" + - key: + name: PMControlPolicy_Policies + version: 0.0.1 + value: + key: + name: PMControlPolicy_Policies + version: 0.0.1 + UUID: be3d180d-ef9c-3a75-8e9c-84271a038bed + description: Generated description for concept referred to by key "PMControlPolicy_Policies:0.0.1" + - key: + name: PMControlPolicy_Schemas + version: 0.0.1 + value: + key: + name: PMControlPolicy_Schemas + version: 0.0.1 + UUID: e61973f1-189c-39e5-82f6-0d3afe298a20 + description: Generated description for concept referred to by key "PMControlPolicy_Schemas:0.0.1" + - key: + name: PMControlPolicy_Tasks + version: 0.0.1 + value: + key: + name: PMControlPolicy_Tasks + version: 0.0.1 + UUID: 5658adb3-2962-30a3-a241-fae75bb8eb4a + description: Generated description for concept referred to by key "PMControlPolicy_Tasks:0.0.1" + - key: + name: PMSubscriptionAlbum + version: 0.0.1 + value: + key: + name: PMSubscriptionAlbum + version: 0.0.1 + UUID: c2bd6f0d-6854-317a-9be2-97c08338428c + description: Generated description for concept referred to by key "PMSubscriptionAlbum:0.0.1" + - key: + name: PMSubscriptionOutputEvent + version: 0.0.1 + value: + key: + name: PMSubscriptionOutputEvent + version: 0.0.1 + UUID: 992b7819-9f69-3aa0-bb0f-6e45ea15ce05 + description: Generated description for concept referred to by key "PMSubscriptionOutputEvent:0.0.1" + - key: + name: PMSubscriptionType + version: 0.0.1 + value: + key: + name: PMSubscriptionType + version: 0.0.1 + UUID: 73c1c397-4fc3-357f-93b6-a8ad707fbaae + description: Generated description for concept referred to by key "PMSubscriptionType:0.0.1" + - key: + name: ReceiveEventPolicy + version: 0.0.1 + value: + key: + name: ReceiveEventPolicy + version: 0.0.1 + UUID: 568b7345-9de1-36d3-b6a3-9b857e6809a1 + description: Generated description for concept referred to by key "ReceiveEventPolicy:0.0.1" + - key: + name: ReceiveSubscriptionTask + version: 0.0.1 + value: + key: + name: ReceiveSubscriptionTask + version: 0.0.1 + UUID: f596afc8-100c-35eb-92c8-352355ea457d + description: Generated description for concept referred to by key "ReceiveSubscriptionTask:0.0.1" + - key: + name: SimpleIntType + version: 0.0.1 + value: + key: + name: SimpleIntType + version: 0.0.1 + UUID: 153791fd-ae0a-36a7-88a5-309a7936415d + description: Generated description for concept referred to by key "SimpleIntType:0.0.1" + - key: + name: SimpleStringType + version: 0.0.1 + value: + key: + name: SimpleStringType + version: 0.0.1 + UUID: 8a4957cf-9493-3a76-8c22-a208e23259af + description: Generated description for concept referred to by key "SimpleStringType:0.0.1" + - key: + name: SubscriptionStatusType + version: 0.0.1 + value: + key: + name: SubscriptionStatusType + version: 0.0.1 + UUID: 597643b1-9db1-31ce-85d0-e1c63c43b30b + description: Generated description for concept referred to by key "SubscriptionStatusType:0.0.1" + - key: + name: SubscriptionType + version: 0.0.1 + value: + key: + name: SubscriptionType + version: 0.0.1 + UUID: 184547bb-7d64-3cb2-a273-d7185102c5ce + description: Generated description for concept referred to by key "SubscriptionType:0.0.1" + - key: + name: UUIDType + version: 0.0.1 + value: + key: + name: UUIDType + version: 0.0.1 + UUID: 6a8cc68e-dfc8-3403-9c6d-071c886b319c + description: Generated description for concept referred to by key "UUIDType:0.0.1" + - key: + name: pmsh-operational-policy + version: 0.0.1 + value: + key: + name: pmsh-operational-policy + version: 0.0.1 + UUID: fdf2c9ff-6422-3ea6-b6b6-49b12116265d + description: Generated description for concept referred to by key "pmsh-operational-policy:0.0.1" + policies: + key: + name: PMControlPolicy_Policies + version: 0.0.1 + policyMap: + entry: + - key: + name: CDSCreateResponsePolicy + version: 0.0.1 + value: + policyKey: + name: CDSCreateResponsePolicy + version: 0.0.1 + template: Freestyle + state: + entry: + - key: CDSCreateResponseState + value: + stateKey: + parentKeyName: CDSCreateResponsePolicy + parentKeyVersion: 0.0.1 + parentLocalName: 'NULL' + localName: CDSCreateResponseState + trigger: + name: CDSCreateResponseEvent + version: 0.0.1 + stateOutputs: + entry: + - key: ResponseOutput + value: + key: + parentKeyName: CDSCreateResponsePolicy + parentKeyVersion: 0.0.1 + parentLocalName: CDSCreateResponseState + localName: ResponseOutput + outgoingEvent: + name: CDSResponseStatusEvent + version: 0.0.1 + nextState: + parentKeyName: 'NULL' + parentKeyVersion: 0.0.0 + parentLocalName: 'NULL' + localName: 'NULL' + contextAlbumReference: [] + taskSelectionLogic: + key: 'NULL' + logicFlavour: UNDEFINED + logic: '' + stateFinalizerLogicMap: + entry: [] + defaultTask: + name: CDSCreateResponseTask + version: 0.0.1 + taskReferences: + entry: + - key: + name: CDSCreateResponseTask + version: 0.0.1 + value: + key: + parentKeyName: CDSCreateResponsePolicy + parentKeyVersion: 0.0.1 + parentLocalName: CDSCreateResponseState + localName: CDSCreateResponsePolicy + outputType: DIRECT + output: + parentKeyName: CDSCreateResponsePolicy + parentKeyVersion: 0.0.1 + parentLocalName: CDSCreateResponseState + localName: ResponseOutput + firstState: CDSCreateResponseState + - key: + name: CDSDeleteResponsePolicy + version: 0.0.1 + value: + policyKey: + name: CDSDeleteResponsePolicy + version: 0.0.1 + template: Freestyle + state: + entry: + - key: CDSDeleteResponseState + value: + stateKey: + parentKeyName: CDSDeleteResponsePolicy + parentKeyVersion: 0.0.1 + parentLocalName: 'NULL' + localName: CDSDeleteResponseState + trigger: + name: CDSDeleteResponseEvent + version: 0.0.1 + stateOutputs: + entry: + - key: ResponseOutput + value: + key: + parentKeyName: CDSDeleteResponsePolicy + parentKeyVersion: 0.0.1 + parentLocalName: CDSDeleteResponseState + localName: ResponseOutput + outgoingEvent: + name: CDSResponseStatusEvent + version: 0.0.1 + nextState: + parentKeyName: 'NULL' + parentKeyVersion: 0.0.0 + parentLocalName: 'NULL' + localName: 'NULL' + contextAlbumReference: [] + taskSelectionLogic: + key: 'NULL' + logicFlavour: UNDEFINED + logic: '' + stateFinalizerLogicMap: + entry: [] + defaultTask: + name: CDSDeleteResponseTask + version: 0.0.1 + taskReferences: + entry: + - key: + name: CDSDeleteResponseTask + version: 0.0.1 + value: + key: + parentKeyName: CDSDeleteResponsePolicy + parentKeyVersion: 0.0.1 + parentLocalName: CDSDeleteResponseState + localName: CDSDeleteResponsePolicy + outputType: DIRECT + output: + parentKeyName: CDSDeleteResponsePolicy + parentKeyVersion: 0.0.1 + parentLocalName: CDSDeleteResponseState + localName: ResponseOutput + firstState: CDSDeleteResponseState + - key: + name: ReceiveEventPolicy + version: 0.0.1 + value: + policyKey: + name: ReceiveEventPolicy + version: 0.0.1 + template: Freestyle + state: + entry: + - key: CreateOrDeleteState + value: + stateKey: + parentKeyName: ReceiveEventPolicy + parentKeyVersion: 0.0.1 + parentLocalName: 'NULL' + localName: CreateOrDeleteState + trigger: + name: PMSubscriptionOutputEvent + version: 0.0.1 + stateOutputs: + entry: + - key: CreateSubscriptionPayload + value: + key: + parentKeyName: ReceiveEventPolicy + parentKeyVersion: 0.0.1 + parentLocalName: CreateOrDeleteState + localName: CreateSubscriptionPayload + outgoingEvent: + name: CreateSubscriptionPayloadEvent + version: 0.0.1 + nextState: + parentKeyName: ReceiveEventPolicy + parentKeyVersion: 0.0.1 + parentLocalName: 'NULL' + localName: CreateSubscription + - key: DeleteSubscriptionPayload + value: + key: + parentKeyName: ReceiveEventPolicy + parentKeyVersion: 0.0.1 + parentLocalName: CreateOrDeleteState + localName: DeleteSubscriptionPayload + outgoingEvent: + name: DeleteSubscriptionPayloadEvent + version: 0.0.1 + nextState: + parentKeyName: ReceiveEventPolicy + parentKeyVersion: 0.0.1 + parentLocalName: 'NULL' + localName: DeleteSubscription + contextAlbumReference: + - name: PMSubscriptionAlbum + version: 0.0.1 + taskSelectionLogic: + key: TaskSelectionLogic + logicFlavour: JAVASCRIPT + logic: |- + /* + * ============LICENSE_START======================================================= + * Copyright (C) 2020 Nordix. 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); + + var pmSubscriptionInfo = executor.getContextAlbum("PMSubscriptionAlbum").get(executor.inFields.get("albumID").toString()) + var changeType = pmSubscriptionInfo.get("changeType").toString() + + executor.logger.info("Change Type is " + changeType) + + if ("CREATE".equals(changeType)) { + executor.logger.info("Choosing to create a subscription") + executor.subject.getTaskKey("CreateSubscriptionPayloadTask").copyTo(executor.selectedTask); + } + else if ("DELETE".equals(changeType)) { + executor.logger.info("Choosing to delete a subscription") + executor.subject.getTaskKey("DeleteSubscriptionPayloadTask").copyTo(executor.selectedTask); + } + + //var returnValue = executor.isTrue; + true; + stateFinalizerLogicMap: + entry: [] + defaultTask: + name: CreateSubscriptionPayloadTask + version: 0.0.1 + taskReferences: + entry: + - key: + name: CreateSubscriptionPayloadTask + version: 0.0.1 + value: + key: + parentKeyName: ReceiveEventPolicy + parentKeyVersion: 0.0.1 + parentLocalName: CreateOrDeleteState + localName: ReceiveEventPolicy + outputType: DIRECT + output: + parentKeyName: ReceiveEventPolicy + parentKeyVersion: 0.0.1 + parentLocalName: CreateOrDeleteState + localName: CreateSubscriptionPayload + - key: + name: DeleteSubscriptionPayloadTask + version: 0.0.1 + value: + key: + parentKeyName: ReceiveEventPolicy + parentKeyVersion: 0.0.1 + parentLocalName: CreateOrDeleteState + localName: ReceiveEventPolicy + outputType: DIRECT + output: + parentKeyName: ReceiveEventPolicy + parentKeyVersion: 0.0.1 + parentLocalName: CreateOrDeleteState + localName: DeleteSubscriptionPayload + - key: CreateSubscription + value: + stateKey: + parentKeyName: ReceiveEventPolicy + parentKeyVersion: 0.0.1 + parentLocalName: 'NULL' + localName: CreateSubscription + trigger: + name: CreateSubscriptionPayloadEvent + version: 0.0.1 + stateOutputs: + entry: + - key: IssueCreateSubscriptionRequestOutput + value: + key: + parentKeyName: ReceiveEventPolicy + parentKeyVersion: 0.0.1 + parentLocalName: CreateSubscription + localName: IssueCreateSubscriptionRequestOutput + outgoingEvent: + name: CDSCreateSubscriptionRequestEvent + version: 0.0.1 + nextState: + parentKeyName: 'NULL' + parentKeyVersion: 0.0.0 + parentLocalName: 'NULL' + localName: 'NULL' + contextAlbumReference: + - name: PMSubscriptionAlbum + version: 0.0.1 + taskSelectionLogic: + key: 'NULL' + logicFlavour: UNDEFINED + logic: '' + stateFinalizerLogicMap: + entry: [] + defaultTask: + name: CreateSubscriptionRequestTask + version: 0.0.1 + taskReferences: + entry: + - key: + name: CreateSubscriptionRequestTask + version: 0.0.1 + value: + key: + parentKeyName: ReceiveEventPolicy + parentKeyVersion: 0.0.1 + parentLocalName: CreateSubscription + localName: ReceiveEventPolicy + outputType: DIRECT + output: + parentKeyName: ReceiveEventPolicy + parentKeyVersion: 0.0.1 + parentLocalName: CreateSubscription + localName: IssueCreateSubscriptionRequestOutput + - key: DeleteSubscription + value: + stateKey: + parentKeyName: ReceiveEventPolicy + parentKeyVersion: 0.0.1 + parentLocalName: 'NULL' + localName: DeleteSubscription + trigger: + name: DeleteSubscriptionPayloadEvent + version: 0.0.1 + stateOutputs: + entry: + - key: IssueDeleteSubscriptionRequestOutput + value: + key: + parentKeyName: ReceiveEventPolicy + parentKeyVersion: 0.0.1 + parentLocalName: DeleteSubscription + localName: IssueDeleteSubscriptionRequestOutput + outgoingEvent: + name: CDSDeleteSubscriptionRequestEvent + version: 0.0.1 + nextState: + parentKeyName: 'NULL' + parentKeyVersion: 0.0.0 + parentLocalName: 'NULL' + localName: 'NULL' + contextAlbumReference: + - name: PMSubscriptionAlbum + version: 0.0.1 + taskSelectionLogic: + key: 'NULL' + logicFlavour: UNDEFINED + logic: '' + stateFinalizerLogicMap: + entry: [] + defaultTask: + name: DeleteSubscriptionRequestTask + version: 0.0.1 + taskReferences: + entry: + - key: + name: DeleteSubscriptionRequestTask + version: 0.0.1 + value: + key: + parentKeyName: ReceiveEventPolicy + parentKeyVersion: 0.0.1 + parentLocalName: DeleteSubscription + localName: ReceiveEventPolicy + outputType: DIRECT + output: + parentKeyName: ReceiveEventPolicy + parentKeyVersion: 0.0.1 + parentLocalName: DeleteSubscription + localName: IssueDeleteSubscriptionRequestOutput + - key: ReceiveSubscriptionState + value: + stateKey: + parentKeyName: ReceiveEventPolicy + parentKeyVersion: 0.0.1 + parentLocalName: 'NULL' + localName: ReceiveSubscriptionState + trigger: + name: pmsh-operational-policy + version: 0.0.1 + stateOutputs: + entry: + - key: ReceivePMSubscriptionOutput + value: + key: + parentKeyName: ReceiveEventPolicy + parentKeyVersion: 0.0.1 + parentLocalName: ReceiveSubscriptionState + localName: ReceivePMSubscriptionOutput + outgoingEvent: + name: PMSubscriptionOutputEvent + version: 0.0.1 + nextState: + parentKeyName: ReceiveEventPolicy + parentKeyVersion: 0.0.1 + parentLocalName: 'NULL' + localName: CreateOrDeleteState + contextAlbumReference: + - name: PMSubscriptionAlbum + version: 0.0.1 + taskSelectionLogic: + key: 'NULL' + logicFlavour: UNDEFINED + logic: '' + stateFinalizerLogicMap: + entry: [] + defaultTask: + name: ReceiveSubscriptionTask + version: 0.0.1 + taskReferences: + entry: + - key: + name: ReceiveSubscriptionTask + version: 0.0.1 + value: + key: + parentKeyName: ReceiveEventPolicy + parentKeyVersion: 0.0.1 + parentLocalName: ReceiveSubscriptionState + localName: ReceiveEventPolicy + outputType: DIRECT + output: + parentKeyName: ReceiveEventPolicy + parentKeyVersion: 0.0.1 + parentLocalName: ReceiveSubscriptionState + localName: ReceivePMSubscriptionOutput + firstState: ReceiveSubscriptionState + tasks: + key: + name: PMControlPolicy_Tasks + version: 0.0.1 + taskMap: + entry: + - key: + name: CDSCreateResponseTask + version: 0.0.1 + value: + key: + name: CDSCreateResponseTask + version: 0.0.1 + inputFields: + entry: + - key: actionIdentifiers + value: + key: actionIdentifiers + fieldSchemaKey: + name: CDSActionIdentifiersType + version: 0.0.1 + optional: false + - key: commonHeader + value: + key: commonHeader + fieldSchemaKey: + name: CDSResponseCommonHeaderType + version: 0.0.1 + optional: false + - key: payload + value: + key: payload + fieldSchemaKey: + name: CDSCreateResponsePayloadType + version: 0.0.1 + optional: false + - key: status + value: + key: status + fieldSchemaKey: + name: CDSResponseStatusType + version: 0.0.1 + optional: false + outputFields: + entry: + - key: status + value: + key: status + fieldSchemaKey: + name: SubscriptionStatusType + version: 0.0.1 + optional: false + taskParameters: + entry: [] + contextAlbumReference: + - name: PMSubscriptionAlbum + version: 0.0.1 + taskLogic: + key: TaskLogic + logicFlavour: JAVASCRIPT + logic: |- + /* + * ============LICENSE_START======================================================= + * Copyright (C) 2020 Nordix. 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); + + var commonHeader = executor.inFields.get("commonHeader") + var response = executor.inFields.get("payload") + var albumID = commonHeader.get("requestId") + + var pmSubscriptionInfo = executor.getContextAlbum("PMSubscriptionAlbum").get(albumID.toString()); + var responseStatus = executor.subject.getOutFieldSchemaHelper("status").createNewInstance(); + + responseStatus.put("subscriptionName", pmSubscriptionInfo.get("subscription").get("subscriptionName")) + responseStatus.put("nfName", pmSubscriptionInfo.get("nfName")) + responseStatus.put("changeType", pmSubscriptionInfo.get("changeType")) + + var status = response.get(pmSubscriptionInfo.get("changeType").toLowerCase() + "_DasH_subscription_DasH_response").get("odl_DasH_response").get("status") + + executor.logger.info("RESPONSE STATUS = " + status) + + if(status == "success") { + responseStatus.put("message", "success") + } else { + responseStatus.put("message", "failed") + } + + executor.outFields.put("status", responseStatus) + + //var returnValue = executor.isTrue; + true; + - key: + name: CDSDeleteResponseTask + version: 0.0.1 + value: + key: + name: CDSDeleteResponseTask + version: 0.0.1 + inputFields: + entry: + - key: actionIdentifiers + value: + key: actionIdentifiers + fieldSchemaKey: + name: CDSActionIdentifiersType + version: 0.0.1 + optional: false + - key: commonHeader + value: + key: commonHeader + fieldSchemaKey: + name: CDSResponseCommonHeaderType + version: 0.0.1 + optional: false + - key: payload + value: + key: payload + fieldSchemaKey: + name: CDSDeleteResponsePayloadType + version: 0.0.1 + optional: false + - key: status + value: + key: status + fieldSchemaKey: + name: CDSResponseStatusType + version: 0.0.1 + optional: false + outputFields: + entry: + - key: status + value: + key: status + fieldSchemaKey: + name: SubscriptionStatusType + version: 0.0.1 + optional: false + taskParameters: + entry: [] + contextAlbumReference: + - name: PMSubscriptionAlbum + version: 0.0.1 + taskLogic: + key: TaskLogic + logicFlavour: JAVASCRIPT + logic: |- + /* + * ============LICENSE_START======================================================= + * Copyright (C) 2020 Nordix. 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); + + var commonHeader = executor.inFields.get("commonHeader") + var response = executor.inFields.get("payload") + var albumID = commonHeader.get("requestId") + + var pmSubscriptionInfo = executor.getContextAlbum("PMSubscriptionAlbum").get(albumID.toString()); + var responseStatus = executor.subject.getOutFieldSchemaHelper("status").createNewInstance(); + + responseStatus.put("subscriptionName", pmSubscriptionInfo.get("subscription").get("subscriptionName")) + responseStatus.put("nfName", pmSubscriptionInfo.get("nfName")) + responseStatus.put("changeType", pmSubscriptionInfo.get("changeType")) + + var status = response.get(pmSubscriptionInfo.get("changeType").toLowerCase() + "_DasH_subscription_DasH_response").get("odl_DasH_response").get("status") + + executor.logger.info("RESPONSE STATUS = " + status) + + if(status == "success") { + responseStatus.put("message", "success") + } else { + responseStatus.put("message", "failed") + } + + executor.outFields.put("status", responseStatus) + + //var returnValue = executor.isTrue; + true; + - key: + name: CreateSubscriptionPayloadTask + version: 0.0.1 + value: + key: + name: CreateSubscriptionPayloadTask + version: 0.0.1 + inputFields: + entry: + - key: albumID + value: + key: albumID + fieldSchemaKey: + name: UUIDType + version: 0.0.1 + optional: false + outputFields: + entry: + - key: albumID + value: + key: albumID + fieldSchemaKey: + name: UUIDType + version: 0.0.1 + optional: false + - key: payload + value: + key: payload + fieldSchemaKey: + name: CDSCreateSubscriptionPayloadType + version: 0.0.1 + optional: false + taskParameters: + entry: [] + contextAlbumReference: + - name: PMSubscriptionAlbum + version: 0.0.1 + taskLogic: + key: TaskLogic + logicFlavour: JAVASCRIPT + logic: |- + /* + * ============LICENSE_START======================================================= + * Copyright (C) 2020 Nordix. 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); + + var pmSubscriptionInfo = executor.getContextAlbum("PMSubscriptionAlbum").get(executor.inFields.get("albumID").toString()) + + var changeType = pmSubscriptionInfo.get("changeType").toLowerCase() + + var payloadProperties = executor.subject.getOutFieldSchemaHelper("payload").createNewSubInstance(changeType + "_DasH_subscription_DasH_properties_record"); + + payloadProperties.put("nfName", pmSubscriptionInfo.get("nfName")) + payloadProperties.put("subscriptionName", pmSubscriptionInfo.get("subscription").get("subscriptionName")) + payloadProperties.put("administrativeState", pmSubscriptionInfo.get("subscription").get("administrativeState")) + payloadProperties.put("fileBasedGP", pmSubscriptionInfo.get("subscription").get("fileBasedGP").toString()) + payloadProperties.put("fileLocation", pmSubscriptionInfo.get("subscription").get("fileLocation")) + payloadProperties.put("measurementGroups", pmSubscriptionInfo.get("subscription").get("measurementGroups")) + + var payloadEntry = executor.subject.getOutFieldSchemaHelper("payload").createNewSubInstance("CDSRequestPayloadEntry"); + payloadEntry.put(changeType + "_DasH_subscription_DasH_properties", payloadProperties) + + var payload = executor.subject.getOutFieldSchemaHelper("payload").createNewInstance(); + payload.put(changeType + "_DasH_subscription_DasH_request", payloadEntry); + + executor.outFields.put("albumID", executor.inFields.get("albumID")) + executor.outFields.put("payload", payload); + + //var returnValue = executor.isTrue; + true; + - key: + name: CreateSubscriptionRequestTask + version: 0.0.1 + value: + key: + name: CreateSubscriptionRequestTask + version: 0.0.1 + inputFields: + entry: + - key: albumID + value: + key: albumID + fieldSchemaKey: + name: UUIDType + version: 0.0.1 + optional: false + - key: payload + value: + key: payload + fieldSchemaKey: + name: CDSCreateSubscriptionPayloadType + version: 0.0.1 + optional: false + outputFields: + entry: + - key: actionIdentifiers + value: + key: actionIdentifiers + fieldSchemaKey: + name: CDSActionIdentifiersType + version: 0.0.1 + optional: false + - key: commonHeader + value: + key: commonHeader + fieldSchemaKey: + name: CDSRequestCommonHeaderType + version: 0.0.1 + optional: false + - key: payload + value: + key: payload + fieldSchemaKey: + name: CDSCreateSubscriptionPayloadType + version: 0.0.1 + optional: false + taskParameters: + entry: [] + contextAlbumReference: + - name: PMSubscriptionAlbum + version: 0.0.1 + taskLogic: + key: TaskLogic + logicFlavour: JAVASCRIPT + logic: |- + /* + * ============LICENSE_START======================================================= + * Copyright (C) 2020 Nordix. 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); + + var pmSubscriptionInfo = executor.getContextAlbum("PMSubscriptionAlbum").get(executor.inFields.get("albumID").toString()) + + var changeType = pmSubscriptionInfo.get("changeType").toLowerCase() + var blueprintName = pmSubscriptionInfo.get("blueprintName").toLowerCase() + var blueprintVersion = pmSubscriptionInfo.get("blueprintVersion").toLowerCase() + var payload = executor.inFields.get("payload") + var actionName = changeType + "-subscription" + + var commonHeader = executor.subject.getOutFieldSchemaHelper("commonHeader").createNewInstance(); + commonHeader.put("originatorId", "sdnc"); + commonHeader.put("requestId", executor.inFields.get("albumID").toString()); + commonHeader.put("subRequestId", "sub-123456-1000"); + + var actionIdentifiers = executor.subject.getOutFieldSchemaHelper("actionIdentifiers").createNewInstance(); + actionIdentifiers.put("actionName", actionName); + actionIdentifiers.put("blueprintName", blueprintName); + actionIdentifiers.put("blueprintVersion", blueprintVersion); + actionIdentifiers.put("mode", "sync"); + + executor.outFields.put("commonHeader", commonHeader); + executor.outFields.put("actionIdentifiers", actionIdentifiers); + executor.outFields.put("payload", payload); + + //var returnValue = executor.isTrue; + true; + - key: + name: DeleteSubscriptionPayloadTask + version: 0.0.1 + value: + key: + name: DeleteSubscriptionPayloadTask + version: 0.0.1 + inputFields: + entry: + - key: albumID + value: + key: albumID + fieldSchemaKey: + name: UUIDType + version: 0.0.1 + optional: false + outputFields: + entry: + - key: albumID + value: + key: albumID + fieldSchemaKey: + name: UUIDType + version: 0.0.1 + optional: false + - key: payload + value: + key: payload + fieldSchemaKey: + name: CDSDeleteSubscriptionPayloadType + version: 0.0.1 + optional: false + taskParameters: + entry: [] + contextAlbumReference: + - name: PMSubscriptionAlbum + version: 0.0.1 + taskLogic: + key: TaskLogic + logicFlavour: JAVASCRIPT + logic: |- + /* + * ============LICENSE_START======================================================= + * Copyright (C) 2020 Nordix. 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); + + var pmSubscriptionInfo = executor.getContextAlbum("PMSubscriptionAlbum").get(executor.inFields.get("albumID").toString()) + + var changeType = pmSubscriptionInfo.get("changeType").toLowerCase() + + var payloadProperties = executor.subject.getOutFieldSchemaHelper("payload").createNewSubInstance(changeType + "_DasH_subscription_DasH_properties_record"); + + payloadProperties.put("nfName", pmSubscriptionInfo.get("nfName")) + payloadProperties.put("subscriptionName", pmSubscriptionInfo.get("subscription").get("subscriptionName")) + payloadProperties.put("administrativeState", pmSubscriptionInfo.get("subscription").get("administrativeState")) + payloadProperties.put("fileBasedGP", pmSubscriptionInfo.get("subscription").get("fileBasedGP").toString()) + payloadProperties.put("fileLocation", pmSubscriptionInfo.get("subscription").get("fileLocation")) + payloadProperties.put("measurementGroups", pmSubscriptionInfo.get("subscription").get("measurementGroups")) + + var payloadEntry = executor.subject.getOutFieldSchemaHelper("payload").createNewSubInstance("CDSRequestPayloadEntry"); + payloadEntry.put(changeType + "_DasH_subscription_DasH_properties", payloadProperties) + + var payload = executor.subject.getOutFieldSchemaHelper("payload").createNewInstance(); + payload.put(changeType + "_DasH_subscription_DasH_request", payloadEntry); + + executor.outFields.put("albumID", executor.inFields.get("albumID")) + executor.outFields.put("payload", payload); + + //var returnValue = executor.isTrue; + true; + - key: + name: DeleteSubscriptionRequestTask + version: 0.0.1 + value: + key: + name: DeleteSubscriptionRequestTask + version: 0.0.1 + inputFields: + entry: + - key: albumID + value: + key: albumID + fieldSchemaKey: + name: UUIDType + version: 0.0.1 + optional: false + - key: payload + value: + key: payload + fieldSchemaKey: + name: CDSDeleteSubscriptionPayloadType + version: 0.0.1 + optional: false + outputFields: + entry: + - key: actionIdentifiers + value: + key: actionIdentifiers + fieldSchemaKey: + name: CDSActionIdentifiersType + version: 0.0.1 + optional: false + - key: commonHeader + value: + key: commonHeader + fieldSchemaKey: + name: CDSRequestCommonHeaderType + version: 0.0.1 + optional: false + - key: payload + value: + key: payload + fieldSchemaKey: + name: CDSDeleteSubscriptionPayloadType + version: 0.0.1 + optional: false + taskParameters: + entry: [] + contextAlbumReference: + - name: PMSubscriptionAlbum + version: 0.0.1 + taskLogic: + key: TaskLogic + logicFlavour: JAVASCRIPT + logic: |- + /* + * ============LICENSE_START======================================================= + * Copyright (C) 2020 Nordix. 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); + + var pmSubscriptionInfo = executor.getContextAlbum("PMSubscriptionAlbum").get(executor.inFields.get("albumID").toString()) + + var changeType = pmSubscriptionInfo.get("changeType").toLowerCase() + var blueprintName = pmSubscriptionInfo.get("blueprintName").toLowerCase() + var blueprintVersion = pmSubscriptionInfo.get("blueprintVersion").toLowerCase() + var payload = executor.inFields.get("payload") + var actionName = changeType + "-subscription" + + var commonHeader = executor.subject.getOutFieldSchemaHelper("commonHeader").createNewInstance(); + commonHeader.put("originatorId", "sdnc"); + commonHeader.put("requestId", executor.inFields.get("albumID").toString()); + commonHeader.put("subRequestId", "sub-123456-1000"); + + var actionIdentifiers = executor.subject.getOutFieldSchemaHelper("actionIdentifiers").createNewInstance(); + actionIdentifiers.put("actionName", actionName); + actionIdentifiers.put("blueprintName", blueprintName); + actionIdentifiers.put("blueprintVersion", blueprintVersion); + actionIdentifiers.put("mode", "sync"); + + executor.outFields.put("commonHeader", commonHeader); + executor.outFields.put("actionIdentifiers", actionIdentifiers); + executor.outFields.put("payload", payload); + + //var returnValue = executor.isTrue; + true; + - key: + name: ReceiveSubscriptionTask + version: 0.0.1 + value: + key: + name: ReceiveSubscriptionTask + version: 0.0.1 + inputFields: + entry: + - key: blueprintName + value: + key: blueprintName + fieldSchemaKey: + name: SimpleStringType + version: 0.0.1 + optional: false + - key: blueprintVersion + value: + key: blueprintVersion + fieldSchemaKey: + name: SimpleStringType + version: 0.0.1 + optional: false + - key: changeType + value: + key: changeType + fieldSchemaKey: + name: SimpleStringType + version: 0.0.1 + optional: false + - key: closedLoopControlName + value: + key: closedLoopControlName + fieldSchemaKey: + name: SimpleStringType + version: 0.0.1 + optional: false + - key: nfName + value: + key: nfName + fieldSchemaKey: + name: SimpleStringType + version: 0.0.1 + optional: false + - key: policyName + value: + key: policyName + fieldSchemaKey: + name: SimpleStringType + version: 0.0.1 + optional: false + - key: subscription + value: + key: subscription + fieldSchemaKey: + name: SubscriptionType + version: 0.0.1 + optional: false + outputFields: + entry: + - key: albumID + value: + key: albumID + fieldSchemaKey: + name: UUIDType + version: 0.0.1 + optional: false + taskParameters: + entry: [] + contextAlbumReference: + - name: PMSubscriptionAlbum + version: 0.0.1 + taskLogic: + key: TaskLogic + logicFlavour: JAVASCRIPT + logic: |- + /* + * ============LICENSE_START======================================================= + * Copyright (C) 2020 Nordix. 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========================================================= + */ + var uuidType = java.util.UUID; + + executor.logger.info(executor.subject.id); + + //albumID will be used to fetch info from our album later + var albumID = uuidType.randomUUID(); + var pmSubscriptionInfo = executor.getContextAlbum("PMSubscriptionAlbum").getSchemaHelper().createNewInstance(); + var returnValue = true; + + if(executor.inFields.get("policyName") != null) { + executor.logger.info("nfName in receive sub event " + executor.inFields.get("nfName")); + + var changeType = executor.inFields.get("changeType") + var nfName = executor.inFields.get("nfName") + var policyName = executor.inFields.get("policyName") + var closedLoopControlName = executor.inFields.get("closedLoopControlName") + var subscription = executor.inFields.get("subscription") + var blueprintName = executor.inFields.get("blueprintName") + var blueprintVersion = executor.inFields.get("blueprintVersion") + + pmSubscriptionInfo.put("nfName", executor.inFields.get("nfName")); + pmSubscriptionInfo.put("changeType", executor.inFields.get("changeType")) + pmSubscriptionInfo.put("policyName", executor.inFields.get("policyName")) + pmSubscriptionInfo.put("closedLoopControlName", executor.inFields.get("closedLoopControlName")) + pmSubscriptionInfo.put("subscription", subscription) + pmSubscriptionInfo.put("blueprintName", blueprintName) + pmSubscriptionInfo.put("blueprintVersion", blueprintVersion) + + + executor.getContextAlbum("PMSubscriptionAlbum").put(albumID.toString(), pmSubscriptionInfo); + + executor.outFields.put("albumID", albumID) + } else { + executor.message = "Received invalid event" + returnValue = false; + } + + returnValue; + events: + key: + name: PMControlPolicy_Events + version: 0.0.1 + eventMap: + entry: + - key: + name: CDSCreateResponseEvent + version: 0.0.1 + value: + key: + name: CDSCreateResponseEvent + version: 0.0.1 + nameSpace: org.onap.policy.apex.onap.pmcontrol + source: CDS + target: APEX + parameter: + entry: + - key: actionIdentifiers + value: + key: actionIdentifiers + fieldSchemaKey: + name: CDSActionIdentifiersType + version: 0.0.1 + optional: false + - key: commonHeader + value: + key: commonHeader + fieldSchemaKey: + name: CDSResponseCommonHeaderType + version: 0.0.1 + optional: false + - key: payload + value: + key: payload + fieldSchemaKey: + name: CDSCreateResponsePayloadType + version: 0.0.1 + optional: false + - key: status + value: + key: status + fieldSchemaKey: + name: CDSResponseStatusType + version: 0.0.1 + optional: false + - key: + name: CDSCreateSubscriptionRequestEvent + version: 0.0.1 + value: + key: + name: CDSCreateSubscriptionRequestEvent + version: 0.0.1 + nameSpace: org.onap.policy.apex.onap.pmcontrol + source: APEX + target: APEX + parameter: + entry: + - key: actionIdentifiers + value: + key: actionIdentifiers + fieldSchemaKey: + name: CDSActionIdentifiersType + version: 0.0.1 + optional: false + - key: commonHeader + value: + key: commonHeader + fieldSchemaKey: + name: CDSRequestCommonHeaderType + version: 0.0.1 + optional: false + - key: payload + value: + key: payload + fieldSchemaKey: + name: CDSCreateSubscriptionPayloadType + version: 0.0.1 + optional: false + - key: + name: CDSDeleteResponseEvent + version: 0.0.1 + value: + key: + name: CDSDeleteResponseEvent + version: 0.0.1 + nameSpace: org.onap.policy.apex.onap.pmcontrol + source: CDS + target: APEX + parameter: + entry: + - key: actionIdentifiers + value: + key: actionIdentifiers + fieldSchemaKey: + name: CDSActionIdentifiersType + version: 0.0.1 + optional: false + - key: commonHeader + value: + key: commonHeader + fieldSchemaKey: + name: CDSResponseCommonHeaderType + version: 0.0.1 + optional: false + - key: payload + value: + key: payload + fieldSchemaKey: + name: CDSDeleteResponsePayloadType + version: 0.0.1 + optional: false + - key: status + value: + key: status + fieldSchemaKey: + name: CDSResponseStatusType + version: 0.0.1 + optional: false + - key: + name: CDSDeleteSubscriptionRequestEvent + version: 0.0.1 + value: + key: + name: CDSDeleteSubscriptionRequestEvent + version: 0.0.1 + nameSpace: org.onap.policy.apex.onap.pmcontrol + source: APEX + target: APEX + parameter: + entry: + - key: actionIdentifiers + value: + key: actionIdentifiers + fieldSchemaKey: + name: CDSActionIdentifiersType + version: 0.0.1 + optional: false + - key: commonHeader + value: + key: commonHeader + fieldSchemaKey: + name: CDSRequestCommonHeaderType + version: 0.0.1 + optional: false + - key: payload + value: + key: payload + fieldSchemaKey: + name: CDSDeleteSubscriptionPayloadType + version: 0.0.1 + optional: false + - key: + name: CDSResponseStatusEvent + version: 0.0.1 + value: + key: + name: CDSResponseStatusEvent + version: 0.0.1 + nameSpace: org.onap.policy.apex.onap.pmcontrol + source: APEX + target: DCAE + parameter: + entry: + - key: status + value: + key: status + fieldSchemaKey: + name: SubscriptionStatusType + version: 0.0.1 + optional: false + - key: + name: CreateSubscriptionPayloadEvent + version: 0.0.1 + value: + key: + name: CreateSubscriptionPayloadEvent + version: 0.0.1 + nameSpace: org.onap.policy.apex.onap.pmcontrol + source: APEX + target: APEX + parameter: + entry: + - key: albumID + value: + key: albumID + fieldSchemaKey: + name: UUIDType + version: 0.0.1 + optional: false + - key: payload + value: + key: payload + fieldSchemaKey: + name: CDSCreateSubscriptionPayloadType + version: 0.0.1 + optional: false + - key: + name: DeleteSubscriptionPayloadEvent + version: 0.0.1 + value: + key: + name: DeleteSubscriptionPayloadEvent + version: 0.0.1 + nameSpace: org.onap.policy.apex.onap.pmcontrol + source: APEX + target: APEX + parameter: + entry: + - key: albumID + value: + key: albumID + fieldSchemaKey: + name: UUIDType + version: 0.0.1 + optional: false + - key: payload + value: + key: payload + fieldSchemaKey: + name: CDSDeleteSubscriptionPayloadType + version: 0.0.1 + optional: false + - key: + name: MRResponseEvent + version: 0.0.1 + value: + key: + name: MRResponseEvent + version: 0.0.1 + nameSpace: org.onap.policy.apex.onap.pmcontrol + source: DCAE + target: APEX + parameter: + entry: + - key: count + value: + key: count + fieldSchemaKey: + name: SimpleIntType + version: 0.0.1 + optional: false + - key: serverTimeMs + value: + key: serverTimeMs + fieldSchemaKey: + name: SimpleIntType + version: 0.0.1 + optional: false + - key: + name: PMSubscriptionOutputEvent + version: 0.0.1 + value: + key: + name: PMSubscriptionOutputEvent + version: 0.0.1 + nameSpace: org.onap.policy.apex.onap.pmcontrol + source: APEX + target: APEX + parameter: + entry: + - key: albumID + value: + key: albumID + fieldSchemaKey: + name: UUIDType + version: 0.0.1 + optional: false + - key: + name: pmsh-operational-policy + version: 0.0.1 + value: + key: + name: pmsh-operational-policy + version: 0.0.1 + nameSpace: org.onap.policy.apex.onap.pmcontrol + source: DCAE + target: APEX + parameter: + entry: + - key: blueprintName + value: + key: blueprintName + fieldSchemaKey: + name: SimpleStringType + version: 0.0.1 + optional: false + - key: blueprintVersion + value: + key: blueprintVersion + fieldSchemaKey: + name: SimpleStringType + version: 0.0.1 + optional: false + - key: changeType + value: + key: changeType + fieldSchemaKey: + name: SimpleStringType + version: 0.0.1 + optional: false + - key: closedLoopControlName + value: + key: closedLoopControlName + fieldSchemaKey: + name: SimpleStringType + version: 0.0.1 + optional: false + - key: nfName + value: + key: nfName + fieldSchemaKey: + name: SimpleStringType + version: 0.0.1 + optional: false + - key: policyName + value: + key: policyName + fieldSchemaKey: + name: SimpleStringType + version: 0.0.1 + optional: false + - key: subscription + value: + key: subscription + fieldSchemaKey: + name: SubscriptionType + version: 0.0.1 + optional: false + albums: + key: + name: PMControlPolicy_Albums + version: 0.0.1 + albums: + entry: + - key: + name: PMSubscriptionAlbum + version: 0.0.1 + value: + key: + name: PMSubscriptionAlbum + version: 0.0.1 + scope: policy + isWritable: true + itemSchema: + name: PMSubscriptionType + version: 0.0.1 + schemas: + key: + name: PMControlPolicy_Schemas + version: 0.0.1 + schemas: + entry: + - key: + name: CDSActionIdentifiersType + version: 0.0.1 + value: + key: + name: CDSActionIdentifiersType + version: 0.0.1 + schemaFlavour: Avro + schemaDefinition: |- + { + "type": "record", + "name": "ActionIdentifiers_Type", + "namespace": "org.onap.policy.apex.onap.helloworld", + "fields": [ + { + "name": "actionName", + "type": "string" + }, + { + "name": "blueprintName", + "type": "string" + }, + { + "name": "blueprintVersion", + "type": "string" + }, + { + "name": "mode", + "type": "string" + } + ] + } + - key: + name: CDSCreateResponsePayloadType + version: 0.0.1 + value: + key: + name: CDSCreateResponsePayloadType + version: 0.0.1 + schemaFlavour: Avro + schemaDefinition: |- + { + "name": "CreateResponsePayloadEntry", + "type": "record", + "namespace": "org.onap.policy.apex.onap.helloworld", + "fields": [ + { + "name": "create_DasH_subscription_DasH_response", + "type": { + "name": "create_DasH_subscription_DasH_response", + "type": "record", + "fields": [ + { + "name": "odl_DasH_response", + "type": { + "name": "odl_DasH_response", + "type": "record", + "fields": [ + { + "name": "status", + "type": "string" + } + ] + } + } + ] + } + } + ] + } + - key: + name: CDSCreateSubscriptionPayloadType + version: 0.0.1 + value: + key: + name: CDSCreateSubscriptionPayloadType + version: 0.0.1 + schemaFlavour: Avro + schemaDefinition: |- + { + "type": "map", + "values": { + "type": "record", + "name": "CDSRequestPayloadEntry", + "fields": [ + { + "name": "create_DasH_subscription_DasH_properties", + "type": { + "name": "create_DasH_subscription_DasH_properties_record", + "type": "record", + "fields": [ + { + "name": "nfName", + "type": "string" + }, + { + "name": "subscriptionName", + "type": "string" + }, + { + "name": "administrativeState", + "type": "string" + }, + { + "name": "fileBasedGP", + "type": "string" + }, + { + "name": "fileLocation", + "type": "string" + }, + { + "name": "measurementGroups", + "type": { + "type": "array", + "items": { + "name": "measurementGroups_record", + "type": "record", + "fields": [ + { + "name": "measurementGroup", + "type": { + "name": "measurementGroup", + "type": "record", + "fields": [ + { + "name": "measurementTypes", + "type": { + "type": "array", + "items": { + "name": "measurementTypes_record", + "type": "record", + "fields": [ + { + "name": "measurementType", + "type": "string" + } + ] + } + } + }, + { + "name": "managedObjectDNsBasic", + "type": { + "type": "array", + "items": { + "name": "managedObjectDNsBasic_record", + "type": "record", + "fields": [ + { + "name": "DN", + "type": "string" + } + ] + } + } + } + ] + } + } + ] + } + } + } + ] + } + } + ] + } + } + - key: + name: CDSDeleteResponsePayloadType + version: 0.0.1 + value: + key: + name: CDSDeleteResponsePayloadType + version: 0.0.1 + schemaFlavour: Avro + schemaDefinition: |- + { + "name": "DeleteResponsePayloadEntry", + "type": "record", + "namespace": "com.acme.avro", + "fields": [ + { + "name": "delete_DasH_subscription_DasH_response", + "type": { + "name": "delete_DasH_subscription_DasH_response", + "type": "record", + "fields": [ + { + "name": "odl_DasH_response", + "type": { + "name": "odl_DasH_response", + "type": "record", + "fields": [ + { + "name": "status", + "type": "string" + } + ] + } + } + ] + } + } + ] + } + - key: + name: CDSDeleteSubscriptionPayloadType + version: 0.0.1 + value: + key: + name: CDSDeleteSubscriptionPayloadType + version: 0.0.1 + schemaFlavour: Avro + schemaDefinition: |- + { + "type": "map", + "values": { + "type": "record", + "name": "CDSRequestPayloadEntry", + "fields": [ + { + "name": "delete_DasH_subscription_DasH_properties", + "type": { + "name": "delete_DasH_subscription_DasH_properties_record", + "type": "record", + "fields": [ + { + "name": "nfName", + "type": "string" + }, + { + "name": "subscriptionName", + "type": "string" + }, + { + "name": "administrativeState", + "type": "string" + }, + { + "name": "fileBasedGP", + "type": "string" + }, + { + "name": "fileLocation", + "type": "string" + }, + { + "name": "measurementGroups", + "type": { + "type": "array", + "items": { + "name": "measurementGroups_record", + "type": "record", + "fields": [ + { + "name": "measurementGroup", + "type": { + "name": "measurementGroup", + "type": "record", + "fields": [ + { + "name": "measurementTypes", + "type": { + "type": "array", + "items": { + "name": "measurementTypes_record", + "type": "record", + "fields": [ + { + "name": "measurementType", + "type": "string" + } + ] + } + } + }, + { + "name": "managedObjectDNsBasic", + "type": { + "type": "array", + "items": { + "name": "managedObjectDNsBasic_record", + "type": "record", + "fields": [ + { + "name": "DN", + "type": "string" + } + ] + } + } + } + ] + } + } + ] + } + } + } + ] + } + } + ] + } + } + - key: + name: CDSRequestCommonHeaderType + version: 0.0.1 + value: + key: + name: CDSRequestCommonHeaderType + version: 0.0.1 + schemaFlavour: Avro + schemaDefinition: |- + { + "type": "record", + "name": "RequestCommonHeader_Type", + "namespace": "org.onap.policy.apex.onap.helloworld", + "fields": [ + { + "name": "originatorId", + "type": "string" + }, + { + "name": "requestId", + "type": "string" + }, + { + "name": "subRequestId", + "type": "string" + } + ] + } + - key: + name: CDSResponseCommonHeaderType + version: 0.0.1 + value: + key: + name: CDSResponseCommonHeaderType + version: 0.0.1 + schemaFlavour: Avro + schemaDefinition: |- + { + "type": "record", + "name": "ResponseCommonHeader_Type", + "namespace": "org.onap.policy.apex.onap.helloworld", + "fields": [ + { + "name": "originatorId", + "type": "string" + }, + { + "name": "requestId", + "type": "string" + }, + { + "name": "subRequestId", + "type": "string" + }, + { + "name": "timestamp", + "type": "string" + }, + { + "name": "flags", + "type": ["null", "string"] + } + ] + } + - key: + name: CDSResponseStatusType + version: 0.0.1 + value: + key: + name: CDSResponseStatusType + version: 0.0.1 + schemaFlavour: Avro + schemaDefinition: |- + { + "type": "record", + "name": "ResponseStatus_Type", + "namespace": "org.onap.policy.apex.onap.helloworld", + "fields": [ + { + "name": "code", + "type": "int" + }, + { + "name": "eventType", + "type": "string" + }, + { + "name": "timestamp", + "type": "string" + }, + { + "name": "message", + "type": "string" + } + ] + } + - key: + name: PMSubscriptionType + version: 0.0.1 + value: + key: + name: PMSubscriptionType + version: 0.0.1 + schemaFlavour: Avro + schemaDefinition: "{\n\t\"name\": \"PMSubscription\",\n\t\"type\": \"record\",\n\t\"namespace\": \"\ + org.onap.policy.apex.onap.pmcontrol\",\n\t\"fields\": [\n {\n \"name\": \"nfName\"\ + ,\n \"type\": \"string\"\n },\n\t {\n\t\t\t\"name\": \"changeType\",\n\t\t\t\"\ + type\": \"string\"\n\t\t},\n\t\t{\n\t\t\t\"name\": \"closedLoopControlName\",\n\t\t\t\"type\": \"\ + string\"\n\t\t},\n\t\t{\n\t\t\t\"name\": \"policyName\",\n\t\t\t\"type\": \"string\"\n\t\t},\n\t\t\ + {\n\t\t \"name\": \"blueprintName\",\n\t\t \"type\": \"string\"\n\t\t},\n\t\t{\n\t\t \"name\"\ + : \"blueprintVersion\",\n\t\t \"type\": \"string\"\n\t\t},\n\t\t{\n\t\t\t\"name\": \"subscription\"\ + ,\n\t\t\t\"type\": {\n\t\t\t\t\"name\": \"subscription\",\n\t\t\t\t\"type\": \"record\",\n\t\t\t\t\ + \"fields\": [{\n\t\t\t\t\t\t\"name\": \"subscriptionName\",\n\t\t\t\t\t\t\"type\": \"string\"\n\t\t\ + \t\t\t},\n\t\t\t\t\t{\n\t\t\t\t\t\t\"name\": \"administrativeState\",\n\t\t\t\t\t\t\"type\": \"string\"\ + \n\t\t\t\t\t},\n\t\t\t\t\t{\n\t\t\t\t\t\t\"name\": \"fileBasedGP\",\n\t\t\t\t\t\t\"type\": \"int\"\ + \n\t\t\t\t\t},\n\t\t\t\t\t{\n\t\t\t\t\t\t\"name\": \"fileLocation\",\n\t\t\t\t\t\t\"type\": \"string\"\ + \n\t\t\t\t\t},\n\t\t\t\t\t{\n\t\t\t\t\t\t\"name\": \"measurementGroups\",\n\t\t\t\t\t\t\"type\": {\n\ + \t\t\t\t\t\t\t\"type\": \"array\",\n\t\t\t\t\t\t\t\"items\": {\n\t\t\t\t\t\t\t\t\"name\": \"Measurement_Groups_Type\"\ + ,\n\t\t\t\t\t\t\t\t\"type\": \"record\",\n\t\t\t\t\t\t\t\t\"fields\": [{\n\t\t\t\t\t\t\t\t\t\"name\"\ + : \"measurementGroup\",\n\t\t\t\t\t\t\t\t\t\"type\": {\n\t\t\t\t\t\t\t\t\t\t\"name\": \"Measurement_Group_Type\"\ + ,\n\t\t\t\t\t\t\t\t\t\t\"type\": \"record\",\n\t\t\t\t\t\t\t\t\t\t\"fields\": [{\n\t\t\t\t\t\t\t\t\ + \t\t\t\t\"name\": \"measurementTypes\",\n\t\t\t\t\t\t\t\t\t\t\t\t\"type\": {\n\t\t\t\t\t\t\t\t\t\t\ + \t\t\t\"type\": \"array\",\n\t\t\t\t\t\t\t\t\t\t\t\t\t\"items\": {\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\"\ + name\": \"Measurement_Types_Type\",\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\"type\": \"record\",\n\t\t\t\t\t\ + \t\t\t\t\t\t\t\t\t\"fields\": [{\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\"name\": \"measurementType\",\n\t\ + \t\t\t\t\t\t\t\t\t\t\t\t\t\t\"type\": \"string\"\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t}]\n\t\t\t\t\t\t\t\t\ + \t\t\t\t\t}\n\t\t\t\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\t\t\t\t{\n\t\t\t\t\ + \t\t\t\t\t\t\t\t\"name\": \"managedObjectDNsBasic\",\n\t\t\t\t\t\t\t\t\t\t\t\t\"type\": {\n\t\t\t\t\ + \t\t\t\t\t\t\t\t\t\"type\": \"array\",\n\t\t\t\t\t\t\t\t\t\t\t\t\t\"items\": {\n\t\t\t\t\t\t\t\t\t\ + \t\t\t\t\t\"name\": \"Managed_Object_Dns_Basic_Type\",\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\"type\": \"record\"\ + ,\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\"fields\": [{\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\"name\": \"DN\",\n\t\ + \t\t\t\t\t\t\t\t\t\t\t\t\t\t\"type\": \"string\"\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t}]\n\t\t\t\t\t\t\t\t\ + \t\t\t\t\t}\n\t\t\t\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\t\t]\n\t\t\t\t\t\ + \t\t\t\t}\n\t\t\t\t\t\t\t\t}]\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t]\n\t\t\t}\n\t\ + \t}\n\t]\n}" + - key: + name: SimpleIntType + version: 0.0.1 + value: + key: + name: SimpleIntType + version: 0.0.1 + schemaFlavour: Java + schemaDefinition: java.lang.Integer + - key: + name: SimpleStringType + version: 0.0.1 + value: + key: + name: SimpleStringType + version: 0.0.1 + schemaFlavour: Java + schemaDefinition: java.lang.String + - key: + name: SubscriptionStatusType + version: 0.0.1 + value: + key: + name: SubscriptionStatusType + version: 0.0.1 + schemaFlavour: Avro + schemaDefinition: |- + { + "type": "record", + "name": "ActivateSubscriptionStatus_Type", + "namespace": "org.onap.policy.apex.onap.helloworld", + "fields": [ + { + "name": "subscriptionName", + "type": "string" + }, + { + "name": "nfName", + "type": "string" + }, + { + "name": "changeType", + "type": "string" + }, + { + "name": "message", + "type": "string" + } + ] + } + - key: + name: SubscriptionType + version: 0.0.1 + value: + key: + name: SubscriptionType + version: 0.0.1 + schemaFlavour: Avro + schemaDefinition: "{\n\t\"name\": \"subscription\",\n\t\"type\": \"record\",\n\t\"fields\": [{\n\t\t\ + \t\"name\": \"subscriptionName\",\n\t\t\t\"type\": \"string\"\n\t\t},\n\t\t{\n\t\t\t\"name\": \"administrativeState\"\ + ,\n\t\t\t\"type\": \"string\"\n\t\t},\n\t\t{\n\t\t\t\"name\": \"fileBasedGP\",\n\t\t\t\"type\": \"\ + int\"\n\t\t},\n\t\t{\n\t\t\t\"name\": \"fileLocation\",\n\t\t\t\"type\": \"string\"\n\t\t},\n\t\t\ + {\n\t\t\t\"name\": \"measurementGroups\",\n\t\t\t\"type\": {\n\t\t\t\t\"type\": \"array\",\n\t\t\t\ + \t\"items\": {\n\t\t\t\t\t\"name\": \"Measurement_Groups_Type\",\n\t\t\t\t\t\"type\": \"record\",\n\ + \t\t\t\t\t\"fields\": [{\n\t\t\t\t\t\t\"name\": \"measurementGroup\",\n\t\t\t\t\t\t\"type\": {\n\t\ + \t\t\t\t\t\t\"name\": \"Measurement_Group_Type\",\n\t\t\t\t\t\t\t\"type\": \"record\",\n\t\t\t\t\t\ + \t\t\"fields\": [{\n\t\t\t\t\t\t\t\t\t\"name\": \"measurementTypes\",\n\t\t\t\t\t\t\t\t\t\"type\"\ + : {\n\t\t\t\t\t\t\t\t\t\t\"type\": \"array\",\n\t\t\t\t\t\t\t\t\t\t\"items\": {\n\t\t\t\t\t\t\t\t\t\ + \t\t\"name\": \"Measurement_Types_Type\",\n\t\t\t\t\t\t\t\t\t\t\t\"type\": \"record\",\n\t\t\t\t\t\ + \t\t\t\t\t\t\"fields\": [{\n\t\t\t\t\t\t\t\t\t\t\t\t\"name\": \"measurementType\",\n\t\t\t\t\t\t\t\ + \t\t\t\t\t\"type\": \"string\"\n\t\t\t\t\t\t\t\t\t\t\t}]\n\t\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\t\ + }\n\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\t\"name\": \"managedObjectDNsBasic\",\n\ + \t\t\t\t\t\t\t\t\t\"type\": {\n\t\t\t\t\t\t\t\t\t\t\"type\": \"array\",\n\t\t\t\t\t\t\t\t\t\t\"items\"\ + : {\n\t\t\t\t\t\t\t\t\t\t\t\"name\": \"Managed_Object_Dns_Basic_Type\",\n\t\t\t\t\t\t\t\t\t\t\t\"\ + type\": \"record\",\n\t\t\t\t\t\t\t\t\t\t\t\"fields\": [{\n\t\t\t\t\t\t\t\t\t\t\t\t\"name\": \"DN\"\ + ,\n\t\t\t\t\t\t\t\t\t\t\t\t\"type\": \"string\"\n\t\t\t\t\t\t\t\t\t\t\t}]\n\t\t\t\t\t\t\t\t\t\t}\n\ + \t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t]\n\t\t\t\t\t\t}\n\t\t\t\t\t}]\n\t\t\t\t}\n\t\ + \t\t}\n\t\t}\n\t]\n}" + - key: + name: UUIDType + version: 0.0.1 + value: + key: + name: UUIDType + version: 0.0.1 + schemaFlavour: Java + schemaDefinition: java.util.UUID + 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.acm.util.Serialization$GsonInstantAdapter + eventInputParameters: + DCAEConsumer: + carrierTechnologyParameters: + carrierTechnology: RESTCLIENT + parameterClassName: org.onap.policy.apex.plugins.event.carrier.restclient.RestClientCarrierTechnologyParameters + parameters: + consumerPollTime: '50' + url: https://message-router:3905/events/unauthenticated.DCAE_CL_OUTPUT/cg1/sg1 + eventProtocolParameters: + eventProtocol: JSON + parameters: + nameAlias: policyName + eventName: pmsh-operational-policy + eventNameFilter: pmsh-operational-policy + CDSRequestConsumer: + carrierTechnologyParameters: + carrierTechnology: RESTREQUESTOR + parameterClassName: org.onap.policy.apex.plugins.event.carrier.restrequestor.RestRequestorCarrierTechnologyParameters + parameters: + url: http://10.10.10.184:30254/api/v1/execution-service/process + httpMethod: POST + restRequestTimeout: 2000 + httpHeaders: + - - Authorization + - Basic Y2NzZGthcHBzOmNjc2RrYXBwcw== + eventProtocolParameters: + eventProtocol: JSON + eventName: CDSCreateResponseEvent + eventNameFilter: CDSCreateResponseEvent + requestorMode: true + requestorPeer: CDSRequestProducer + requestorTimeout: 500 + CDSDeleteRequestConsumer: + carrierTechnologyParameters: + carrierTechnology: RESTREQUESTOR + parameterClassName: org.onap.policy.apex.plugins.event.carrier.restrequestor.RestRequestorCarrierTechnologyParameters + parameters: + url: http://10.10.10.184:30254/api/v1/execution-service/process + httpMethod: POST + restRequestTimeout: 2000 + httpHeaders: + - - Authorization + - Basic Y2NzZGthcHBzOmNjc2RrYXBwcw== + eventProtocolParameters: + eventProtocol: JSON + eventName: CDSDeleteResponseEvent + eventNameFilter: CDSDeleteResponseEvent + requestorMode: true + requestorPeer: CDSDeleteRequestProducer + requestorTimeout: 500 + CDSReplyConsumer: + carrierTechnologyParameters: + carrierTechnology: RESTREQUESTOR + parameterClassName: org.onap.policy.apex.plugins.event.carrier.restrequestor.RestRequestorCarrierTechnologyParameters + parameters: + url: https://message-router:3905/events/unauthenticated.PMSH_CL_INPUT + httpMethod: POST + restRequestTimeout: 2000 + eventProtocolParameters: + eventProtocol: JSON + eventName: MRResponseEvent + eventNameFilter: MRResponseEvent + requestorMode: true + requestorPeer: CDSReplyProducer + requestorTimeout: 500 + eventOutputParameters: + logOutputter: + carrierTechnologyParameters: + carrierTechnology: FILE + parameters: + fileName: /tmp/outputevents.log + eventProtocolParameters: + eventProtocol: JSON + StdOutOutputter: + carrierTechnologyParameters: + carrierTechnology: FILE + parameters: + standardIo: true + eventProtocolParameters: + eventProtocol: JSON + CDSRequestProducer: + carrierTechnologyParameters: + carrierTechnology: RESTREQUESTOR + parameterClassName: org.onap.policy.apex.plugins.event.carrier.restrequestor.RestRequestorCarrierTechnologyParameters + eventProtocolParameters: + eventProtocol: JSON + eventNameFilter: CDSCreateSubscriptionRequestEvent + requestorMode: true + requestorPeer: CDSRequestConsumer + requestorTimeout: 500 + CDSDeleteRequestProducer: + carrierTechnologyParameters: + carrierTechnology: RESTREQUESTOR + parameterClassName: org.onap.policy.apex.plugins.event.carrier.restrequestor.RestRequestorCarrierTechnologyParameters + eventProtocolParameters: + eventProtocol: JSON + eventNameFilter: CDSDeleteSubscriptionRequestEvent + requestorMode: true + requestorPeer: CDSDeleteRequestConsumer + requestorTimeout: 500 + CDSReplyProducer: + carrierTechnologyParameters: + carrierTechnology: RESTREQUESTOR + parameterClassName: org.onap.policy.apex.plugins.event.carrier.restrequestor.RestRequestorCarrierTechnologyParameters + eventProtocolParameters: + eventProtocol: JSON + eventNameFilter: CDSResponseStatusEvent + requestorMode: true + requestorPeer: CDSReplyConsumer + requestorTimeout: 500 diff --git a/runtime-acm/src/test/resources/rest/servicetemplates/pm_automation_composition_tosca.yaml b/runtime-acm/src/test/resources/rest/servicetemplates/pm_automation_composition_tosca.yaml new file mode 100644 index 000000000..77fcac35e --- /dev/null +++ b/runtime-acm/src/test/resources/rest/servicetemplates/pm_automation_composition_tosca.yaml @@ -0,0 +1,452 @@ +tosca_definitions_version: tosca_simple_yaml_1_3 +capability_types: + org.onap.EventProducer: + properties: + carrier_protocol_type: + type: string + required: true + constraints: + - valid_values: + - DMAAP_message_router + - SOMETHING_ELSE + - REST + data_format: + type: string + required: true + constraints: + - valid_values: + - JSON + - YAML + - JMS + event_format: + type: string + required: true + event_format_version: + type: string + required: false + config_keys: + type: list + required: false + entry_schema: + type: string + constraints: + - valid_values: + - all valid values should be added here + - if not specified, events of any config key may be generated + - 'examples for config_key: ves-measurement, ves-syslog, tca_handle_out, + etc.' + version: 0.0.1 + derived_from: tosca.capabilities.Root + org.onap.EventConsumer: + properties: + responding_capability: + type: string + required: false + carrier_protocol_type: + type: string + required: true + constraints: + - valid_values: + - DMAAP_message_router + - SOMETHING_ELSE + - REST + data_format: + type: string + required: true + constraints: + - valid_values: + - JSON + - YAML + - JMS + - all valid values should be added here + event_format: + type: string + description: 'examples for event_format: Ves_specification, LinkUp, VnfConfigured, + etc.' + required: true + event_format_version: + type: string + description: 'examples for event_format_version: 5.28.4, 7.30.1, etc.' + required: false + config_keys: + type: list + required: false + entry_schema: + type: string + constraints: + - valid_values: + - all valid values should be added here + - if not specified, events of any config key may be generated + - 'examples for config_key: ves-measurement, ves-syslog, tca_handle_out, + etc.' + version: 0.0.1 + derived_from: tosca.capabilities.Root +node_types: + org.onap.DynamicConfig: + properties: + application_name: + type: string + description: Value used to tie the config to an application ? should we be + using a relationship here instead? + required: true + application_version: + type: string + required: true + application_provider: + type: string + required: false + data_types: + type: object + required: false + schema: + type: object + required: false + version: 0.0.1 + derived_from: tosca.nodes.Root + org.onap.APP: + properties: + application_name: + type: string + description: Human readable name for the application Product + required: false + provider: + type: string + description: Provider of the application and of the descriptor + required: true + application_version: + type: string + description: Software version of the application + required: true + blueprint_id: + type: string + description: A reference to the app blueprint + required: false + monitoring_policy: + type: string + description: A reference to the monitoring policy + required: false + requirements: + - receive: + capability: org.onap.EventProducer + relationship: org.onap.PropagateEvent + occurrences: + - 0.0 + - UNBOUNDED + version: 0.0.0 + - send: + capability: org.onap.EventConsumer + relationship: org.onap.PropagateEvent + occurrences: + - 0.0 + - UNBOUNDED + version: 0.0.0 + version: 0.0.1 + derived_from: tosca.nodes.Root + org.onap.EventRelay: + properties: + event_format: + type: string + description: 'examples for event_format: Ves_specification, etc.' + required: true + event_format_version: + type: string + description: 'examples for event_format_version: 5.28.4, 7.30.1, etc.' + required: true + config_keys: + type: list + required: false + entry_schema: + type: string + constraints: + - valid_values: + - all valid values should be added here + - if not specified, events of any config key is relayed + - 'examples for config_key: ves-measurement, ves-syslog, tca_handle_out, + etc.' + supported_carrier_protocols: + type: map + description: 'A map describing supported carrier protocols and translations. + The tuples define what protocol combinations are supported on the producer + and consumer side: e.g. { REST: REST, DMAAP: REST, DMAAP: DMAAP}' + required: true + key_schema: + type: string + constraints: + - valid_values: + - DMAAP_message_router + - SOMETHING_ELSE + - REST + - all valid values should be added here + entry_schema: + type: string + constraints: + - valid_values: + - DMAAP_message_router + - SOMETHING_ELSE + - REST + - all valid values should be added here + supported_data_formats: + type: map + description: 'Is a map describing supported data formats and translation. + The tuples define what protocol combinations are supported on the producer + and consumer side: e.g. { JSON: JSON, JMS: JSON, YAML:YAML }' + required: true + key_schema: + type: string + constraints: + - valid_values: + - JSON + - JMS + - YAML + - etc + - all valid values should be added here + entry_schema: + type: string + constraints: + - valid_values: + - JSON + - JMS + - YAML + - etc + - all valid values should be added here + requirements: + - receive: + capability: org.onap.EventProducer + relationship: org.onap.PropagateEvent + occurrences: + - 0.0 + - UNBOUNDED + version: 0.0.0 + - send: + capability: org.onap.EventConsumer + relationship: org.onap.PropagateEvent + occurrences: + - 0.0 + - UNBOUNDED + version: 0.0.0 + version: 0.0.1 + derived_from: tosca.nodes.Root +relationship_types: + org.onap.PropagateEvent: + properties: + config_keys: + type: list + description: The relationship type used on requirements to org.onap.EventProducer + and org.onap.EventConsumer capabilities. Filters events by specific config_keys + to be transferred by this relationship. That is, any event with a specific + config_key found in the list is transferred. If list is not defined or is + empty, events with all config_keys are transferred. + required: false + entry_schema: + type: string + version: 0.0.1 + derived_from: tosca.relationships.Root +topology_template: + inputs: + pm_subscription_topic: + type: string + pm_subscription_response_topic: + type: string + pm_subscription_handler_blueprint_id: + type: string + pm_subscription_operational_policy_id: + type: string + pm_subscription_cds_blueprint_id: + type: string + enable_tls: + type: string + node_templates: + org.onap.PM_Subscription_Handler: + type: org.onap.APP + properties: + application_name: PM Subscription Handler + provider: Ericsson + application_version: 1.0.0 + artifact_id: + get_input: pm_subscription_handler_blueprint_id + description: Is this a reference to the DCAE Cloudify Blueprint that is + already stored(or will be stored before CL configuration & instatiation) + in DCAE Inventory? + artifact_config: + enable_tls: + get_input: enable_tls + pmsh_publish_topic_name: + get_input: pm_subscription_topic + capabilities: + pm-subscription-event-publisher: + properties: + carrier_protocol_type: DMAAP_message_router + data_format: JSON + event_format: pm-subscription-event-format + event_format_version: 1.0.0 + attributes: + type: org.onap.EventProducer + occurrences: + - 0.0 + - UNBOUNDED + version: 0.0.0 + pm-subscription-event-receiver: + properties: + carrier_protocol_type: DMAAP_message_router + data_format: JSON + event_format: pm-subscription-event-response-format + event_format_version: 1.0.0 + relationships: + - type: tosca.relationships.DependsOn + - description: any ideas on a better realtionship ? or is it better to + just use the root realtionship ? + - target: org.onap.PM_Monitoring_Policy + attributes: + type: org.onap.EventConsumer + occurrences: + - 0.0 + - UNBOUNDED + version: 0.0.0 + version: 0.0.0 + org.onap.PM_Monitoring_Policy: + type: org.onap.DynamicConfig + properties: + application_name: PM Subscription Handler + application_version: 1.0.0 + provider: Ericsson + data_types: + measurementType: + type: string + DN: + type: string + nfFilter: + properties: + nfNames: + type: list + entry_schema: string + modelInvariantIDs: + type: list + entry_schema: + type: string + modelVersionIDs: + type: list + entry_schema: + type: string + measurementGroup: + properties: + masurementTypes: + type: list + entry_schema: + type: measurementType + managedObjectDNsBasic: + type: list + entry_schema: + type: DN + schema: + subscription: + subscriptionName: + type: string + required: true + administrativeState: + type: string + required: true + filebasedGP: + type: integer + required: true + fileLocation: + type: string + required: true + nfFilter: + type: nfFilter + measurementGroups: + type: list + entry_schema: + type: measurementGroup + version: 0.0.0 + description: Should I be showing a dependency between PM Subscription Handler + and the PM Monitoring Policy + org.onap.PM_Policy: + type: org.onap.APP + properties: + application_name: PM Subscription Operational Policy + provider: Ericsson + application_version: 1.0.0 + artifact_id: + get_input: pm_subscription_operational_policy_id + artifact_config: NOT_DEFINED + requirements: + - receive_0: + capability: pm-subscription-event-publisher + node: org.onap.PM_Subscription_Handler + relationship: NOT_DEFINED + properties: + config_keys: + - topic_name: + get_input: pm_subscription_topic + version: 0.0.0 + - send_0: + capability: cds-rest-receive + node: org.onap.CDS + version: 0.0.0 + - receive_1: + capability: cds-rest-response + node: org.onap.CDS + version: 0.0.0 + - send_1: + capability: pm-subscription-event-receiver + node: org.onap.PM_Subscription_Handler + relationship: NOT_DEFINED + properties: + config_keys: + - topic_name: + get_input: pm_subscription_response_topic + version: 0.0.0 + capabilities: + pm-subscription-response-event-publisher: + properties: + type: org.onap.EventProducer + carrier_protocol_type: DMAAP_message_router + data_format: JSON + event_format: pm-subscription-event-response-format + event_format_version: 1.0.0 + occurrences: + - 0.0 + - UNBOUNDED + version: 0.0.0 + version: 0.0.0 + org.onap.PM_CDS_Blueprint: + type: org.onap.APP + properties: + application_name: PM Subscription CDS Blueprint + provider: Ericsson + application_version: 1.0.0 + artifact_id: + get_input: pm_subscription_cds_blueprint_id + capabilities: + cds-rest-receive: + properties: + type: org.onap.EventConsumer + protocol_type: REST + data_format: JSON + event_format: cds_action_format + event_format_version: 1.0.0 + responding_capability: cds-rest-response + occurrences: + - 0.0 + - UNBOUNDED + version: 0.0.0 + cds-rest-response: + properties: + type: org.onap.EventProducer + protocol_type: REST + data_format: JSON + event_format: cds_action_response_format + event_format_version: 1.0.0 + occurrences: + - 0.0 + version: 0.0.0 + version: 0.0.0 + org.onap.controlloop0: + type: org.onap.APP + properties: + application_name: Test Automation Composition + provider: Ericsson + application_version: 1.0.0 + status: NOT_DEPLOYED + version: 0.0.0 +version: 0.0.0 diff --git a/runtime-acm/src/test/resources/rest/servicetemplates/pmsh_multiple_ac_tosca.yaml b/runtime-acm/src/test/resources/rest/servicetemplates/pmsh_multiple_ac_tosca.yaml new file mode 100644 index 000000000..1d3825f75 --- /dev/null +++ b/runtime-acm/src/test/resources/rest/servicetemplates/pmsh_multiple_ac_tosca.yaml @@ -0,0 +1,238 @@ +tosca_definitions_version: tosca_simple_yaml_1_3 +data_types: + onap.datatypes.ToscaConceptIdentifier: + derived_from: tosca.datatypes.Root + properties: + name: + type: string + required: true + version: + type: string + required: true +node_types: + org.onap.policy.clamp.acm.Participant: + version: 1.0.1 + derived_from: tosca.nodetypes.Root + properties: + provider: + type: string + requred: false + org.onap.policy.clamp.acm.AutomationCompositionElement: + version: 1.0.1 + derived_from: tosca.nodetypes.Root + properties: + provider: + type: string + requred: false + participantType: + type: onap.datatypes.ToscaConceptIdentifier + requred: true + startPhase: + type: integer + required: false + constraints: + - greater-or-equal: 0 + metadata: + common: true + description: A value indicating the start phase in which this automation composition element will be started, the + first start phase is zero. Automation Composition Elements are started in their start_phase order and stopped + in reverse start phase order. Automation Composition Elements with the same start phase are started and + stopped simultaneously + org.onap.policy.clamp.acm.AutomationComposition: + version: 1.0.1 + derived_from: tosca.nodetypes.Root + properties: + provider: + type: string + requred: false + elements: + type: list + required: true + entry_schema: + type: onap.datatypes.ToscaConceptIdentifier + org.onap.policy.clamp.acm.DCAEMicroserviceAutomationCompositionElement: + version: 1.0.1 + derived_from: org.onap.policy.clamp.acm.AutomationCompositionElement + properties: + dcae_blueprint_id: + type: onap.datatypes.ToscaConceptIdentifier + requred: true + org.onap.policy.clamp.acm.PolicyTypeAutomationCompositionElement: + version: 1.0.1 + derived_from: org.onap.policy.clamp.acm.AutomationCompositionElement + properties: + policy_type_id: + type: onap.datatypes.ToscaConceptIdentifier + requred: true + org.onap.policy.clamp.acm.CDSAutomationCompositionElement: + version: 1.0.1 + derived_from: org.onap.policy.clamp.acm.AutomationCompositionElement + properties: + cds_blueprint_id: + type: onap.datatypes.ToscaConceptIdentifier + requred: true +topology_template: + node_templates: + org.onap.dcae.acm.DCAEMicroserviceAutomationCompositionParticipant: + version: 2.3.4 + type: org.onap.policy.clamp.acm.Participant + type_version: 1.0.1 + description: Participant for DCAE microservices + properties: + provider: ONAP + org.onap.policy.acm.PolicyAutomationCompositionParticipant: + version: 2.2.1 + type: org.onap.policy.clamp.acm.Participant + type_version: 1.0.1 + description: Participant for DCAE microservices + properties: + provider: ONAP + org.onap.ccsdk.cds.acm.CdsAutomationCompositionParticipant: + version: 2.2.1 + type: org.onap.policy.clamp.acm.Participant + type_version: 1.0.1 + description: Participant for DCAE microservices + properties: + provider: ONAP + org.onap.domain.pmsh.PMSH_DCAEMicroservice: + version: 1.2.3 + type: org.onap.policy.clamp.acm.DCAEMicroserviceAutomationCompositionElement + type_version: 1.0.0 + description: Automation composition element for the DCAE microservice for Performance Management Subscription Handling + properties: + provider: Ericsson + participantType: + name: org.onap.dcae.acm.DCAEMicroserviceAutomationCompositionParticipant + version: 2.3.4 + dcae_blueprint_id: + name: org.onap.dcae.blueprints.PMSHBlueprint + version: 1.0.0 + org.onap.domain.pmsh.PMSH_MonitoringPolicyAutomationCompositionElement: + version: 1.2.3 + type: org.onap.policy.clamp.acm.PolicyTypeAutomationCompositionElement + type_version: 1.0.0 + description: Automation composition element for the monitoring policy for Performance Management Subscription Handling + properties: + provider: Ericsson + participantType: + name: org.onap.policy.acm.PolicyAutomationCompositionParticipant + version: 2.2.1 + policy_type_id: + name: onap.policies.monitoring.pm-subscription-handler + version: 1.0.0 + org.onap.domain.pmsh.PMSH_OperationalPolicyAutomationCompositionElement: + version: 1.2.3 + type: org.onap.policy.clamp.acm.PolicyTypeAutomationCompositionElement + type_version: 1.0.0 + description: Automation composition element for the operational policy for Performance Management Subscription Handling + properties: + provider: Ericsson + participantType: + name: org.onap.policy.acm.PolicyAutomationCompositionParticipant + version: 2.2.1 + policy_type_id: + name: onap.policies.operational.pm-subscription-handler + version: 1.0.0 + org.onap.domain.pmsh.PMSH_CDS_AutomationCompositionElement: + version: 1.2.3 + type: org.onap.policy.clamp.acm.AutomationCompositionElement + type_version: 1.0.0 + description: Automation composition element for CDS for Performance Management Subscription Handling + properties: + provider: Ericsson + participantType: + name: org.onap.ccsdk.cds.acm.CdsAutomationCompositionParticipant + version: 3.2.1 + cds_blueprint_id: + name: org.onap.ccsdk.cds.PMSHCdsBlueprint + version: 1.0.0 + org.onap.domain.pmsh.PMSHAutomationCompositionDefinition: + version: 1.2.3 + type: org.onap.policy.clamp.acm.AutomationComposition + type_version: 1.0.0 + description: Automation composition for Performance Management Subscription Handling + properties: + provider: Ericsson + elements: + - name: org.onap.domain.pmsh.PMSH_DCAEMicroservice + version: 1.2.3 + - name: org.onap.domain.pmsh.PMSH_MonitoringPolicyAutomationCompositionElement + version: 1.2.3 + - name: org.onap.domain.pmsh.PMSH_OperationalPolicyAutomationCompositionElement + version: 1.2.3 + - name: org.onap.domain.pmsh.PMSH_CDS_AutomationCompositionElement + version: 1.2.3 + org.onap.domain.pmsh.PMSD_DCAEMicroservice: + version: 1.2.3 + type: org.onap.policy.clamp.acm.DCAEMicroserviceAutomationCompositionElement + type_version: 1.0.0 + description: Automation composition element for the DCAE microservice for Performance Management Subscription Handling + properties: + provider: Ericsson + participantType: + name: org.onap.dcae.acm.DCAEMicroserviceAutomationCompositionParticipant + version: 2.3.4 + dcae_blueprint_id: + name: org.onap.dcae.blueprints.PMSDBlueprint + version: 1.0.0 + org.onap.domain.pmsh.PMSD_MonitoringPolicyAutomationCompositionElement: + version: 1.2.3 + type: org.onap.policy.clamp.acm.PolicyTypeAutomationCompositionElement + type_version: 1.0.0 + description: Automation composition element for the monitoring policy for Performance Management Subscription Handling + properties: + provider: Ericsson + participantType: + name: org.onap.policy.acm.PolicyAutomationCompositionParticipant + version: 2.2.1 + policy_type_id: + name: onap.policies.monitoring.pm-subscription-handler + version: 1.0.0 + policy_id: + name: onap.policies.monitoring.pm-subscription-handler + version: 1.0.0 + org.onap.domain.pmsh.PMSD_OperationalPolicyAutomationCompositionElement: + version: 1.2.3 + type: org.onap.policy.clamp.acm.PolicyTypeAutomationCompositionElement + type_version: 1.0.0 + description: Automation composition element for the operational policy for Performance Management Subscription Handling + properties: + provider: Ericsson + participantType: + name: org.onap.policy.acm.PolicyAutomationCompositionParticipant + version: 2.2.1 + policy_type_id: + name: onap.policies.operational.pm-subscription-handler + version: 1.0.0 + policy_id: + name: onap.policies.monitoring.pm-subscription-handler + version: 1.0.0 + org.onap.domain.pmsh.PMSD_CDS_AutomationCompositionElement: + version: 1.2.3 + type: org.onap.policy.clamp.acm.AutomationCompositionElement + type_version: 1.0.0 + description: Automation composition element for CDS for Performance Management Subscription Handling + properties: + provider: Ericsson + participantType: + name: org.onap.ccsdk.cds.acm.CdsAutomationCompositionParticipant + version: 3.2.1 + cds_blueprint_id: + name: org.onap.ccsdk.cds.PMSDCdsBlueprint + version: 1.0.0 + org.onap.domain.pmsh.PMSDAutomationCompositionDefinition: + version: 1.2.3 + type: org.onap.policy.clamp.acm.AutomationComposition + type_version: 1.0.0 + description: Automation composition for Performance Management Subscription Handling + properties: + provider: Ericsson + elements: + - name: org.onap.domain.pmsh.PMSD_DCAEMicroservice + version: 1.2.3 + - name: org.onap.domain.pmsh.PMSD_MonitoringPolicyAutomationCompositionElement + version: 1.2.3 + - name: org.onap.domain.pmsh.PMSD_OperationalPolicyAutomationCompositionElement + version: 1.2.3 + - name: org.onap.domain.pmsh.PMSD_CDS_AutomationCompositionElement + version: 1.2.3 diff --git a/runtime-acm/src/test/resources/rest/servicetemplates/tosca-for-smoke-testing.yaml b/runtime-acm/src/test/resources/rest/servicetemplates/tosca-for-smoke-testing.yaml new file mode 100644 index 000000000..f5590a1b5 --- /dev/null +++ b/runtime-acm/src/test/resources/rest/servicetemplates/tosca-for-smoke-testing.yaml @@ -0,0 +1,3488 @@ +tosca_definitions_version: tosca_simple_yaml_1_3 +data_types: + onap.datatypes.ToscaConceptIdentifier: + derived_from: tosca.datatypes.Root + properties: + name: + type: string + required: true + version: + type: string + required: true + onap.datatype.acm.Target: + derived_from: tosca.datatypes.Root + description: Definition for a entity in A&AI to perform a control loop operation on + properties: + targetType: + type: string + description: Category for the target type + required: true + constraints: + - valid_values: + - VNF + - VM + - VFMODULE + - PNF + entityIds: + type: map + description: | + Map of values that identify the resource. If none are provided, it is assumed that the + entity that generated the ONSET event will be the target. + required: false + metadata: + clamp_possible_values: ClampExecution:CSAR_RESOURCES + entry_schema: + type: string + onap.datatype.acm.Actor: + derived_from: tosca.datatypes.Root + description: An actor/operation/target definition + properties: + actor: + type: string + description: The actor performing the operation. + required: true + metadata: + clamp_possible_values: Dictionary:DefaultActors,ClampExecution:CDS/actor + operation: + type: string + description: The operation the actor is performing. + metadata: + clamp_possible_values: Dictionary:DefaultOperations,ClampExecution:CDS/operation + required: true + target: + type: onap.datatype.acm.Target + description: The resource the operation should be performed on. + required: true + payload: + type: map + description: Name/value pairs of payload information passed by Policy to the actor + required: false + metadata: + clamp_possible_values: ClampExecution:CDS/payload + entry_schema: + type: string + onap.datatype.acm.Operation: + derived_from: tosca.datatypes.Root + description: An operation supported by an actor + properties: + id: + type: string + description: Unique identifier for the operation + required: true + description: + type: string + description: A user-friendly description of the intent for the operation + required: false + operation: + type: onap.datatype.acm.Actor + description: The definition of the operation to be performed. + required: true + timeout: + type: integer + description: The amount of time for the actor to perform the operation. + required: true + retries: + type: integer + description: The number of retries the actor should attempt to perform the operation. + required: true + default: 0 + success: + type: string + description: Points to the operation to invoke on success. A value of "final_success" indicates and end to the operation. + required: false + default: final_success + failure: + type: string + description: Points to the operation to invoke on Actor operation failure. + required: false + default: final_failure + failure_timeout: + type: string + description: Points to the operation to invoke when the time out for the operation occurs. + required: false + default: final_failure_timeout + failure_retries: + type: string + description: Points to the operation to invoke when the current operation has exceeded its max retries. + required: false + default: final_failure_retries + failure_exception: + type: string + description: Points to the operation to invoke when the current operation causes an exception. + required: false + default: final_failure_exception + failure_guard: + type: string + description: Points to the operation to invoke when the current operation is blocked due to guard policy enforcement. + required: false + default: final_failure_guard + onap.datatypes.monitoring.managedObjectDNsBasic: + constraints: [] + properties: + DN: + name: DN + type: string + typeVersion: 0.0.0 + description: Managed object distinguished name + required: true + constraints: [] + metadata: {} + name: onap.datatypes.monitoring.managedObjectDNsBasic + version: 0.0.0 + derived_from: tosca.datatypes.Root + metadata: {} + onap.datatypes.monitoring.managedObjectDNsBasics: + constraints: [] + properties: + managedObjectDNsBasic: + name: managedObjectDNsBasic + type: map + typeVersion: 0.0.0 + description: Managed object distinguished name object + required: true + constraints: [] + entry_schema: + type: onap.datatypes.monitoring.managedObjectDNsBasic + typeVersion: 0.0.0 + constraints: [] + metadata: {} + name: onap.datatypes.monitoring.managedObjectDNsBasics + version: 0.0.0 + derived_from: tosca.datatypes.Root + metadata: {} + onap.datatypes.monitoring.measurementGroup: + constraints: [] + properties: + measurementTypes: + name: measurementTypes + type: list + typeVersion: 0.0.0 + description: List of measurement types + required: true + constraints: [] + entry_schema: + type: onap.datatypes.monitoring.measurementTypes + typeVersion: 0.0.0 + constraints: [] + metadata: {} + managedObjectDNsBasic: + name: managedObjectDNsBasic + type: list + typeVersion: 0.0.0 + description: List of managed object distinguished names + required: true + constraints: [] + entry_schema: + type: onap.datatypes.monitoring.managedObjectDNsBasics + typeVersion: 0.0.0 + constraints: [] + metadata: {} + name: onap.datatypes.monitoring.measurementGroup + version: 0.0.0 + derived_from: tosca.datatypes.Root + metadata: {} + onap.datatypes.monitoring.measurementGroups: + constraints: [] + properties: + measurementGroup: + name: measurementGroup + type: map + typeVersion: 0.0.0 + description: Measurement Group + required: true + constraints: [] + entry_schema: + type: onap.datatypes.monitoring.measurementGroup + typeVersion: 0.0.0 + constraints: [] + metadata: {} + name: onap.datatypes.monitoring.measurementGroups + version: 0.0.0 + derived_from: tosca.datatypes.Root + metadata: {} + onap.datatypes.monitoring.measurementType: + constraints: [] + properties: + measurementType: + name: measurementType + type: string + typeVersion: 0.0.0 + description: Measurement type + required: true + constraints: [] + metadata: {} + name: onap.datatypes.monitoring.measurementType + version: 0.0.0 + derived_from: tosca.datatypes.Root + metadata: {} + onap.datatypes.monitoring.measurementTypes: + constraints: [] + properties: + measurementType: + name: measurementType + type: map + typeVersion: 0.0.0 + description: Measurement type object + required: true + constraints: [] + entry_schema: + type: onap.datatypes.monitoring.measurementType + typeVersion: 0.0.0 + constraints: [] + metadata: {} + name: onap.datatypes.monitoring.measurementTypes + version: 0.0.0 + derived_from: tosca.datatypes.Root + metadata: {} + onap.datatypes.monitoring.nfFilter: + constraints: [] + properties: + modelNames: + name: modelNames + type: list + typeVersion: 0.0.0 + description: List of model names + required: true + constraints: [] + entry_schema: + type: string + typeVersion: 0.0.0 + constraints: [] + metadata: {} + modelInvariantIDs: + name: modelInvariantIDs + type: list + typeVersion: 0.0.0 + description: List of model invariant IDs + required: true + constraints: [] + entry_schema: + type: string + typeVersion: 0.0.0 + constraints: [] + metadata: {} + modelVersionIDs: + name: modelVersionIDs + type: list + typeVersion: 0.0.0 + description: List of model version IDs + required: true + constraints: [] + entry_schema: + type: string + typeVersion: 0.0.0 + constraints: [] + metadata: {} + nfNames: + name: nfNames + type: list + typeVersion: 0.0.0 + description: List of network functions + required: true + constraints: [] + entry_schema: + type: string + typeVersion: 0.0.0 + constraints: [] + metadata: {} + name: onap.datatypes.monitoring.nfFilter + version: 0.0.0 + derived_from: tosca.datatypes.Root + metadata: {} + onap.datatypes.monitoring.subscription: + constraints: [] + properties: + measurementGroups: + name: measurementGroups + type: list + typeVersion: 0.0.0 + description: Measurement Groups + required: true + constraints: [] + entry_schema: + type: onap.datatypes.monitoring.measurementGroups + typeVersion: 0.0.0 + constraints: [] + metadata: {} + fileBasedGP: + name: fileBasedGP + type: integer + typeVersion: 0.0.0 + description: File based granularity period + required: true + constraints: [] + metadata: {} + fileLocation: + name: fileLocation + type: string + typeVersion: 0.0.0 + description: ROP file location + required: true + constraints: [] + metadata: {} + subscriptionName: + name: subscriptionName + type: string + typeVersion: 0.0.0 + description: Name of the subscription + required: true + constraints: [] + metadata: {} + administrativeState: + name: administrativeState + type: string + typeVersion: 0.0.0 + description: State of the subscription + required: true + constraints: + - valid_values: + - LOCKED + - UNLOCKED + metadata: {} + nfFilter: + name: nfFilter + type: map + typeVersion: 0.0.0 + description: Network function filter + required: true + constraints: [] + entry_schema: + type: onap.datatypes.monitoring.nfFilter + typeVersion: 0.0.0 + constraints: [] + metadata: {} + name: onap.datatypes.monitoring.subscription + version: 0.0.0 + derived_from: tosca.datatypes.Root + metadata: {} + org.onap.datatypes.policy.clamp.acm.httpAutomationCompositionElement.RestRequest: + version: 1.0.0 + derived_from: tosca.datatypes.Root + properties: + restRequestId: + type: onap.datatypes.ToscaConceptIdentifier + typeVersion: 1.0.0 + required: true + description: The name and version of a REST request to be sent to a REST endpoint + httpMethod: + type: string + required: true + constraints: + - valid_values: [POST, PUT, GET, DELETE] + description: The REST method to use + path: + type: string + required: true + description: The path of the REST request relative to the base URL + body: + type: string + required: false + description: The body of the REST request for PUT and POST requests + expectedResponse: + type: integer + required: true + constraints: [] + description: THe expected HTTP status code for the REST request + org.onap.datatypes.policy.clamp.acm.httpAutomationCompositionElement.ConfigurationEntity: + version: 1.0.0 + derived_from: tosca.datatypes.Root + properties: + configurationEntityId: + type: onap.datatypes.ToscaConceptIdentifier + typeVersion: 1.0.0 + required: true + description: The name and version of a Configuration Entity to be handled by the HTTP Automation Composition Element + restSequence: + type: list + entry_schema: + type: org.onap.datatypes.policy.clamp.acm.httpAutomationCompositionElement.RestRequest + typeVersion: 1.0.0 + description: A sequence of REST commands to send to the REST endpoint +policy_types: + onap.policies.Monitoring: + derived_from: tosca.policies.Root + description: a base policy type for all policies that govern monitoring provisioning + version: 1.0.0 + name: onap.policies.Monitoring + onap.policies.Sirisha: + derived_from: tosca.policies.Root + description: a base policy type for all policies that govern monitoring provisioning + version: 1.0.0 + name: onap.policies.Sirisha + onap.policies.monitoring.dcae-pm-subscription-handler: + properties: + pmsh_policy: + name: pmsh_policy + type: onap.datatypes.monitoring.subscription + typeVersion: 0.0.0 + description: PMSH Policy JSON + required: false + constraints: [] + metadata: {} + name: onap.policies.monitoring.dcae-pm-subscription-handler + version: 1.0.0 + derived_from: onap.policies.Monitoring + metadata: {} + onap.policies.acm.operational.Common: + derived_from: tosca.policies.Root + version: 1.0.0 + name: onap.policies.acm.operational.Common + description: | + Operational Policy for Automation Composition execution. Originated in Frankfurt to support TOSCA Compliant + Policy Types. This does NOT support the legacy Policy YAML policy type. + properties: + id: + type: string + description: The unique control loop id. + required: true + timeout: + type: integer + description: | + Overall timeout for executing all the operations. This timeout should equal or exceed the total + timeout for each operation listed. + required: true + abatement: + type: boolean + description: Whether an abatement event message will be expected for the control loop from DCAE. + required: true + default: false + trigger: + type: string + description: Initial operation to execute upon receiving an Onset event message for the Automation Composition. + required: true + operations: + type: list + description: List of operations to be performed when Automation Composition is triggered. + required: true + entry_schema: + type: onap.datatype.acm.Operation + onap.policies.acm.operational.common.Apex: + derived_from: onap.policies.acm.operational.Common + type_version: 1.0.0 + version: 1.0.0 + name: onap.policies.acm.operational.common.Apex + description: Operational policies for Apex PDP + properties: + engineServiceParameters: + type: string + description: The engine parameters like name, instanceCount, policy implementation, parameters etc. + required: true + eventInputParameters: + type: string + description: The event input parameters. + required: true + eventOutputParameters: + type: string + description: The event output parameters. + required: true + javaProperties: + type: string + description: Name/value pairs of properties to be set for APEX if needed. + required: false +node_types: + org.onap.policy.clamp.acm.Participant: + version: 1.0.1 + derived_from: tosca.nodetypes.Root + properties: + provider: + type: string + requred: false + org.onap.policy.clamp.acm.AutomationCompositionElement: + version: 1.0.1 + derived_from: tosca.nodetypes.Root + properties: + provider: + type: string + required: false + metadata: + common: true + description: Specifies the organization that provides the automation composition element + participant_id: + type: onap.datatypes.ToscaConceptIdentifier + requred: true + metadata: + common: true + participantType: + type: onap.datatypes.ToscaConceptIdentifier + required: true + metadata: + common: true + description: The identity of the participant type that hosts this type of Automation Composition Element + startPhase: + type: integer + required: false + constraints: + - greater_or_equal: 0 + metadata: + common: true + description: A value indicating the start phase in which this automation composition element will be started, the + first start phase is zero. Automation Composition Elements are started in their start_phase order and stopped + in reverse start phase order. Automation Composition Elements with the same start phase are started and + stopped simultaneously + uninitializedToPassiveTimeout: + type: integer + required: false + constraints: + - greater_or_equal: 0 + default: 60 + metadata: + common: true + description: The maximum time in seconds to wait for a state chage from uninitialized to passive + passiveToRunningTimeout: + type: integer + required: false + constraints: + - greater_or_equal: 0 + default: 60 + metadata: + common: true + description: The maximum time in seconds to wait for a state chage from passive to running + runningToPassiveTimeout: + type: integer + required: false + constraints: + - greater_or_equal: 0 + default: 60 + metadata: + common: true + description: The maximum time in seconds to wait for a state chage from running to passive + passiveToUninitializedTimeout: + type: integer + required: false + constraints: + - greater_or_equal: 0 + default: 60 + metadata: + common: true + description: The maximum time in seconds to wait for a state chage from passive to uninitialized + org.onap.policy.clamp.acm.AutomationComposition: + version: 1.0.1 + derived_from: tosca.nodetypes.Root + properties: + provider: + type: string + required: false + metadata: + common: true + description: Specifies the organization that provides the automation composition element + elements: + type: list + required: true + metadata: + common: true + entry_schema: + type: onap.datatypes.ToscaConceptIdentifier + description: Specifies a list of automation composition element definitions that make up this automation composition definition + org.onap.policy.clamp.acm.PolicyAutomationCompositionElement: + version: 1.0.1 + derived_from: org.onap.policy.clamp.acm.AutomationCompositionElement + properties: + policy_type_id: + type: onap.datatypes.ToscaConceptIdentifier + requred: true + policy_id: + type: onap.datatypes.ToscaConceptIdentifier + requred: false + org.onap.policy.clamp.acm.CDSAutomationCompositionElement: + version: 1.0.1 + derived_from: org.onap.policy.clamp.acm.AutomationCompositionElement + properties: + cds_blueprint_id: + type: onap.datatypes.ToscaConceptIdentifier + requred: true + org.onap.policy.clamp.acm.K8SMicroserviceAutomationCompositionElement: + version: 1.0.1 + derived_from: org.onap.policy.clamp.acm.AutomationCompositionElement + properties: + chart: + type: string + required: true + configs: + type: list + required: false + requirements: + type: string + requred: false + templates: + type: list + required: false + entry_schema: + values: + type: string + requred: true + org.onap.policy.clamp.acm.HttpAutomationCompositionElement: + version: 1.0.1 + derived_from: org.onap.policy.clamp.acm.AutomationCompositionElement + properties: + baseUrl: + type: string + required: true + description: The base URL to be prepended to each path, identifies the host for the REST endpoints. + httpHeaders: + type: map + required: false + entry_schema: + type: string + description: HTTP headers to send on REST requests + configurationEntities: + type: map + required: true + entry_schema: + type: org.onap.datatypes.policy.clamp.acm.httpAutomationCompositionElement.ConfigurationEntity + typeVersion: 1.0.0 + description: The connfiguration entities the Automation Composition Element is managing and their associated REST requests + +topology_template: + inputs: + pmsh_monitoring_policy: + type: onap.datatypes.ToscaConceptIdentifier + description: The ID of the PMSH monitoring policy to use + default: + name: MICROSERVICE_vLoadBalancerMS_v1_0_dcae-pm-subscription-handler_1_0_0test + version: 1.0.0 + pmsh_operational_policy: + type: onap.datatypes.ToscaConceptIdentifier + description: The ID of the PMSH operational policy to use + default: + name: operational.apex.pmcontrol + version: 1.0.0 + node_templates: + org.onap.policy.acm.PolicyAutomationCompositionParticipant: + version: 2.3.1 + type: org.onap.policy.clamp.acm.Participant + type_version: 1.0.1 + description: Participant for DCAE microservices + properties: + provider: ONAP + org.onap.domain.pmsh.PMSH_MonitoringPolicyAutomationCompositionElement: + version: 1.2.3 + type: org.onap.policy.clamp.acm.PolicyAutomationCompositionElement + type_version: 1.0.0 + description: Automation composition element for the monitoring policy for Performance Management Subscription Handling + properties: + provider: Ericsson + participant_id: + name: org.onap.PM_Policy + version: 1.0.0 + participantType: + name: org.onap.policy.acm.PolicyAutomationCompositionParticipant + version: 2.3.1 + policy_type_id: + name: onap.policies.monitoring.pm-subscription-handler + version: 1.0.0 + policy_id: + get_input: pmsh_monitoring_policy + org.onap.domain.pmsh.PMSH_OperationalPolicyAutomationCompositionElement: + version: 1.2.3 + type: org.onap.policy.clamp.acm.PolicyAutomationCompositionElement + type_version: 1.0.0 + description: Automation composition element for the operational policy for Performance Management Subscription Handling + properties: + provider: Ericsson + participant_id: + name: org.onap.PM_Policy + version: 1.0.0 + participantType: + name: org.onap.policy.acm.PolicyAutomationCompositionParticipant + version: 2.3.1 + policy_type_id: + name: onap.policies.operational.pm-subscription-handler + version: 1.0.0 + policy_id: + get_input: pmsh_operational_policy + org.onap.k8s.acm.K8SAutomationCompositionParticipant: + version: 2.3.4 + type: org.onap.policy.clamp.acm.Participant + type_version: 1.0.1 + description: Participant for K8S + properties: + provider: ONAP + org.onap.domain.database.PMSH_K8SMicroserviceAutomationCompositionElement: + # Chart from new repository + version: 1.2.3 + type: org.onap.policy.clamp.acm.K8SMicroserviceAutomationCompositionElement + type_version: 1.0.0 + description: Automation composition element for the K8S microservice for PMSH + properties: + provider: ONAP + participant_id: + name: K8sParticipant0 + version: 1.0.0 + participantType: + name: org.onap.k8s.acm.K8SAutomationCompositionParticipant + version: 2.3.4 + chart: + chartId: + name: dcae-pmsh + version: 8.0.0 + namespace: onap + releaseName: pmshms + repository: + repoName: chartmuseum + protocol: http + address: 10.152.183.120 + port: 80 + userName: onapinitializer + password: demo123456! + overrideParams: + global.masterPassword: test + + org.onap.domain.database.Local_K8SMicroserviceAutomationCompositionElement: + # Chart installation without passing repository info + version: 1.2.3 + type: org.onap.policy.clamp.acm.K8SMicroserviceAutomationCompositionElement + type_version: 1.0.0 + description: Automation composition element for the K8S microservice for local chart + properties: + provider: ONAP + participant_id: + name: K8sParticipant0 + version: 1.0.0 + participantType: + name: org.onap.k8s.acm.K8SAutomationCompositionParticipant + version: 2.3.4 + chart: + chartId: + name: nginx-ingress + version: 0.9.1 + releaseName: nginxms + namespace: test + org.onap.acm.HttpAutomationCompositionParticipant: + version: 2.3.4 + type: org.onap.policy.clamp.acm.Participant + type_version: 1.0.1 + description: Participant for Http requests + properties: + provider: ONAP + org.onap.domain.database.Http_PMSHMicroserviceAutomationCompositionElement: + # Consul http config for PMSH. + version: 1.2.3 + type: org.onap.policy.clamp.acm.HttpAutomationCompositionElement + type_version: 1.0.1 + description: Automation composition element for the http requests of PMSH microservice + properties: + provider: ONAP + participant_id: + name: HttpParticipant0 + version: 1.0.0 + participantType: + name: org.onap.k8s.acm.HttpAutomationCompositionParticipant + version: 2.3.4 + uninitializedToPassiveTimeout: 180 + startPhase: 1 + baseUrl: http://10.152.183.51:8500 + httpHeaders: + Content-Type: application/json + configurationEntities: + - configurationEntityId: + name: entity1 + version: 1.0.1 + restSequence: + - restRequestId: + name: request1 + version: 1.0.1 + httpMethod: PUT + path: v1/kv/dcae-pmsh2 + body: '{ + "control_loop_name":"pmsh-control-loop", + "operational_policy_name":"pmsh-operational-policy", + "aaf_password":"demo123456!", + "aaf_identity":"dcae@dcae.onap.org", + "cert_path":"/opt/app/pmsh/etc/certs/cert.pem", + "key_path":"/opt/app/pmsh/etc/certs/key.pem", + "ca_cert_path":"/opt/app/pmsh/etc/certs/cacert.pem", + "enable_tls":"true", + "pmsh_policy":{ + "subscription":{ + "subscriptionName":"ExtraPM-All-gNB-R2B", + "administrativeState":"UNLOCKED", + "fileBasedGP":15, + "fileLocation":"\/pm\/pm.xml", + "nfFilter":{ + "nfNames":[ + "^pnf.*", + "^vnf.*" + ], + "modelInvariantIDs":[ + ], + "modelVersionIDs":[ + ], + "modelNames":[ + ] + }, + "measurementGroups":[ + { + "measurementGroup":{ + "measurementTypes":[ + { + "measurementType":"countera" + }, + { + "measurementType":"counterb" + } + ], + "managedObjectDNsBasic":[ + { + "DN":"dna" + }, + { + "DN":"dnb" + } + ] + } + }, + { + "measurementGroup":{ + "measurementTypes":[ + { + "measurementType":"counterc" + }, + { + "measurementType":"counterd" + } + ], + "managedObjectDNsBasic":[ + { + "DN":"dnc" + }, + { + "DN":"dnd" + } + ] + } + } + ] + } + }, + "streams_subscribes":{ + "aai_subscriber":{ + "type":"message_router", + "dmaap_info":{ + "topic_url":"https://10.152.183.151:3905/events/AAI_EVENT", + "client_role":"org.onap.dcae.aaiSub", + "location":"san-francisco", + "client_id":"1575976809466" + } + }, + "policy_pm_subscriber":{ + "type":"message_router", + "dmaap_info":{ + "topic_url":"https://10.152.183.151:3905/events/org.onap.dmaap.mr.PM_SUBSCRIPTIONS", + "client_role":"org.onap.dcae.pmSubscriber", + "location":"san-francisco", + "client_id":"1575876809456" + } + } + }, + "streams_publishes":{ + "policy_pm_publisher":{ + "type":"message_router", + "dmaap_info":{ + "topic_url":"https://10.152.183.151:3905/events/org.onap.dmaap.mr.PM_SUBSCRIPTIONS", + "client_role":"org.onap.dcae.pmPublisher", + "location":"san-francisco", + "client_id":"1475976809466" + } + }, + "other_publisher":{ + "type":"message_router", + "dmaap_info":{ + "topic_url":"https://10.152.183.151:3905/events/org.onap.dmaap.mr.SOME_OTHER_TOPIC", + "client_role":"org.onap.dcae.pmControlPub", + "location":"san-francisco", + "client_id":"1875976809466" + } + } + } + }' + expectedResponse: 200 + org.onap.domain.sample.GenericK8s_AutomationCompositionDefinition: + version: 1.2.3 + type: org.onap.policy.clamp.acm.AutomationComposition + type_version: 1.0.0 + description: Automation composition for Hello World + properties: + provider: ONAP + elements: + - name: org.onap.domain.database.PMSH_K8SMicroserviceAutomationCompositionElement + version: 1.2.3 + - name: org.onap.domain.database.Local_K8SMicroserviceAutomationCompositionElement + version: 1.2.3 + - name: org.onap.domain.database.Http_PMSHMicroserviceAutomationCompositionElement + version: 1.2.3 + - name: org.onap.domain.pmsh.PMSH_MonitoringPolicyAutomationCompositionElement + version: 1.2.3 + - name: org.onap.domain.pmsh.PMSH_OperationalPolicyAutomationCompositionElement + version: 1.2.3 + policies: + - operational.apex.pmcontrol: + type: onap.policies.acm.operational.common.Apex + type_version: 1.0.0 + version: 1.0.0 + metadata: + policy-id: operational.apex.pmcontrol + policy-version: 1 + properties: + engineServiceParameters: + name: MyApexEngine + version: 0.0.1 + id: 45 + instanceCount: 2 + deploymentPort: 12561 + policy_type_impl: + apexPolicyModel: + key: + name: PMControlPolicy + version: 0.0.1 + keyInformation: + key: + name: PMControlPolicy_KeyInfo + version: 0.0.1 + keyInfoMap: + entry: + - key: + name: CDSActionIdentifiersType + version: 0.0.1 + value: + key: + name: CDSActionIdentifiersType + version: 0.0.1 + UUID: 6e5fa19b-14df-37e3-a4ae-8c537e861a82 + description: Generated description for concept referred to by key "CDSActionIdentifiersType:0.0.1" + - key: + name: CDSCreateResponseEvent + version: 0.0.1 + value: + key: + name: CDSCreateResponseEvent + version: 0.0.1 + UUID: 14b29e38-ac75-3273-aa4e-8583c0aa7dad + description: Generated description for concept referred to by key "CDSCreateResponseEvent:0.0.1" + - key: + name: CDSCreateResponsePayloadType + version: 0.0.1 + value: + key: + name: CDSCreateResponsePayloadType + version: 0.0.1 + UUID: 04573f8f-e772-30a5-b1d9-d7318d4a1e13 + description: Generated description for concept referred to by key "CDSCreateResponsePayloadType:0.0.1" + - key: + name: CDSCreateResponsePolicy + version: 0.0.1 + value: + key: + name: CDSCreateResponsePolicy + version: 0.0.1 + UUID: e126c965-fc09-3bfe-8f55-70f380a4a49c + description: Generated description for concept referred to by key "CDSCreateResponsePolicy:0.0.1" + - key: + name: CDSCreateResponseTask + version: 0.0.1 + value: + key: + name: CDSCreateResponseTask + version: 0.0.1 + UUID: 6165ee82-afd2-3aab-a517-f00b3f2461d2 + description: Generated description for concept referred to by key "CDSCreateResponseTask:0.0.1" + - key: + name: CDSCreateSubscriptionPayloadType + version: 0.0.1 + value: + key: + name: CDSCreateSubscriptionPayloadType + version: 0.0.1 + UUID: 8350ac5e-c157-38b9-9614-a0f93a830e60 + description: Generated description for concept referred to by key "CDSCreateSubscriptionPayloadType:0.0.1" + - key: + name: CDSCreateSubscriptionRequestEvent + version: 0.0.1 + value: + key: + name: CDSCreateSubscriptionRequestEvent + version: 0.0.1 + UUID: cfa325ba-226b-3a31-9183-ec43e2b6e9a2 + description: Generated description for concept referred to by key "CDSCreateSubscriptionRequestEvent:0.0.1" + - key: + name: CDSDeleteResponseEvent + version: 0.0.1 + value: + key: + name: CDSDeleteResponseEvent + version: 0.0.1 + UUID: 8be9c0fa-7437-3841-aff2-b3cec6ae3bd8 + description: Generated description for concept referred to by key "CDSDeleteResponseEvent:0.0.1" + - key: + name: CDSDeleteResponsePayloadType + version: 0.0.1 + value: + key: + name: CDSDeleteResponsePayloadType + version: 0.0.1 + UUID: 3fbfe0c9-152e-34d3-a504-09cd13c058d0 + description: Generated description for concept referred to by key "CDSDeleteResponsePayloadType:0.0.1" + - key: + name: CDSDeleteResponsePolicy + version: 0.0.1 + value: + key: + name: CDSDeleteResponsePolicy + version: 0.0.1 + UUID: a780251c-edd5-3132-b865-04313246b43c + description: Generated description for concept referred to by key "CDSDeleteResponsePolicy:0.0.1" + - key: + name: CDSDeleteResponseTask + version: 0.0.1 + value: + key: + name: CDSDeleteResponseTask + version: 0.0.1 + UUID: afce4555-3aa3-3521-a7d8-ee8cdf0d3efc + description: Generated description for concept referred to by key "CDSDeleteResponseTask:0.0.1" + - key: + name: CDSDeleteSubscriptionPayloadType + version: 0.0.1 + value: + key: + name: CDSDeleteSubscriptionPayloadType + version: 0.0.1 + UUID: 12658406-9147-3c9d-a38c-5ad5e30b092b + description: Generated description for concept referred to by key "CDSDeleteSubscriptionPayloadType:0.0.1" + - key: + name: CDSDeleteSubscriptionRequestEvent + version: 0.0.1 + value: + key: + name: CDSDeleteSubscriptionRequestEvent + version: 0.0.1 + UUID: 24380c95-9289-36e6-8cbf-0edefa15ccd9 + description: Generated description for concept referred to by key "CDSDeleteSubscriptionRequestEvent:0.0.1" + - key: + name: CDSRequestCommonHeaderType + version: 0.0.1 + value: + key: + name: CDSRequestCommonHeaderType + version: 0.0.1 + UUID: 35590ac0-062c-39f1-8786-b4ff716e30b1 + description: Generated description for concept referred to by key "CDSRequestCommonHeaderType:0.0.1" + - key: + name: CDSResponseCommonHeaderType + version: 0.0.1 + value: + key: + name: CDSResponseCommonHeaderType + version: 0.0.1 + UUID: dd7e1805-885a-350b-aaf9-ed541321ae3c + description: Generated description for concept referred to by key "CDSResponseCommonHeaderType:0.0.1" + - key: + name: CDSResponseStatusEvent + version: 0.0.1 + value: + key: + name: CDSResponseStatusEvent + version: 0.0.1 + UUID: 7986e21b-32f7-302e-9554-31f21b673493 + description: Generated description for concept referred to by key "CDSResponseStatusEvent:0.0.1" + - key: + name: CDSResponseStatusType + version: 0.0.1 + value: + key: + name: CDSResponseStatusType + version: 0.0.1 + UUID: 92b8a2cf-344e-3ce1-8cc0-2b7d3cb695fa + description: Generated description for concept referred to by key "CDSResponseStatusType:0.0.1" + - key: + name: CreateSubscriptionPayloadEvent + version: 0.0.1 + value: + key: + name: CreateSubscriptionPayloadEvent + version: 0.0.1 + UUID: 92162397-1a8e-3a3f-a469-d2af7700af4a + description: Generated description for concept referred to by key "CreateSubscriptionPayloadEvent:0.0.1" + - key: + name: CreateSubscriptionPayloadTask + version: 0.0.1 + value: + key: + name: CreateSubscriptionPayloadTask + version: 0.0.1 + UUID: bc0c69f0-52ed-38ea-b468-ae4a6fd1730d + description: Generated description for concept referred to by key "CreateSubscriptionPayloadTask:0.0.1" + - key: + name: CreateSubscriptionRequestTask + version: 0.0.1 + value: + key: + name: CreateSubscriptionRequestTask + version: 0.0.1 + UUID: 89cb75e9-f06c-30d3-b4ff-698d45f63869 + description: Generated description for concept referred to by key "CreateSubscriptionRequestTask:0.0.1" + - key: + name: DeleteSubscriptionPayloadEvent + version: 0.0.1 + value: + key: + name: DeleteSubscriptionPayloadEvent + version: 0.0.1 + UUID: 994fa441-04ab-33bb-832d-1cd12ab5d074 + description: Generated description for concept referred to by key "DeleteSubscriptionPayloadEvent:0.0.1" + - key: + name: DeleteSubscriptionPayloadTask + version: 0.0.1 + value: + key: + name: DeleteSubscriptionPayloadTask + version: 0.0.1 + UUID: 0f519117-5fea-3e4b-941f-8f778100465f + description: Generated description for concept referred to by key "DeleteSubscriptionPayloadTask:0.0.1" + - key: + name: DeleteSubscriptionRequestTask + version: 0.0.1 + value: + key: + name: DeleteSubscriptionRequestTask + version: 0.0.1 + UUID: acb772fe-d442-39e3-98f9-b1080caf4150 + description: Generated description for concept referred to by key "DeleteSubscriptionRequestTask:0.0.1" + - key: + name: MRResponseEvent + version: 0.0.1 + value: + key: + name: MRResponseEvent + version: 0.0.1 + UUID: 13c747a3-6bae-3bcf-9c80-b152e01dc194 + description: Generated description for concept referred to by key "MRResponseEvent:0.0.1" + - key: + name: PMControlPolicy + version: 0.0.1 + value: + key: + name: PMControlPolicy + version: 0.0.1 + UUID: acf1e55c-7bc5-3bd5-975a-0ca54afcd8a4 + description: Generated description for concept referred to by key "PMControlPolicy:0.0.1" + - key: + name: PMControlPolicy_Albums + version: 0.0.1 + value: + key: + name: PMControlPolicy_Albums + version: 0.0.1 + UUID: b38ad204-c2c8-32f4-9b5a-dda0aeb0145b + description: Generated description for concept referred to by key "PMControlPolicy_Albums:0.0.1" + - key: + name: PMControlPolicy_Events + version: 0.0.1 + value: + key: + name: PMControlPolicy_Events + version: 0.0.1 + UUID: be3871a0-c42a-3113-a066-82d192840eca + description: Generated description for concept referred to by key "PMControlPolicy_Events:0.0.1" + - key: + name: PMControlPolicy_KeyInfo + version: 0.0.1 + value: + key: + name: PMControlPolicy_KeyInfo + version: 0.0.1 + UUID: ced37634-28a4-3178-b7f6-2980794927b0 + description: Generated description for concept referred to by key "PMControlPolicy_KeyInfo:0.0.1" + - key: + name: PMControlPolicy_Policies + version: 0.0.1 + value: + key: + name: PMControlPolicy_Policies + version: 0.0.1 + UUID: be3d180d-ef9c-3a75-8e9c-84271a038bed + description: Generated description for concept referred to by key "PMControlPolicy_Policies:0.0.1" + - key: + name: PMControlPolicy_Schemas + version: 0.0.1 + value: + key: + name: PMControlPolicy_Schemas + version: 0.0.1 + UUID: e61973f1-189c-39e5-82f6-0d3afe298a20 + description: Generated description for concept referred to by key "PMControlPolicy_Schemas:0.0.1" + - key: + name: PMControlPolicy_Tasks + version: 0.0.1 + value: + key: + name: PMControlPolicy_Tasks + version: 0.0.1 + UUID: 5658adb3-2962-30a3-a241-fae75bb8eb4a + description: Generated description for concept referred to by key "PMControlPolicy_Tasks:0.0.1" + - key: + name: PMSubscriptionAlbum + version: 0.0.1 + value: + key: + name: PMSubscriptionAlbum + version: 0.0.1 + UUID: c2bd6f0d-6854-317a-9be2-97c08338428c + description: Generated description for concept referred to by key "PMSubscriptionAlbum:0.0.1" + - key: + name: PMSubscriptionOutputEvent + version: 0.0.1 + value: + key: + name: PMSubscriptionOutputEvent + version: 0.0.1 + UUID: 992b7819-9f69-3aa0-bb0f-6e45ea15ce05 + description: Generated description for concept referred to by key "PMSubscriptionOutputEvent:0.0.1" + - key: + name: PMSubscriptionType + version: 0.0.1 + value: + key: + name: PMSubscriptionType + version: 0.0.1 + UUID: 73c1c397-4fc3-357f-93b6-a8ad707fbaae + description: Generated description for concept referred to by key "PMSubscriptionType:0.0.1" + - key: + name: ReceiveEventPolicy + version: 0.0.1 + value: + key: + name: ReceiveEventPolicy + version: 0.0.1 + UUID: 568b7345-9de1-36d3-b6a3-9b857e6809a1 + description: Generated description for concept referred to by key "ReceiveEventPolicy:0.0.1" + - key: + name: ReceiveSubscriptionTask + version: 0.0.1 + value: + key: + name: ReceiveSubscriptionTask + version: 0.0.1 + UUID: f596afc8-100c-35eb-92c8-352355ea457d + description: Generated description for concept referred to by key "ReceiveSubscriptionTask:0.0.1" + - key: + name: SimpleIntType + version: 0.0.1 + value: + key: + name: SimpleIntType + version: 0.0.1 + UUID: 153791fd-ae0a-36a7-88a5-309a7936415d + description: Generated description for concept referred to by key "SimpleIntType:0.0.1" + - key: + name: SimpleStringType + version: 0.0.1 + value: + key: + name: SimpleStringType + version: 0.0.1 + UUID: 8a4957cf-9493-3a76-8c22-a208e23259af + description: Generated description for concept referred to by key "SimpleStringType:0.0.1" + - key: + name: SubscriptionStatusType + version: 0.0.1 + value: + key: + name: SubscriptionStatusType + version: 0.0.1 + UUID: 597643b1-9db1-31ce-85d0-e1c63c43b30b + description: Generated description for concept referred to by key "SubscriptionStatusType:0.0.1" + - key: + name: SubscriptionType + version: 0.0.1 + value: + key: + name: SubscriptionType + version: 0.0.1 + UUID: 184547bb-7d64-3cb2-a273-d7185102c5ce + description: Generated description for concept referred to by key "SubscriptionType:0.0.1" + - key: + name: UUIDType + version: 0.0.1 + value: + key: + name: UUIDType + version: 0.0.1 + UUID: 6a8cc68e-dfc8-3403-9c6d-071c886b319c + description: Generated description for concept referred to by key "UUIDType:0.0.1" + - key: + name: pmsh-operational-policy + version: 0.0.1 + value: + key: + name: pmsh-operational-policy + version: 0.0.1 + UUID: fdf2c9ff-6422-3ea6-b6b6-49b12116265d + description: Generated description for concept referred to by key "pmsh-operational-policy:0.0.1" + policies: + key: + name: PMControlPolicy_Policies + version: 0.0.1 + policyMap: + entry: + - key: + name: CDSCreateResponsePolicy + version: 0.0.1 + value: + policyKey: + name: CDSCreateResponsePolicy + version: 0.0.1 + template: Freestyle + state: + entry: + - key: CDSCreateResponseState + value: + stateKey: + parentKeyName: CDSCreateResponsePolicy + parentKeyVersion: 0.0.1 + parentLocalName: 'NULL' + localName: CDSCreateResponseState + trigger: + name: CDSCreateResponseEvent + version: 0.0.1 + stateOutputs: + entry: + - key: ResponseOutput + value: + key: + parentKeyName: CDSCreateResponsePolicy + parentKeyVersion: 0.0.1 + parentLocalName: CDSCreateResponseState + localName: ResponseOutput + outgoingEvent: + name: CDSResponseStatusEvent + version: 0.0.1 + nextState: + parentKeyName: 'NULL' + parentKeyVersion: 0.0.0 + parentLocalName: 'NULL' + localName: 'NULL' + contextAlbumReference: [ ] + taskSelectionLogic: + key: 'NULL' + logicFlavour: UNDEFINED + logic: '' + stateFinalizerLogicMap: + entry: [ ] + defaultTask: + name: CDSCreateResponseTask + version: 0.0.1 + taskReferences: + entry: + - key: + name: CDSCreateResponseTask + version: 0.0.1 + value: + key: + parentKeyName: CDSCreateResponsePolicy + parentKeyVersion: 0.0.1 + parentLocalName: CDSCreateResponseState + localName: CDSCreateResponsePolicy + outputType: DIRECT + output: + parentKeyName: CDSCreateResponsePolicy + parentKeyVersion: 0.0.1 + parentLocalName: CDSCreateResponseState + localName: ResponseOutput + firstState: CDSCreateResponseState + - key: + name: CDSDeleteResponsePolicy + version: 0.0.1 + value: + policyKey: + name: CDSDeleteResponsePolicy + version: 0.0.1 + template: Freestyle + state: + entry: + - key: CDSDeleteResponseState + value: + stateKey: + parentKeyName: CDSDeleteResponsePolicy + parentKeyVersion: 0.0.1 + parentLocalName: 'NULL' + localName: CDSDeleteResponseState + trigger: + name: CDSDeleteResponseEvent + version: 0.0.1 + stateOutputs: + entry: + - key: ResponseOutput + value: + key: + parentKeyName: CDSDeleteResponsePolicy + parentKeyVersion: 0.0.1 + parentLocalName: CDSDeleteResponseState + localName: ResponseOutput + outgoingEvent: + name: CDSResponseStatusEvent + version: 0.0.1 + nextState: + parentKeyName: 'NULL' + parentKeyVersion: 0.0.0 + parentLocalName: 'NULL' + localName: 'NULL' + contextAlbumReference: [ ] + taskSelectionLogic: + key: 'NULL' + logicFlavour: UNDEFINED + logic: '' + stateFinalizerLogicMap: + entry: [ ] + defaultTask: + name: CDSDeleteResponseTask + version: 0.0.1 + taskReferences: + entry: + - key: + name: CDSDeleteResponseTask + version: 0.0.1 + value: + key: + parentKeyName: CDSDeleteResponsePolicy + parentKeyVersion: 0.0.1 + parentLocalName: CDSDeleteResponseState + localName: CDSDeleteResponsePolicy + outputType: DIRECT + output: + parentKeyName: CDSDeleteResponsePolicy + parentKeyVersion: 0.0.1 + parentLocalName: CDSDeleteResponseState + localName: ResponseOutput + firstState: CDSDeleteResponseState + - key: + name: ReceiveEventPolicy + version: 0.0.1 + value: + policyKey: + name: ReceiveEventPolicy + version: 0.0.1 + template: Freestyle + state: + entry: + - key: CreateOrDeleteState + value: + stateKey: + parentKeyName: ReceiveEventPolicy + parentKeyVersion: 0.0.1 + parentLocalName: 'NULL' + localName: CreateOrDeleteState + trigger: + name: PMSubscriptionOutputEvent + version: 0.0.1 + stateOutputs: + entry: + - key: CreateSubscriptionPayload + value: + key: + parentKeyName: ReceiveEventPolicy + parentKeyVersion: 0.0.1 + parentLocalName: CreateOrDeleteState + localName: CreateSubscriptionPayload + outgoingEvent: + name: CreateSubscriptionPayloadEvent + version: 0.0.1 + nextState: + parentKeyName: ReceiveEventPolicy + parentKeyVersion: 0.0.1 + parentLocalName: 'NULL' + localName: CreateSubscription + - key: DeleteSubscriptionPayload + value: + key: + parentKeyName: ReceiveEventPolicy + parentKeyVersion: 0.0.1 + parentLocalName: CreateOrDeleteState + localName: DeleteSubscriptionPayload + outgoingEvent: + name: DeleteSubscriptionPayloadEvent + version: 0.0.1 + nextState: + parentKeyName: ReceiveEventPolicy + parentKeyVersion: 0.0.1 + parentLocalName: 'NULL' + localName: DeleteSubscription + contextAlbumReference: + - name: PMSubscriptionAlbum + version: 0.0.1 + taskSelectionLogic: + key: TaskSelectionLogic + logicFlavour: JAVASCRIPT + logic: |- + /* + * ============LICENSE_START======================================================= + * Copyright (C) 2020 Nordix. 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); + + var pmSubscriptionInfo = executor.getContextAlbum("PMSubscriptionAlbum").get(executor.inFields.get("albumID").toString()) + var changeType = pmSubscriptionInfo.get("changeType").toString() + + executor.logger.info("Change Type is " + changeType) + + if ("CREATE".equals(changeType)) { + executor.logger.info("Choosing to create a subscription") + executor.subject.getTaskKey("CreateSubscriptionPayloadTask").copyTo(executor.selectedTask); + } + else if ("DELETE".equals(changeType)) { + executor.logger.info("Choosing to delete a subscription") + executor.subject.getTaskKey("DeleteSubscriptionPayloadTask").copyTo(executor.selectedTask); + } + + //var returnValue = executor.isTrue; + true; + stateFinalizerLogicMap: + entry: [ ] + defaultTask: + name: CreateSubscriptionPayloadTask + version: 0.0.1 + taskReferences: + entry: + - key: + name: CreateSubscriptionPayloadTask + version: 0.0.1 + value: + key: + parentKeyName: ReceiveEventPolicy + parentKeyVersion: 0.0.1 + parentLocalName: CreateOrDeleteState + localName: ReceiveEventPolicy + outputType: DIRECT + output: + parentKeyName: ReceiveEventPolicy + parentKeyVersion: 0.0.1 + parentLocalName: CreateOrDeleteState + localName: CreateSubscriptionPayload + - key: + name: DeleteSubscriptionPayloadTask + version: 0.0.1 + value: + key: + parentKeyName: ReceiveEventPolicy + parentKeyVersion: 0.0.1 + parentLocalName: CreateOrDeleteState + localName: ReceiveEventPolicy + outputType: DIRECT + output: + parentKeyName: ReceiveEventPolicy + parentKeyVersion: 0.0.1 + parentLocalName: CreateOrDeleteState + localName: DeleteSubscriptionPayload + - key: CreateSubscription + value: + stateKey: + parentKeyName: ReceiveEventPolicy + parentKeyVersion: 0.0.1 + parentLocalName: 'NULL' + localName: CreateSubscription + trigger: + name: CreateSubscriptionPayloadEvent + version: 0.0.1 + stateOutputs: + entry: + - key: IssueCreateSubscriptionRequestOutput + value: + key: + parentKeyName: ReceiveEventPolicy + parentKeyVersion: 0.0.1 + parentLocalName: CreateSubscription + localName: IssueCreateSubscriptionRequestOutput + outgoingEvent: + name: CDSCreateSubscriptionRequestEvent + version: 0.0.1 + nextState: + parentKeyName: 'NULL' + parentKeyVersion: 0.0.0 + parentLocalName: 'NULL' + localName: 'NULL' + contextAlbumReference: + - name: PMSubscriptionAlbum + version: 0.0.1 + taskSelectionLogic: + key: 'NULL' + logicFlavour: UNDEFINED + logic: '' + stateFinalizerLogicMap: + entry: [ ] + defaultTask: + name: CreateSubscriptionRequestTask + version: 0.0.1 + taskReferences: + entry: + - key: + name: CreateSubscriptionRequestTask + version: 0.0.1 + value: + key: + parentKeyName: ReceiveEventPolicy + parentKeyVersion: 0.0.1 + parentLocalName: CreateSubscription + localName: ReceiveEventPolicy + outputType: DIRECT + output: + parentKeyName: ReceiveEventPolicy + parentKeyVersion: 0.0.1 + parentLocalName: CreateSubscription + localName: IssueCreateSubscriptionRequestOutput + - key: DeleteSubscription + value: + stateKey: + parentKeyName: ReceiveEventPolicy + parentKeyVersion: 0.0.1 + parentLocalName: 'NULL' + localName: DeleteSubscription + trigger: + name: DeleteSubscriptionPayloadEvent + version: 0.0.1 + stateOutputs: + entry: + - key: IssueDeleteSubscriptionRequestOutput + value: + key: + parentKeyName: ReceiveEventPolicy + parentKeyVersion: 0.0.1 + parentLocalName: DeleteSubscription + localName: IssueDeleteSubscriptionRequestOutput + outgoingEvent: + name: CDSDeleteSubscriptionRequestEvent + version: 0.0.1 + nextState: + parentKeyName: 'NULL' + parentKeyVersion: 0.0.0 + parentLocalName: 'NULL' + localName: 'NULL' + contextAlbumReference: + - name: PMSubscriptionAlbum + version: 0.0.1 + taskSelectionLogic: + key: 'NULL' + logicFlavour: UNDEFINED + logic: '' + stateFinalizerLogicMap: + entry: [ ] + defaultTask: + name: DeleteSubscriptionRequestTask + version: 0.0.1 + taskReferences: + entry: + - key: + name: DeleteSubscriptionRequestTask + version: 0.0.1 + value: + key: + parentKeyName: ReceiveEventPolicy + parentKeyVersion: 0.0.1 + parentLocalName: DeleteSubscription + localName: ReceiveEventPolicy + outputType: DIRECT + output: + parentKeyName: ReceiveEventPolicy + parentKeyVersion: 0.0.1 + parentLocalName: DeleteSubscription + localName: IssueDeleteSubscriptionRequestOutput + - key: ReceiveSubscriptionState + value: + stateKey: + parentKeyName: ReceiveEventPolicy + parentKeyVersion: 0.0.1 + parentLocalName: 'NULL' + localName: ReceiveSubscriptionState + trigger: + name: pmsh-operational-policy + version: 0.0.1 + stateOutputs: + entry: + - key: ReceivePMSubscriptionOutput + value: + key: + parentKeyName: ReceiveEventPolicy + parentKeyVersion: 0.0.1 + parentLocalName: ReceiveSubscriptionState + localName: ReceivePMSubscriptionOutput + outgoingEvent: + name: PMSubscriptionOutputEvent + version: 0.0.1 + nextState: + parentKeyName: ReceiveEventPolicy + parentKeyVersion: 0.0.1 + parentLocalName: 'NULL' + localName: CreateOrDeleteState + contextAlbumReference: + - name: PMSubscriptionAlbum + version: 0.0.1 + taskSelectionLogic: + key: 'NULL' + logicFlavour: UNDEFINED + logic: '' + stateFinalizerLogicMap: + entry: [ ] + defaultTask: + name: ReceiveSubscriptionTask + version: 0.0.1 + taskReferences: + entry: + - key: + name: ReceiveSubscriptionTask + version: 0.0.1 + value: + key: + parentKeyName: ReceiveEventPolicy + parentKeyVersion: 0.0.1 + parentLocalName: ReceiveSubscriptionState + localName: ReceiveEventPolicy + outputType: DIRECT + output: + parentKeyName: ReceiveEventPolicy + parentKeyVersion: 0.0.1 + parentLocalName: ReceiveSubscriptionState + localName: ReceivePMSubscriptionOutput + firstState: ReceiveSubscriptionState + tasks: + key: + name: PMControlPolicy_Tasks + version: 0.0.1 + taskMap: + entry: + - key: + name: CDSCreateResponseTask + version: 0.0.1 + value: + key: + name: CDSCreateResponseTask + version: 0.0.1 + inputFields: + entry: + - key: actionIdentifiers + value: + key: actionIdentifiers + fieldSchemaKey: + name: CDSActionIdentifiersType + version: 0.0.1 + optional: false + - key: commonHeader + value: + key: commonHeader + fieldSchemaKey: + name: CDSResponseCommonHeaderType + version: 0.0.1 + optional: false + - key: payload + value: + key: payload + fieldSchemaKey: + name: CDSCreateResponsePayloadType + version: 0.0.1 + optional: false + - key: status + value: + key: status + fieldSchemaKey: + name: CDSResponseStatusType + version: 0.0.1 + optional: false + outputFields: + entry: + - key: status + value: + key: status + fieldSchemaKey: + name: SubscriptionStatusType + version: 0.0.1 + optional: false + taskParameters: + entry: [ ] + contextAlbumReference: + - name: PMSubscriptionAlbum + version: 0.0.1 + taskLogic: + key: TaskLogic + logicFlavour: JAVASCRIPT + logic: |- + /* + * ============LICENSE_START======================================================= + * Copyright (C) 2020 Nordix. 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); + + var commonHeader = executor.inFields.get("commonHeader") + var response = executor.inFields.get("payload") + var albumID = commonHeader.get("requestId") + + var pmSubscriptionInfo = executor.getContextAlbum("PMSubscriptionAlbum").get(albumID.toString()); + var responseStatus = executor.subject.getOutFieldSchemaHelper("status").createNewInstance(); + + responseStatus.put("subscriptionName", pmSubscriptionInfo.get("subscription").get("subscriptionName")) + responseStatus.put("nfName", pmSubscriptionInfo.get("nfName")) + responseStatus.put("changeType", pmSubscriptionInfo.get("changeType")) + + var status = response.get(pmSubscriptionInfo.get("changeType").toLowerCase() + "_DasH_subscription_DasH_response").get("odl_DasH_response").get("status") + + executor.logger.info("RESPONSE STATUS = " + status) + + if(status == "success") { + responseStatus.put("message", "success") + } else { + responseStatus.put("message", "failed") + } + + executor.outFields.put("status", responseStatus) + + //var returnValue = executor.isTrue; + true; + - key: + name: CDSDeleteResponseTask + version: 0.0.1 + value: + key: + name: CDSDeleteResponseTask + version: 0.0.1 + inputFields: + entry: + - key: actionIdentifiers + value: + key: actionIdentifiers + fieldSchemaKey: + name: CDSActionIdentifiersType + version: 0.0.1 + optional: false + - key: commonHeader + value: + key: commonHeader + fieldSchemaKey: + name: CDSResponseCommonHeaderType + version: 0.0.1 + optional: false + - key: payload + value: + key: payload + fieldSchemaKey: + name: CDSDeleteResponsePayloadType + version: 0.0.1 + optional: false + - key: status + value: + key: status + fieldSchemaKey: + name: CDSResponseStatusType + version: 0.0.1 + optional: false + outputFields: + entry: + - key: status + value: + key: status + fieldSchemaKey: + name: SubscriptionStatusType + version: 0.0.1 + optional: false + taskParameters: + entry: [ ] + contextAlbumReference: + - name: PMSubscriptionAlbum + version: 0.0.1 + taskLogic: + key: TaskLogic + logicFlavour: JAVASCRIPT + logic: |- + /* + * ============LICENSE_START======================================================= + * Copyright (C) 2020 Nordix. 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); + + var commonHeader = executor.inFields.get("commonHeader") + var response = executor.inFields.get("payload") + var albumID = commonHeader.get("requestId") + + var pmSubscriptionInfo = executor.getContextAlbum("PMSubscriptionAlbum").get(albumID.toString()); + var responseStatus = executor.subject.getOutFieldSchemaHelper("status").createNewInstance(); + + responseStatus.put("subscriptionName", pmSubscriptionInfo.get("subscription").get("subscriptionName")) + responseStatus.put("nfName", pmSubscriptionInfo.get("nfName")) + responseStatus.put("changeType", pmSubscriptionInfo.get("changeType")) + + var status = response.get(pmSubscriptionInfo.get("changeType").toLowerCase() + "_DasH_subscription_DasH_response").get("odl_DasH_response").get("status") + + executor.logger.info("RESPONSE STATUS = " + status) + + if(status == "success") { + responseStatus.put("message", "success") + } else { + responseStatus.put("message", "failed") + } + + executor.outFields.put("status", responseStatus) + + //var returnValue = executor.isTrue; + true; + - key: + name: CreateSubscriptionPayloadTask + version: 0.0.1 + value: + key: + name: CreateSubscriptionPayloadTask + version: 0.0.1 + inputFields: + entry: + - key: albumID + value: + key: albumID + fieldSchemaKey: + name: UUIDType + version: 0.0.1 + optional: false + outputFields: + entry: + - key: albumID + value: + key: albumID + fieldSchemaKey: + name: UUIDType + version: 0.0.1 + optional: false + - key: payload + value: + key: payload + fieldSchemaKey: + name: CDSCreateSubscriptionPayloadType + version: 0.0.1 + optional: false + taskParameters: + entry: [ ] + contextAlbumReference: + - name: PMSubscriptionAlbum + version: 0.0.1 + taskLogic: + key: TaskLogic + logicFlavour: JAVASCRIPT + logic: |- + /* + * ============LICENSE_START======================================================= + * Copyright (C) 2020 Nordix. 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); + + var pmSubscriptionInfo = executor.getContextAlbum("PMSubscriptionAlbum").get(executor.inFields.get("albumID").toString()) + + var changeType = pmSubscriptionInfo.get("changeType").toLowerCase() + + var payloadProperties = executor.subject.getOutFieldSchemaHelper("payload").createNewSubInstance(changeType + "_DasH_subscription_DasH_properties_record"); + + payloadProperties.put("nfName", pmSubscriptionInfo.get("nfName")) + payloadProperties.put("subscriptionName", pmSubscriptionInfo.get("subscription").get("subscriptionName")) + payloadProperties.put("administrativeState", pmSubscriptionInfo.get("subscription").get("administrativeState")) + payloadProperties.put("fileBasedGP", pmSubscriptionInfo.get("subscription").get("fileBasedGP").toString()) + payloadProperties.put("fileLocation", pmSubscriptionInfo.get("subscription").get("fileLocation")) + payloadProperties.put("measurementGroups", pmSubscriptionInfo.get("subscription").get("measurementGroups")) + + var payloadEntry = executor.subject.getOutFieldSchemaHelper("payload").createNewSubInstance("CDSRequestPayloadEntry"); + payloadEntry.put(changeType + "_DasH_subscription_DasH_properties", payloadProperties) + + var payload = executor.subject.getOutFieldSchemaHelper("payload").createNewInstance(); + payload.put(changeType + "_DasH_subscription_DasH_request", payloadEntry); + + executor.outFields.put("albumID", executor.inFields.get("albumID")) + executor.outFields.put("payload", payload); + + //var returnValue = executor.isTrue; + true; + - key: + name: CreateSubscriptionRequestTask + version: 0.0.1 + value: + key: + name: CreateSubscriptionRequestTask + version: 0.0.1 + inputFields: + entry: + - key: albumID + value: + key: albumID + fieldSchemaKey: + name: UUIDType + version: 0.0.1 + optional: false + - key: payload + value: + key: payload + fieldSchemaKey: + name: CDSCreateSubscriptionPayloadType + version: 0.0.1 + optional: false + outputFields: + entry: + - key: actionIdentifiers + value: + key: actionIdentifiers + fieldSchemaKey: + name: CDSActionIdentifiersType + version: 0.0.1 + optional: false + - key: commonHeader + value: + key: commonHeader + fieldSchemaKey: + name: CDSRequestCommonHeaderType + version: 0.0.1 + optional: false + - key: payload + value: + key: payload + fieldSchemaKey: + name: CDSCreateSubscriptionPayloadType + version: 0.0.1 + optional: false + taskParameters: + entry: [ ] + contextAlbumReference: + - name: PMSubscriptionAlbum + version: 0.0.1 + taskLogic: + key: TaskLogic + logicFlavour: JAVASCRIPT + logic: |- + /* + * ============LICENSE_START======================================================= + * Copyright (C) 2020 Nordix. 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); + + var pmSubscriptionInfo = executor.getContextAlbum("PMSubscriptionAlbum").get(executor.inFields.get("albumID").toString()) + + var changeType = pmSubscriptionInfo.get("changeType").toLowerCase() + var blueprintName = pmSubscriptionInfo.get("blueprintName").toLowerCase() + var blueprintVersion = pmSubscriptionInfo.get("blueprintVersion").toLowerCase() + var payload = executor.inFields.get("payload") + var actionName = changeType + "-subscription" + + var commonHeader = executor.subject.getOutFieldSchemaHelper("commonHeader").createNewInstance(); + commonHeader.put("originatorId", "sdnc"); + commonHeader.put("requestId", executor.inFields.get("albumID").toString()); + commonHeader.put("subRequestId", "sub-123456-1000"); + + var actionIdentifiers = executor.subject.getOutFieldSchemaHelper("actionIdentifiers").createNewInstance(); + actionIdentifiers.put("actionName", actionName); + actionIdentifiers.put("blueprintName", blueprintName); + actionIdentifiers.put("blueprintVersion", blueprintVersion); + actionIdentifiers.put("mode", "sync"); + + executor.outFields.put("commonHeader", commonHeader); + executor.outFields.put("actionIdentifiers", actionIdentifiers); + executor.outFields.put("payload", payload); + + //var returnValue = executor.isTrue; + true; + - key: + name: DeleteSubscriptionPayloadTask + version: 0.0.1 + value: + key: + name: DeleteSubscriptionPayloadTask + version: 0.0.1 + inputFields: + entry: + - key: albumID + value: + key: albumID + fieldSchemaKey: + name: UUIDType + version: 0.0.1 + optional: false + outputFields: + entry: + - key: albumID + value: + key: albumID + fieldSchemaKey: + name: UUIDType + version: 0.0.1 + optional: false + - key: payload + value: + key: payload + fieldSchemaKey: + name: CDSDeleteSubscriptionPayloadType + version: 0.0.1 + optional: false + taskParameters: + entry: [ ] + contextAlbumReference: + - name: PMSubscriptionAlbum + version: 0.0.1 + taskLogic: + key: TaskLogic + logicFlavour: JAVASCRIPT + logic: |- + /* + * ============LICENSE_START======================================================= + * Copyright (C) 2020 Nordix. 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); + + var pmSubscriptionInfo = executor.getContextAlbum("PMSubscriptionAlbum").get(executor.inFields.get("albumID").toString()) + + var changeType = pmSubscriptionInfo.get("changeType").toLowerCase() + + var payloadProperties = executor.subject.getOutFieldSchemaHelper("payload").createNewSubInstance(changeType + "_DasH_subscription_DasH_properties_record"); + + payloadProperties.put("nfName", pmSubscriptionInfo.get("nfName")) + payloadProperties.put("subscriptionName", pmSubscriptionInfo.get("subscription").get("subscriptionName")) + payloadProperties.put("administrativeState", pmSubscriptionInfo.get("subscription").get("administrativeState")) + payloadProperties.put("fileBasedGP", pmSubscriptionInfo.get("subscription").get("fileBasedGP").toString()) + payloadProperties.put("fileLocation", pmSubscriptionInfo.get("subscription").get("fileLocation")) + payloadProperties.put("measurementGroups", pmSubscriptionInfo.get("subscription").get("measurementGroups")) + + var payloadEntry = executor.subject.getOutFieldSchemaHelper("payload").createNewSubInstance("CDSRequestPayloadEntry"); + payloadEntry.put(changeType + "_DasH_subscription_DasH_properties", payloadProperties) + + var payload = executor.subject.getOutFieldSchemaHelper("payload").createNewInstance(); + payload.put(changeType + "_DasH_subscription_DasH_request", payloadEntry); + + executor.outFields.put("albumID", executor.inFields.get("albumID")) + executor.outFields.put("payload", payload); + + //var returnValue = executor.isTrue; + true; + - key: + name: DeleteSubscriptionRequestTask + version: 0.0.1 + value: + key: + name: DeleteSubscriptionRequestTask + version: 0.0.1 + inputFields: + entry: + - key: albumID + value: + key: albumID + fieldSchemaKey: + name: UUIDType + version: 0.0.1 + optional: false + - key: payload + value: + key: payload + fieldSchemaKey: + name: CDSDeleteSubscriptionPayloadType + version: 0.0.1 + optional: false + outputFields: + entry: + - key: actionIdentifiers + value: + key: actionIdentifiers + fieldSchemaKey: + name: CDSActionIdentifiersType + version: 0.0.1 + optional: false + - key: commonHeader + value: + key: commonHeader + fieldSchemaKey: + name: CDSRequestCommonHeaderType + version: 0.0.1 + optional: false + - key: payload + value: + key: payload + fieldSchemaKey: + name: CDSDeleteSubscriptionPayloadType + version: 0.0.1 + optional: false + taskParameters: + entry: [ ] + contextAlbumReference: + - name: PMSubscriptionAlbum + version: 0.0.1 + taskLogic: + key: TaskLogic + logicFlavour: JAVASCRIPT + logic: |- + /* + * ============LICENSE_START======================================================= + * Copyright (C) 2020 Nordix. 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); + + var pmSubscriptionInfo = executor.getContextAlbum("PMSubscriptionAlbum").get(executor.inFields.get("albumID").toString()) + + var changeType = pmSubscriptionInfo.get("changeType").toLowerCase() + var blueprintName = pmSubscriptionInfo.get("blueprintName").toLowerCase() + var blueprintVersion = pmSubscriptionInfo.get("blueprintVersion").toLowerCase() + var payload = executor.inFields.get("payload") + var actionName = changeType + "-subscription" + + var commonHeader = executor.subject.getOutFieldSchemaHelper("commonHeader").createNewInstance(); + commonHeader.put("originatorId", "sdnc"); + commonHeader.put("requestId", executor.inFields.get("albumID").toString()); + commonHeader.put("subRequestId", "sub-123456-1000"); + + var actionIdentifiers = executor.subject.getOutFieldSchemaHelper("actionIdentifiers").createNewInstance(); + actionIdentifiers.put("actionName", actionName); + actionIdentifiers.put("blueprintName", blueprintName); + actionIdentifiers.put("blueprintVersion", blueprintVersion); + actionIdentifiers.put("mode", "sync"); + + executor.outFields.put("commonHeader", commonHeader); + executor.outFields.put("actionIdentifiers", actionIdentifiers); + executor.outFields.put("payload", payload); + + //var returnValue = executor.isTrue; + true; + - key: + name: ReceiveSubscriptionTask + version: 0.0.1 + value: + key: + name: ReceiveSubscriptionTask + version: 0.0.1 + inputFields: + entry: + - key: blueprintName + value: + key: blueprintName + fieldSchemaKey: + name: SimpleStringType + version: 0.0.1 + optional: false + - key: blueprintVersion + value: + key: blueprintVersion + fieldSchemaKey: + name: SimpleStringType + version: 0.0.1 + optional: false + - key: changeType + value: + key: changeType + fieldSchemaKey: + name: SimpleStringType + version: 0.0.1 + optional: false + - key: closedLoopControlName + value: + key: closedLoopControlName + fieldSchemaKey: + name: SimpleStringType + version: 0.0.1 + optional: false + - key: nfName + value: + key: nfName + fieldSchemaKey: + name: SimpleStringType + version: 0.0.1 + optional: false + - key: policyName + value: + key: policyName + fieldSchemaKey: + name: SimpleStringType + version: 0.0.1 + optional: false + - key: subscription + value: + key: subscription + fieldSchemaKey: + name: SubscriptionType + version: 0.0.1 + optional: false + outputFields: + entry: + - key: albumID + value: + key: albumID + fieldSchemaKey: + name: UUIDType + version: 0.0.1 + optional: false + taskParameters: + entry: [ ] + contextAlbumReference: + - name: PMSubscriptionAlbum + version: 0.0.1 + taskLogic: + key: TaskLogic + logicFlavour: JAVASCRIPT + logic: |- + /* + * ============LICENSE_START======================================================= + * Copyright (C) 2020 Nordix. 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========================================================= + */ + var uuidType = java.util.UUID; + + executor.logger.info(executor.subject.id); + + //albumID will be used to fetch info from our album later + var albumID = uuidType.randomUUID(); + var pmSubscriptionInfo = executor.getContextAlbum("PMSubscriptionAlbum").getSchemaHelper().createNewInstance(); + var returnValue = true; + + if(executor.inFields.get("policyName") != null) { + executor.logger.info("nfName in receive sub event " + executor.inFields.get("nfName")); + + var changeType = executor.inFields.get("changeType") + var nfName = executor.inFields.get("nfName") + var policyName = executor.inFields.get("policyName") + var closedLoopControlName = executor.inFields.get("closedLoopControlName") + var subscription = executor.inFields.get("subscription") + var blueprintName = executor.inFields.get("blueprintName") + var blueprintVersion = executor.inFields.get("blueprintVersion") + + pmSubscriptionInfo.put("nfName", executor.inFields.get("nfName")); + pmSubscriptionInfo.put("changeType", executor.inFields.get("changeType")) + pmSubscriptionInfo.put("policyName", executor.inFields.get("policyName")) + pmSubscriptionInfo.put("closedLoopControlName", executor.inFields.get("closedLoopControlName")) + pmSubscriptionInfo.put("subscription", subscription) + pmSubscriptionInfo.put("blueprintName", blueprintName) + pmSubscriptionInfo.put("blueprintVersion", blueprintVersion) + + + executor.getContextAlbum("PMSubscriptionAlbum").put(albumID.toString(), pmSubscriptionInfo); + + executor.outFields.put("albumID", albumID) + } else { + executor.message = "Received invalid event" + returnValue = false; + } + + returnValue; + events: + key: + name: PMControlPolicy_Events + version: 0.0.1 + eventMap: + entry: + - key: + name: CDSCreateResponseEvent + version: 0.0.1 + value: + key: + name: CDSCreateResponseEvent + version: 0.0.1 + nameSpace: org.onap.policy.apex.onap.pmcontrol + source: CDS + target: APEX + parameter: + entry: + - key: actionIdentifiers + value: + key: actionIdentifiers + fieldSchemaKey: + name: CDSActionIdentifiersType + version: 0.0.1 + optional: false + - key: commonHeader + value: + key: commonHeader + fieldSchemaKey: + name: CDSResponseCommonHeaderType + version: 0.0.1 + optional: false + - key: payload + value: + key: payload + fieldSchemaKey: + name: CDSCreateResponsePayloadType + version: 0.0.1 + optional: false + - key: status + value: + key: status + fieldSchemaKey: + name: CDSResponseStatusType + version: 0.0.1 + optional: false + - key: + name: CDSCreateSubscriptionRequestEvent + version: 0.0.1 + value: + key: + name: CDSCreateSubscriptionRequestEvent + version: 0.0.1 + nameSpace: org.onap.policy.apex.onap.pmcontrol + source: APEX + target: APEX + parameter: + entry: + - key: actionIdentifiers + value: + key: actionIdentifiers + fieldSchemaKey: + name: CDSActionIdentifiersType + version: 0.0.1 + optional: false + - key: commonHeader + value: + key: commonHeader + fieldSchemaKey: + name: CDSRequestCommonHeaderType + version: 0.0.1 + optional: false + - key: payload + value: + key: payload + fieldSchemaKey: + name: CDSCreateSubscriptionPayloadType + version: 0.0.1 + optional: false + - key: + name: CDSDeleteResponseEvent + version: 0.0.1 + value: + key: + name: CDSDeleteResponseEvent + version: 0.0.1 + nameSpace: org.onap.policy.apex.onap.pmcontrol + source: CDS + target: APEX + parameter: + entry: + - key: actionIdentifiers + value: + key: actionIdentifiers + fieldSchemaKey: + name: CDSActionIdentifiersType + version: 0.0.1 + optional: false + - key: commonHeader + value: + key: commonHeader + fieldSchemaKey: + name: CDSResponseCommonHeaderType + version: 0.0.1 + optional: false + - key: payload + value: + key: payload + fieldSchemaKey: + name: CDSDeleteResponsePayloadType + version: 0.0.1 + optional: false + - key: status + value: + key: status + fieldSchemaKey: + name: CDSResponseStatusType + version: 0.0.1 + optional: false + - key: + name: CDSDeleteSubscriptionRequestEvent + version: 0.0.1 + value: + key: + name: CDSDeleteSubscriptionRequestEvent + version: 0.0.1 + nameSpace: org.onap.policy.apex.onap.pmcontrol + source: APEX + target: APEX + parameter: + entry: + - key: actionIdentifiers + value: + key: actionIdentifiers + fieldSchemaKey: + name: CDSActionIdentifiersType + version: 0.0.1 + optional: false + - key: commonHeader + value: + key: commonHeader + fieldSchemaKey: + name: CDSRequestCommonHeaderType + version: 0.0.1 + optional: false + - key: payload + value: + key: payload + fieldSchemaKey: + name: CDSDeleteSubscriptionPayloadType + version: 0.0.1 + optional: false + - key: + name: CDSResponseStatusEvent + version: 0.0.1 + value: + key: + name: CDSResponseStatusEvent + version: 0.0.1 + nameSpace: org.onap.policy.apex.onap.pmcontrol + source: APEX + target: DCAE + parameter: + entry: + - key: status + value: + key: status + fieldSchemaKey: + name: SubscriptionStatusType + version: 0.0.1 + optional: false + - key: + name: CreateSubscriptionPayloadEvent + version: 0.0.1 + value: + key: + name: CreateSubscriptionPayloadEvent + version: 0.0.1 + nameSpace: org.onap.policy.apex.onap.pmcontrol + source: APEX + target: APEX + parameter: + entry: + - key: albumID + value: + key: albumID + fieldSchemaKey: + name: UUIDType + version: 0.0.1 + optional: false + - key: payload + value: + key: payload + fieldSchemaKey: + name: CDSCreateSubscriptionPayloadType + version: 0.0.1 + optional: false + - key: + name: DeleteSubscriptionPayloadEvent + version: 0.0.1 + value: + key: + name: DeleteSubscriptionPayloadEvent + version: 0.0.1 + nameSpace: org.onap.policy.apex.onap.pmcontrol + source: APEX + target: APEX + parameter: + entry: + - key: albumID + value: + key: albumID + fieldSchemaKey: + name: UUIDType + version: 0.0.1 + optional: false + - key: payload + value: + key: payload + fieldSchemaKey: + name: CDSDeleteSubscriptionPayloadType + version: 0.0.1 + optional: false + - key: + name: MRResponseEvent + version: 0.0.1 + value: + key: + name: MRResponseEvent + version: 0.0.1 + nameSpace: org.onap.policy.apex.onap.pmcontrol + source: DCAE + target: APEX + parameter: + entry: + - key: count + value: + key: count + fieldSchemaKey: + name: SimpleIntType + version: 0.0.1 + optional: false + - key: serverTimeMs + value: + key: serverTimeMs + fieldSchemaKey: + name: SimpleIntType + version: 0.0.1 + optional: false + - key: + name: PMSubscriptionOutputEvent + version: 0.0.1 + value: + key: + name: PMSubscriptionOutputEvent + version: 0.0.1 + nameSpace: org.onap.policy.apex.onap.pmcontrol + source: APEX + target: APEX + parameter: + entry: + - key: albumID + value: + key: albumID + fieldSchemaKey: + name: UUIDType + version: 0.0.1 + optional: false + - key: + name: pmsh-operational-policy + version: 0.0.1 + value: + key: + name: pmsh-operational-policy + version: 0.0.1 + nameSpace: org.onap.policy.apex.onap.pmcontrol + source: DCAE + target: APEX + parameter: + entry: + - key: blueprintName + value: + key: blueprintName + fieldSchemaKey: + name: SimpleStringType + version: 0.0.1 + optional: false + - key: blueprintVersion + value: + key: blueprintVersion + fieldSchemaKey: + name: SimpleStringType + version: 0.0.1 + optional: false + - key: changeType + value: + key: changeType + fieldSchemaKey: + name: SimpleStringType + version: 0.0.1 + optional: false + - key: closedLoopControlName + value: + key: closedLoopControlName + fieldSchemaKey: + name: SimpleStringType + version: 0.0.1 + optional: false + - key: nfName + value: + key: nfName + fieldSchemaKey: + name: SimpleStringType + version: 0.0.1 + optional: false + - key: policyName + value: + key: policyName + fieldSchemaKey: + name: SimpleStringType + version: 0.0.1 + optional: false + - key: subscription + value: + key: subscription + fieldSchemaKey: + name: SubscriptionType + version: 0.0.1 + optional: false + albums: + key: + name: PMControlPolicy_Albums + version: 0.0.1 + albums: + entry: + - key: + name: PMSubscriptionAlbum + version: 0.0.1 + value: + key: + name: PMSubscriptionAlbum + version: 0.0.1 + scope: policy + isWritable: true + itemSchema: + name: PMSubscriptionType + version: 0.0.1 + schemas: + key: + name: PMControlPolicy_Schemas + version: 0.0.1 + schemas: + entry: + - key: + name: CDSActionIdentifiersType + version: 0.0.1 + value: + key: + name: CDSActionIdentifiersType + version: 0.0.1 + schemaFlavour: Avro + schemaDefinition: |- + { + "type": "record", + "name": "ActionIdentifiers_Type", + "namespace": "org.onap.policy.apex.onap.helloworld", + "fields": [ + { + "name": "actionName", + "type": "string" + }, + { + "name": "blueprintName", + "type": "string" + }, + { + "name": "blueprintVersion", + "type": "string" + }, + { + "name": "mode", + "type": "string" + } + ] + } + - key: + name: CDSCreateResponsePayloadType + version: 0.0.1 + value: + key: + name: CDSCreateResponsePayloadType + version: 0.0.1 + schemaFlavour: Avro + schemaDefinition: |- + { + "name": "CreateResponsePayloadEntry", + "type": "record", + "namespace": "org.onap.policy.apex.onap.helloworld", + "fields": [ + { + "name": "create_DasH_subscription_DasH_response", + "type": { + "name": "create_DasH_subscription_DasH_response", + "type": "record", + "fields": [ + { + "name": "odl_DasH_response", + "type": { + "name": "odl_DasH_response", + "type": "record", + "fields": [ + { + "name": "status", + "type": "string" + } + ] + } + } + ] + } + } + ] + } + - key: + name: CDSCreateSubscriptionPayloadType + version: 0.0.1 + value: + key: + name: CDSCreateSubscriptionPayloadType + version: 0.0.1 + schemaFlavour: Avro + schemaDefinition: |- + { + "type": "map", + "values": { + "type": "record", + "name": "CDSRequestPayloadEntry", + "fields": [ + { + "name": "create_DasH_subscription_DasH_properties", + "type": { + "name": "create_DasH_subscription_DasH_properties_record", + "type": "record", + "fields": [ + { + "name": "nfName", + "type": "string" + }, + { + "name": "subscriptionName", + "type": "string" + }, + { + "name": "administrativeState", + "type": "string" + }, + { + "name": "fileBasedGP", + "type": "string" + }, + { + "name": "fileLocation", + "type": "string" + }, + { + "name": "measurementGroups", + "type": { + "type": "array", + "items": { + "name": "measurementGroups_record", + "type": "record", + "fields": [ + { + "name": "measurementGroup", + "type": { + "name": "measurementGroup", + "type": "record", + "fields": [ + { + "name": "measurementTypes", + "type": { + "type": "array", + "items": { + "name": "measurementTypes_record", + "type": "record", + "fields": [ + { + "name": "measurementType", + "type": "string" + } + ] + } + } + }, + { + "name": "managedObjectDNsBasic", + "type": { + "type": "array", + "items": { + "name": "managedObjectDNsBasic_record", + "type": "record", + "fields": [ + { + "name": "DN", + "type": "string" + } + ] + } + } + } + ] + } + } + ] + } + } + } + ] + } + } + ] + } + } + - key: + name: CDSDeleteResponsePayloadType + version: 0.0.1 + value: + key: + name: CDSDeleteResponsePayloadType + version: 0.0.1 + schemaFlavour: Avro + schemaDefinition: |- + { + "name": "DeleteResponsePayloadEntry", + "type": "record", + "namespace": "com.acme.avro", + "fields": [ + { + "name": "delete_DasH_subscription_DasH_response", + "type": { + "name": "delete_DasH_subscription_DasH_response", + "type": "record", + "fields": [ + { + "name": "odl_DasH_response", + "type": { + "name": "odl_DasH_response", + "type": "record", + "fields": [ + { + "name": "status", + "type": "string" + } + ] + } + } + ] + } + } + ] + } + - key: + name: CDSDeleteSubscriptionPayloadType + version: 0.0.1 + value: + key: + name: CDSDeleteSubscriptionPayloadType + version: 0.0.1 + schemaFlavour: Avro + schemaDefinition: |- + { + "type": "map", + "values": { + "type": "record", + "name": "CDSRequestPayloadEntry", + "fields": [ + { + "name": "delete_DasH_subscription_DasH_properties", + "type": { + "name": "delete_DasH_subscription_DasH_properties_record", + "type": "record", + "fields": [ + { + "name": "nfName", + "type": "string" + }, + { + "name": "subscriptionName", + "type": "string" + }, + { + "name": "administrativeState", + "type": "string" + }, + { + "name": "fileBasedGP", + "type": "string" + }, + { + "name": "fileLocation", + "type": "string" + }, + { + "name": "measurementGroups", + "type": { + "type": "array", + "items": { + "name": "measurementGroups_record", + "type": "record", + "fields": [ + { + "name": "measurementGroup", + "type": { + "name": "measurementGroup", + "type": "record", + "fields": [ + { + "name": "measurementTypes", + "type": { + "type": "array", + "items": { + "name": "measurementTypes_record", + "type": "record", + "fields": [ + { + "name": "measurementType", + "type": "string" + } + ] + } + } + }, + { + "name": "managedObjectDNsBasic", + "type": { + "type": "array", + "items": { + "name": "managedObjectDNsBasic_record", + "type": "record", + "fields": [ + { + "name": "DN", + "type": "string" + } + ] + } + } + } + ] + } + } + ] + } + } + } + ] + } + } + ] + } + } + - key: + name: CDSRequestCommonHeaderType + version: 0.0.1 + value: + key: + name: CDSRequestCommonHeaderType + version: 0.0.1 + schemaFlavour: Avro + schemaDefinition: |- + { + "type": "record", + "name": "RequestCommonHeader_Type", + "namespace": "org.onap.policy.apex.onap.helloworld", + "fields": [ + { + "name": "originatorId", + "type": "string" + }, + { + "name": "requestId", + "type": "string" + }, + { + "name": "subRequestId", + "type": "string" + } + ] + } + - key: + name: CDSResponseCommonHeaderType + version: 0.0.1 + value: + key: + name: CDSResponseCommonHeaderType + version: 0.0.1 + schemaFlavour: Avro + schemaDefinition: |- + { + "type": "record", + "name": "ResponseCommonHeader_Type", + "namespace": "org.onap.policy.apex.onap.helloworld", + "fields": [ + { + "name": "originatorId", + "type": "string" + }, + { + "name": "requestId", + "type": "string" + }, + { + "name": "subRequestId", + "type": "string" + }, + { + "name": "timestamp", + "type": "string" + }, + { + "name": "flags", + "type": ["null", "string"] + } + ] + } + - key: + name: CDSResponseStatusType + version: 0.0.1 + value: + key: + name: CDSResponseStatusType + version: 0.0.1 + schemaFlavour: Avro + schemaDefinition: |- + { + "type": "record", + "name": "ResponseStatus_Type", + "namespace": "org.onap.policy.apex.onap.helloworld", + "fields": [ + { + "name": "code", + "type": "int" + }, + { + "name": "eventType", + "type": "string" + }, + { + "name": "timestamp", + "type": "string" + }, + { + "name": "message", + "type": "string" + } + ] + } + - key: + name: PMSubscriptionType + version: 0.0.1 + value: + key: + name: PMSubscriptionType + version: 0.0.1 + schemaFlavour: Avro + schemaDefinition: "{\n\t\"name\": \"PMSubscription\",\n\t\"type\": \"record\",\n\t\"namespace\": \"\ + org.onap.policy.apex.onap.pmcontrol\",\n\t\"fields\": [\n {\n \"name\": \"nfName\"\ + ,\n \"type\": \"string\"\n },\n\t {\n\t\t\t\"name\": \"changeType\",\n\t\t\t\"\ + type\": \"string\"\n\t\t},\n\t\t{\n\t\t\t\"name\": \"closedLoopControlName\",\n\t\t\t\"type\": \"\ + string\"\n\t\t},\n\t\t{\n\t\t\t\"name\": \"policyName\",\n\t\t\t\"type\": \"string\"\n\t\t},\n\t\t\ + {\n\t\t \"name\": \"blueprintName\",\n\t\t \"type\": \"string\"\n\t\t},\n\t\t{\n\t\t \"name\"\ + : \"blueprintVersion\",\n\t\t \"type\": \"string\"\n\t\t},\n\t\t{\n\t\t\t\"name\": \"subscription\"\ + ,\n\t\t\t\"type\": {\n\t\t\t\t\"name\": \"subscription\",\n\t\t\t\t\"type\": \"record\",\n\t\t\t\t\ + \"fields\": [{\n\t\t\t\t\t\t\"name\": \"subscriptionName\",\n\t\t\t\t\t\t\"type\": \"string\"\n\t\t\ + \t\t\t},\n\t\t\t\t\t{\n\t\t\t\t\t\t\"name\": \"administrativeState\",\n\t\t\t\t\t\t\"type\": \"string\"\ + \n\t\t\t\t\t},\n\t\t\t\t\t{\n\t\t\t\t\t\t\"name\": \"fileBasedGP\",\n\t\t\t\t\t\t\"type\": \"int\"\ + \n\t\t\t\t\t},\n\t\t\t\t\t{\n\t\t\t\t\t\t\"name\": \"fileLocation\",\n\t\t\t\t\t\t\"type\": \"string\"\ + \n\t\t\t\t\t},\n\t\t\t\t\t{\n\t\t\t\t\t\t\"name\": \"measurementGroups\",\n\t\t\t\t\t\t\"type\": {\n\ + \t\t\t\t\t\t\t\"type\": \"array\",\n\t\t\t\t\t\t\t\"items\": {\n\t\t\t\t\t\t\t\t\"name\": \"Measurement_Groups_Type\"\ + ,\n\t\t\t\t\t\t\t\t\"type\": \"record\",\n\t\t\t\t\t\t\t\t\"fields\": [{\n\t\t\t\t\t\t\t\t\t\"name\"\ + : \"measurementGroup\",\n\t\t\t\t\t\t\t\t\t\"type\": {\n\t\t\t\t\t\t\t\t\t\t\"name\": \"Measurement_Group_Type\"\ + ,\n\t\t\t\t\t\t\t\t\t\t\"type\": \"record\",\n\t\t\t\t\t\t\t\t\t\t\"fields\": [{\n\t\t\t\t\t\t\t\t\ + \t\t\t\t\"name\": \"measurementTypes\",\n\t\t\t\t\t\t\t\t\t\t\t\t\"type\": {\n\t\t\t\t\t\t\t\t\t\t\ + \t\t\t\"type\": \"array\",\n\t\t\t\t\t\t\t\t\t\t\t\t\t\"items\": {\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\"\ + name\": \"Measurement_Types_Type\",\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\"type\": \"record\",\n\t\t\t\t\t\ + \t\t\t\t\t\t\t\t\t\"fields\": [{\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\"name\": \"measurementType\",\n\t\ + \t\t\t\t\t\t\t\t\t\t\t\t\t\t\"type\": \"string\"\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t}]\n\t\t\t\t\t\t\t\t\ + \t\t\t\t\t}\n\t\t\t\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\t\t\t\t{\n\t\t\t\t\ + \t\t\t\t\t\t\t\t\"name\": \"managedObjectDNsBasic\",\n\t\t\t\t\t\t\t\t\t\t\t\t\"type\": {\n\t\t\t\t\ + \t\t\t\t\t\t\t\t\t\"type\": \"array\",\n\t\t\t\t\t\t\t\t\t\t\t\t\t\"items\": {\n\t\t\t\t\t\t\t\t\t\ + \t\t\t\t\t\"name\": \"Managed_Object_Dns_Basic_Type\",\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\"type\": \"record\"\ + ,\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\"fields\": [{\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\"name\": \"DN\",\n\t\ + \t\t\t\t\t\t\t\t\t\t\t\t\t\t\"type\": \"string\"\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t}]\n\t\t\t\t\t\t\t\t\ + \t\t\t\t\t}\n\t\t\t\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\t\t]\n\t\t\t\t\t\ + \t\t\t\t}\n\t\t\t\t\t\t\t\t}]\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t]\n\t\t\t}\n\t\ + \t}\n\t]\n}" + - key: + name: SimpleIntType + version: 0.0.1 + value: + key: + name: SimpleIntType + version: 0.0.1 + schemaFlavour: Java + schemaDefinition: java.lang.Integer + - key: + name: SimpleStringType + version: 0.0.1 + value: + key: + name: SimpleStringType + version: 0.0.1 + schemaFlavour: Java + schemaDefinition: java.lang.String + - key: + name: SubscriptionStatusType + version: 0.0.1 + value: + key: + name: SubscriptionStatusType + version: 0.0.1 + schemaFlavour: Avro + schemaDefinition: |- + { + "type": "record", + "name": "ActivateSubscriptionStatus_Type", + "namespace": "org.onap.policy.apex.onap.helloworld", + "fields": [ + { + "name": "subscriptionName", + "type": "string" + }, + { + "name": "nfName", + "type": "string" + }, + { + "name": "changeType", + "type": "string" + }, + { + "name": "message", + "type": "string" + } + ] + } + - key: + name: SubscriptionType + version: 0.0.1 + value: + key: + name: SubscriptionType + version: 0.0.1 + schemaFlavour: Avro + schemaDefinition: "{\n\t\"name\": \"subscription\",\n\t\"type\": \"record\",\n\t\"fields\": [{\n\t\t\ + \t\"name\": \"subscriptionName\",\n\t\t\t\"type\": \"string\"\n\t\t},\n\t\t{\n\t\t\t\"name\": \"administrativeState\"\ + ,\n\t\t\t\"type\": \"string\"\n\t\t},\n\t\t{\n\t\t\t\"name\": \"fileBasedGP\",\n\t\t\t\"type\": \"\ + int\"\n\t\t},\n\t\t{\n\t\t\t\"name\": \"fileLocation\",\n\t\t\t\"type\": \"string\"\n\t\t},\n\t\t\ + {\n\t\t\t\"name\": \"measurementGroups\",\n\t\t\t\"type\": {\n\t\t\t\t\"type\": \"array\",\n\t\t\t\ + \t\"items\": {\n\t\t\t\t\t\"name\": \"Measurement_Groups_Type\",\n\t\t\t\t\t\"type\": \"record\",\n\ + \t\t\t\t\t\"fields\": [{\n\t\t\t\t\t\t\"name\": \"measurementGroup\",\n\t\t\t\t\t\t\"type\": {\n\t\ + \t\t\t\t\t\t\"name\": \"Measurement_Group_Type\",\n\t\t\t\t\t\t\t\"type\": \"record\",\n\t\t\t\t\t\ + \t\t\"fields\": [{\n\t\t\t\t\t\t\t\t\t\"name\": \"measurementTypes\",\n\t\t\t\t\t\t\t\t\t\"type\"\ + : {\n\t\t\t\t\t\t\t\t\t\t\"type\": \"array\",\n\t\t\t\t\t\t\t\t\t\t\"items\": {\n\t\t\t\t\t\t\t\t\t\ + \t\t\"name\": \"Measurement_Types_Type\",\n\t\t\t\t\t\t\t\t\t\t\t\"type\": \"record\",\n\t\t\t\t\t\ + \t\t\t\t\t\t\"fields\": [{\n\t\t\t\t\t\t\t\t\t\t\t\t\"name\": \"measurementType\",\n\t\t\t\t\t\t\t\ + \t\t\t\t\t\"type\": \"string\"\n\t\t\t\t\t\t\t\t\t\t\t}]\n\t\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\t\ + }\n\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\t\"name\": \"managedObjectDNsBasic\",\n\ + \t\t\t\t\t\t\t\t\t\"type\": {\n\t\t\t\t\t\t\t\t\t\t\"type\": \"array\",\n\t\t\t\t\t\t\t\t\t\t\"items\"\ + : {\n\t\t\t\t\t\t\t\t\t\t\t\"name\": \"Managed_Object_Dns_Basic_Type\",\n\t\t\t\t\t\t\t\t\t\t\t\"\ + type\": \"record\",\n\t\t\t\t\t\t\t\t\t\t\t\"fields\": [{\n\t\t\t\t\t\t\t\t\t\t\t\t\"name\": \"DN\"\ + ,\n\t\t\t\t\t\t\t\t\t\t\t\t\"type\": \"string\"\n\t\t\t\t\t\t\t\t\t\t\t}]\n\t\t\t\t\t\t\t\t\t\t}\n\ + \t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t]\n\t\t\t\t\t\t}\n\t\t\t\t\t}]\n\t\t\t\t}\n\t\ + \t\t}\n\t\t}\n\t]\n}" + - key: + name: UUIDType + version: 0.0.1 + value: + key: + name: UUIDType + version: 0.0.1 + schemaFlavour: Java + schemaDefinition: java.util.UUID + 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.acm.util.Serialization$GsonInstantAdapter + eventInputParameters: + DCAEConsumer: + carrierTechnologyParameters: + carrierTechnology: RESTCLIENT + parameterClassName: org.onap.policy.apex.plugins.event.carrier.restclient.RestClientCarrierTechnologyParameters + parameters: + consumerPollTime: '50' + url: https://message-router:3905/events/unauthenticated.DCAE_CL_OUTPUT/cg1/sg1 + eventProtocolParameters: + eventProtocol: JSON + parameters: + nameAlias: policyName + eventName: pmsh-operational-policy + eventNameFilter: pmsh-operational-policy + CDSRequestConsumer: + carrierTechnologyParameters: + carrierTechnology: RESTREQUESTOR + parameterClassName: org.onap.policy.apex.plugins.event.carrier.restrequestor.RestRequestorCarrierTechnologyParameters + parameters: + url: http://10.10.10.184:30254/api/v1/execution-service/process + httpMethod: POST + restRequestTimeout: 2000 + httpHeaders: + - - Authorization + - Basic Y2NzZGthcHBzOmNjc2RrYXBwcw== + eventProtocolParameters: + eventProtocol: JSON + eventName: CDSCreateResponseEvent + eventNameFilter: CDSCreateResponseEvent + requestorMode: true + requestorPeer: CDSRequestProducer + requestorTimeout: 500 + CDSDeleteRequestConsumer: + carrierTechnologyParameters: + carrierTechnology: RESTREQUESTOR + parameterClassName: org.onap.policy.apex.plugins.event.carrier.restrequestor.RestRequestorCarrierTechnologyParameters + parameters: + url: http://10.10.10.184:30254/api/v1/execution-service/process + httpMethod: POST + restRequestTimeout: 2000 + httpHeaders: + - - Authorization + - Basic Y2NzZGthcHBzOmNjc2RrYXBwcw== + eventProtocolParameters: + eventProtocol: JSON + eventName: CDSDeleteResponseEvent + eventNameFilter: CDSDeleteResponseEvent + requestorMode: true + requestorPeer: CDSDeleteRequestProducer + requestorTimeout: 500 + CDSReplyConsumer: + carrierTechnologyParameters: + carrierTechnology: RESTREQUESTOR + parameterClassName: org.onap.policy.apex.plugins.event.carrier.restrequestor.RestRequestorCarrierTechnologyParameters + parameters: + url: https://message-router:3905/events/unauthenticated.PMSH_CL_INPUT + httpMethod: POST + restRequestTimeout: 2000 + eventProtocolParameters: + eventProtocol: JSON + eventName: MRResponseEvent + eventNameFilter: MRResponseEvent + requestorMode: true + requestorPeer: CDSReplyProducer + requestorTimeout: 500 + eventOutputParameters: + logOutputter: + carrierTechnologyParameters: + carrierTechnology: FILE + parameters: + fileName: /tmp/outputevents.log + eventProtocolParameters: + eventProtocol: JSON + StdOutOutputter: + carrierTechnologyParameters: + carrierTechnology: FILE + parameters: + standardIo: true + eventProtocolParameters: + eventProtocol: JSON + CDSRequestProducer: + carrierTechnologyParameters: + carrierTechnology: RESTREQUESTOR + parameterClassName: org.onap.policy.apex.plugins.event.carrier.restrequestor.RestRequestorCarrierTechnologyParameters + eventProtocolParameters: + eventProtocol: JSON + eventNameFilter: CDSCreateSubscriptionRequestEvent + requestorMode: true + requestorPeer: CDSRequestConsumer + requestorTimeout: 500 + CDSDeleteRequestProducer: + carrierTechnologyParameters: + carrierTechnology: RESTREQUESTOR + parameterClassName: org.onap.policy.apex.plugins.event.carrier.restrequestor.RestRequestorCarrierTechnologyParameters + eventProtocolParameters: + eventProtocol: JSON + eventNameFilter: CDSDeleteSubscriptionRequestEvent + requestorMode: true + requestorPeer: CDSDeleteRequestConsumer + requestorTimeout: 500 + CDSReplyProducer: + carrierTechnologyParameters: + carrierTechnology: RESTREQUESTOR + parameterClassName: org.onap.policy.apex.plugins.event.carrier.restrequestor.RestRequestorCarrierTechnologyParameters + eventProtocolParameters: + eventProtocol: JSON + eventNameFilter: CDSResponseStatusEvent + requestorMode: true + requestorPeer: CDSReplyConsumer + requestorTimeout: 500 diff --git a/runtime-acm/src/test/resources/testscripts/listenOnTopic.sh b/runtime-acm/src/test/resources/testscripts/listenOnTopic.sh new file mode 100755 index 000000000..5e661777b --- /dev/null +++ b/runtime-acm/src/test/resources/testscripts/listenOnTopic.sh @@ -0,0 +1,31 @@ +#! /bin/bash +# ============LICENSE_START======================================================= +# Copyright (C) 2021 Nordix Foundation. +# ================================================================================ +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# SPDX-License-Identifier: Apache-2.0 +# ============LICENSE_END========================================================= + +if [ $# -ne 1 ] +then + echo invalid parameters $*, specify a single parameter as the topic to listen on + exit 1 +fi + +while true +do + curl "http://localhost:3904/events/$1/TEST/1?timeout=60000" + echo "" +done + diff --git a/runtime-controlloop/pom.xml b/runtime-controlloop/pom.xml deleted file mode 100644 index be5597fa1..000000000 --- a/runtime-controlloop/pom.xml +++ /dev/null @@ -1,124 +0,0 @@ - - - - - 4.0.0 - - - org.onap.policy.clamp - policy-clamp - 6.2.1-SNAPSHOT - - - policy-clamp-runtime-controlloop - ${project.artifactId} - - - - org.onap.policy.clamp - policy-clamp-common - ${project.version} - - - org.onap.policy.clamp - policy-clamp-models - ${project.version} - - - com.fasterxml.jackson.module - jackson-module-jsonSchema - ${version.jackson} - - - javax.validation - validation-api - - - - - org.springframework.boot - spring-boot-starter-web - - - org.springframework.boot - spring-boot-starter-json - - - - - org.springframework.boot - spring-boot-starter-aop - ${version.springboot} - - - org.springframework.boot - spring-boot-starter-security - - - org.springframework.boot - spring-boot-starter-validation - - - io.springfox - springfox-boot-starter - ${version.springfox} - - - org.springframework.boot - spring-boot-starter-actuator - ${version.springboot} - - - io.micrometer - micrometer-registry-prometheus - ${version.io.micrometer} - - - io.springfox - springfox-swagger-ui - runtime - - - org.springframework.boot - spring-boot-starter-test - test - - - - - - - org.springframework.boot - spring-boot-maven-plugin - - - - repackage - - package - - - - - - diff --git a/runtime-controlloop/src/main/java/org/onap/policy/clamp/controlloop/runtime/Application.java b/runtime-controlloop/src/main/java/org/onap/policy/clamp/controlloop/runtime/Application.java deleted file mode 100644 index 44a661e55..000000000 --- a/runtime-controlloop/src/main/java/org/onap/policy/clamp/controlloop/runtime/Application.java +++ /dev/null @@ -1,45 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * Copyright (C) 2021 Nordix Foundation. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - * SPDX-License-Identifier: Apache-2.0 - * ============LICENSE_END========================================================= - */ - -package org.onap.policy.clamp.controlloop.runtime; - -import org.springframework.boot.SpringApplication; -import org.springframework.boot.autoconfigure.SpringBootApplication; -import org.springframework.boot.autoconfigure.domain.EntityScan; -import org.springframework.boot.context.properties.ConfigurationPropertiesScan; -import org.springframework.context.annotation.ComponentScan; -import org.springframework.data.jpa.repository.config.EnableJpaRepositories; -import org.springframework.scheduling.annotation.EnableScheduling; - -@EnableScheduling -@SpringBootApplication -@EnableJpaRepositories({"org.onap.policy.clamp.controlloop.models.controlloop.persistence.repository"}) -@ComponentScan({"org.onap.policy.clamp.controlloop.models.controlloop.persistence.provider", - "org.onap.policy.clamp.controlloop.runtime", - "org.onap.policy.clamp.controlloop.common.rest"}) -@ConfigurationPropertiesScan("org.onap.policy.clamp.controlloop.runtime.main.parameters") -@EntityScan({"org.onap.policy.models.tosca.simple.concepts", - "org.onap.policy.clamp.controlloop.models.controlloop.persistence.concepts"}) -public class Application { - - public static void main(String[] args) { - SpringApplication.run(Application.class, args); - } -} diff --git a/runtime-controlloop/src/main/java/org/onap/policy/clamp/controlloop/runtime/commissioning/CommissioningProvider.java b/runtime-controlloop/src/main/java/org/onap/policy/clamp/controlloop/runtime/commissioning/CommissioningProvider.java deleted file mode 100644 index 382823b19..000000000 --- a/runtime-controlloop/src/main/java/org/onap/policy/clamp/controlloop/runtime/commissioning/CommissioningProvider.java +++ /dev/null @@ -1,378 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * Copyright (C) 2021 Nordix Foundation. - * Modifications Copyright (C) 2021 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - * SPDX-License-Identifier: Apache-2.0 - * ============LICENSE_END========================================================= - */ - -package org.onap.policy.clamp.controlloop.runtime.commissioning; - -import com.fasterxml.jackson.core.JsonProcessingException; -import com.fasterxml.jackson.databind.ObjectMapper; -import com.fasterxml.jackson.databind.PropertyNamingStrategies; -import com.fasterxml.jackson.module.jsonSchema.factories.SchemaFactoryWrapper; -import java.util.ArrayList; -import java.util.Collections; -import java.util.HashMap; -import java.util.List; -import java.util.Map; -import java.util.stream.Collectors; -import javax.ws.rs.core.Response.Status; -import org.apache.commons.collections4.CollectionUtils; -import org.apache.commons.collections4.MapUtils; -import org.onap.policy.clamp.controlloop.models.controlloop.concepts.Participant; -import org.onap.policy.clamp.controlloop.models.controlloop.persistence.provider.ControlLoopProvider; -import org.onap.policy.clamp.controlloop.models.controlloop.persistence.provider.ParticipantProvider; -import org.onap.policy.clamp.controlloop.models.controlloop.persistence.provider.ServiceTemplateProvider; -import org.onap.policy.clamp.controlloop.models.messages.rest.commissioning.CommissioningResponse; -import org.onap.policy.clamp.controlloop.runtime.supervision.SupervisionHandler; -import org.onap.policy.models.base.PfModelException; -import org.onap.policy.models.tosca.authorative.concepts.ToscaCapabilityType; -import org.onap.policy.models.tosca.authorative.concepts.ToscaConceptIdentifier; -import org.onap.policy.models.tosca.authorative.concepts.ToscaDataType; -import org.onap.policy.models.tosca.authorative.concepts.ToscaNodeTemplate; -import org.onap.policy.models.tosca.authorative.concepts.ToscaNodeType; -import org.onap.policy.models.tosca.authorative.concepts.ToscaPolicyType; -import org.onap.policy.models.tosca.authorative.concepts.ToscaRelationshipType; -import org.onap.policy.models.tosca.authorative.concepts.ToscaServiceTemplate; -import org.onap.policy.models.tosca.authorative.concepts.ToscaServiceTemplates; -import org.onap.policy.models.tosca.authorative.concepts.ToscaTopologyTemplate; -import org.onap.policy.models.tosca.authorative.concepts.ToscaTypedEntityFilter; -import org.springframework.stereotype.Service; -import org.springframework.transaction.annotation.Transactional; - -/** - * This class provides the create, read and delete actions on Commissioning of Control Loop concepts in the database to - * the callers. - */ -@Service -@Transactional -public class CommissioningProvider { - public static final String CONTROL_LOOP_NODE_TYPE = "org.onap.policy.clamp.controlloop.ControlLoop"; - private static final String INSTANCE_TEXT = "_Instance"; - - private final ServiceTemplateProvider serviceTemplateProvider; - private final ControlLoopProvider clProvider; - private final ObjectMapper mapper = new ObjectMapper(); - private final ParticipantProvider participantProvider; - private final SupervisionHandler supervisionHandler; - - /** - * Create a commissioning provider. - * - * @param serviceTemplateProvider the ServiceTemplate Provider - * @param clProvider the ControlLoop Provider - * @param supervisionHandler the Supervision Handler - * @param participantProvider the Participant Provider - */ - public CommissioningProvider(ServiceTemplateProvider serviceTemplateProvider, ControlLoopProvider clProvider, - SupervisionHandler supervisionHandler, ParticipantProvider participantProvider) { - this.serviceTemplateProvider = serviceTemplateProvider; - this.clProvider = clProvider; - this.supervisionHandler = supervisionHandler; - this.participantProvider = participantProvider; - mapper.setPropertyNamingStrategy(PropertyNamingStrategies.SNAKE_CASE); - } - - /** - * Create control loops from a service template. - * - * @param serviceTemplate the service template - * @return the result of the commissioning operation - * @throws PfModelException on creation errors - */ - public CommissioningResponse createControlLoopDefinitions(ToscaServiceTemplate serviceTemplate) - throws PfModelException { - - if (verifyIfInstancePropertiesExists()) { - throw new PfModelException(Status.BAD_REQUEST, "Delete instances, to commission control loop definitions"); - } - serviceTemplate = serviceTemplateProvider.createServiceTemplate(serviceTemplate); - List participantList = participantProvider.getParticipants(); - if (!participantList.isEmpty()) { - supervisionHandler.handleSendCommissionMessage(serviceTemplate.getName(), serviceTemplate.getVersion()); - } - var response = new CommissioningResponse(); - // @formatter:off - response.setAffectedControlLoopDefinitions(serviceTemplate.getToscaTopologyTemplate().getNodeTemplates() - .values() - .stream() - .map(template -> template.getKey().asIdentifier()) - .collect(Collectors.toList())); - // @formatter:on - - return response; - } - - /** - * Delete the control loop definition with the given name and version. - * - * @param name the name of the control loop definition to delete - * @param version the version of the control loop to delete - * @return the result of the deletion - * @throws PfModelException on deletion errors - */ - public CommissioningResponse deleteControlLoopDefinition(String name, String version) throws PfModelException { - - if (verifyIfInstancePropertiesExists()) { - throw new PfModelException(Status.BAD_REQUEST, "Delete instances, to commission control loop definitions"); - } - List participantList = participantProvider.getParticipants(); - if (!participantList.isEmpty()) { - supervisionHandler.handleSendDeCommissionMessage(); - } - serviceTemplateProvider.deleteServiceTemplate(name, version); - var response = new CommissioningResponse(); - response.setAffectedControlLoopDefinitions(List.of(new ToscaConceptIdentifier(name, version))); - - return response; - } - - /** - * Get control loop node templates. - * - * @param clName the name of the control loop, null for all - * @param clVersion the version of the control loop, null for all - * @return list of control loop node templates - * @throws PfModelException on errors getting control loop definitions - */ - @Transactional(readOnly = true) - public List getControlLoopDefinitions(String clName, String clVersion) throws PfModelException { - - // @formatter:off - ToscaTypedEntityFilter nodeTemplateFilter = ToscaTypedEntityFilter - .builder() - .name(clName) - .version(clVersion) - .type(CONTROL_LOOP_NODE_TYPE) - .build(); - // @formatter:on - - return clProvider.getFilteredNodeTemplates(nodeTemplateFilter); - } - - /** - * Get the control loop elements from a control loop node template. - * - * @param controlLoopNodeTemplate the control loop node template - * @return a list of the control loop element node templates in a control loop node template - * @throws PfModelException on errors get control loop element node templates - */ - @Transactional(readOnly = true) - public List getControlLoopElementDefinitions(ToscaNodeTemplate controlLoopNodeTemplate) - throws PfModelException { - if (!CONTROL_LOOP_NODE_TYPE.equals(controlLoopNodeTemplate.getType())) { - return Collections.emptyList(); - } - - if (MapUtils.isEmpty(controlLoopNodeTemplate.getProperties())) { - return Collections.emptyList(); - } - - @SuppressWarnings("unchecked") - List> controlLoopElements = - (List>) controlLoopNodeTemplate.getProperties().get("elements"); - - if (CollectionUtils.isEmpty(controlLoopElements)) { - return Collections.emptyList(); - } - - List controlLoopElementList = new ArrayList<>(); - // @formatter:off - controlLoopElementList.addAll( - controlLoopElements - .stream() - .map(elementMap -> clProvider.getNodeTemplates(elementMap.get("name"), - elementMap.get("version"))) - .flatMap(List::stream) - .collect(Collectors.toList()) - ); - // @formatter:on - - return controlLoopElementList; - } - - /** - * Get node templates with common properties added. - * - * @param common boolean indicating common or instance properties to be used - * @param name the name of the definition to use, null for all definitions - * @param version the version of the definition to use, null for all definitions - * @return the nodes templates with common or instance properties - * @throws PfModelException on errors getting common or instance properties from node_templates - */ - @Transactional(readOnly = true) - public Map getNodeTemplatesWithCommonOrInstanceProperties(boolean common, String name, - String version) throws PfModelException { - - if (common && verifyIfInstancePropertiesExists()) { - throw new PfModelException(Status.BAD_REQUEST, - "Cannot create or edit common properties, delete all the instantiations first"); - } - - var serviceTemplateList = serviceTemplateProvider.getServiceTemplateList(name, version); - var commonOrInstanceNodeTypeProps = - serviceTemplateProvider.getCommonOrInstancePropertiesFromNodeTypes(common, serviceTemplateList.get(0)); - - var serviceTemplates = new ToscaServiceTemplates(); - serviceTemplates.setServiceTemplates(filterToscaNodeTemplateInstance(serviceTemplateList)); - - return serviceTemplateProvider.getDerivedCommonOrInstanceNodeTemplates( - serviceTemplates.getServiceTemplates().get(0).getToscaTopologyTemplate().getNodeTemplates(), - commonOrInstanceNodeTypeProps); - } - - /** - * Get the requested control loop definitions. - * - * @param name the name of the definition to get, null for all definitions - * @param version the version of the definition to get, null for all definitions - * @return the control loop definitions - * @throws PfModelException on errors getting control loop definitions - */ - @Transactional(readOnly = true) - public ToscaServiceTemplate getToscaServiceTemplate(String name, String version) throws PfModelException { - return serviceTemplateProvider.getToscaServiceTemplate(name, version); - } - - /** - * Get All the requested control loop definitions. - * - * @return the control loop definitions - * @throws PfModelException on errors getting control loop definitions - */ - @Transactional(readOnly = true) - public List getAllToscaServiceTemplate() throws PfModelException { - return serviceTemplateProvider.getAllServiceTemplates(); - } - - /** - * Get the tosca service template with only required sections. - * - * @param name the name of the template to get, null for all definitions - * @param version the version of the template to get, null for all definitions - * @return the tosca service template - * @throws PfModelException on errors getting tosca service template - */ - @Transactional(readOnly = true) - public String getToscaServiceTemplateReduced(String name, String version) throws PfModelException { - var serviceTemplateList = serviceTemplateProvider.getServiceTemplateList(name, version); - - List filteredServiceTemplateList = filterToscaNodeTemplateInstance(serviceTemplateList); - - if (filteredServiceTemplateList.isEmpty()) { - throw new PfModelException(Status.BAD_REQUEST, "Invalid Service Template"); - } - - ToscaServiceTemplate fullTemplate = filteredServiceTemplateList.get(0); - - var template = new HashMap(); - template.put("tosca_definitions_version", fullTemplate.getToscaDefinitionsVersion()); - template.put("data_types", fullTemplate.getDataTypes()); - template.put("policy_types", fullTemplate.getPolicyTypes()); - template.put("node_types", fullTemplate.getNodeTypes()); - template.put("topology_template", fullTemplate.getToscaTopologyTemplate()); - - try { - return mapper.writerWithDefaultPrettyPrinter().writeValueAsString(template); - - } catch (JsonProcessingException e) { - throw new PfModelException(Status.BAD_REQUEST, "Converion to Json Schema failed", e); - } - } - - /** - * Get the requested json schema. - * - * @param section section of the tosca service template to get schema for - * @return the specified tosca service template or section Json Schema - * @throws PfModelException on errors with retrieving the classes - */ - @Transactional(readOnly = true) - public String getToscaServiceTemplateSchema(String section) throws PfModelException { - var visitor = new SchemaFactoryWrapper(); - - try { - switch (section) { - case "data_types": - mapper.acceptJsonFormatVisitor(mapper.constructType(ToscaDataType.class), visitor); - break; - case "capability_types": - mapper.acceptJsonFormatVisitor(mapper.constructType(ToscaCapabilityType.class), visitor); - break; - case "node_types": - mapper.acceptJsonFormatVisitor(mapper.constructType(ToscaNodeType.class), visitor); - break; - case "relationship_types": - mapper.acceptJsonFormatVisitor(mapper.constructType(ToscaRelationshipType.class), visitor); - break; - case "policy_types": - mapper.acceptJsonFormatVisitor(mapper.constructType(ToscaPolicyType.class), visitor); - break; - case "topology_template": - mapper.acceptJsonFormatVisitor(mapper.constructType(ToscaTopologyTemplate.class), visitor); - break; - case "node_templates": - mapper.acceptJsonFormatVisitor( - mapper.getTypeFactory().constructCollectionType(List.class, ToscaNodeTemplate.class), - visitor); - break; - default: - mapper.acceptJsonFormatVisitor(mapper.constructType(ToscaServiceTemplate.class), visitor); - } - - var jsonSchema = visitor.finalSchema(); - return mapper.writerWithDefaultPrettyPrinter().writeValueAsString(jsonSchema); - } catch (JsonProcessingException e) { - throw new PfModelException(Status.BAD_REQUEST, "Converion to Json Schema failed", e); - } - } - - private List filterToscaNodeTemplateInstance(List serviceTemplates) { - - List toscaServiceTemplates = new ArrayList<>(); - - serviceTemplates.stream().forEach(serviceTemplate -> { - - Map toscaNodeTemplates = new HashMap<>(); - - serviceTemplate.getToscaTopologyTemplate().getNodeTemplates().forEach((key, nodeTemplate) -> { - if (!nodeTemplate.getName().contains(INSTANCE_TEXT)) { - toscaNodeTemplates.put(key, nodeTemplate); - } - }); - - serviceTemplate.getToscaTopologyTemplate().getNodeTemplates().clear(); - serviceTemplate.getToscaTopologyTemplate().setNodeTemplates(toscaNodeTemplates); - - toscaServiceTemplates.add(serviceTemplate); - }); - - return toscaServiceTemplates; - } - - /** - * Validates to see if there is any instance properties saved. - * - * @return true if exists instance properties - */ - private boolean verifyIfInstancePropertiesExists() { - return clProvider.getAllNodeTemplates().stream() - .anyMatch(nodeTemplate -> nodeTemplate.getKey().getName().contains(INSTANCE_TEXT)); - - } -} diff --git a/runtime-controlloop/src/main/java/org/onap/policy/clamp/controlloop/runtime/config/AafConfiguration.java b/runtime-controlloop/src/main/java/org/onap/policy/clamp/controlloop/runtime/config/AafConfiguration.java deleted file mode 100644 index 4483fbd1b..000000000 --- a/runtime-controlloop/src/main/java/org/onap/policy/clamp/controlloop/runtime/config/AafConfiguration.java +++ /dev/null @@ -1,46 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * ONAP CLAMP - * ================================================================================ - * Copyright (C) 2017-2018 AT&T Intellectual Property. All rights - * reserved. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============LICENSE_END============================================ - * =================================================================== - * - */ - -package org.onap.policy.clamp.controlloop.runtime.config; - -import javax.servlet.Filter; -import org.onap.policy.clamp.controlloop.runtime.main.web.ControlLoopAafFilter; -import org.springframework.context.annotation.Bean; -import org.springframework.context.annotation.Configuration; -import org.springframework.context.annotation.Profile; - -@Configuration -@Profile("clamp-aaf-authentication") -public class AafConfiguration { - - /** - * Method to return Aaf filter. - * - * @return Filter - */ - @Bean - public Filter aafFilter() { - return new ControlLoopAafFilter(); - } - -} diff --git a/runtime-controlloop/src/main/java/org/onap/policy/clamp/controlloop/runtime/config/ConverterConfiguration.java b/runtime-controlloop/src/main/java/org/onap/policy/clamp/controlloop/runtime/config/ConverterConfiguration.java deleted file mode 100644 index d67d2e75d..000000000 --- a/runtime-controlloop/src/main/java/org/onap/policy/clamp/controlloop/runtime/config/ConverterConfiguration.java +++ /dev/null @@ -1,44 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * Copyright (C) 2021 Nordix Foundation. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - * SPDX-License-Identifier: Apache-2.0 - * ============LICENSE_END========================================================= - */ - -package org.onap.policy.clamp.controlloop.runtime.config; - -import java.util.Arrays; -import java.util.List; -import org.onap.policy.clamp.controlloop.common.rest.CoderHttpMesageConverter; -import org.springframework.context.annotation.Configuration; -import org.springframework.http.MediaType; -import org.springframework.http.converter.HttpMessageConverter; -import org.springframework.http.converter.StringHttpMessageConverter; -import org.springframework.web.servlet.config.annotation.WebMvcConfigurer; - -@Configuration -public class ConverterConfiguration implements WebMvcConfigurer { - - @Override - public void extendMessageConverters(List> converters) { - converters.add(new CoderHttpMesageConverter<>("yaml")); - converters.add(new CoderHttpMesageConverter<>("json")); - - StringHttpMessageConverter converter = new StringHttpMessageConverter(); - converter.setSupportedMediaTypes(Arrays.asList(MediaType.TEXT_PLAIN)); - converters.add(converter); - } -} diff --git a/runtime-controlloop/src/main/java/org/onap/policy/clamp/controlloop/runtime/config/FilterConfig.java b/runtime-controlloop/src/main/java/org/onap/policy/clamp/controlloop/runtime/config/FilterConfig.java deleted file mode 100644 index 57bfc2e7c..000000000 --- a/runtime-controlloop/src/main/java/org/onap/policy/clamp/controlloop/runtime/config/FilterConfig.java +++ /dev/null @@ -1,45 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * Copyright (C) 2021 Nordix Foundation. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - * SPDX-License-Identifier: Apache-2.0 - * ============LICENSE_END========================================================= - */ - -package org.onap.policy.clamp.controlloop.runtime.config; - -import org.onap.policy.clamp.controlloop.common.rest.RequestResponseLoggingFilter; -import org.springframework.boot.web.servlet.FilterRegistrationBean; -import org.springframework.context.annotation.Bean; -import org.springframework.context.annotation.Configuration; - -@Configuration -public class FilterConfig { - - /** - * Logging Filter configuration. - * - * @return FilterRegistrationBean - */ - @Bean - public FilterRegistrationBean loggingFilter() { - FilterRegistrationBean registrationBean = new FilterRegistrationBean<>(); - - registrationBean.setFilter(new RequestResponseLoggingFilter()); - registrationBean.addUrlPatterns("/onap/controlloop/v2/*"); - - return registrationBean; - } -} diff --git a/runtime-controlloop/src/main/java/org/onap/policy/clamp/controlloop/runtime/config/SecurityConfig.java b/runtime-controlloop/src/main/java/org/onap/policy/clamp/controlloop/runtime/config/SecurityConfig.java deleted file mode 100644 index 846944ea2..000000000 --- a/runtime-controlloop/src/main/java/org/onap/policy/clamp/controlloop/runtime/config/SecurityConfig.java +++ /dev/null @@ -1,47 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * Copyright (C) 2021 Nordix Foundation. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - * SPDX-License-Identifier: Apache-2.0 - * ============LICENSE_END========================================================= - */ - -package org.onap.policy.clamp.controlloop.runtime.config; - -import org.springframework.beans.factory.annotation.Value; -import org.springframework.context.annotation.Configuration; -import org.springframework.security.config.annotation.web.builders.HttpSecurity; -import org.springframework.security.config.annotation.web.configuration.WebSecurityConfigurerAdapter; - -@Configuration -public class SecurityConfig extends WebSecurityConfigurerAdapter { - - @Value("${security.enable-csrf:true}") - private boolean csrfEnabled = true; - - @Override - protected void configure(HttpSecurity http) throws Exception { - // @formatter:off - http.authorizeRequests() - .antMatchers().authenticated() - .anyRequest().authenticated() - .and().httpBasic(); - // @formatter:on - - if (!csrfEnabled) { - http.csrf().disable(); - } - } -} diff --git a/runtime-controlloop/src/main/java/org/onap/policy/clamp/controlloop/runtime/config/SpringFoxConfig.java b/runtime-controlloop/src/main/java/org/onap/policy/clamp/controlloop/runtime/config/SpringFoxConfig.java deleted file mode 100644 index d8c703397..000000000 --- a/runtime-controlloop/src/main/java/org/onap/policy/clamp/controlloop/runtime/config/SpringFoxConfig.java +++ /dev/null @@ -1,45 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * Copyright (C) 2021 Nordix Foundation. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - * SPDX-License-Identifier: Apache-2.0 - * ============LICENSE_END========================================================= - */ - -package org.onap.policy.clamp.controlloop.runtime.config; - -import org.onap.policy.clamp.controlloop.runtime.main.rest.MonitoringQueryController; -import org.springframework.context.annotation.Bean; -import org.springframework.context.annotation.Configuration; -import springfox.documentation.builders.PathSelectors; -import springfox.documentation.builders.RequestHandlerSelectors; -import springfox.documentation.spi.DocumentationType; -import springfox.documentation.spring.web.plugins.Docket; - -@Configuration -public class SpringFoxConfig { - - /** - * Docket Spring Fox Config. - * - * @return Docket - */ - @Bean - public Docket api() { - return new Docket(DocumentationType.SWAGGER_2).select() - .apis(RequestHandlerSelectors.basePackage(MonitoringQueryController.class.getPackageName())) - .paths(PathSelectors.any()).build(); - } -} diff --git a/runtime-controlloop/src/main/java/org/onap/policy/clamp/controlloop/runtime/config/messaging/Listener.java b/runtime-controlloop/src/main/java/org/onap/policy/clamp/controlloop/runtime/config/messaging/Listener.java deleted file mode 100644 index 0afbf1c4c..000000000 --- a/runtime-controlloop/src/main/java/org/onap/policy/clamp/controlloop/runtime/config/messaging/Listener.java +++ /dev/null @@ -1,41 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * Copyright (C) 2021 Nordix Foundation. - * Modifications Copyright (C) 2021 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - * SPDX-License-Identifier: Apache-2.0 - * ============LICENSE_END========================================================= - */ - -package org.onap.policy.clamp.controlloop.runtime.config.messaging; - -import org.onap.policy.common.endpoints.listeners.ScoListener; - -public interface Listener { - - /** - * Get the type of message of interest to the listener. - * - * @return type of message of interest to the listener - */ - String getType(); - - /** - * Get listener to register. - * - * @return listener to register - */ - ScoListener getScoListener(); -} diff --git a/runtime-controlloop/src/main/java/org/onap/policy/clamp/controlloop/runtime/config/messaging/MessageDispatcherActivator.java b/runtime-controlloop/src/main/java/org/onap/policy/clamp/controlloop/runtime/config/messaging/MessageDispatcherActivator.java deleted file mode 100644 index 284094bc4..000000000 --- a/runtime-controlloop/src/main/java/org/onap/policy/clamp/controlloop/runtime/config/messaging/MessageDispatcherActivator.java +++ /dev/null @@ -1,137 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * Copyright (C) 2021 Nordix Foundation. - * Modifications Copyright (C) 2021 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - * SPDX-License-Identifier: Apache-2.0 - * ============LICENSE_END========================================================= - */ - -package org.onap.policy.clamp.controlloop.runtime.config.messaging; - -import java.io.Closeable; -import java.io.IOException; -import java.util.List; -import lombok.Getter; -import org.onap.policy.clamp.controlloop.common.exception.ControlLoopRuntimeException; -import org.onap.policy.clamp.controlloop.runtime.main.parameters.ClRuntimeParameterGroup; -import org.onap.policy.common.endpoints.event.comm.TopicEndpointManager; -import org.onap.policy.common.endpoints.event.comm.TopicSink; -import org.onap.policy.common.endpoints.event.comm.TopicSource; -import org.onap.policy.common.endpoints.listeners.MessageTypeDispatcher; -import org.onap.policy.common.utils.services.ServiceManagerContainer; -import org.springframework.context.event.ContextClosedEvent; -import org.springframework.context.event.ContextRefreshedEvent; -import org.springframework.context.event.EventListener; -import org.springframework.stereotype.Component; - -@Component -public class MessageDispatcherActivator extends ServiceManagerContainer implements Closeable { - - private static final String[] MSG_TYPE_NAMES = {"messageType"}; - - // Topics from which the application receives and to which the application sends messages - private List topicSinks; - private List topicSources; - - @Getter - private final MessageTypeDispatcher msgDispatcher; - - /** - * Constructor. - * - * @param clRuntimeParameterGroup the parameters for the control loop runtime service - * @param publishers list of Publishers - * @param listeners list of Listeners - * @throws ControlLoopRuntimeException if the activator does not start - */ - public MessageDispatcherActivator(final ClRuntimeParameterGroup clRuntimeParameterGroup, - List publishers, List> listeners) { - topicSinks = TopicEndpointManager.getManager() - .addTopicSinks(clRuntimeParameterGroup.getTopicParameterGroup().getTopicSinks()); - - topicSources = TopicEndpointManager.getManager() - .addTopicSources(clRuntimeParameterGroup.getTopicParameterGroup().getTopicSources()); - - msgDispatcher = new MessageTypeDispatcher(MSG_TYPE_NAMES); - - // @formatter:off - addAction("Topic endpoint management", - () -> TopicEndpointManager.getManager().start(), - () -> TopicEndpointManager.getManager().shutdown()); - - publishers.forEach(publisher -> - addAction("Publisher " + publisher.getClass().getSimpleName(), - () -> publisher.active(topicSinks), - publisher::stop)); - - listeners.forEach(listener -> - addAction("Listener " + listener.getClass().getSimpleName(), - () -> msgDispatcher.register(listener.getType(), listener.getScoListener()), - () -> msgDispatcher.unregister(listener.getType()))); - - addAction("Topic Message Dispatcher", this::registerMsgDispatcher, this::unregisterMsgDispatcher); - // @formatter:on - } - - /** - * Registers the dispatcher with the topic source(s). - */ - private void registerMsgDispatcher() { - for (final TopicSource source : topicSources) { - source.register(msgDispatcher); - } - } - - /** - * Unregisters the dispatcher from the topic source(s). - */ - private void unregisterMsgDispatcher() { - for (final TopicSource source : topicSources) { - source.unregister(msgDispatcher); - } - } - - /** - * Start Manager after the application is Started. - * - * @param cre Refreshed Event - */ - @EventListener - public void handleContextStart(ContextRefreshedEvent cre) { - if (!isAlive()) { - start(); - } - } - - /** - * Handle ContextClosedEvent. - * - * @param ctxClosedEvent ContextClosedEvent - */ - @EventListener - public void handleContextClosedEvent(ContextClosedEvent ctxClosedEvent) { - if (isAlive()) { - stop(); - } - } - - @Override - public void close() throws IOException { - if (isAlive()) { - super.shutdown(); - } - } -} diff --git a/runtime-controlloop/src/main/java/org/onap/policy/clamp/controlloop/runtime/config/messaging/Publisher.java b/runtime-controlloop/src/main/java/org/onap/policy/clamp/controlloop/runtime/config/messaging/Publisher.java deleted file mode 100644 index 3cd4dff85..000000000 --- a/runtime-controlloop/src/main/java/org/onap/policy/clamp/controlloop/runtime/config/messaging/Publisher.java +++ /dev/null @@ -1,34 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * Copyright (C) 2021 Nordix Foundation. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - * SPDX-License-Identifier: Apache-2.0 - * ============LICENSE_END========================================================= - */ - -package org.onap.policy.clamp.controlloop.runtime.config.messaging; - -import java.util.List; -import org.onap.policy.common.endpoints.event.comm.TopicSink; - -/** - * Publisher. - */ -public interface Publisher { - - void active(List topicSinks); - - void stop(); -} diff --git a/runtime-controlloop/src/main/java/org/onap/policy/clamp/controlloop/runtime/instantiation/ControlLoopInstantiationProvider.java b/runtime-controlloop/src/main/java/org/onap/policy/clamp/controlloop/runtime/instantiation/ControlLoopInstantiationProvider.java deleted file mode 100644 index 1bff2d747..000000000 --- a/runtime-controlloop/src/main/java/org/onap/policy/clamp/controlloop/runtime/instantiation/ControlLoopInstantiationProvider.java +++ /dev/null @@ -1,619 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * Copyright (C) 2021 Nordix Foundation. - * Modifications Copyright (C) 2021 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - * SPDX-License-Identifier: Apache-2.0 - * ============LICENSE_END========================================================= - */ - -package org.onap.policy.clamp.controlloop.runtime.instantiation; - -import com.google.gson.Gson; -import com.google.gson.internal.LinkedTreeMap; -import com.google.gson.reflect.TypeToken; -import java.lang.reflect.Type; -import java.util.ArrayList; -import java.util.Collection; -import java.util.HashMap; -import java.util.List; -import java.util.Map; -import java.util.UUID; -import java.util.function.Function; -import java.util.function.UnaryOperator; -import java.util.stream.Collectors; -import java.util.stream.Stream; -import javax.ws.rs.core.Response; -import javax.ws.rs.core.Response.Status; -import lombok.AllArgsConstructor; -import org.onap.policy.clamp.controlloop.common.exception.ControlLoopException; -import org.onap.policy.clamp.controlloop.models.controlloop.concepts.ControlLoop; -import org.onap.policy.clamp.controlloop.models.controlloop.concepts.ControlLoopElement; -import org.onap.policy.clamp.controlloop.models.controlloop.concepts.ControlLoopOrderedState; -import org.onap.policy.clamp.controlloop.models.controlloop.concepts.ControlLoopState; -import org.onap.policy.clamp.controlloop.models.controlloop.concepts.ControlLoops; -import org.onap.policy.clamp.controlloop.models.controlloop.concepts.Participant; -import org.onap.policy.clamp.controlloop.models.controlloop.persistence.provider.ControlLoopProvider; -import org.onap.policy.clamp.controlloop.models.controlloop.persistence.provider.ParticipantProvider; -import org.onap.policy.clamp.controlloop.models.messages.rest.GenericNameVersion; -import org.onap.policy.clamp.controlloop.models.messages.rest.instantiation.ControlLoopOrderStateResponse; -import org.onap.policy.clamp.controlloop.models.messages.rest.instantiation.ControlLoopPrimed; -import org.onap.policy.clamp.controlloop.models.messages.rest.instantiation.ControlLoopPrimedResponse; -import org.onap.policy.clamp.controlloop.models.messages.rest.instantiation.InstancePropertiesResponse; -import org.onap.policy.clamp.controlloop.models.messages.rest.instantiation.InstantiationCommand; -import org.onap.policy.clamp.controlloop.models.messages.rest.instantiation.InstantiationResponse; -import org.onap.policy.clamp.controlloop.runtime.commissioning.CommissioningProvider; -import org.onap.policy.clamp.controlloop.runtime.supervision.SupervisionHandler; -import org.onap.policy.common.parameters.BeanValidationResult; -import org.onap.policy.common.parameters.ObjectValidationResult; -import org.onap.policy.common.parameters.ValidationResult; -import org.onap.policy.common.parameters.ValidationStatus; -import org.onap.policy.models.base.PfModelException; -import org.onap.policy.models.tosca.authorative.concepts.ToscaConceptIdentifier; -import org.onap.policy.models.tosca.authorative.concepts.ToscaNameVersion; -import org.onap.policy.models.tosca.authorative.concepts.ToscaNodeTemplate; -import org.onap.policy.models.tosca.authorative.concepts.ToscaServiceTemplate; -import org.springframework.stereotype.Service; -import org.springframework.transaction.annotation.Transactional; - -/** - * This class is dedicated to the Instantiation of Commissioned control loop. - */ -@Service -@Transactional -@AllArgsConstructor -public class ControlLoopInstantiationProvider { - private static final String CONTROL_LOOP_NODE_TYPE = "org.onap.policy.clamp.controlloop.ControlLoop"; - private static final String CONTROL_LOOP_NODE_ELEMENT_TYPE = "ControlLoopElement"; - private static final String PARTICIPANT_ID_PROPERTY_KEY = "participant_id"; - private static final String PARTICIPANT_TYPE_PROPERTY_KEY = "participantType"; - private static final String CL_ELEMENT_NAME = "name"; - private static final String CL_ELEMENT_VERSION = "version"; - private static final String INSTANCE_TEXT = "_Instance"; - - private static final Gson GSON = new Gson(); - - private final ControlLoopProvider controlLoopProvider; - private final CommissioningProvider commissioningProvider; - private final SupervisionHandler supervisionHandler; - private final ParticipantProvider participantProvider; - private static final String ENTRY = "entry "; - - /** - * Creates Instance Properties and Control Loop. - * - * @param serviceTemplate the service template - * @return the result of the instantiation operation - * @throws PfModelException on creation errors - */ - public InstancePropertiesResponse createInstanceProperties(ToscaServiceTemplate serviceTemplate) - throws PfModelException { - - String instanceName = generateSequentialInstanceName(); - ControlLoop controlLoop = new ControlLoop(); - Map controlLoopElements = new HashMap<>(); - - ToscaServiceTemplate toscaServiceTemplate = commissioningProvider.getAllToscaServiceTemplate().get(0); - - Map persistedNodeTemplateMap = - toscaServiceTemplate.getToscaTopologyTemplate().getNodeTemplates(); - - Map nodeTemplates = deepCloneNodeTemplate(serviceTemplate); - - nodeTemplates.forEach((key, template) -> { - ToscaNodeTemplate newNodeTemplate = new ToscaNodeTemplate(); - String name = key + instanceName; - String version = template.getVersion(); - String description = template.getDescription() + instanceName; - newNodeTemplate.setName(name); - newNodeTemplate.setVersion(version); - newNodeTemplate.setDescription(description); - newNodeTemplate.setProperties(new HashMap<>(template.getProperties())); - newNodeTemplate.setType(template.getType()); - newNodeTemplate.setTypeVersion(template.getTypeVersion()); - newNodeTemplate.setMetadata(template.getMetadata()); - - crateNewControlLoopInstance(instanceName, controlLoop, controlLoopElements, template, newNodeTemplate); - - persistedNodeTemplateMap.put(name, newNodeTemplate); - }); - - ControlLoops controlLoops = new ControlLoops(); - - serviceTemplate.getToscaTopologyTemplate().getNodeTemplates().putAll(persistedNodeTemplateMap); - - controlLoop.setElements(controlLoopElements); - controlLoops.getControlLoopList().add(controlLoop); - - return saveInstancePropertiesAndControlLoop(serviceTemplate, controlLoops); - } - - /** - * Deletes Instance Properties. - * - * @param name the name of the control loop to delete - * @param version the version of the control loop to delete - * @return the result of the deletion - * @throws PfModelException on deletion errors - */ - public InstantiationResponse deleteInstanceProperties(String name, String version) throws PfModelException { - - String instanceName = getInstancePropertyName(name, version); - - Map filteredToscaNodeTemplateMap = new HashMap<>(); - - ToscaServiceTemplate toscaServiceTemplate = commissioningProvider.getAllToscaServiceTemplate().get(0); - - toscaServiceTemplate.getToscaTopologyTemplate().getNodeTemplates().forEach((key, nodeTemplate) -> { - if (!nodeTemplate.getName().contains(instanceName)) { - filteredToscaNodeTemplateMap.put(key, nodeTemplate); - } - }); - - List filteredToscaNodeTemplateList = toscaServiceTemplate.getToscaTopologyTemplate() - .getNodeTemplates().values().stream() - .filter(nodeTemplate -> nodeTemplate.getName().contains(instanceName)).collect(Collectors.toList()); - - InstantiationResponse response = this.deleteControlLoop(name, version); - - controlLoopProvider.deleteInstanceProperties(filteredToscaNodeTemplateMap, filteredToscaNodeTemplateList); - - return response; - } - - /** - * Create control loops. - * - * @param controlLoops the control loop - * @return the result of the instantiation operation - * @throws PfModelException on creation errors - */ - public InstantiationResponse createControlLoops(ControlLoops controlLoops) throws PfModelException { - for (ControlLoop controlLoop : controlLoops.getControlLoopList()) { - var checkControlLoopOpt = controlLoopProvider.findControlLoop(controlLoop.getKey().asIdentifier()); - if (checkControlLoopOpt.isPresent()) { - throw new PfModelException(Response.Status.BAD_REQUEST, - controlLoop.getKey().asIdentifier() + " already defined"); - } - } - BeanValidationResult validationResult = validateControlLoops(controlLoops); - if (!validationResult.isValid()) { - throw new PfModelException(Response.Status.BAD_REQUEST, validationResult.getResult()); - } - controlLoopProvider.saveControlLoops(controlLoops.getControlLoopList()); - - var response = new InstantiationResponse(); - response.setAffectedControlLoops(controlLoops.getControlLoopList().stream() - .map(cl -> cl.getKey().asIdentifier()).collect(Collectors.toList())); - - return response; - } - - /** - * Update control loops. - * - * @param controlLoops the control loop - * @return the result of the instantiation operation - * @throws PfModelException on update errors - */ - public InstantiationResponse updateControlLoops(ControlLoops controlLoops) throws PfModelException { - BeanValidationResult validationResult = validateControlLoops(controlLoops); - if (!validationResult.isValid()) { - throw new PfModelException(Response.Status.BAD_REQUEST, validationResult.getResult()); - } - controlLoopProvider.saveControlLoops(controlLoops.getControlLoopList()); - - var response = new InstantiationResponse(); - response.setAffectedControlLoops(controlLoops.getControlLoopList().stream() - .map(cl -> cl.getKey().asIdentifier()).collect(Collectors.toList())); - - return response; - } - - /** - * Validate ControlLoops. - * - * @param controlLoops ControlLoops to validate - * @return the result of validation - * @throws PfModelException if controlLoops is not valid - */ - private BeanValidationResult validateControlLoops(ControlLoops controlLoops) throws PfModelException { - - var result = new BeanValidationResult("ControlLoops", controlLoops); - - for (ControlLoop controlLoop : controlLoops.getControlLoopList()) { - var subResult = new BeanValidationResult(ENTRY + controlLoop.getDefinition().getName(), controlLoop); - - List toscaNodeTemplates = commissioningProvider.getControlLoopDefinitions( - controlLoop.getDefinition().getName(), controlLoop.getDefinition().getVersion()); - - if (toscaNodeTemplates.isEmpty()) { - subResult.addResult(new ObjectValidationResult("ControlLoop", controlLoop.getDefinition().getName(), - ValidationStatus.INVALID, "Commissioned control loop definition not FOUND")); - } else if (toscaNodeTemplates.size() > 1) { - subResult.addResult(new ObjectValidationResult("ControlLoop", controlLoop.getDefinition().getName(), - ValidationStatus.INVALID, "Commissioned control loop definition not VALID")); - } else { - - List clElementDefinitions = - commissioningProvider.getControlLoopElementDefinitions(toscaNodeTemplates.get(0)); - - // @formatter:off - Map definitions = clElementDefinitions - .stream() - .map(nodeTemplate -> nodeTemplate.getKey().asIdentifier()) - .collect(Collectors.toMap(ToscaConceptIdentifier::getName, UnaryOperator.identity())); - // @formatter:on - - for (ControlLoopElement element : controlLoop.getElements().values()) { - subResult.addResult(validateDefinition(definitions, element.getDefinition())); - } - } - result.addResult(subResult); - } - return result; - } - - /** - * Validate ToscaConceptIdentifier, checking if exist in ToscaConceptIdentifiers map. - * - * @param definitions map of all ToscaConceptIdentifiers - * @param definition ToscaConceptIdentifier to validate - * @return the validation result - */ - private ValidationResult validateDefinition(Map definitions, - ToscaConceptIdentifier definition) { - var result = new BeanValidationResult(ENTRY + definition.getName(), definition); - ToscaConceptIdentifier identifier = definitions.get(definition.getName()); - if (identifier == null) { - result.setResult(ValidationStatus.INVALID, "Not FOUND"); - } else if (!identifier.equals(definition)) { - result.setResult(ValidationStatus.INVALID, "Version not matching"); - } - return (result.isClean() ? null : result); - } - - /** - * Delete the control loop with the given name and version. - * - * @param name the name of the control loop to delete - * @param version the version of the control loop to delete - * @return the result of the deletion - * @throws PfModelException on deletion errors - */ - public InstantiationResponse deleteControlLoop(String name, String version) throws PfModelException { - var controlLoopOpt = controlLoopProvider.findControlLoop(name, version); - if (controlLoopOpt.isEmpty()) { - throw new PfModelException(Response.Status.NOT_FOUND, "Control Loop not found"); - } - var controlLoop = controlLoopOpt.get(); - if (!ControlLoopState.UNINITIALISED.equals(controlLoop.getState())) { - throw new PfModelException(Response.Status.BAD_REQUEST, - "Control Loop State is still " + controlLoop.getState()); - } - var response = new InstantiationResponse(); - response.setAffectedControlLoops( - List.of(controlLoopProvider.deleteControlLoop(name, version).getKey().asIdentifier())); - return response; - } - - /** - * Get the requested control loops. - * - * @param name the name of the control loop to get, null for all control loops - * @param version the version of the control loop to get, null for all control loops - * @return the control loops - * @throws PfModelException on errors getting control loops - */ - @Transactional(readOnly = true) - public ControlLoops getControlLoops(String name, String version) throws PfModelException { - var controlLoops = new ControlLoops(); - controlLoops.setControlLoopList(controlLoopProvider.getControlLoops(name, version)); - - return controlLoops; - } - - /** - * Issue a command to control loops, setting their ordered state. - * - * @param command the command to issue to control loops - * @return the result of the initiation command - * @throws PfModelException on errors setting the ordered state on the control loops - * @throws ControlLoopException on ordered state invalid - */ - public InstantiationResponse issueControlLoopCommand(InstantiationCommand command) - throws ControlLoopException, PfModelException { - - if (command.getOrderedState() == null) { - throw new ControlLoopException(Status.BAD_REQUEST, "ordered state invalid or not specified on command"); - } - - var participants = participantProvider.getParticipants(); - if (participants.isEmpty()) { - throw new ControlLoopException(Status.BAD_REQUEST, "No participants registered"); - } - var validationResult = new BeanValidationResult("InstantiationCommand", command); - List controlLoops = new ArrayList<>(command.getControlLoopIdentifierList().size()); - for (ToscaConceptIdentifier id : command.getControlLoopIdentifierList()) { - var controlLoopOpt = controlLoopProvider.findControlLoop(id); - if (controlLoopOpt.isEmpty()) { - validationResult.addResult("ToscaConceptIdentifier", id, ValidationStatus.INVALID, - "ControlLoop with id " + id + " not found"); - } else { - var controlLoop = controlLoopOpt.get(); - controlLoop.setCascadedOrderedState(command.getOrderedState()); - controlLoops.add(controlLoop); - } - } - if (validationResult.isValid()) { - validationResult = validateIssueControlLoops(controlLoops, participants); - } - if (!validationResult.isValid()) { - throw new PfModelException(Response.Status.BAD_REQUEST, validationResult.getResult()); - } - controlLoopProvider.saveControlLoops(controlLoops); - - supervisionHandler.triggerControlLoopSupervision(command.getControlLoopIdentifierList()); - var response = new InstantiationResponse(); - response.setAffectedControlLoops(command.getControlLoopIdentifierList()); - - return response; - } - - private BeanValidationResult validateIssueControlLoops(List controlLoops, - List participants) { - var result = new BeanValidationResult("ControlLoops", controlLoops); - - Map participantMap = participants.stream() - .collect(Collectors.toMap(participant -> participant.getKey().asIdentifier(), Function.identity())); - - for (ControlLoop controlLoop : controlLoops) { - - for (var element : controlLoop.getElements().values()) { - - var subResult = new BeanValidationResult(ENTRY + element.getDefinition().getName(), element); - Participant p = participantMap.get(element.getParticipantId()); - if (p == null) { - subResult.addResult(new ObjectValidationResult(CONTROL_LOOP_NODE_ELEMENT_TYPE, - element.getDefinition().getName(), ValidationStatus.INVALID, - "Participant with ID " + element.getParticipantId() + " is not registered")); - } else if (!p.getParticipantType().equals(element.getParticipantType())) { - subResult.addResult(new ObjectValidationResult(CONTROL_LOOP_NODE_ELEMENT_TYPE, - element.getDefinition().getName(), ValidationStatus.INVALID, - "Participant with ID " + element.getParticipantType() + " - " + element.getParticipantId() - + " is not registered")); - } - result.addResult(subResult); - } - - } - - return result; - } - - /** - * Gets a list of control loops with it's ordered state. - * - * @param name the name of the control loop to get, null for all control loops - * @param version the version of the control loop to get, null for all control loops - * @return a list of Instantiation Command - * @throws PfModelException on errors getting control loops - */ - @Transactional(readOnly = true) - public ControlLoopOrderStateResponse getInstantiationOrderState(String name, String version) - throws PfModelException { - - List controlLoops = controlLoopProvider.getControlLoops(name, version); - - var response = new ControlLoopOrderStateResponse(); - - controlLoops.forEach(controlLoop -> { - var genericNameVersion = new GenericNameVersion(); - genericNameVersion.setName(controlLoop.getName()); - genericNameVersion.setVersion(controlLoop.getVersion()); - response.getControlLoopIdentifierList().add(genericNameVersion); - }); - - return response; - } - - /** - * Saves Instance Properties and Control Loop. - * Gets a list of control loops which are primed or de-primed. - * - * @param name the name of the control loop to get, null for all control loops - * @param version the version of the control loop to get, null for all control loops - * @return a list of Instantiation Command - * @throws PfModelException on errors getting control loops - */ - @Transactional(readOnly = true) - public ControlLoopPrimedResponse getControlLoopPriming(String name, String version) throws PfModelException { - - List controlLoops = controlLoopProvider.getControlLoops(name, version); - - var response = new ControlLoopPrimedResponse(); - - controlLoops.forEach(controlLoop -> { - var primed = new ControlLoopPrimed(); - primed.setName(controlLoop.getName()); - primed.setVersion(controlLoop.getVersion()); - primed.setPrimed(controlLoop.getPrimed()); - response.getPrimedControlLoopsList().add(primed); - }); - - return response; - } - - /** - * Creates instance element name. - * - * @param serviceTemplate the service template - * @param controlLoops a list of control loops - * @return the result of the instance properties and instantiation operation - * @throws PfModelException on creation errors - */ - private InstancePropertiesResponse saveInstancePropertiesAndControlLoop(ToscaServiceTemplate serviceTemplate, - ControlLoops controlLoops) throws PfModelException { - - for (var controlLoop : controlLoops.getControlLoopList()) { - var checkControlLoopOpt = controlLoopProvider.findControlLoop(controlLoop.getKey().asIdentifier()); - if (checkControlLoopOpt.isPresent()) { - throw new PfModelException(Response.Status.BAD_REQUEST, - "Control loop with id " + controlLoop.getKey().asIdentifier() + " already defined"); - } - } - Map toscaSavedNodeTemplate = - controlLoopProvider.saveInstanceProperties(serviceTemplate); - controlLoopProvider.saveControlLoops(controlLoops.getControlLoopList()); - List affectedControlLoops = controlLoops.getControlLoopList().stream() - .map(cl -> cl.getKey().asIdentifier()).collect(Collectors.toList()); - - List toscaAffectedProperties = toscaSavedNodeTemplate.values().stream() - .map(template -> template.getKey().asIdentifier()).collect(Collectors.toList()); - - var response = new InstancePropertiesResponse(); - response.setAffectedInstanceProperties(Stream.of(affectedControlLoops, toscaAffectedProperties) - .flatMap(Collection::stream).collect(Collectors.toList())); - - return response; - } - - /** - * Crates a new Control Loop instance. - * - * @param instanceName Control Loop Instance name - * @param controlLoop empty Control Loop - * @param controlLoopElements new Control Loop Element map - * @param template original Cloned Tosca Node Template - * @param newNodeTemplate new Tosca Node Template - */ - private void crateNewControlLoopInstance(String instanceName, ControlLoop controlLoop, - Map controlLoopElements, ToscaNodeTemplate template, - ToscaNodeTemplate newNodeTemplate) { - if (template.getType().equals(CONTROL_LOOP_NODE_TYPE)) { - controlLoop.setDefinition(getControlLoopDefinition(newNodeTemplate)); - } - - if (template.getType().contains(CONTROL_LOOP_NODE_ELEMENT_TYPE)) { - ControlLoopElement controlLoopElement = getControlLoopElement(newNodeTemplate); - controlLoopElements.put(controlLoopElement.getId(), controlLoopElement); - } - - controlLoop.setName("PMSH" + instanceName); - controlLoop.setVersion(template.getVersion()); - controlLoop.setDescription("PMSH control loop " + instanceName); - controlLoop.setState(ControlLoopState.UNINITIALISED); - controlLoop.setOrderedState(ControlLoopOrderedState.UNINITIALISED); - } - - /** - * Get's the instance property name of the control loop. - * - * @param name the name of the control loop to get, null for all control loops - * @param version the version of the control loop to get, null for all control loops - * @return the instance name of the control loop instance properties - * @throws PfModelException on errors getting control loops - */ - private String getInstancePropertyName(String name, String version) throws PfModelException { - List toscaDefinitionsNames = controlLoopProvider.getControlLoops(name, version).stream() - .map(ControlLoop::getDefinition).map(ToscaNameVersion::getName).collect(Collectors.toList()); - - return toscaDefinitionsNames.stream().reduce("", (s1, s2) -> { - - if (s2.contains(INSTANCE_TEXT)) { - String[] instances = s2.split(INSTANCE_TEXT); - - return INSTANCE_TEXT + instances[1]; - } - - return s1; - }); - } - - /** - * Generates Instance Name in sequential order and return it to append to the Node Template Name. - * - * @return instanceName - */ - private String generateSequentialInstanceName() { - List nodeTemplates = controlLoopProvider.getAllNodeTemplates(); - - int instanceNumber = nodeTemplates.stream().map(ToscaNodeTemplate::getName) - .filter(name -> name.contains(INSTANCE_TEXT)).map(n -> { - String[] defNameArr = n.split(INSTANCE_TEXT); - - return Integer.parseInt(defNameArr[1]); - }).reduce(0, Math::max); - - return INSTANCE_TEXT + (instanceNumber + 1); - } - - /** - * Retrieves Control Loop Definition. - * - * @param template tosca node template - * @return control loop definition - */ - private ToscaConceptIdentifier getControlLoopDefinition(ToscaNodeTemplate template) { - ToscaConceptIdentifier definition = new ToscaConceptIdentifier(); - definition.setName(template.getName()); - definition.setVersion(template.getVersion()); - return definition; - } - - /** - * Retrieves Control Loop Element. - * - * @param template tosca node template - * @return a control loop element - */ - @SuppressWarnings("unchecked") - private ControlLoopElement getControlLoopElement(ToscaNodeTemplate template) { - ControlLoopElement controlLoopElement = new ControlLoopElement(); - ToscaConceptIdentifier definition = new ToscaConceptIdentifier(); - definition.setName(template.getName()); - definition.setVersion(template.getVersion()); - controlLoopElement.setDefinition(definition); - LinkedTreeMap participantId = - (LinkedTreeMap) template.getProperties().get(PARTICIPANT_ID_PROPERTY_KEY); - if (participantId != null) { - ToscaConceptIdentifier participantIdProperty = new ToscaConceptIdentifier(); - participantIdProperty.setName(String.valueOf(participantId.get(CL_ELEMENT_NAME))); - participantIdProperty.setVersion(String.valueOf(participantId.get(CL_ELEMENT_VERSION))); - controlLoopElement.setParticipantId(participantIdProperty); - } - LinkedTreeMap participantType = - (LinkedTreeMap) template.getProperties().get(PARTICIPANT_TYPE_PROPERTY_KEY); - if (participantType != null) { - ToscaConceptIdentifier participantTypeProperty = new ToscaConceptIdentifier(); - participantTypeProperty.setName(String.valueOf(participantType.get(CL_ELEMENT_NAME))); - participantTypeProperty.setVersion(participantType.get(CL_ELEMENT_VERSION).toString()); - controlLoopElement.setParticipantType(participantTypeProperty); - } - return controlLoopElement; - } - - /** - * Deep clones ToscaNodeTemplate. - * - * @param serviceTemplate ToscaServiceTemplate - * @return a cloned Hash Map of ToscaNodeTemplate - */ - private Map deepCloneNodeTemplate(ToscaServiceTemplate serviceTemplate) { - String jsonString = GSON.toJson(serviceTemplate.getToscaTopologyTemplate().getNodeTemplates()); - Type type = new TypeToken>() {}.getType(); - return GSON.fromJson(jsonString, type); - } -} diff --git a/runtime-controlloop/src/main/java/org/onap/policy/clamp/controlloop/runtime/main/parameters/ClRuntimeParameterGroup.java b/runtime-controlloop/src/main/java/org/onap/policy/clamp/controlloop/runtime/main/parameters/ClRuntimeParameterGroup.java deleted file mode 100644 index 047bca2b1..000000000 --- a/runtime-controlloop/src/main/java/org/onap/policy/clamp/controlloop/runtime/main/parameters/ClRuntimeParameterGroup.java +++ /dev/null @@ -1,49 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * Copyright (C) 2021 Nordix Foundation. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - * SPDX-License-Identifier: Apache-2.0 - * ============LICENSE_END========================================================= - */ - -package org.onap.policy.clamp.controlloop.runtime.main.parameters; - -import javax.validation.Valid; -import javax.validation.constraints.NotNull; -import lombok.Getter; -import lombok.Setter; -import org.onap.policy.common.endpoints.parameters.TopicParameterGroup; -import org.onap.policy.common.parameters.validation.ParameterGroupConstraint; -import org.springframework.boot.context.properties.ConfigurationProperties; -import org.springframework.validation.annotation.Validated; - -/** - * Class to hold all parameters needed for the Control Loop runtime component. - * - */ -@Validated -@Getter -@Setter -@ConfigurationProperties(prefix = "runtime") -public class ClRuntimeParameterGroup { - - @Valid - @NotNull - private ParticipantParameters participantParameters; - - @NotNull - @ParameterGroupConstraint - private TopicParameterGroup topicParameterGroup; -} diff --git a/runtime-controlloop/src/main/java/org/onap/policy/clamp/controlloop/runtime/main/parameters/ParticipantParameters.java b/runtime-controlloop/src/main/java/org/onap/policy/clamp/controlloop/runtime/main/parameters/ParticipantParameters.java deleted file mode 100644 index e3e34878f..000000000 --- a/runtime-controlloop/src/main/java/org/onap/policy/clamp/controlloop/runtime/main/parameters/ParticipantParameters.java +++ /dev/null @@ -1,45 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * Copyright (C) 2021 Nordix Foundation. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============LICENSE_END========================================================= - */ - -package org.onap.policy.clamp.controlloop.runtime.main.parameters; - -import javax.validation.Valid; -import javax.validation.constraints.Min; -import javax.validation.constraints.NotNull; -import lombok.Getter; -import lombok.Setter; -import org.springframework.validation.annotation.Validated; - -/** - * Parameters for communicating with participants. - */ -@Getter -@Setter -@Validated -public class ParticipantParameters { - - @Min(100) - private long heartBeatMs; - - @Min(100) - private long maxStatusWaitMs; - - @Valid - @NotNull - private ParticipantUpdateParameters updateParameters; -} diff --git a/runtime-controlloop/src/main/java/org/onap/policy/clamp/controlloop/runtime/main/parameters/ParticipantUpdateParameters.java b/runtime-controlloop/src/main/java/org/onap/policy/clamp/controlloop/runtime/main/parameters/ParticipantUpdateParameters.java deleted file mode 100644 index c0b0480de..000000000 --- a/runtime-controlloop/src/main/java/org/onap/policy/clamp/controlloop/runtime/main/parameters/ParticipantUpdateParameters.java +++ /dev/null @@ -1,46 +0,0 @@ -/* - * ============LICENSE_START======================================================= - * Copyright (C) 2021 Nordix Foundation. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============LICENSE_END========================================================= - */ - -package org.onap.policy.clamp.controlloop.runtime.main.parameters; - -import javax.validation.constraints.Min; -import lombok.Getter; -import lombok.Setter; -import org.springframework.validation.annotation.Validated; - -/** - * Parameters for Participant UPDATE requests. - */ -@Getter -@Setter -@Validated -public class ParticipantUpdateParameters { - - /** - * Maximum number of times to re-send a request to a PDP. - */ - @Min(value = 1) - private int maxRetryCount; - - /** - * Maximum time to wait, in milliseconds, for a PDP response. - */ - @Min(value = 100) - private long maxWaitMs; - -} diff --git a/runtime-controlloop/src/main/java/org/onap/policy/clamp/controlloop/runtime/main/rest/CommissioningController.java b/runtime-controlloop/src/main/java/org/onap/policy/clamp/controlloop/runtime/main/rest/CommissioningController.java deleted file mode 100644 index fcb5aed97..000000000 --- a/runtime-controlloop/src/main/java/org/onap/policy/clamp/controlloop/runtime/main/rest/CommissioningController.java +++ /dev/null @@ -1,515 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * Copyright (C) 2021 Nordix Foundation. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - * SPDX-License-Identifier: Apache-2.0 - * ============LICENSE_END========================================================= - */ - -package org.onap.policy.clamp.controlloop.runtime.main.rest; - -import io.swagger.annotations.ApiOperation; -import io.swagger.annotations.ApiParam; -import io.swagger.annotations.ApiResponse; -import io.swagger.annotations.ApiResponses; -import io.swagger.annotations.Authorization; -import io.swagger.annotations.Extension; -import io.swagger.annotations.ExtensionProperty; -import io.swagger.annotations.ResponseHeader; -import java.util.List; -import java.util.Map; -import java.util.UUID; -import javax.ws.rs.core.Response.Status; -import lombok.RequiredArgsConstructor; -import org.onap.policy.clamp.controlloop.common.exception.ControlLoopException; -import org.onap.policy.clamp.controlloop.models.messages.rest.commissioning.CommissioningResponse; -import org.onap.policy.clamp.controlloop.runtime.commissioning.CommissioningProvider; -import org.onap.policy.clamp.controlloop.runtime.main.web.AbstractRestController; -import org.onap.policy.models.base.PfModelException; -import org.onap.policy.models.tosca.authorative.concepts.ToscaNodeTemplate; -import org.onap.policy.models.tosca.authorative.concepts.ToscaServiceTemplate; -import org.springframework.http.MediaType; -import org.springframework.http.ResponseEntity; -import org.springframework.web.bind.annotation.DeleteMapping; -import org.springframework.web.bind.annotation.GetMapping; -import org.springframework.web.bind.annotation.PostMapping; -import org.springframework.web.bind.annotation.RequestBody; -import org.springframework.web.bind.annotation.RequestHeader; -import org.springframework.web.bind.annotation.RequestParam; -import org.springframework.web.bind.annotation.RestController; - -/** - * Class to provide REST end points for creating, deleting, querying commissioned control loops. - */ -@RestController -@RequiredArgsConstructor -public class CommissioningController extends AbstractRestController { - - private static final String TAGS = "Clamp Control Loop Commissioning API"; - - private final CommissioningProvider provider; - - /** - * Creates a control loop definition. - * - * @param requestId request ID used in ONAP logging - * @param body the body of control loop following TOSCA definition - * @return a response - * @throws PfModelException on errors creating a control loop definition - */ - // @formatter:off - @PostMapping(value = "/commission", - consumes = {MediaType.APPLICATION_JSON_VALUE, APPLICATION_YAML}, - produces = {MediaType.APPLICATION_JSON_VALUE, APPLICATION_YAML}) - @ApiOperation( - value = "Commissions control loop definitions", - notes = "Commissions control loop definitions, returning the commissioned control loop definition IDs", - response = CommissioningResponse.class, - tags = {TAGS}, - authorizations = @Authorization(value = AUTHORIZATION_TYPE), - responseHeaders = { - @ResponseHeader( - name = VERSION_MINOR_NAME, - description = VERSION_MINOR_DESCRIPTION, - response = String.class), - @ResponseHeader( - name = VERSION_PATCH_NAME, - description = VERSION_PATCH_DESCRIPTION, - response = String.class), - @ResponseHeader( - name = VERSION_LATEST_NAME, - description = VERSION_LATEST_DESCRIPTION, - response = String.class), - @ResponseHeader( - name = REQUEST_ID_NAME, - description = REQUEST_ID_HDR_DESCRIPTION, - response = UUID.class) - }, - extensions = { - @Extension - ( - name = EXTENSION_NAME, - properties = { - @ExtensionProperty(name = API_VERSION_NAME, value = API_VERSION), - @ExtensionProperty(name = LAST_MOD_NAME, value = LAST_MOD_RELEASE) - } - ) - } - ) - @ApiResponses( - value = { - @ApiResponse(code = AUTHENTICATION_ERROR_CODE, message = AUTHENTICATION_ERROR_MESSAGE), - @ApiResponse(code = AUTHORIZATION_ERROR_CODE, message = AUTHORIZATION_ERROR_MESSAGE), - @ApiResponse(code = SERVER_ERROR_CODE, message = SERVER_ERROR_MESSAGE) - } - ) - // @formatter:on - public ResponseEntity create( - @RequestHeader( - name = REQUEST_ID_NAME, - required = false) @ApiParam(REQUEST_ID_PARAM_DESCRIPTION) UUID requestId, - @ApiParam(value = "Entity Body of Control Loop", required = true) @RequestBody ToscaServiceTemplate body) - throws PfModelException { - - return ResponseEntity.ok().body(provider.createControlLoopDefinitions(body)); - } - - /** - * Deletes a control loop definition. - * - * @param requestId request ID used in ONAP logging - * @param name the name of the control loop definition to delete - * @param version the version of the control loop definition to delete - * @return a response - * @throws PfModelException on errors deleting a control loop definition - */ - // @formatter:off - @DeleteMapping(value = "/commission", - produces = {MediaType.APPLICATION_JSON_VALUE, APPLICATION_YAML}) - @ApiOperation(value = "Delete a commissioned control loop", - notes = "Deletes a Commissioned Control Loop, returning optional error details", - response = CommissioningResponse.class, - tags = {TAGS}, - authorizations = @Authorization(value = AUTHORIZATION_TYPE), - responseHeaders = { - @ResponseHeader( - name = VERSION_MINOR_NAME, - description = VERSION_MINOR_DESCRIPTION, - response = String.class), - @ResponseHeader( - name = VERSION_PATCH_NAME, - description = VERSION_PATCH_DESCRIPTION, - response = String.class), - @ResponseHeader( - name = VERSION_LATEST_NAME, - description = VERSION_LATEST_DESCRIPTION, - response = String.class), - @ResponseHeader( - name = REQUEST_ID_NAME, - description = REQUEST_ID_HDR_DESCRIPTION, - response = UUID.class)}, - extensions = { - @Extension - ( - name = EXTENSION_NAME, - properties = { - @ExtensionProperty(name = API_VERSION_NAME, value = API_VERSION), - @ExtensionProperty(name = LAST_MOD_NAME, value = LAST_MOD_RELEASE) - } - ) - } - ) - @ApiResponses( - value = { - @ApiResponse(code = AUTHENTICATION_ERROR_CODE, message = AUTHENTICATION_ERROR_MESSAGE), - @ApiResponse(code = AUTHORIZATION_ERROR_CODE, message = AUTHORIZATION_ERROR_MESSAGE), - @ApiResponse(code = SERVER_ERROR_CODE, message = SERVER_ERROR_MESSAGE) - } - ) - // @formatter:on - public ResponseEntity delete( - @RequestHeader( - name = REQUEST_ID_NAME, - required = false) @ApiParam(REQUEST_ID_PARAM_DESCRIPTION) UUID requestId, - @ApiParam(value = "Control Loop definition name", required = true) @RequestParam( - value = "name") String name, - @ApiParam( - value = "Control Loop definition version", - required = true) @RequestParam("version") String version) - throws PfModelException { - - return ResponseEntity.ok().body(provider.deleteControlLoopDefinition(name, version)); - } - - /** - * Queries details of all or specific control loop definitions. - * - * @param requestId request ID used in ONAP logging - * @param name the name of the control loop definition to get, null for all definitions - * @param version the version of the control loop definition to get, null for all definitions - * @return the control loop definitions - * @throws PfModelException on errors getting details of all or specific control loop definitions - */ - // @formatter:off - @GetMapping(value = "/commission", - produces = {MediaType.APPLICATION_JSON_VALUE, APPLICATION_YAML}) - @ApiOperation(value = "Query details of the requested commissioned control loop definitions", - notes = "Queries details of the requested commissioned control loop definitions, " - + "returning all control loop details", - response = ToscaNodeTemplate.class, - tags = {TAGS}, - authorizations = @Authorization(value = AUTHORIZATION_TYPE), - responseHeaders = { - @ResponseHeader( - name = VERSION_MINOR_NAME, description = VERSION_MINOR_DESCRIPTION, - response = String.class), - @ResponseHeader(name = VERSION_PATCH_NAME, description = VERSION_PATCH_DESCRIPTION, - response = String.class), - @ResponseHeader(name = VERSION_LATEST_NAME, description = VERSION_LATEST_DESCRIPTION, - response = String.class), - @ResponseHeader(name = REQUEST_ID_NAME, description = REQUEST_ID_HDR_DESCRIPTION, - response = UUID.class)}, - extensions = { - @Extension - ( - name = EXTENSION_NAME, - properties = { - @ExtensionProperty(name = API_VERSION_NAME, value = API_VERSION), - @ExtensionProperty(name = LAST_MOD_NAME, value = LAST_MOD_RELEASE) - } - ) - } - ) - @ApiResponses( - value = { - @ApiResponse(code = AUTHENTICATION_ERROR_CODE, message = AUTHENTICATION_ERROR_MESSAGE), - @ApiResponse(code = AUTHORIZATION_ERROR_CODE, message = AUTHORIZATION_ERROR_MESSAGE), - @ApiResponse(code = SERVER_ERROR_CODE, message = SERVER_ERROR_MESSAGE) - } - ) - // @formatter:on - public ResponseEntity> query( - @RequestHeader( - name = REQUEST_ID_NAME, - required = false) @ApiParam(REQUEST_ID_PARAM_DESCRIPTION) UUID requestId, - @ApiParam(value = "Control Loop definition name", required = false) @RequestParam( - value = "name", - required = false) String name, - @ApiParam(value = "Control Loop definition version", required = false) @RequestParam( - value = "version", - required = false) String version) - throws PfModelException { - - return ResponseEntity.ok().body(provider.getControlLoopDefinitions(name, version)); - } - - /** - * Retrieves the Tosca Service Template. - * - * @param requestId request ID used in ONAP logging - * @param name the name of the tosca service template to retrieve - * @param version the version of the tosca service template to get - * @return the specified tosca service template - * @throws PfModelException on errors getting the Tosca Service Template - */ - // @formatter:off - @GetMapping(value = "/commission/toscaservicetemplate", - produces = {MediaType.APPLICATION_JSON_VALUE, APPLICATION_YAML}) - @ApiOperation(value = "Query details of the requested tosca service templates", - notes = "Queries details of the requested commissioned tosca service template, " - + "returning all tosca service template details", - response = ToscaServiceTemplate.class, - tags = {TAGS}, - authorizations = @Authorization(value = AUTHORIZATION_TYPE), - responseHeaders = { - @ResponseHeader( - name = VERSION_MINOR_NAME, description = VERSION_MINOR_DESCRIPTION, - response = String.class), - @ResponseHeader(name = VERSION_PATCH_NAME, description = VERSION_PATCH_DESCRIPTION, - response = String.class), - @ResponseHeader(name = VERSION_LATEST_NAME, description = VERSION_LATEST_DESCRIPTION, - response = String.class), - @ResponseHeader(name = REQUEST_ID_NAME, description = REQUEST_ID_HDR_DESCRIPTION, - response = UUID.class)}, - extensions = { - @Extension - ( - name = EXTENSION_NAME, - properties = { - @ExtensionProperty(name = API_VERSION_NAME, value = API_VERSION), - @ExtensionProperty(name = LAST_MOD_NAME, value = LAST_MOD_RELEASE) - } - ) - } - ) - @ApiResponses( - value = { - @ApiResponse(code = AUTHENTICATION_ERROR_CODE, message = AUTHENTICATION_ERROR_MESSAGE), - @ApiResponse(code = AUTHORIZATION_ERROR_CODE, message = AUTHORIZATION_ERROR_MESSAGE), - @ApiResponse(code = SERVER_ERROR_CODE, message = SERVER_ERROR_MESSAGE) - } - ) - // @formatter:on - public ResponseEntity queryToscaServiceTemplate( - @RequestHeader( - name = REQUEST_ID_NAME, - required = false) @ApiParam(REQUEST_ID_PARAM_DESCRIPTION) UUID requestId, - @ApiParam(value = "Tosca service template name", required = false) @RequestParam( - value = "name", - required = false) String name, - @ApiParam(value = "Tosca service template version", required = false) @RequestParam( - value = "version", - required = false) String version) - throws PfModelException { - - return ResponseEntity.ok().body(provider.getToscaServiceTemplateReduced(name, version)); - } - - /** - * Retrieves the Json Schema for the specified Tosca Service Template. - * - * @param requestId request ID used in ONAP logging - * @param section section of the tosca service template to get schema for - * @return the specified tosca service template or section Json Schema - * @throws PfModelException on errros getting the Json Schema for the specified Tosca Service Template - */ - // @formatter:off - @GetMapping(value = "/commission/toscaServiceTemplateSchema", - produces = {MediaType.APPLICATION_JSON_VALUE, APPLICATION_YAML}) - @ApiOperation(value = "Query details of the requested tosca service template json schema", - notes = "Queries details of the requested commissioned tosca service template json schema, " - + "returning all tosca service template json schema details", - response = ToscaServiceTemplate.class, - tags = {TAGS}, - authorizations = @Authorization(value = AUTHORIZATION_TYPE), - responseHeaders = { - @ResponseHeader( - name = VERSION_MINOR_NAME, description = VERSION_MINOR_DESCRIPTION, - response = String.class), - @ResponseHeader(name = VERSION_PATCH_NAME, description = VERSION_PATCH_DESCRIPTION, - response = String.class), - @ResponseHeader(name = VERSION_LATEST_NAME, description = VERSION_LATEST_DESCRIPTION, - response = String.class), - @ResponseHeader(name = REQUEST_ID_NAME, description = REQUEST_ID_HDR_DESCRIPTION, - response = UUID.class)}, - extensions = { - @Extension - ( - name = EXTENSION_NAME, - properties = { - @ExtensionProperty(name = API_VERSION_NAME, value = API_VERSION), - @ExtensionProperty(name = LAST_MOD_NAME, value = LAST_MOD_RELEASE) - } - ) - } - ) - @ApiResponses( - value = { - @ApiResponse(code = AUTHENTICATION_ERROR_CODE, message = AUTHENTICATION_ERROR_MESSAGE), - @ApiResponse(code = AUTHORIZATION_ERROR_CODE, message = AUTHORIZATION_ERROR_MESSAGE), - @ApiResponse(code = SERVER_ERROR_CODE, message = SERVER_ERROR_MESSAGE) - } - ) - // @formatter:on - public ResponseEntity queryToscaServiceTemplateJsonSchema( - @RequestHeader( - name = REQUEST_ID_NAME, - required = false) @ApiParam(REQUEST_ID_PARAM_DESCRIPTION) UUID requestId, - @ApiParam(value = "Section of Template schema is desired for", required = false) @RequestParam( - value = "section", - required = false, - defaultValue = "all") String section) - throws PfModelException { - - return ResponseEntity.ok().body(provider.getToscaServiceTemplateSchema(section)); - } - - /** - * Retrieves the Common or Instance Properties for the specified Tosca Service Template. - * - * @param requestId request ID used in ONAP logging - * @param common a flag, true to get common properties, false to get instance properties - * @param name the name of the tosca service template to retrieve - * @param version the version of the tosca service template to get - * @return the specified tosca service template or section Json Schema - * @throws PfModelException on errors getting the Common or Instance Properties - * @throws ControlLoopException on error getting the Common or Instance Properties - */ - // @formatter:off - @GetMapping(value = "/commission/getCommonOrInstanceProperties", - produces = {MediaType.APPLICATION_JSON_VALUE, APPLICATION_YAML}) - @ApiOperation(value = "Query details of the requested tosca service template common or instance properties", - notes = "Queries details of the requested commissioned tosca service template json common" - + "or instance properties, returning all tosca service template common or instance property details", - response = ToscaServiceTemplate.class, - tags = {"Clamp Control Loop Commissioning API"}, - authorizations = @Authorization(value = AUTHORIZATION_TYPE), - responseHeaders = { - @ResponseHeader( - name = VERSION_MINOR_NAME, description = VERSION_MINOR_DESCRIPTION, - response = String.class), - @ResponseHeader(name = VERSION_PATCH_NAME, description = VERSION_PATCH_DESCRIPTION, - response = String.class), - @ResponseHeader(name = VERSION_LATEST_NAME, description = VERSION_LATEST_DESCRIPTION, - response = String.class), - @ResponseHeader(name = REQUEST_ID_NAME, description = REQUEST_ID_HDR_DESCRIPTION, - response = UUID.class)}, - extensions = { - @Extension - ( - name = EXTENSION_NAME, - properties = { - @ExtensionProperty(name = API_VERSION_NAME, value = API_VERSION), - @ExtensionProperty(name = LAST_MOD_NAME, value = LAST_MOD_RELEASE) - } - ) - } - ) - @ApiResponses( - value = { - @ApiResponse(code = AUTHENTICATION_ERROR_CODE, message = AUTHENTICATION_ERROR_MESSAGE), - @ApiResponse(code = AUTHORIZATION_ERROR_CODE, message = AUTHORIZATION_ERROR_MESSAGE), - @ApiResponse(code = SERVER_ERROR_CODE, message = SERVER_ERROR_MESSAGE) - } - ) - // @formatter:on - public ResponseEntity> queryToscaServiceCommonOrInstanceProperties( - @RequestHeader( - name = REQUEST_ID_NAME, - required = false) @ApiParam(REQUEST_ID_PARAM_DESCRIPTION) UUID requestId, - @ApiParam(value = "Flag, true for common properties, false for instance", required = false) @RequestParam( - value = "common", - defaultValue = "false", - required = false) boolean common, - @ApiParam(value = "Tosca service template name", required = false) @RequestParam( - value = "name", - required = false) String name, - @ApiParam(value = "Tosca service template version", required = false) @RequestParam( - value = "version", - required = false) String version) - throws PfModelException { - - return ResponseEntity.ok().body(provider.getNodeTemplatesWithCommonOrInstanceProperties(common, name, version)); - } - - /** - * Queries the elements of a specific control loop. - * - * @param requestId request ID used in ONAP logging - * @param name the name of the control loop definition to get - * @param version the version of the control loop definition to get - * @return the control loop element definitions - * @throws PfModelException on errors getting the elements of a specific control loop - */ - // @formatter:off - @GetMapping(value = "/commission/elements", - produces = {MediaType.APPLICATION_JSON_VALUE, APPLICATION_YAML}) - @ApiOperation(value = "Query details of the requested commissioned control loop element definitions", - notes = "Queries details of the requested commissioned control loop element definitions, " - + "returning all control loop elements' details", - response = ToscaNodeTemplate.class, - tags = {TAGS}, - authorizations = @Authorization(value = AUTHORIZATION_TYPE), - responseHeaders = { - @ResponseHeader( - name = VERSION_MINOR_NAME, description = VERSION_MINOR_DESCRIPTION, - response = String.class), - @ResponseHeader(name = VERSION_PATCH_NAME, description = VERSION_PATCH_DESCRIPTION, - response = String.class), - @ResponseHeader(name = VERSION_LATEST_NAME, description = VERSION_LATEST_DESCRIPTION, - response = String.class), - @ResponseHeader(name = REQUEST_ID_NAME, description = REQUEST_ID_HDR_DESCRIPTION, - response = UUID.class)}, - extensions = { - @Extension - ( - name = EXTENSION_NAME, - properties = { - @ExtensionProperty(name = API_VERSION_NAME, value = API_VERSION), - @ExtensionProperty(name = LAST_MOD_NAME, value = LAST_MOD_RELEASE) - } - ) - } - ) - @ApiResponses( - value = { - @ApiResponse(code = AUTHENTICATION_ERROR_CODE, message = AUTHENTICATION_ERROR_MESSAGE), - @ApiResponse(code = AUTHORIZATION_ERROR_CODE, message = AUTHORIZATION_ERROR_MESSAGE), - @ApiResponse(code = SERVER_ERROR_CODE, message = SERVER_ERROR_MESSAGE) - } - ) - // @formatter:on - public ResponseEntity> queryElements( - @RequestHeader( - name = REQUEST_ID_NAME, - required = false) @ApiParam(REQUEST_ID_PARAM_DESCRIPTION) UUID requestId, - @ApiParam(value = "Control Loop definition name", required = false) @RequestParam( - value = "name", - required = false) String name, - @ApiParam(value = "Control Loop definition version", required = false) @RequestParam( - value = "version", - required = false) String version) - throws PfModelException { - - List nodeTemplate = provider.getControlLoopDefinitions(name, version); - // Prevent ambiguous queries with multiple returns - if (nodeTemplate.size() > 1) { - throw new PfModelException(Status.NOT_ACCEPTABLE, "Multiple ControlLoops are not supported"); - } - - List response = provider.getControlLoopElementDefinitions(nodeTemplate.get(0)); - return ResponseEntity.ok().body(response); - } -} diff --git a/runtime-controlloop/src/main/java/org/onap/policy/clamp/controlloop/runtime/main/rest/InstantiationController.java b/runtime-controlloop/src/main/java/org/onap/policy/clamp/controlloop/runtime/main/rest/InstantiationController.java deleted file mode 100644 index d229e68cb..000000000 --- a/runtime-controlloop/src/main/java/org/onap/policy/clamp/controlloop/runtime/main/rest/InstantiationController.java +++ /dev/null @@ -1,637 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * Copyright (C) 2021 Nordix Foundation. - * Modifications Copyright (C) 2021 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - * SPDX-License-Identifier: Apache-2.0 - * ============LICENSE_END========================================================= - */ - -package org.onap.policy.clamp.controlloop.runtime.main.rest; - -import io.swagger.annotations.ApiOperation; -import io.swagger.annotations.ApiParam; -import io.swagger.annotations.ApiResponse; -import io.swagger.annotations.ApiResponses; -import io.swagger.annotations.Authorization; -import io.swagger.annotations.Extension; -import io.swagger.annotations.ExtensionProperty; -import io.swagger.annotations.ResponseHeader; -import java.util.UUID; -import lombok.RequiredArgsConstructor; -import org.onap.policy.clamp.controlloop.common.exception.ControlLoopException; -import org.onap.policy.clamp.controlloop.models.controlloop.concepts.ControlLoops; -import org.onap.policy.clamp.controlloop.models.messages.rest.instantiation.ControlLoopOrderStateResponse; -import org.onap.policy.clamp.controlloop.models.messages.rest.instantiation.ControlLoopPrimedResponse; -import org.onap.policy.clamp.controlloop.models.messages.rest.instantiation.InstancePropertiesResponse; -import org.onap.policy.clamp.controlloop.models.messages.rest.instantiation.InstantiationCommand; -import org.onap.policy.clamp.controlloop.models.messages.rest.instantiation.InstantiationResponse; -import org.onap.policy.clamp.controlloop.runtime.instantiation.ControlLoopInstantiationProvider; -import org.onap.policy.clamp.controlloop.runtime.main.web.AbstractRestController; -import org.onap.policy.models.base.PfModelException; -import org.onap.policy.models.tosca.authorative.concepts.ToscaServiceTemplate; -import org.springframework.http.MediaType; -import org.springframework.http.ResponseEntity; -import org.springframework.web.bind.annotation.DeleteMapping; -import org.springframework.web.bind.annotation.GetMapping; -import org.springframework.web.bind.annotation.PostMapping; -import org.springframework.web.bind.annotation.PutMapping; -import org.springframework.web.bind.annotation.RequestBody; -import org.springframework.web.bind.annotation.RequestHeader; -import org.springframework.web.bind.annotation.RequestParam; -import org.springframework.web.bind.annotation.RestController; - -/** - * Class to provide REST end points for creating, deleting, query and commanding a control loop definition. - */ -@RestController -@RequiredArgsConstructor -public class InstantiationController extends AbstractRestController { - - private static final String TAGS = "Clamp Control Loop Instantiation API"; - - // The CL provider for instantiation requests - private final ControlLoopInstantiationProvider provider; - - /** - * Creates a control loop. - * - * @param requestId request ID used in ONAP logging - * @param controlLoops the control loops - * @return a response - * @throws PfModelException on errors creating a control loop - */ - // @formatter:off - @PostMapping(value = "/instantiation", - produces = {MediaType.APPLICATION_JSON_VALUE, APPLICATION_YAML}, - consumes = {MediaType.APPLICATION_JSON_VALUE, APPLICATION_YAML}) - @ApiOperation( - value = "Commissions control loop definitions", - notes = "Commissions control loop definitions, returning the control loop IDs", - response = InstantiationResponse.class, - tags = {TAGS}, - authorizations = @Authorization(value = AUTHORIZATION_TYPE), - responseHeaders = { - @ResponseHeader( - name = VERSION_MINOR_NAME, - description = VERSION_MINOR_DESCRIPTION, - response = String.class), - @ResponseHeader( - name = VERSION_PATCH_NAME, - description = VERSION_PATCH_DESCRIPTION, - response = String.class), - @ResponseHeader( - name = VERSION_LATEST_NAME, - description = VERSION_LATEST_DESCRIPTION, - response = String.class), - @ResponseHeader( - name = REQUEST_ID_NAME, - description = REQUEST_ID_HDR_DESCRIPTION, - response = UUID.class) - }, - extensions = { - @Extension - ( - name = EXTENSION_NAME, - properties = { - @ExtensionProperty(name = API_VERSION_NAME, value = API_VERSION), - @ExtensionProperty(name = LAST_MOD_NAME, value = LAST_MOD_RELEASE) - } - ) - } - ) - @ApiResponses( - value = { - @ApiResponse(code = AUTHENTICATION_ERROR_CODE, message = AUTHENTICATION_ERROR_MESSAGE), - @ApiResponse(code = AUTHORIZATION_ERROR_CODE, message = AUTHORIZATION_ERROR_MESSAGE), - @ApiResponse(code = SERVER_ERROR_CODE, message = SERVER_ERROR_MESSAGE) - } - ) - // @formatter:on - public ResponseEntity create( - @RequestHeader( - name = REQUEST_ID_NAME, - required = false) @ApiParam(REQUEST_ID_PARAM_DESCRIPTION) UUID requestId, - @ApiParam(value = "Entity Body of Control Loop", required = true) @RequestBody ControlLoops controlLoops) - throws PfModelException { - - return ResponseEntity.ok().body(provider.createControlLoops(controlLoops)); - } - - /** - * Saves instance properties. - * - * @param requestId request ID used in ONAP logging - * @param body the body of control loop following TOSCA definition - * @return a response - */ - // @formatter:off - @PostMapping(value = "/instanceProperties", - consumes = {MediaType.APPLICATION_JSON_VALUE, APPLICATION_YAML}, - produces = {MediaType.APPLICATION_JSON_VALUE, APPLICATION_YAML}) - @ApiOperation( - value = "Saves instance properties", - notes = "Saves instance properties, returning the saved instances properties and it's version", - response = InstancePropertiesResponse.class, - tags = {TAGS}, - authorizations = @Authorization(value = AUTHORIZATION_TYPE), - responseHeaders = { - @ResponseHeader( - name = VERSION_MINOR_NAME, - description = VERSION_MINOR_DESCRIPTION, - response = String.class), - @ResponseHeader( - name = VERSION_PATCH_NAME, - description = VERSION_PATCH_DESCRIPTION, - response = String.class), - @ResponseHeader( - name = VERSION_LATEST_NAME, - description = VERSION_LATEST_DESCRIPTION, - response = String.class), - @ResponseHeader( - name = REQUEST_ID_NAME, - description = REQUEST_ID_HDR_DESCRIPTION, - response = UUID.class) - }, - extensions = { - @Extension - ( - name = EXTENSION_NAME, - properties = { - @ExtensionProperty(name = API_VERSION_NAME, value = API_VERSION), - @ExtensionProperty(name = LAST_MOD_NAME, value = LAST_MOD_RELEASE) - } - ) - } - ) - @ApiResponses( - value = { - @ApiResponse(code = AUTHENTICATION_ERROR_CODE, message = AUTHENTICATION_ERROR_MESSAGE), - @ApiResponse(code = AUTHORIZATION_ERROR_CODE, message = AUTHORIZATION_ERROR_MESSAGE), - @ApiResponse(code = SERVER_ERROR_CODE, message = SERVER_ERROR_MESSAGE) - } - ) - // @formatter:on - public ResponseEntity createInstanceProperties( - @RequestHeader( - name = REQUEST_ID_NAME, - required = false) @ApiParam(REQUEST_ID_PARAM_DESCRIPTION) UUID requestId, - @ApiParam(value = "Body of instance properties", required = true) @RequestBody ToscaServiceTemplate body) - throws PfModelException { - - return ResponseEntity.ok().body(provider.createInstanceProperties(body)); - } - - /** - * Deletes a control loop definition and instance properties. - * - * @param requestId request ID used in ONAP logging - * @param name the name of the control loop to delete - * @param version the version of the control loop to delete - * @return a response - * @throws PfModelException on errors deleting of control loop and instance properties - */ - // @formatter:off - @DeleteMapping(value = "/instanceProperties", - produces = {MediaType.APPLICATION_JSON_VALUE, APPLICATION_YAML}) - @ApiOperation(value = "Delete a control loop and instance properties", - notes = "Deletes a control loop and instance properties, returning optional error details", - response = InstantiationResponse.class, - tags = {TAGS}, - authorizations = @Authorization(value = AUTHORIZATION_TYPE), - responseHeaders = { - @ResponseHeader( - name = VERSION_MINOR_NAME, - description = VERSION_MINOR_DESCRIPTION, - response = String.class), - @ResponseHeader( - name = VERSION_PATCH_NAME, - description = VERSION_PATCH_DESCRIPTION, - response = String.class), - @ResponseHeader( - name = VERSION_LATEST_NAME, - description = VERSION_LATEST_DESCRIPTION, - response = String.class), - @ResponseHeader( - name = REQUEST_ID_NAME, - description = REQUEST_ID_HDR_DESCRIPTION, - response = UUID.class)}, - extensions = { - @Extension - ( - name = EXTENSION_NAME, - properties = { - @ExtensionProperty(name = API_VERSION_NAME, value = API_VERSION), - @ExtensionProperty(name = LAST_MOD_NAME, value = LAST_MOD_RELEASE) - } - ) - } - ) - @ApiResponses( - value = { - @ApiResponse(code = AUTHENTICATION_ERROR_CODE, message = AUTHENTICATION_ERROR_MESSAGE), - @ApiResponse(code = AUTHORIZATION_ERROR_CODE, message = AUTHORIZATION_ERROR_MESSAGE), - @ApiResponse(code = SERVER_ERROR_CODE, message = SERVER_ERROR_MESSAGE) - } - ) - // @formatter:on - - public ResponseEntity deleteInstanceProperties( - @RequestHeader( - name = REQUEST_ID_NAME, - required = false) @ApiParam(REQUEST_ID_PARAM_DESCRIPTION) UUID requestId, - @ApiParam(value = "Control Loop definition name", required = true) @RequestParam("name") String name, - @ApiParam(value = "Control Loop definition version") @RequestParam( - value = "version", - required = true) String version) - throws PfModelException { - - return ResponseEntity.ok().body(provider.deleteInstanceProperties(name, version)); - } - - /** - * Queries details of all control loops. - * - * @param requestId request ID used in ONAP logging - * @param name the name of the control loop to get, null for all control loops - * @param version the version of the control loop to get, null for all control loops - * @return the control loops - * @throws PfModelException on errors getting commissioning of control loop - */ - // @formatter:off - @GetMapping(value = "/instantiation", - produces = {MediaType.APPLICATION_JSON_VALUE, APPLICATION_YAML}) - @ApiOperation(value = "Query details of the requested control loops", - notes = "Queries details of the requested control loops, returning all control loop details", - response = ControlLoops.class, - tags = {TAGS}, - authorizations = @Authorization(value = AUTHORIZATION_TYPE), - responseHeaders = { - @ResponseHeader( - name = VERSION_MINOR_NAME, description = VERSION_MINOR_DESCRIPTION, - response = String.class), - @ResponseHeader(name = VERSION_PATCH_NAME, description = VERSION_PATCH_DESCRIPTION, - response = String.class), - @ResponseHeader(name = VERSION_LATEST_NAME, description = VERSION_LATEST_DESCRIPTION, - response = String.class), - @ResponseHeader(name = REQUEST_ID_NAME, description = REQUEST_ID_HDR_DESCRIPTION, - response = UUID.class)}, - extensions = { - @Extension - ( - name = EXTENSION_NAME, - properties = { - @ExtensionProperty(name = API_VERSION_NAME, value = API_VERSION), - @ExtensionProperty(name = LAST_MOD_NAME, value = LAST_MOD_RELEASE) - } - ) - } - ) - @ApiResponses( - value = { - @ApiResponse(code = AUTHENTICATION_ERROR_CODE, message = AUTHENTICATION_ERROR_MESSAGE), - @ApiResponse(code = AUTHORIZATION_ERROR_CODE, message = AUTHORIZATION_ERROR_MESSAGE), - @ApiResponse(code = SERVER_ERROR_CODE, message = SERVER_ERROR_MESSAGE) - } - ) - // @formatter:on - public ResponseEntity query( - @RequestHeader( - name = REQUEST_ID_NAME, - required = false) @ApiParam(REQUEST_ID_PARAM_DESCRIPTION) UUID requestId, - @ApiParam(value = "Control Loop definition name", required = false) @RequestParam( - value = "name", - required = false) String name, - @ApiParam(value = "Control Loop definition version", required = false) @RequestParam( - value = "version", - required = false) String version) - throws PfModelException { - - return ResponseEntity.ok().body(provider.getControlLoops(name, version)); - } - - /** - * Updates a control loop. - * - * @param requestId request ID used in ONAP logging - * @param controlLoops the control loops - * @return a response - * @throws PfModelException on errors updating of control loops - */ - // @formatter:off - @PutMapping(value = "/instantiation", - produces = {MediaType.APPLICATION_JSON_VALUE, APPLICATION_YAML}, - consumes = {MediaType.APPLICATION_JSON_VALUE, APPLICATION_YAML}) - @ApiOperation( - value = "Updates control loop definitions", - notes = "Updates control loop definitions, returning the updated control loop definition IDs", - response = InstantiationResponse.class, - tags = {TAGS}, - authorizations = @Authorization(value = AUTHORIZATION_TYPE), - responseHeaders = { - @ResponseHeader( - name = VERSION_MINOR_NAME, - description = VERSION_MINOR_DESCRIPTION, - response = String.class), - @ResponseHeader( - name = VERSION_PATCH_NAME, - description = VERSION_PATCH_DESCRIPTION, - response = String.class), - @ResponseHeader( - name = VERSION_LATEST_NAME, - description = VERSION_LATEST_DESCRIPTION, - response = String.class), - @ResponseHeader( - name = REQUEST_ID_NAME, - description = REQUEST_ID_HDR_DESCRIPTION, - response = UUID.class) - }, - extensions = { - @Extension - ( - name = EXTENSION_NAME, - properties = { - @ExtensionProperty(name = API_VERSION_NAME, value = API_VERSION), - @ExtensionProperty(name = LAST_MOD_NAME, value = LAST_MOD_RELEASE) - } - ) - } - ) - @ApiResponses( - value = { - @ApiResponse(code = AUTHENTICATION_ERROR_CODE, message = AUTHENTICATION_ERROR_MESSAGE), - @ApiResponse(code = AUTHORIZATION_ERROR_CODE, message = AUTHORIZATION_ERROR_MESSAGE), - @ApiResponse(code = SERVER_ERROR_CODE, message = SERVER_ERROR_MESSAGE) - } - ) - // @formatter:on - public ResponseEntity update( - @RequestHeader( - name = REQUEST_ID_NAME, - required = false) @ApiParam(REQUEST_ID_PARAM_DESCRIPTION) UUID requestId, - @ApiParam(value = "Entity Body of Control Loop", required = true) @RequestBody ControlLoops controlLoops) - throws PfModelException { - - return ResponseEntity.ok().body(provider.updateControlLoops(controlLoops)); - } - - /** - * Deletes a control loop definition. - * - * @param requestId request ID used in ONAP logging - * @param name the name of the control loop to delete - * @param version the version of the control loop to delete - * @return a response - * @throws PfModelException on errors deleting of control loop - */ - // @formatter:off - @DeleteMapping(value = "/instantiation", - produces = {MediaType.APPLICATION_JSON_VALUE, APPLICATION_YAML}) - @ApiOperation(value = "Delete a control loop", - notes = "Deletes a control loop, returning optional error details", - response = InstantiationResponse.class, - tags = {TAGS}, - authorizations = @Authorization(value = AUTHORIZATION_TYPE), - responseHeaders = { - @ResponseHeader( - name = VERSION_MINOR_NAME, - description = VERSION_MINOR_DESCRIPTION, - response = String.class), - @ResponseHeader( - name = VERSION_PATCH_NAME, - description = VERSION_PATCH_DESCRIPTION, - response = String.class), - @ResponseHeader( - name = VERSION_LATEST_NAME, - description = VERSION_LATEST_DESCRIPTION, - response = String.class), - @ResponseHeader( - name = REQUEST_ID_NAME, - description = REQUEST_ID_HDR_DESCRIPTION, - response = UUID.class)}, - extensions = { - @Extension - ( - name = EXTENSION_NAME, - properties = { - @ExtensionProperty(name = API_VERSION_NAME, value = API_VERSION), - @ExtensionProperty(name = LAST_MOD_NAME, value = LAST_MOD_RELEASE) - } - ) - } - ) - @ApiResponses( - value = { - @ApiResponse(code = AUTHENTICATION_ERROR_CODE, message = AUTHENTICATION_ERROR_MESSAGE), - @ApiResponse(code = AUTHORIZATION_ERROR_CODE, message = AUTHORIZATION_ERROR_MESSAGE), - @ApiResponse(code = SERVER_ERROR_CODE, message = SERVER_ERROR_MESSAGE) - } - ) - // @formatter:on - - public ResponseEntity delete( - @RequestHeader( - name = REQUEST_ID_NAME, - required = false) @ApiParam(REQUEST_ID_PARAM_DESCRIPTION) UUID requestId, - @ApiParam(value = "Control Loop definition name", required = true) @RequestParam("name") String name, - @ApiParam(value = "Control Loop definition version") @RequestParam( - value = "version", - required = true) String version) - throws PfModelException { - - return ResponseEntity.ok().body(provider.deleteControlLoop(name, version)); - } - - /** - * Issues control loop commands to control loops. - * - * @param requestId request ID used in ONAP logging - * @param command the command to issue to control loops - * @return the control loop definitions - * @throws PfModelException on errors issuing a command - * @throws ControlLoopException on errors issuing a command - */ - // @formatter:off - @PutMapping(value = "/instantiation/command", - produces = {MediaType.APPLICATION_JSON_VALUE, APPLICATION_YAML}, - consumes = {MediaType.APPLICATION_JSON_VALUE, APPLICATION_YAML}) - @ApiOperation(value = "Issue a command to the requested control loops", - notes = "Issues a command to a control loop, ordering a state change on the control loop", - response = InstantiationResponse.class, - tags = {TAGS}, - authorizations = @Authorization(value = AUTHORIZATION_TYPE), - responseHeaders = { - @ResponseHeader( - name = VERSION_MINOR_NAME, description = VERSION_MINOR_DESCRIPTION, - response = String.class), - @ResponseHeader(name = VERSION_PATCH_NAME, description = VERSION_PATCH_DESCRIPTION, - response = String.class), - @ResponseHeader(name = VERSION_LATEST_NAME, description = VERSION_LATEST_DESCRIPTION, - response = String.class), - @ResponseHeader(name = REQUEST_ID_NAME, description = REQUEST_ID_HDR_DESCRIPTION, - response = UUID.class)}, - extensions = { - @Extension - ( - name = EXTENSION_NAME, - properties = { - @ExtensionProperty(name = API_VERSION_NAME, value = API_VERSION), - @ExtensionProperty(name = LAST_MOD_NAME, value = LAST_MOD_RELEASE) - } - ) - } - ) - @ApiResponses( - value = { - @ApiResponse(code = AUTHENTICATION_ERROR_CODE, message = AUTHENTICATION_ERROR_MESSAGE), - @ApiResponse(code = AUTHORIZATION_ERROR_CODE, message = AUTHORIZATION_ERROR_MESSAGE), - @ApiResponse(code = SERVER_ERROR_CODE, message = SERVER_ERROR_MESSAGE) - } - ) - // @formatter:on - public ResponseEntity issueControlLoopCommand( - @RequestHeader( - name = REQUEST_ID_NAME, - required = false) @ApiParam(REQUEST_ID_PARAM_DESCRIPTION) UUID requestId, - @ApiParam( - value = "Entity Body of control loop command", - required = true) @RequestBody InstantiationCommand command) - throws ControlLoopException, PfModelException { - - return ResponseEntity.accepted().body(provider.issueControlLoopCommand(command)); - } - - /** - * Queries details of all control loops. - * - * @param requestId request ID used in ONAP logging - * @param name the name of the control loop to get, null for all control loops - * @param version the version of the control loop to get, null for all control loops - * @return the control loops - * @throws PfModelException on errors getting commissioning of control loop - */ - // @formatter:off - @GetMapping(value = "/instantiationState", - produces = {MediaType.APPLICATION_JSON_VALUE, APPLICATION_YAML}) - @ApiOperation(value = "Query details of the requested control loops", - notes = "Queries details of the requested control loops, returning all control loop details", - response = ControlLoops.class, - tags = {TAGS}, - authorizations = @Authorization(value = AUTHORIZATION_TYPE), - responseHeaders = { - @ResponseHeader( - name = VERSION_MINOR_NAME, description = VERSION_MINOR_DESCRIPTION, - response = String.class), - @ResponseHeader(name = VERSION_PATCH_NAME, description = VERSION_PATCH_DESCRIPTION, - response = String.class), - @ResponseHeader(name = VERSION_LATEST_NAME, description = VERSION_LATEST_DESCRIPTION, - response = String.class), - @ResponseHeader(name = REQUEST_ID_NAME, description = REQUEST_ID_HDR_DESCRIPTION, - response = UUID.class)}, - extensions = { - @Extension - ( - name = EXTENSION_NAME, - properties = { - @ExtensionProperty(name = API_VERSION_NAME, value = API_VERSION), - @ExtensionProperty(name = LAST_MOD_NAME, value = LAST_MOD_RELEASE) - } - ) - } - ) - @ApiResponses( - value = { - @ApiResponse(code = AUTHENTICATION_ERROR_CODE, message = AUTHENTICATION_ERROR_MESSAGE), - @ApiResponse(code = AUTHORIZATION_ERROR_CODE, message = AUTHORIZATION_ERROR_MESSAGE), - @ApiResponse(code = SERVER_ERROR_CODE, message = SERVER_ERROR_MESSAGE) - } - ) - // @formatter:on - public ResponseEntity getInstantiationOrderState( - @RequestHeader( - name = REQUEST_ID_NAME, - required = false) @ApiParam(REQUEST_ID_PARAM_DESCRIPTION) UUID requestId, - @ApiParam(value = "Control Loop name", required = false) @RequestParam( - value = "name", - required = false) String name, - @ApiParam(value = "Control Loop version", required = false) @RequestParam( - value = "version", - required = false) String version) - throws PfModelException { - - return ResponseEntity.ok().body(provider.getInstantiationOrderState(name, version)); - } - - /** - * Queries Primed/De-Primed status of a control loop. - * - * @param requestId request ID used in ONAP logging - * @param name the name of the control loop to get, null for all control loops - * @param version the version of the control loop to get, null for all control loops - * @return the control loops - * @throws PfModelException on errors getting priming of control loop - */ - // @formatter:off - @GetMapping(value = "/controlLoopPriming", - produces = {MediaType.APPLICATION_JSON_VALUE, APPLICATION_YAML}) - @ApiOperation(value = "Query priming details of the requested control loops", - notes = "Queries priming details of the requested control loops, returning primed/deprimed control loops", - response = ControlLoopPrimedResponse.class, - tags = {TAGS}, - authorizations = @Authorization(value = AUTHORIZATION_TYPE), - responseHeaders = { - @ResponseHeader( - name = VERSION_MINOR_NAME, description = VERSION_MINOR_DESCRIPTION, - response = String.class), - @ResponseHeader(name = VERSION_PATCH_NAME, description = VERSION_PATCH_DESCRIPTION, - response = String.class), - @ResponseHeader(name = VERSION_LATEST_NAME, description = VERSION_LATEST_DESCRIPTION, - response = String.class), - @ResponseHeader(name = REQUEST_ID_NAME, description = REQUEST_ID_HDR_DESCRIPTION, - response = UUID.class)}, - extensions = { - @Extension - ( - name = EXTENSION_NAME, - properties = { - @ExtensionProperty(name = API_VERSION_NAME, value = API_VERSION), - @ExtensionProperty(name = LAST_MOD_NAME, value = LAST_MOD_RELEASE) - } - ) - } - ) - @ApiResponses( - value = { - @ApiResponse(code = AUTHENTICATION_ERROR_CODE, message = AUTHENTICATION_ERROR_MESSAGE), - @ApiResponse(code = AUTHORIZATION_ERROR_CODE, message = AUTHORIZATION_ERROR_MESSAGE), - @ApiResponse(code = SERVER_ERROR_CODE, message = SERVER_ERROR_MESSAGE) - } - ) - // @formatter:on - public ResponseEntity getControlLoopPriming( - @RequestHeader( - name = REQUEST_ID_NAME, - required = false) @ApiParam(REQUEST_ID_PARAM_DESCRIPTION) UUID requestId, - @ApiParam(value = "Control Loop definition name", required = false) @RequestParam( - value = "name", - required = false) String name, - @ApiParam(value = "Control Loop definition version", required = false) @RequestParam( - value = "version", - required = false) String version) - throws PfModelException { - - return ResponseEntity.ok().body(provider.getControlLoopPriming(name, version)); - } -} diff --git a/runtime-controlloop/src/main/java/org/onap/policy/clamp/controlloop/runtime/main/rest/MonitoringQueryController.java b/runtime-controlloop/src/main/java/org/onap/policy/clamp/controlloop/runtime/main/rest/MonitoringQueryController.java deleted file mode 100644 index c4ce5bb05..000000000 --- a/runtime-controlloop/src/main/java/org/onap/policy/clamp/controlloop/runtime/main/rest/MonitoringQueryController.java +++ /dev/null @@ -1,341 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * Copyright (C) 2021 Nordix Foundation. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - * SPDX-License-Identifier: Apache-2.0 - * ============LICENSE_END========================================================= - */ - -package org.onap.policy.clamp.controlloop.runtime.main.rest; - -import io.swagger.annotations.ApiOperation; -import io.swagger.annotations.ApiParam; -import io.swagger.annotations.ApiResponse; -import io.swagger.annotations.ApiResponses; -import io.swagger.annotations.Authorization; -import io.swagger.annotations.Extension; -import io.swagger.annotations.ExtensionProperty; -import io.swagger.annotations.ResponseHeader; -import java.time.Instant; -import java.util.UUID; -import lombok.RequiredArgsConstructor; -import org.onap.policy.clamp.controlloop.models.controlloop.concepts.ClElementStatisticsList; -import org.onap.policy.clamp.controlloop.models.controlloop.concepts.ParticipantStatisticsList; -import org.onap.policy.clamp.controlloop.runtime.main.web.AbstractRestController; -import org.onap.policy.clamp.controlloop.runtime.monitoring.MonitoringProvider; -import org.onap.policy.models.base.PfModelException; -import org.springframework.http.MediaType; -import org.springframework.http.ResponseEntity; -import org.springframework.web.bind.annotation.GetMapping; -import org.springframework.web.bind.annotation.RequestHeader; -import org.springframework.web.bind.annotation.RequestParam; -import org.springframework.web.bind.annotation.RestController; - -/** - * This class handles REST endpoints for CL Statistics monitoring. - */ -@RestController -@RequiredArgsConstructor -public class MonitoringQueryController extends AbstractRestController { - - private static final String TAGS = "Clamp Control Loop Monitoring API"; - private final MonitoringProvider provider; - - /** - * Queries details of control loop participants statistics. - * - * @param requestId request ID used in ONAP logging - * @param name the name of the participant to get, null for all participants statistics - * @param version the version of the participant to get, null for all participants with the given name - * @param recordCount the record count to be fetched - * @param startTime the time from which to get statistics - * @param endTime the time to which to get statistics - * @return the participant statistics - */ - // @formatter:off - @GetMapping(value = "/monitoring/participant", - produces = {MediaType.APPLICATION_JSON_VALUE, APPLICATION_YAML}) - @ApiOperation(value = "Query details of the requested participant stats", - notes = "Queries details of the requested participant stats, returning all participant stats", - response = ParticipantStatisticsList.class, - tags = {TAGS}, - authorizations = @Authorization(value = AUTHORIZATION_TYPE), - responseHeaders = { - @ResponseHeader( - name = VERSION_MINOR_NAME, description = VERSION_MINOR_DESCRIPTION, - response = String.class), - @ResponseHeader(name = VERSION_PATCH_NAME, description = VERSION_PATCH_DESCRIPTION, - response = String.class), - @ResponseHeader(name = VERSION_LATEST_NAME, description = VERSION_LATEST_DESCRIPTION, - response = String.class), - @ResponseHeader(name = REQUEST_ID_NAME, description = REQUEST_ID_HDR_DESCRIPTION, - response = UUID.class)}, - extensions = { - @Extension - ( - name = EXTENSION_NAME, - properties = { - @ExtensionProperty(name = API_VERSION_NAME, value = API_VERSION), - @ExtensionProperty(name = LAST_MOD_NAME, value = LAST_MOD_RELEASE) - } - ) - } - ) - @ApiResponses( - value = { - @ApiResponse(code = AUTHENTICATION_ERROR_CODE, message = AUTHENTICATION_ERROR_MESSAGE), - @ApiResponse(code = AUTHORIZATION_ERROR_CODE, message = AUTHORIZATION_ERROR_MESSAGE), - @ApiResponse(code = SERVER_ERROR_CODE, message = SERVER_ERROR_MESSAGE) - } - ) - // @formatter:on - public ResponseEntity queryParticipantStatistics( - @RequestHeader( - name = REQUEST_ID_NAME, - required = false) @ApiParam(REQUEST_ID_PARAM_DESCRIPTION) UUID requestId, - @ApiParam(value = "Control Loop participant name") @RequestParam( - value = "name", - required = false) final String name, - @ApiParam(value = "Control Loop participant version", required = false) @RequestParam( - value = "version", - required = false) final String version, - @ApiParam(value = "Record count", required = false) @RequestParam( - value = "recordCount", - required = false, - defaultValue = "0") final int recordCount, - @ApiParam(value = "start time", required = false) @RequestParam( - value = "startTime", - required = false) final String startTime, - @ApiParam(value = "end time", required = false) @RequestParam( - value = "endTime", - required = false) final String endTime) { - - Instant startTimestamp = null; - Instant endTimestamp = null; - - if (startTime != null) { - startTimestamp = Instant.parse(startTime); - } - if (endTime != null) { - endTimestamp = Instant.parse(endTime); - } - return ResponseEntity.ok().body( - provider.fetchFilteredParticipantStatistics(name, version, recordCount, startTimestamp, endTimestamp)); - } - - /** - * Queries details of all participant statistics per control loop. - * - * @param requestId request ID used in ONAP logging - * @param name the name of the control loop - * @param version version of the control loop - * @return the control loop element statistics - */ - // @formatter:off - @GetMapping(value = "/monitoring/participants/controlloop", - produces = {MediaType.APPLICATION_JSON_VALUE, APPLICATION_YAML}) - @ApiOperation(value = "Query details of all the participant stats in a control loop", - notes = "Queries details of the participant stats, returning all participant stats", - response = ClElementStatisticsList.class, - tags = {TAGS}, - authorizations = @Authorization(value = AUTHORIZATION_TYPE), - responseHeaders = { - @ResponseHeader( - name = VERSION_MINOR_NAME, description = VERSION_MINOR_DESCRIPTION, - response = String.class), - @ResponseHeader(name = VERSION_PATCH_NAME, description = VERSION_PATCH_DESCRIPTION, - response = String.class), - @ResponseHeader(name = VERSION_LATEST_NAME, description = VERSION_LATEST_DESCRIPTION, - response = String.class), - @ResponseHeader(name = REQUEST_ID_NAME, description = REQUEST_ID_HDR_DESCRIPTION, - response = UUID.class)}, - extensions = { - @Extension - ( - name = EXTENSION_NAME, - properties = { - @ExtensionProperty(name = API_VERSION_NAME, value = API_VERSION), - @ExtensionProperty(name = LAST_MOD_NAME, value = LAST_MOD_RELEASE) - } - ) - }) - @ApiResponses( - value = { - @ApiResponse(code = AUTHENTICATION_ERROR_CODE, message = AUTHENTICATION_ERROR_MESSAGE), - @ApiResponse(code = AUTHORIZATION_ERROR_CODE, message = AUTHORIZATION_ERROR_MESSAGE), - @ApiResponse(code = SERVER_ERROR_CODE, message = SERVER_ERROR_MESSAGE) - } - ) - // @formatter:on - public ResponseEntity queryParticipantStatisticsPerControlLoop( - @RequestHeader( - name = REQUEST_ID_NAME, - required = false) @ApiParam(REQUEST_ID_PARAM_DESCRIPTION) UUID requestId, - @ApiParam(value = "Control Loop name", required = true) @RequestParam( - value = "name", - required = false) final String name, - @ApiParam(value = "Control Loop version", required = true) @RequestParam( - value = "version", - required = false) final String version) { - - return ResponseEntity.ok().body(provider.fetchParticipantStatsPerControlLoop(name, version)); - } - - /** - * Queries details of all control loop element statistics per control loop. - * - * @param requestId request ID used in ONAP logging - * @param name the name of the control loop - * @param version version of the control loop - * @return the control loop element statistics - */ - // @formatter:off - @GetMapping(value = "/monitoring/clelements/controlloop", - produces = {MediaType.APPLICATION_JSON_VALUE, APPLICATION_YAML}) - @ApiOperation(value = "Query details of the requested cl element stats in a control loop", - notes = "Queries details of the requested cl element stats, returning all clElement stats", - response = ClElementStatisticsList.class, - tags = {TAGS}, - authorizations = @Authorization(value = AUTHORIZATION_TYPE), - responseHeaders = { - @ResponseHeader( - name = VERSION_MINOR_NAME, description = VERSION_MINOR_DESCRIPTION, - response = String.class), - @ResponseHeader(name = VERSION_PATCH_NAME, description = VERSION_PATCH_DESCRIPTION, - response = String.class), - @ResponseHeader(name = VERSION_LATEST_NAME, description = VERSION_LATEST_DESCRIPTION, - response = String.class), - @ResponseHeader(name = REQUEST_ID_NAME, description = REQUEST_ID_HDR_DESCRIPTION, - response = UUID.class)}, - extensions = { - @Extension - ( - name = EXTENSION_NAME, - properties = { - @ExtensionProperty(name = API_VERSION_NAME, value = API_VERSION), - @ExtensionProperty(name = LAST_MOD_NAME, value = LAST_MOD_RELEASE) - } - ) - }) - @ApiResponses( - value = { - @ApiResponse(code = AUTHENTICATION_ERROR_CODE, message = AUTHENTICATION_ERROR_MESSAGE), - @ApiResponse(code = AUTHORIZATION_ERROR_CODE, message = AUTHORIZATION_ERROR_MESSAGE), - @ApiResponse(code = SERVER_ERROR_CODE, message = SERVER_ERROR_MESSAGE) - } - ) - // @formatter:on - public ResponseEntity queryElementStatisticsPerControlLoop( - @RequestHeader( - name = REQUEST_ID_NAME, - required = false) @ApiParam(REQUEST_ID_PARAM_DESCRIPTION) UUID requestId, - @ApiParam(value = "Control Loop name", required = true) @RequestParam( - value = "name", - required = false) final String name, - @ApiParam(value = "Control Loop version", required = true) @RequestParam( - value = "version", - required = false) final String version) { - - return ResponseEntity.ok().body(provider.fetchClElementStatsPerControlLoop(name, version)); - } - - /** - * Queries details of all control loop element statistics per control loop. - * - * @param requestId request ID used in ONAP logging - * @param name the name of the control loop - * @param version version of the control loop - * @param id Id of the control loop element - * @param recordCount the record count to be fetched - * @param startTime the time from which to get statistics - * @param endTime the time to which to get statistics - * @return the control loop element statistics - * @throws PfModelException on errors getting details of all control loop element statistics per control loop - */ - // @formatter:off - @GetMapping(value = "/monitoring/clelement", - produces = {MediaType.APPLICATION_JSON_VALUE, APPLICATION_YAML}) - @ApiOperation(value = "Query details of the requested cl element stats", - notes = "Queries details of the requested cl element stats, returning all clElement stats", - response = ClElementStatisticsList.class, - tags = {TAGS}, - authorizations = @Authorization(value = AUTHORIZATION_TYPE), - responseHeaders = { - @ResponseHeader( - name = VERSION_MINOR_NAME, description = VERSION_MINOR_DESCRIPTION, - response = String.class), - @ResponseHeader(name = VERSION_PATCH_NAME, description = VERSION_PATCH_DESCRIPTION, - response = String.class), - @ResponseHeader(name = VERSION_LATEST_NAME, description = VERSION_LATEST_DESCRIPTION, - response = String.class), - @ResponseHeader(name = REQUEST_ID_NAME, description = REQUEST_ID_HDR_DESCRIPTION, - response = UUID.class)}, - extensions = { - @Extension - ( - name = EXTENSION_NAME, - properties = { - @ExtensionProperty(name = API_VERSION_NAME, value = API_VERSION), - @ExtensionProperty(name = LAST_MOD_NAME, value = LAST_MOD_RELEASE) - } - ) - }) - @ApiResponses( - value = { - @ApiResponse(code = AUTHENTICATION_ERROR_CODE, message = AUTHENTICATION_ERROR_MESSAGE), - @ApiResponse(code = AUTHORIZATION_ERROR_CODE, message = AUTHORIZATION_ERROR_MESSAGE), - @ApiResponse(code = SERVER_ERROR_CODE, message = SERVER_ERROR_MESSAGE) - } - ) - // @formatter:on - public ResponseEntity queryElementStatistics( - @RequestHeader( - name = REQUEST_ID_NAME, - required = false) @ApiParam(REQUEST_ID_PARAM_DESCRIPTION) UUID requestId, - @ApiParam(value = "Participant name", required = true) @RequestParam( - value = "name", - required = false) final String name, - @ApiParam(value = "Participant version", required = true) @RequestParam( - value = "version", - required = false) final String version, - @ApiParam(value = "Record count", required = false) @RequestParam( - value = "recordCount", - required = false, - defaultValue = "0") final int recordCount, - @ApiParam(value = "Control Loop element id", required = false) @RequestParam( - value = "id", - required = false) final String id, - @ApiParam(value = "start time", required = false) @RequestParam( - value = "startTime", - required = false) final String startTime, - @ApiParam(value = "end time", required = false) @RequestParam( - value = "endTime", - required = false) final String endTime) - throws PfModelException { - - Instant startTimestamp = null; - Instant endTimestamp = null; - - if (startTime != null) { - startTimestamp = Instant.parse(startTime); - } - if (endTime != null) { - endTimestamp = Instant.parse(endTime); - } - return ResponseEntity.ok().body(provider.fetchFilteredClElementStatistics(name, version, id, startTimestamp, - endTimestamp, recordCount)); - } - -} diff --git a/runtime-controlloop/src/main/java/org/onap/policy/clamp/controlloop/runtime/main/web/AbstractRestController.java b/runtime-controlloop/src/main/java/org/onap/policy/clamp/controlloop/runtime/main/web/AbstractRestController.java deleted file mode 100644 index 7d279ba67..000000000 --- a/runtime-controlloop/src/main/java/org/onap/policy/clamp/controlloop/runtime/main/web/AbstractRestController.java +++ /dev/null @@ -1,91 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * Copyright (C) 2021 Nordix Foundation. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - * SPDX-License-Identifier: Apache-2.0 - * ============LICENSE_END========================================================= - */ - -package org.onap.policy.clamp.controlloop.runtime.main.web; - -import io.swagger.annotations.Api; -import io.swagger.annotations.BasicAuthDefinition; -import io.swagger.annotations.Info; -import io.swagger.annotations.SecurityDefinition; -import io.swagger.annotations.SwaggerDefinition; -import io.swagger.annotations.Tag; -import java.net.HttpURLConnection; -import javax.ws.rs.core.MediaType; -import org.springframework.web.bind.annotation.RequestMapping; - -/** - * Common superclass to provide REST endpoints for the participant simulator. - */ -// @formatter:off -@RequestMapping(value = "/v2", produces = {MediaType.APPLICATION_JSON, AbstractRestController.APPLICATION_YAML}) -@Api(value = "Control Loop Commissioning API") -@SwaggerDefinition( - info = @Info(description = - "Control Loop Service", version = "v1.0", - title = "Control Loop"), - consumes = {MediaType.APPLICATION_JSON, AbstractRestController.APPLICATION_YAML}, - produces = {MediaType.APPLICATION_JSON, AbstractRestController.APPLICATION_YAML}, - schemes = {SwaggerDefinition.Scheme.HTTP, SwaggerDefinition.Scheme.HTTPS}, - tags = {@Tag(name = "controlloop", description = "Control Loop Service")}, - securityDefinition = @SecurityDefinition(basicAuthDefinitions = {@BasicAuthDefinition(key = "basicAuth")})) -// @formatter:on -public abstract class AbstractRestController { - public static final String APPLICATION_YAML = "application/yaml"; - - public static final String EXTENSION_NAME = "interface info"; - - public static final String API_VERSION_NAME = "api-version"; - public static final String API_VERSION = "1.0.0"; - - public static final String LAST_MOD_NAME = "last-mod-release"; - public static final String LAST_MOD_RELEASE = "Dublin"; - - public static final String VERSION_MINOR_NAME = "X-MinorVersion"; - public static final String VERSION_MINOR_DESCRIPTION = - "Used to request or communicate a MINOR version back from the client" - + " to the server, and from the server back to the client"; - - public static final String VERSION_PATCH_NAME = "X-PatchVersion"; - public static final String VERSION_PATCH_DESCRIPTION = "Used only to communicate a PATCH version in a response for" - + " troubleshooting purposes only, and will not be provided by" + " the client on request"; - - public static final String VERSION_LATEST_NAME = "X-LatestVersion"; - public static final String VERSION_LATEST_DESCRIPTION = "Used only to communicate an API's latest version"; - - public static final String REQUEST_ID_NAME = "X-ONAP-RequestID"; - public static final String REQUEST_ID_HDR_DESCRIPTION = "Used to track REST transactions for logging purpose"; - public static final String REQUEST_ID_PARAM_DESCRIPTION = "RequestID for http transaction"; - - public static final String AUTHORIZATION_TYPE = "basicAuth"; - - public static final int AUTHENTICATION_ERROR_CODE = HttpURLConnection.HTTP_UNAUTHORIZED; - public static final int AUTHORIZATION_ERROR_CODE = HttpURLConnection.HTTP_FORBIDDEN; - public static final int SERVER_ERROR_CODE = HttpURLConnection.HTTP_INTERNAL_ERROR; - - public static final String AUTHENTICATION_ERROR_MESSAGE = "Authentication Error"; - public static final String AUTHORIZATION_ERROR_MESSAGE = "Authorization Error"; - public static final String SERVER_ERROR_MESSAGE = "Internal Server Error"; - - /** - * Constructor. - */ - protected AbstractRestController() { - } -} diff --git a/runtime-controlloop/src/main/java/org/onap/policy/clamp/controlloop/runtime/main/web/ControlLoopAafFilter.java b/runtime-controlloop/src/main/java/org/onap/policy/clamp/controlloop/runtime/main/web/ControlLoopAafFilter.java deleted file mode 100644 index 739a691c9..000000000 --- a/runtime-controlloop/src/main/java/org/onap/policy/clamp/controlloop/runtime/main/web/ControlLoopAafFilter.java +++ /dev/null @@ -1,38 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * Copyright (C) 2021 Nordix Foundation. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - * SPDX-License-Identifier: Apache-2.0 - * ============LICENSE_END========================================================= - */ - -package org.onap.policy.clamp.controlloop.runtime.main.web; - -import org.onap.policy.common.endpoints.http.server.aaf.AafGranularAuthFilter; -import org.onap.policy.common.utils.resources.MessageConstants; - -/** - * Class to manage AAF filters for the control loop runtime component. - */ -public class ControlLoopAafFilter extends AafGranularAuthFilter { - - public static final String AAF_NODETYPE = MessageConstants.POLICY_CLAMP; - public static final String AAF_ROOT_PERMISSION = DEFAULT_NAMESPACE + "." + AAF_NODETYPE; - - @Override - public String getPermissionTypeRoot() { - return AAF_ROOT_PERMISSION; - } -} diff --git a/runtime-controlloop/src/main/java/org/onap/policy/clamp/controlloop/runtime/main/web/GlobalControllerExceptionHandler.java b/runtime-controlloop/src/main/java/org/onap/policy/clamp/controlloop/runtime/main/web/GlobalControllerExceptionHandler.java deleted file mode 100644 index fd493fd89..000000000 --- a/runtime-controlloop/src/main/java/org/onap/policy/clamp/controlloop/runtime/main/web/GlobalControllerExceptionHandler.java +++ /dev/null @@ -1,67 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * Copyright (C) 2021 Nordix Foundation. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - * SPDX-License-Identifier: Apache-2.0 - * ============LICENSE_END========================================================= - */ - -package org.onap.policy.clamp.controlloop.runtime.main.web; - -import org.onap.policy.clamp.controlloop.common.exception.ControlLoopException; -import org.onap.policy.clamp.controlloop.models.messages.rest.SimpleResponse; -import org.onap.policy.clamp.controlloop.models.rest.RestUtils; -import org.onap.policy.models.base.PfModelException; -import org.onap.policy.models.base.PfModelRuntimeException; -import org.springframework.http.ResponseEntity; -import org.springframework.web.bind.annotation.ExceptionHandler; -import org.springframework.web.bind.annotation.RestControllerAdvice; - -@RestControllerAdvice -public class GlobalControllerExceptionHandler { - - /** - * Handle ControlLoopException. - * - * @param ex ControlLoopException - * @return ResponseEntity - */ - @ExceptionHandler(ControlLoopException.class) - public ResponseEntity handleBadRequest(ControlLoopException ex) { - return RestUtils.toSimpleResponse(ex); - } - - /** - * Handle PfModelRuntimeException. - * - * @param ex PfModelRuntimeException - * @return ResponseEntity - */ - @ExceptionHandler(PfModelRuntimeException.class) - public ResponseEntity handleBadRequest(PfModelRuntimeException ex) { - return RestUtils.toSimpleResponse(ex); - } - - /** - * Handle PfModelException. - * - * @param ex PfModelException - * @return ResponseEntity - */ - @ExceptionHandler(PfModelException.class) - public ResponseEntity handleBadRequest(PfModelException ex) { - return RestUtils.toSimpleResponse(ex); - } -} diff --git a/runtime-controlloop/src/main/java/org/onap/policy/clamp/controlloop/runtime/main/web/RuntimeErrorController.java b/runtime-controlloop/src/main/java/org/onap/policy/clamp/controlloop/runtime/main/web/RuntimeErrorController.java deleted file mode 100644 index ac2dba355..000000000 --- a/runtime-controlloop/src/main/java/org/onap/policy/clamp/controlloop/runtime/main/web/RuntimeErrorController.java +++ /dev/null @@ -1,104 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * Copyright (C) 2021 Nordix Foundation. - * ================================================================================ - * Modifications Copyright (C) 2021 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - * SPDX-License-Identifier: Apache-2.0 - * ============LICENSE_END========================================================= - */ - -package org.onap.policy.clamp.controlloop.runtime.main.web; - -import io.swagger.v3.oas.annotations.Hidden; -import java.util.Map; -import javax.servlet.RequestDispatcher; -import javax.servlet.http.HttpServletRequest; -import org.onap.policy.clamp.controlloop.models.messages.rest.SimpleResponse; -import org.onap.policy.clamp.controlloop.models.messages.rest.TypedSimpleResponse; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; -import org.springframework.beans.factory.annotation.Value; -import org.springframework.boot.web.error.ErrorAttributeOptions; -import org.springframework.boot.web.servlet.error.ErrorAttributes; -import org.springframework.boot.web.servlet.error.ErrorController; -import org.springframework.http.HttpStatus; -import org.springframework.http.MediaType; -import org.springframework.http.ResponseEntity; -import org.springframework.stereotype.Controller; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.context.request.ServletWebRequest; - -@Controller -@Hidden -public class RuntimeErrorController implements ErrorController { - - private static final Logger LOGGER = LoggerFactory.getLogger(RuntimeErrorController.class); - - private final ErrorAttributes errorAttributes; - - @Value("${server.error.path}") - private String path; - - /** - * Constructor. - * - * @param errorAttributes ErrorAttributes - */ - public RuntimeErrorController(ErrorAttributes errorAttributes) { - this.errorAttributes = errorAttributes; - } - - protected HttpStatus getStatus(HttpServletRequest request) { - Integer statusCode = (Integer) request.getAttribute(RequestDispatcher.ERROR_STATUS_CODE); - if (statusCode == null) { - return HttpStatus.INTERNAL_SERVER_ERROR; - } - try { - return HttpStatus.valueOf(statusCode); - } catch (Exception ex) { - LOGGER.error("statusCode {} Not Valid", statusCode, ex); - return HttpStatus.INTERNAL_SERVER_ERROR; - } - } - - /** - * Handle Errors not handled to GlobalControllerExceptionHandler. - * - * @param request HttpServletRequest - * @return ResponseEntity - */ - @RequestMapping(value = "${server.error.path}", produces = MediaType.APPLICATION_JSON_VALUE) - public ResponseEntity> handleError(HttpServletRequest request) { - Map map = this.errorAttributes.getErrorAttributes(new ServletWebRequest(request), - ErrorAttributeOptions.defaults()); - - var sb = new StringBuilder(); - final Object error = map.get("error"); - if (error != null) { - sb.append(error.toString()).append(" "); - } - final Object message = map.get("message"); - if (message != null) { - sb.append(message.toString()); - } - - TypedSimpleResponse resp = new TypedSimpleResponse<>(); - resp.setErrorDetails(sb.toString()); - - return ResponseEntity.status(getStatus(request)).body(resp); - - } -} diff --git a/runtime-controlloop/src/main/java/org/onap/policy/clamp/controlloop/runtime/monitoring/MonitoringProvider.java b/runtime-controlloop/src/main/java/org/onap/policy/clamp/controlloop/runtime/monitoring/MonitoringProvider.java deleted file mode 100644 index 2ec438bea..000000000 --- a/runtime-controlloop/src/main/java/org/onap/policy/clamp/controlloop/runtime/monitoring/MonitoringProvider.java +++ /dev/null @@ -1,243 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * Copyright (C) 2021 Nordix Foundation. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - * SPDX-License-Identifier: Apache-2.0 - * ============LICENSE_END========================================================= - */ - -package org.onap.policy.clamp.controlloop.runtime.monitoring; - -import java.time.Instant; -import java.util.ArrayList; -import java.util.HashMap; -import java.util.List; -import java.util.Map; -import lombok.AllArgsConstructor; -import lombok.NonNull; -import org.onap.policy.clamp.controlloop.models.controlloop.concepts.ClElementStatistics; -import org.onap.policy.clamp.controlloop.models.controlloop.concepts.ClElementStatisticsList; -import org.onap.policy.clamp.controlloop.models.controlloop.concepts.ControlLoopElement; -import org.onap.policy.clamp.controlloop.models.controlloop.concepts.ParticipantStatistics; -import org.onap.policy.clamp.controlloop.models.controlloop.concepts.ParticipantStatisticsList; -import org.onap.policy.clamp.controlloop.models.controlloop.persistence.provider.ClElementStatisticsProvider; -import org.onap.policy.clamp.controlloop.models.controlloop.persistence.provider.ControlLoopProvider; -import org.onap.policy.clamp.controlloop.models.controlloop.persistence.provider.ParticipantStatisticsProvider; -import org.onap.policy.models.base.PfModelException; -import org.onap.policy.models.base.PfModelRuntimeException; -import org.onap.policy.models.tosca.authorative.concepts.ToscaConceptIdentifier; -import org.springframework.stereotype.Service; -import org.springframework.transaction.annotation.Transactional; - -/** - * This class provides information about statistics data of CL elements and CL Participants in database to callers. - */ -@Service -@Transactional -@AllArgsConstructor -public class MonitoringProvider { - - private static final String DESC_ORDER = "DESC"; - private final ParticipantStatisticsProvider participantStatisticsProvider; - private final ClElementStatisticsProvider clElementStatisticsProvider; - private final ControlLoopProvider controlLoopProvider; - - /** - * Create participant statistics. - * - * @param participantStatistics the participant statistics - * @return the result of create operation - * @throws PfModelException on creation errors - */ - public ParticipantStatisticsList createParticipantStatistics(List participantStatistics) - throws PfModelException { - var participantStatisticsList = new ParticipantStatisticsList(); - participantStatisticsList - .setStatisticsList(participantStatisticsProvider.createParticipantStatistics(participantStatistics)); - - return participantStatisticsList; - } - - /** - * Create clElement statistics. - * - * @param clElementStatisticsList the clElement statistics - * @return the result of create operation - * @throws PfModelException on creation errors - */ - public ClElementStatisticsList createClElementStatistics(List clElementStatisticsList) - throws PfModelException { - var elementStatisticsList = new ClElementStatisticsList(); - elementStatisticsList - .setClElementStatistics(clElementStatisticsProvider.createClElementStatistics(clElementStatisticsList)); - - return elementStatisticsList; - } - - /** - * Get participant statistics based on specific filters. - * - * @param name the name of the participant statistics to get, null to get all statistics - * @param version the version of the participant statistics to get, null to get all statistics - * @param recordCount number of records to be fetched. - * @param startTime start of the timestamp, from statistics to be filtered - * @param endTime end of the timestamp up to which statistics to be filtered - * @return the participant found - */ - @Transactional(readOnly = true) - public ParticipantStatisticsList fetchFilteredParticipantStatistics(@NonNull final String name, - final String version, int recordCount, Instant startTime, Instant endTime) { - var participantStatisticsList = new ParticipantStatisticsList(); - - // Additional parameters can be added in filterMap for filtering data. - Map filterMap = null; - participantStatisticsList.setStatisticsList(participantStatisticsProvider.getFilteredParticipantStatistics(name, - version, startTime, endTime, filterMap, DESC_ORDER, recordCount)); - - return participantStatisticsList; - } - - /** - * Get all participant statistics records found for a specific control loop. * - * - * @param controlLoopName name of the control loop - * @param controlLoopVersion version of the control loop - * @return All the participant statistics found - * @throws PfModelRuntimeException on errors getting participant statistics - */ - @Transactional(readOnly = true) - public ParticipantStatisticsList fetchParticipantStatsPerControlLoop(@NonNull final String controlLoopName, - @NonNull final String controlLoopVersion) { - var statisticsList = new ParticipantStatisticsList(); - List participantStatistics = new ArrayList<>(); - try { - // Fetch all participantIds for a specific control loop - List participantIds = - getAllParticipantIdsPerControlLoop(controlLoopName, controlLoopVersion); - for (ToscaConceptIdentifier id : participantIds) { - participantStatistics.addAll(participantStatisticsProvider.getFilteredParticipantStatistics( - id.getName(), id.getVersion(), null, null, null, DESC_ORDER, 0)); - } - statisticsList.setStatisticsList(participantStatistics); - } catch (PfModelException e) { - throw new PfModelRuntimeException(e); - } - return statisticsList; - } - - /** - * Get clElement statistics based on specific filters. - * - * @param name the name of the clElement statistics to get, null to get all statistics - * @param version the version of the clElement statistics to get, null to get all statistics - * @param id UUID of the control loop element - * @param startTime start of the timestamp, from statistics to be filtered - * @param endTime end of the timestamp up to which statistics to be filtered - * @param recordCount number of records to be fetched. - * @return the participant found - * @throws PfModelException on errors getting control loop statistics - */ - @Transactional(readOnly = true) - public ClElementStatisticsList fetchFilteredClElementStatistics(@NonNull final String name, final String version, - final String id, Instant startTime, Instant endTime, int recordCount) throws PfModelException { - var clElementStatisticsList = new ClElementStatisticsList(); - Map filterMap = new HashMap<>(); - // Adding UUID in filter if present - if (id != null) { - filterMap.put("localName", id); - } - clElementStatisticsList.setClElementStatistics(clElementStatisticsProvider.getFilteredClElementStatistics(name, - version, startTime, endTime, filterMap, DESC_ORDER, recordCount)); - - return clElementStatisticsList; - } - - /** - * Get clElement statistics per control loop. - * - * @param name the name of the control loop - * @param version the version of the control loop - * @return the clElement statistics found - * @throws PfModelRuntimeException on errors getting control loop statistics - */ - @Transactional(readOnly = true) - public ClElementStatisticsList fetchClElementStatsPerControlLoop(@NonNull final String name, - @NonNull final String version) { - var clElementStatisticsList = new ClElementStatisticsList(); - List clElementStats = new ArrayList<>(); - try { - List clElements = new ArrayList<>(); - // Fetch all control loop elements for the control loop - var controlLoopOpt = controlLoopProvider.findControlLoop(new ToscaConceptIdentifier(name, version)); - if (controlLoopOpt.isPresent()) { - clElements.addAll(controlLoopOpt.get().getElements().values()); - // Collect control loop element statistics for each cl element. - for (ControlLoopElement clElement : clElements) { - clElementStats.addAll(fetchFilteredClElementStatistics(clElement.getParticipantId().getName(), - clElement.getParticipantId().getVersion(), clElement.getId().toString(), null, null, 0) - .getClElementStatistics()); - } - } - clElementStatisticsList.setClElementStatistics(clElementStats); - } catch (PfModelException e) { - throw new PfModelRuntimeException(e); - } - return clElementStatisticsList; - } - - /** - * If required, REST end point can be defined for this method to fetch associated participant Ids - * for a control loop. - * - * @param name the name of the control loop - * @param version the version of the control loop - * @return List of participant Id - * @throws PfModelException on errors - */ - @Transactional(readOnly = true) - public List getAllParticipantIdsPerControlLoop(String name, String version) - throws PfModelException { - List participantIds = new ArrayList<>(); - var controlLoopOpt = controlLoopProvider.findControlLoop(new ToscaConceptIdentifier(name, version)); - if (controlLoopOpt.isPresent()) { - for (ControlLoopElement clElement : controlLoopOpt.get().getElements().values()) { - participantIds.add(clElement.getParticipantId()); - } - } - return participantIds; - } - - /** - * If required, REST end point can be defined for this method to fetch associated control loop element Ids - * for a control loop. - * - * @param name the name of the control loop - * @param version the version of the control loop - * @return Map of control loop Id and participant details - * @throws PfModelException on errors - */ - @Transactional(readOnly = true) - public Map getAllClElementsIdPerControlLoop(String name, String version) - throws PfModelException { - Map clElementId = new HashMap<>(); - var controlLoopOpt = controlLoopProvider.findControlLoop(new ToscaConceptIdentifier(name, version)); - if (controlLoopOpt.isPresent()) { - for (ControlLoopElement clElement : controlLoopOpt.get().getElements().values()) { - clElementId.put(clElement.getId().toString(), clElement.getParticipantId()); - } - } - return clElementId; - } -} diff --git a/runtime-controlloop/src/main/java/org/onap/policy/clamp/controlloop/runtime/supervision/HandleCounter.java b/runtime-controlloop/src/main/java/org/onap/policy/clamp/controlloop/runtime/supervision/HandleCounter.java deleted file mode 100644 index 7e070d700..000000000 --- a/runtime-controlloop/src/main/java/org/onap/policy/clamp/controlloop/runtime/supervision/HandleCounter.java +++ /dev/null @@ -1,106 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * Copyright (C) 2021 Nordix Foundation. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - * SPDX-License-Identifier: Apache-2.0 - * ============LICENSE_END========================================================= - */ - -package org.onap.policy.clamp.controlloop.runtime.supervision; - -import java.time.Instant; -import java.util.HashMap; -import java.util.HashSet; -import java.util.Map; -import java.util.Set; -import lombok.Getter; -import lombok.Setter; - -public class HandleCounter { - @Getter - @Setter - private long maxWaitMs; - - @Getter - @Setter - private int maxRetryCount; - - private Map mapCounter = new HashMap<>(); - private Set mapFault = new HashSet<>(); - private Map mapTimer = new HashMap<>(); - - public long getDuration(K id) { - mapTimer.putIfAbsent(id, getEpochMilli()); - return getEpochMilli() - mapTimer.get(id); - } - - /** - * Reset timer and clear counter and fault by id. - * - * @param id the id - */ - public void clear(K id) { - mapFault.remove(id); - mapCounter.put(id, 0); - mapTimer.put(id, getEpochMilli()); - } - - /** - * Remove counter, timer and fault by id. - * - * @param id the id - */ - public void remove(K id) { - mapFault.remove(id); - mapCounter.remove(id); - mapTimer.remove(id); - } - - public void setFault(K id) { - mapCounter.put(id, 0); - mapFault.add(id); - } - - /** - * Increment RetryCount by id e return true if minor or equal of maxRetryCount. - * - * @param id the identifier - * @return false if count is major of maxRetryCount - */ - public boolean count(K id) { - int counter = mapCounter.getOrDefault(id, 0) + 1; - if (counter <= maxRetryCount) { - mapCounter.put(id, counter); - return true; - } - return false; - } - - public boolean isFault(K id) { - return mapFault.contains(id); - } - - public int getCounter(K id) { - return mapCounter.getOrDefault(id, 0); - } - - protected long getEpochMilli() { - return Instant.now().toEpochMilli(); - } - - public Set keySet() { - return mapCounter.keySet(); - } -} diff --git a/runtime-controlloop/src/main/java/org/onap/policy/clamp/controlloop/runtime/supervision/MessageIntercept.java b/runtime-controlloop/src/main/java/org/onap/policy/clamp/controlloop/runtime/supervision/MessageIntercept.java deleted file mode 100644 index c23ed833d..000000000 --- a/runtime-controlloop/src/main/java/org/onap/policy/clamp/controlloop/runtime/supervision/MessageIntercept.java +++ /dev/null @@ -1,32 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * Copyright (C) 2021 Nordix Foundation. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - * SPDX-License-Identifier: Apache-2.0 - * ============LICENSE_END========================================================= - */ - -package org.onap.policy.clamp.controlloop.runtime.supervision; - -import java.lang.annotation.ElementType; -import java.lang.annotation.Retention; -import java.lang.annotation.RetentionPolicy; -import java.lang.annotation.Target; - -@Retention(RetentionPolicy.RUNTIME) -@Target(ElementType.METHOD) -public @interface MessageIntercept { - -} diff --git a/runtime-controlloop/src/main/java/org/onap/policy/clamp/controlloop/runtime/supervision/SupervisionAspect.java b/runtime-controlloop/src/main/java/org/onap/policy/clamp/controlloop/runtime/supervision/SupervisionAspect.java deleted file mode 100644 index d975ec6bc..000000000 --- a/runtime-controlloop/src/main/java/org/onap/policy/clamp/controlloop/runtime/supervision/SupervisionAspect.java +++ /dev/null @@ -1,105 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * Copyright (C) 2021 Nordix Foundation. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - * SPDX-License-Identifier: Apache-2.0 - * ============LICENSE_END========================================================= - */ - -package org.onap.policy.clamp.controlloop.runtime.supervision; - -import java.io.Closeable; -import java.io.IOException; -import java.util.concurrent.LinkedBlockingQueue; -import java.util.concurrent.ThreadPoolExecutor; -import java.util.concurrent.TimeUnit; -import lombok.RequiredArgsConstructor; -import org.apache.commons.lang3.tuple.ImmutablePair; -import org.aspectj.lang.annotation.After; -import org.aspectj.lang.annotation.AfterReturning; -import org.aspectj.lang.annotation.Aspect; -import org.aspectj.lang.annotation.Before; -import org.onap.policy.clamp.controlloop.models.messages.dmaap.participant.ParticipantRegister; -import org.onap.policy.clamp.controlloop.models.messages.dmaap.participant.ParticipantStatus; -import org.onap.policy.clamp.controlloop.models.messages.dmaap.participant.ParticipantUpdateAck; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; -import org.springframework.scheduling.annotation.Scheduled; -import org.springframework.stereotype.Component; - -@Aspect -@Component -@RequiredArgsConstructor -public class SupervisionAspect implements Closeable { - - private static final Logger LOGGER = LoggerFactory.getLogger(SupervisionAspect.class); - - private final SupervisionScanner supervisionScanner; - - private ThreadPoolExecutor executor = - new ThreadPoolExecutor(1, 1, 0L, TimeUnit.MILLISECONDS, new LinkedBlockingQueue<>()); - - @Scheduled( - fixedRateString = "${runtime.participantParameters.heartBeatMs}", - initialDelayString = "${runtime.participantParameters.heartBeatMs}") - public void schedule() { - LOGGER.info("Add scheduled scanning"); - executor.execute(() -> supervisionScanner.run(true)); - } - - /** - * Intercept Messages from participant and run Supervision Scan. - */ - @After("@annotation(MessageIntercept)") - public void doCheck() { - if (executor.getQueue().size() < 2) { - LOGGER.debug("Add scanning Message"); - executor.execute(() -> supervisionScanner.run(false)); - } - } - - @Before("@annotation(MessageIntercept) && args(participantStatusMessage,..)") - public void handleParticipantStatus(ParticipantStatus participantStatusMessage) { - executor.execute(() -> supervisionScanner.handleParticipantStatus(participantStatusMessage.getParticipantId())); - } - - /** - * Intercepts participant Register Message - * if there is a Commissioning starts an execution of handleParticipantRegister. - * - * @param participantRegisterMessage the ParticipantRegister message - * @param isCommissioning is Commissioning - */ - @AfterReturning( - value = "@annotation(MessageIntercept) && args(participantRegisterMessage,..)", - returning = "isCommissioning") - public void handleParticipantRegister(ParticipantRegister participantRegisterMessage, boolean isCommissioning) { - if (isCommissioning) { - executor.execute(() -> supervisionScanner.handleParticipantRegister(new ImmutablePair<>( - participantRegisterMessage.getParticipantId(), participantRegisterMessage.getParticipantType()))); - } - } - - @Before("@annotation(MessageIntercept) && args(participantUpdateAckMessage,..)") - public void handleParticipantUpdateAck(ParticipantUpdateAck participantUpdateAckMessage) { - executor.execute(() -> supervisionScanner.handleParticipantUpdateAck(new ImmutablePair<>( - participantUpdateAckMessage.getParticipantId(), participantUpdateAckMessage.getParticipantType()))); - } - - @Override - public void close() throws IOException { - executor.shutdown(); - } -} diff --git a/runtime-controlloop/src/main/java/org/onap/policy/clamp/controlloop/runtime/supervision/SupervisionHandler.java b/runtime-controlloop/src/main/java/org/onap/policy/clamp/controlloop/runtime/supervision/SupervisionHandler.java deleted file mode 100644 index 6af2788e6..000000000 --- a/runtime-controlloop/src/main/java/org/onap/policy/clamp/controlloop/runtime/supervision/SupervisionHandler.java +++ /dev/null @@ -1,491 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * Copyright (C) 2021 Nordix Foundation. - * Modifications Copyright (C) 2021 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - * SPDX-License-Identifier: Apache-2.0 - * ============LICENSE_END========================================================= - */ - -package org.onap.policy.clamp.controlloop.runtime.supervision; - -import java.util.List; -import java.util.Map; -import java.util.Set; -import java.util.UUID; -import javax.ws.rs.core.Response; -import javax.ws.rs.core.Response.Status; -import lombok.AllArgsConstructor; -import org.apache.commons.collections4.CollectionUtils; -import org.onap.policy.clamp.controlloop.common.exception.ControlLoopException; -import org.onap.policy.clamp.controlloop.models.controlloop.concepts.ControlLoop; -import org.onap.policy.clamp.controlloop.models.controlloop.concepts.ControlLoopElementAck; -import org.onap.policy.clamp.controlloop.models.controlloop.concepts.ControlLoopInfo; -import org.onap.policy.clamp.controlloop.models.controlloop.concepts.ControlLoopState; -import org.onap.policy.clamp.controlloop.models.controlloop.concepts.Participant; -import org.onap.policy.clamp.controlloop.models.controlloop.concepts.ParticipantHealthStatus; -import org.onap.policy.clamp.controlloop.models.controlloop.concepts.ParticipantState; -import org.onap.policy.clamp.controlloop.models.controlloop.concepts.ParticipantUtils; -import org.onap.policy.clamp.controlloop.models.controlloop.persistence.provider.ControlLoopProvider; -import org.onap.policy.clamp.controlloop.models.controlloop.persistence.provider.ParticipantProvider; -import org.onap.policy.clamp.controlloop.models.controlloop.persistence.provider.ServiceTemplateProvider; -import org.onap.policy.clamp.controlloop.models.messages.dmaap.participant.ControlLoopAck; -import org.onap.policy.clamp.controlloop.models.messages.dmaap.participant.ParticipantDeregister; -import org.onap.policy.clamp.controlloop.models.messages.dmaap.participant.ParticipantMessage; -import org.onap.policy.clamp.controlloop.models.messages.dmaap.participant.ParticipantRegister; -import org.onap.policy.clamp.controlloop.models.messages.dmaap.participant.ParticipantStatus; -import org.onap.policy.clamp.controlloop.models.messages.dmaap.participant.ParticipantUpdateAck; -import org.onap.policy.clamp.controlloop.runtime.monitoring.MonitoringProvider; -import org.onap.policy.clamp.controlloop.runtime.supervision.comm.ControlLoopStateChangePublisher; -import org.onap.policy.clamp.controlloop.runtime.supervision.comm.ControlLoopUpdatePublisher; -import org.onap.policy.clamp.controlloop.runtime.supervision.comm.ParticipantDeregisterAckPublisher; -import org.onap.policy.clamp.controlloop.runtime.supervision.comm.ParticipantRegisterAckPublisher; -import org.onap.policy.clamp.controlloop.runtime.supervision.comm.ParticipantUpdatePublisher; -import org.onap.policy.models.base.PfModelException; -import org.onap.policy.models.base.PfModelRuntimeException; -import org.onap.policy.models.tosca.authorative.concepts.ToscaConceptIdentifier; -import org.onap.policy.models.tosca.authorative.concepts.ToscaServiceTemplate; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; -import org.springframework.stereotype.Component; - -/** - * This class handles supervision of control loop instances, so only one object of this type should be built at a time. - * - *

- * It is effectively a singleton that is started at system start. - */ -@Component -@AllArgsConstructor -public class SupervisionHandler { - private static final Logger LOGGER = LoggerFactory.getLogger(SupervisionHandler.class); - - private static final String CONTROL_LOOP_CANNOT_TRANSITION_FROM_STATE = "Control loop can't transition from state "; - private static final String CONTROL_LOOP_IS_ALREADY_IN_STATE = "Control loop is already in state "; - private static final String TO_STATE = " to state "; - private static final String AND_TRANSITIONING_TO_STATE = " and transitioning to state "; - - private final ControlLoopProvider controlLoopProvider; - private final ParticipantProvider participantProvider; - private final MonitoringProvider monitoringProvider; - private final ServiceTemplateProvider serviceTemplateProvider; - - // Publishers for participant communication - private final ControlLoopUpdatePublisher controlLoopUpdatePublisher; - private final ControlLoopStateChangePublisher controlLoopStateChangePublisher; - private final ParticipantRegisterAckPublisher participantRegisterAckPublisher; - private final ParticipantDeregisterAckPublisher participantDeregisterAckPublisher; - private final ParticipantUpdatePublisher participantUpdatePublisher; - - /** - * Supervision trigger called when a command is issued on control loops. - * - *

- * Causes supervision to start or continue supervision on the control loops in question. - * - * @param controlLoopIdentifierList the control loops for which the supervision command has been issued - * @throws ControlLoopException on supervision triggering exceptions - */ - public void triggerControlLoopSupervision(List controlLoopIdentifierList) - throws ControlLoopException { - - LOGGER.debug("triggering control loop supervision on control loops {}", controlLoopIdentifierList); - - if (CollectionUtils.isEmpty(controlLoopIdentifierList)) { - // This is just to force throwing of the exception in certain circumstances. - exceptionOccured(Response.Status.NOT_ACCEPTABLE, "The list of control loops for supervision is empty"); - } - - for (ToscaConceptIdentifier controlLoopId : controlLoopIdentifierList) { - try { - var controlLoop = controlLoopProvider.getControlLoop(controlLoopId); - - superviseControlLoop(controlLoop); - - controlLoopProvider.saveControlLoop(controlLoop); - } catch (PfModelException pfme) { - throw new ControlLoopException(pfme.getErrorResponse().getResponseCode(), pfme.getMessage(), pfme); - } - } - } - - /** - * Handle a ParticipantStatus message from a participant. - * - * @param participantStatusMessage the ParticipantStatus message received from a participant - */ - @MessageIntercept - public void handleParticipantMessage(ParticipantStatus participantStatusMessage) { - LOGGER.debug("Participant Status received {}", participantStatusMessage); - try { - superviseParticipant(participantStatusMessage); - } catch (PfModelException | ControlLoopException svExc) { - LOGGER.warn("error supervising participant {}", participantStatusMessage.getParticipantId(), svExc); - return; - } - - try { - superviseControlLoops(participantStatusMessage); - } catch (PfModelException | ControlLoopException svExc) { - LOGGER.warn("error supervising participant {}", participantStatusMessage.getParticipantId(), svExc); - } - } - - /** - * Handle a ParticipantRegister message from a participant. - * - * @param participantRegisterMessage the ParticipantRegister message received from a participant - */ - @MessageIntercept - public boolean handleParticipantMessage(ParticipantRegister participantRegisterMessage) { - LOGGER.debug("Participant Register received {}", participantRegisterMessage); - try { - checkParticipant(participantRegisterMessage, ParticipantState.UNKNOWN, ParticipantHealthStatus.UNKNOWN); - } catch (PfModelException | ControlLoopException svExc) { - LOGGER.warn("error saving participant {}", participantRegisterMessage.getParticipantId(), svExc); - } - - var isCommissioning = participantUpdatePublisher.sendCommissioning(null, null, - participantRegisterMessage.getParticipantId(), participantRegisterMessage.getParticipantType()); - - participantRegisterAckPublisher.send(participantRegisterMessage.getMessageId(), - participantRegisterMessage.getParticipantId(), participantRegisterMessage.getParticipantType()); - return isCommissioning; - } - - /** - * Handle a ParticipantDeregister message from a participant. - * - * @param participantDeregisterMessage the ParticipantDeregister message received from a participant - */ - @MessageIntercept - public void handleParticipantMessage(ParticipantDeregister participantDeregisterMessage) { - LOGGER.debug("Participant Deregister received {}", participantDeregisterMessage); - try { - var participantOpt = - participantProvider.findParticipant(participantDeregisterMessage.getParticipantId().getName(), - participantDeregisterMessage.getParticipantId().getVersion()); - - if (participantOpt.isPresent()) { - var participant = participantOpt.get(); - participant.setParticipantState(ParticipantState.TERMINATED); - participant.setHealthStatus(ParticipantHealthStatus.OFF_LINE); - participantProvider.saveParticipant(participant); - } - } catch (PfModelException pfme) { - LOGGER.warn("Model exception occured with participant id {}", - participantDeregisterMessage.getParticipantId()); - } - - participantDeregisterAckPublisher.send(participantDeregisterMessage.getMessageId()); - } - - /** - * Handle a ParticipantUpdateAck message from a participant. - * - * @param participantUpdateAckMessage the ParticipantUpdateAck message received from a participant - */ - @MessageIntercept - public void handleParticipantMessage(ParticipantUpdateAck participantUpdateAckMessage) { - LOGGER.debug("Participant Update Ack received {}", participantUpdateAckMessage); - try { - var participantOpt = - participantProvider.findParticipant(participantUpdateAckMessage.getParticipantId().getName(), - participantUpdateAckMessage.getParticipantId().getVersion()); - - if (participantOpt.isPresent()) { - var participant = participantOpt.get(); - participant.setParticipantState(participantUpdateAckMessage.getState()); - participantProvider.saveParticipant(participant); - } else { - LOGGER.warn("Participant not found in database {}", participantUpdateAckMessage.getParticipantId()); - } - } catch (PfModelException pfme) { - LOGGER.warn("Model exception occured with participant id {}", - participantUpdateAckMessage.getParticipantId()); - } - } - - /** - * Send commissioning update message to dmaap. - * - * @param name the ToscaServiceTemplate name - * @param version the ToscaServiceTemplate version - */ - public void handleSendCommissionMessage(String name, String version) { - LOGGER.debug("Participant update message with serviveTemplate {} {} being sent to all participants", name, - version); - participantUpdatePublisher.sendComissioningBroadcast(name, version); - } - - /** - * Send decommissioning update message to dmaap. - * - */ - public void handleSendDeCommissionMessage() { - LOGGER.debug("Participant update message being sent"); - participantUpdatePublisher.sendDecomisioning(); - } - - /** - * Handle a ControlLoop update acknowledge message from a participant. - * - * @param controlLoopAckMessage the ControlLoopAck message received from a participant - */ - @MessageIntercept - public void handleControlLoopUpdateAckMessage(ControlLoopAck controlLoopAckMessage) { - LOGGER.debug("ControlLoop Update Ack message received {}", controlLoopAckMessage); - setClElementStateInDb(controlLoopAckMessage); - } - - /** - * Handle a ControlLoop statechange acknowledge message from a participant. - * - * @param controlLoopAckMessage the ControlLoopAck message received from a participant - */ - @MessageIntercept - public void handleControlLoopStateChangeAckMessage(ControlLoopAck controlLoopAckMessage) { - LOGGER.debug("ControlLoop StateChange Ack message received {}", controlLoopAckMessage); - setClElementStateInDb(controlLoopAckMessage); - } - - private void setClElementStateInDb(ControlLoopAck controlLoopAckMessage) { - if (controlLoopAckMessage.getControlLoopResultMap() != null) { - try { - var controlLoop = controlLoopProvider.getControlLoop(controlLoopAckMessage.getControlLoopId()); - if (controlLoop != null) { - var updated = updateState(controlLoop, controlLoopAckMessage.getControlLoopResultMap().entrySet()); - updated |= setPrimed(controlLoop); - if (updated) { - controlLoopProvider.saveControlLoop(controlLoop); - } - } else { - LOGGER.warn("ControlLoop not found in database {}", controlLoopAckMessage.getControlLoopId()); - } - } catch (PfModelException pfme) { - LOGGER.warn("Model exception occured with ControlLoop Id {}", controlLoopAckMessage.getControlLoopId()); - } - } - } - - private boolean updateState(ControlLoop controlLoop, - Set> controlLoopResultSet) { - var updated = false; - for (var clElementAck : controlLoopResultSet) { - var element = controlLoop.getElements().get(clElementAck.getKey()); - if (element != null) { - element.setState(clElementAck.getValue().getState()); - updated = true; - } - } - return updated; - } - - private boolean setPrimed(ControlLoop controlLoop) { - var clElements = controlLoop.getElements().values(); - if (clElements != null) { - Boolean primedFlag = true; - var checkOpt = controlLoop.getElements().values().stream() - .filter(clElement -> (!clElement.getState().equals(ControlLoopState.PASSIVE) - || !clElement.getState().equals(ControlLoopState.RUNNING))) - .findAny(); - if (checkOpt.isEmpty()) { - primedFlag = false; - } - controlLoop.setPrimed(primedFlag); - return true; - } - - return false; - } - - /** - * Supervise a control loop, performing whatever actions need to be performed on the control loop. - * - * @param controlLoop the control loop to supervises - * @throws ControlLoopException on supervision errors - */ - private void superviseControlLoop(ControlLoop controlLoop) throws ControlLoopException { - switch (controlLoop.getOrderedState()) { - case UNINITIALISED: - superviseControlLoopUninitialization(controlLoop); - break; - - case PASSIVE: - superviseControlLoopPassivation(controlLoop); - break; - - case RUNNING: - superviseControlLoopActivation(controlLoop); - break; - - default: - exceptionOccured(Response.Status.NOT_ACCEPTABLE, - "A control loop cannot be commanded to go into state " + controlLoop.getOrderedState().name()); - } - } - - /** - * Supervise a control loop uninitialisation, performing whatever actions need to be performed on the control loop, - * control loop ordered state is UNINITIALIZED. - * - * @param controlLoop the control loop to supervises - * @throws ControlLoopException on supervision errors - */ - private void superviseControlLoopUninitialization(ControlLoop controlLoop) throws ControlLoopException { - switch (controlLoop.getState()) { - case UNINITIALISED: - exceptionOccured(Response.Status.NOT_ACCEPTABLE, - CONTROL_LOOP_IS_ALREADY_IN_STATE + controlLoop.getState().name()); - break; - - case UNINITIALISED2PASSIVE: - case PASSIVE: - controlLoop.setState(ControlLoopState.PASSIVE2UNINITIALISED); - controlLoopStateChangePublisher.send(controlLoop, getFirstStartPhase(controlLoop)); - break; - - case PASSIVE2UNINITIALISED: - exceptionOccured(Response.Status.NOT_ACCEPTABLE, CONTROL_LOOP_IS_ALREADY_IN_STATE - + controlLoop.getState().name() + AND_TRANSITIONING_TO_STATE + controlLoop.getOrderedState()); - break; - - default: - exceptionOccured(Response.Status.NOT_ACCEPTABLE, CONTROL_LOOP_CANNOT_TRANSITION_FROM_STATE - + controlLoop.getState().name() + TO_STATE + controlLoop.getOrderedState()); - break; - } - } - - private void superviseControlLoopPassivation(ControlLoop controlLoop) throws ControlLoopException { - switch (controlLoop.getState()) { - case PASSIVE: - exceptionOccured(Response.Status.NOT_ACCEPTABLE, - CONTROL_LOOP_IS_ALREADY_IN_STATE + controlLoop.getState().name()); - break; - case UNINITIALISED: - controlLoop.setState(ControlLoopState.UNINITIALISED2PASSIVE); - controlLoopUpdatePublisher.send(controlLoop); - break; - - case UNINITIALISED2PASSIVE: - case RUNNING2PASSIVE: - exceptionOccured(Response.Status.NOT_ACCEPTABLE, CONTROL_LOOP_IS_ALREADY_IN_STATE - + controlLoop.getState().name() + AND_TRANSITIONING_TO_STATE + controlLoop.getOrderedState()); - break; - - case RUNNING: - controlLoop.setState(ControlLoopState.RUNNING2PASSIVE); - controlLoopStateChangePublisher.send(controlLoop, getFirstStartPhase(controlLoop)); - break; - - default: - exceptionOccured(Response.Status.NOT_ACCEPTABLE, CONTROL_LOOP_CANNOT_TRANSITION_FROM_STATE - + controlLoop.getState().name() + TO_STATE + controlLoop.getOrderedState()); - break; - } - } - - private void superviseControlLoopActivation(ControlLoop controlLoop) throws ControlLoopException { - switch (controlLoop.getState()) { - case RUNNING: - exceptionOccured(Response.Status.NOT_ACCEPTABLE, - CONTROL_LOOP_IS_ALREADY_IN_STATE + controlLoop.getState().name()); - break; - - case PASSIVE2RUNNING: - exceptionOccured(Response.Status.NOT_ACCEPTABLE, CONTROL_LOOP_IS_ALREADY_IN_STATE - + controlLoop.getState().name() + AND_TRANSITIONING_TO_STATE + controlLoop.getOrderedState()); - break; - - case PASSIVE: - controlLoop.setState(ControlLoopState.PASSIVE2RUNNING); - controlLoopStateChangePublisher.send(controlLoop, getFirstStartPhase(controlLoop)); - break; - - default: - exceptionOccured(Response.Status.NOT_ACCEPTABLE, CONTROL_LOOP_CANNOT_TRANSITION_FROM_STATE - + controlLoop.getState().name() + TO_STATE + controlLoop.getOrderedState()); - break; - } - } - - private int getFirstStartPhase(ControlLoop controlLoop) { - ToscaServiceTemplate toscaServiceTemplate = null; - try { - toscaServiceTemplate = serviceTemplateProvider.getAllServiceTemplates().get(0); - } catch (PfModelException e) { - throw new PfModelRuntimeException(Status.BAD_REQUEST, "Canont load ToscaServiceTemplate from DB", e); - } - return ParticipantUtils.getFirstStartPhase(controlLoop, toscaServiceTemplate); - } - - private void checkParticipant(ParticipantMessage participantMessage, ParticipantState participantState, - ParticipantHealthStatus healthStatus) throws ControlLoopException, PfModelException { - if (participantMessage.getParticipantId() == null) { - exceptionOccured(Response.Status.NOT_FOUND, "Participant ID on PARTICIPANT_STATUS message is null"); - } - var participantOpt = participantProvider.findParticipant(participantMessage.getParticipantId().getName(), - participantMessage.getParticipantId().getVersion()); - - if (participantOpt.isEmpty()) { - var participant = new Participant(); - participant.setName(participantMessage.getParticipantId().getName()); - participant.setVersion(participantMessage.getParticipantId().getVersion()); - participant.setDefinition(participantMessage.getParticipantId()); - participant.setParticipantType(participantMessage.getParticipantType()); - participant.setParticipantState(participantState); - participant.setHealthStatus(healthStatus); - - participantProvider.saveParticipant(participant); - } else { - var participant = participantOpt.get(); - participant.setParticipantState(participantState); - participant.setHealthStatus(healthStatus); - - participantProvider.saveParticipant(participant); - } - } - - private void superviseParticipant(ParticipantStatus participantStatusMessage) - throws PfModelException, ControlLoopException { - - checkParticipant(participantStatusMessage, participantStatusMessage.getState(), - participantStatusMessage.getHealthStatus()); - - monitoringProvider.createParticipantStatistics(List.of(participantStatusMessage.getParticipantStatistics())); - } - - private void superviseControlLoops(ParticipantStatus participantStatusMessage) - throws PfModelException, ControlLoopException { - if (participantStatusMessage.getControlLoopInfoList() != null) { - for (ControlLoopInfo clEntry : participantStatusMessage.getControlLoopInfoList()) { - var dbControlLoop = - controlLoopProvider.getControlLoop(new ToscaConceptIdentifier(clEntry.getControlLoopId())); - if (dbControlLoop == null) { - exceptionOccured(Response.Status.NOT_FOUND, - "PARTICIPANT_STATUS control loop not found in database: " + clEntry.getControlLoopId()); - } - dbControlLoop.setState(clEntry.getState()); - monitoringProvider.createClElementStatistics( - clEntry.getControlLoopStatistics().getClElementStatisticsList().getClElementStatistics()); - } - } - } - - private void exceptionOccured(Response.Status status, String reason) throws ControlLoopException { - throw new ControlLoopException(status, reason); - } -} diff --git a/runtime-controlloop/src/main/java/org/onap/policy/clamp/controlloop/runtime/supervision/SupervisionScanner.java b/runtime-controlloop/src/main/java/org/onap/policy/clamp/controlloop/runtime/supervision/SupervisionScanner.java deleted file mode 100644 index 01e035b87..000000000 --- a/runtime-controlloop/src/main/java/org/onap/policy/clamp/controlloop/runtime/supervision/SupervisionScanner.java +++ /dev/null @@ -1,301 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * Copyright (C) 2021 Nordix Foundation. - * ================================================================================ - * Modifications Copyright (C) 2021 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - * SPDX-License-Identifier: Apache-2.0 - * ============LICENSE_END========================================================= - */ - -package org.onap.policy.clamp.controlloop.runtime.supervision; - -import java.util.HashMap; -import java.util.Map; -import org.apache.commons.lang3.tuple.Pair; -import org.onap.policy.clamp.controlloop.models.controlloop.concepts.ControlLoop; -import org.onap.policy.clamp.controlloop.models.controlloop.concepts.ControlLoopElement; -import org.onap.policy.clamp.controlloop.models.controlloop.concepts.ControlLoopState; -import org.onap.policy.clamp.controlloop.models.controlloop.concepts.Participant; -import org.onap.policy.clamp.controlloop.models.controlloop.concepts.ParticipantHealthStatus; -import org.onap.policy.clamp.controlloop.models.controlloop.concepts.ParticipantUtils; -import org.onap.policy.clamp.controlloop.models.controlloop.persistence.provider.ControlLoopProvider; -import org.onap.policy.clamp.controlloop.models.controlloop.persistence.provider.ParticipantProvider; -import org.onap.policy.clamp.controlloop.models.controlloop.persistence.provider.ServiceTemplateProvider; -import org.onap.policy.clamp.controlloop.runtime.main.parameters.ClRuntimeParameterGroup; -import org.onap.policy.clamp.controlloop.runtime.supervision.comm.ControlLoopStateChangePublisher; -import org.onap.policy.clamp.controlloop.runtime.supervision.comm.ControlLoopUpdatePublisher; -import org.onap.policy.clamp.controlloop.runtime.supervision.comm.ParticipantStatusReqPublisher; -import org.onap.policy.clamp.controlloop.runtime.supervision.comm.ParticipantUpdatePublisher; -import org.onap.policy.models.base.PfModelException; -import org.onap.policy.models.tosca.authorative.concepts.ToscaConceptIdentifier; -import org.onap.policy.models.tosca.authorative.concepts.ToscaNodeTemplate; -import org.onap.policy.models.tosca.authorative.concepts.ToscaServiceTemplate; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; -import org.springframework.stereotype.Component; - -/** - * This class is used to scan the control loops in the database and check if they are in the correct state. - */ -@Component -public class SupervisionScanner { - private static final Logger LOGGER = LoggerFactory.getLogger(SupervisionScanner.class); - - private final HandleCounter controlLoopCounter = new HandleCounter<>(); - private final HandleCounter participantStatusCounter = new HandleCounter<>(); - private final HandleCounter> participantUpdateCounter = - new HandleCounter<>(); - - private final Map phaseMap = new HashMap<>(); - - private final ControlLoopProvider controlLoopProvider; - private final ServiceTemplateProvider serviceTemplateProvider; - private final ControlLoopStateChangePublisher controlLoopStateChangePublisher; - private final ControlLoopUpdatePublisher controlLoopUpdatePublisher; - private final ParticipantProvider participantProvider; - private final ParticipantStatusReqPublisher participantStatusReqPublisher; - private final ParticipantUpdatePublisher participantUpdatePublisher; - - /** - * Constructor for instantiating SupervisionScanner. - * - * @param controlLoopProvider the provider to use to read control loops from the database - * @param serviceTemplateProvider the Policy Models Provider - * @param controlLoopStateChangePublisher the ControlLoop StateChange Publisher - * @param controlLoopUpdatePublisher the ControlLoopUpdate Publisher - * @param participantProvider the Participant Provider - * @param participantStatusReqPublisher the Participant StatusReq Publisher - * @param participantUpdatePublisher the Participant Update Publisher - * @param clRuntimeParameterGroup the parameters for the control loop runtime - */ - public SupervisionScanner(final ControlLoopProvider controlLoopProvider, - ServiceTemplateProvider serviceTemplateProvider, - final ControlLoopStateChangePublisher controlLoopStateChangePublisher, - ControlLoopUpdatePublisher controlLoopUpdatePublisher, ParticipantProvider participantProvider, - ParticipantStatusReqPublisher participantStatusReqPublisher, - ParticipantUpdatePublisher participantUpdatePublisher, - final ClRuntimeParameterGroup clRuntimeParameterGroup) { - this.controlLoopProvider = controlLoopProvider; - this.serviceTemplateProvider = serviceTemplateProvider; - this.controlLoopStateChangePublisher = controlLoopStateChangePublisher; - this.controlLoopUpdatePublisher = controlLoopUpdatePublisher; - this.participantProvider = participantProvider; - this.participantStatusReqPublisher = participantStatusReqPublisher; - this.participantUpdatePublisher = participantUpdatePublisher; - - controlLoopCounter.setMaxRetryCount( - clRuntimeParameterGroup.getParticipantParameters().getUpdateParameters().getMaxRetryCount()); - controlLoopCounter.setMaxWaitMs(clRuntimeParameterGroup.getParticipantParameters().getMaxStatusWaitMs()); - - participantUpdateCounter.setMaxRetryCount( - clRuntimeParameterGroup.getParticipantParameters().getUpdateParameters().getMaxRetryCount()); - participantUpdateCounter - .setMaxWaitMs(clRuntimeParameterGroup.getParticipantParameters().getUpdateParameters().getMaxWaitMs()); - - participantStatusCounter.setMaxRetryCount( - clRuntimeParameterGroup.getParticipantParameters().getUpdateParameters().getMaxRetryCount()); - participantStatusCounter.setMaxWaitMs(clRuntimeParameterGroup.getParticipantParameters().getMaxStatusWaitMs()); - } - - /** - * Run Scanning. - * - * @param counterCheck if true activate counter and retry - */ - public void run(boolean counterCheck) { - LOGGER.debug("Scanning control loops in the database . . ."); - - if (counterCheck) { - try { - for (var participant : participantProvider.getParticipants()) { - scanParticipantStatus(participant); - } - } catch (PfModelException pfme) { - LOGGER.warn("error reading participant from database", pfme); - return; - } - } - - try { - var list = serviceTemplateProvider.getAllServiceTemplates(); - if (list != null && !list.isEmpty()) { - ToscaServiceTemplate toscaServiceTemplate = list.get(0); - - for (ControlLoop controlLoop : controlLoopProvider.getControlLoops()) { - scanControlLoop(controlLoop, toscaServiceTemplate, counterCheck); - } - } - } catch (PfModelException pfme) { - LOGGER.warn("error reading control loops from database", pfme); - } - - if (counterCheck) { - scanParticipantUpdate(); - } - - LOGGER.debug("Control loop scan complete . . ."); - } - - private void scanParticipantUpdate() { - LOGGER.debug("Scanning participants to update . . ."); - - for (var id : participantUpdateCounter.keySet()) { - if (participantUpdateCounter.isFault(id)) { - LOGGER.debug("report Participant Update fault"); - - } else if (participantUpdateCounter.getDuration(id) > participantUpdateCounter.getMaxWaitMs()) { - - if (participantUpdateCounter.count(id)) { - LOGGER.debug("retry message ParticipantUpdate"); - participantUpdatePublisher.sendCommissioning(null, null, id.getLeft(), id.getRight()); - } else { - LOGGER.debug("report Participant Update fault"); - participantUpdateCounter.setFault(id); - } - } - } - - LOGGER.debug("Participants to update scan complete . . ."); - } - - private void scanParticipantStatus(Participant participant) throws PfModelException { - ToscaConceptIdentifier id = participant.getKey().asIdentifier(); - if (participantStatusCounter.isFault(id)) { - LOGGER.debug("report Participant fault"); - return; - } - if (participantStatusCounter.getDuration(id) > participantStatusCounter.getMaxWaitMs()) { - if (participantStatusCounter.count(id)) { - LOGGER.debug("retry message ParticipantStatusReq"); - participantStatusReqPublisher.send(id); - participant.setHealthStatus(ParticipantHealthStatus.NOT_HEALTHY); - } else { - LOGGER.debug("report Participant fault"); - participantStatusCounter.setFault(id); - participant.setHealthStatus(ParticipantHealthStatus.OFF_LINE); - } - participantProvider.saveParticipant(participant); - } - } - - /** - * handle participant Status message. - */ - public void handleParticipantStatus(ToscaConceptIdentifier id) { - participantStatusCounter.clear(id); - } - - public void handleParticipantRegister(Pair id) { - participantUpdateCounter.clear(id); - } - - public void handleParticipantUpdateAck(Pair id) { - participantUpdateCounter.remove(id); - } - - private void scanControlLoop(final ControlLoop controlLoop, ToscaServiceTemplate toscaServiceTemplate, - boolean counterCheck) throws PfModelException { - LOGGER.debug("scanning control loop {} . . .", controlLoop.getKey().asIdentifier()); - - if (controlLoop.getState().equals(controlLoop.getOrderedState().asState())) { - LOGGER.debug("control loop {} scanned, OK", controlLoop.getKey().asIdentifier()); - - // Clear missed report counter on Control Loop - clearFaultAndCounter(controlLoop); - return; - } - - var completed = true; - var minSpNotCompleted = 1000; // min startPhase not completed - var maxSpNotCompleted = 0; // max startPhase not completed - var defaultMin = 1000; // min startPhase - var defaultMax = 0; // max startPhase - for (ControlLoopElement element : controlLoop.getElements().values()) { - ToscaNodeTemplate toscaNodeTemplate = toscaServiceTemplate.getToscaTopologyTemplate().getNodeTemplates() - .get(element.getDefinition().getName()); - int startPhase = ParticipantUtils.findStartPhase(toscaNodeTemplate.getProperties()); - defaultMin = Math.min(defaultMin, startPhase); - defaultMax = Math.max(defaultMax, startPhase); - if (!element.getState().equals(element.getOrderedState().asState())) { - completed = false; - minSpNotCompleted = Math.min(minSpNotCompleted, startPhase); - maxSpNotCompleted = Math.max(maxSpNotCompleted, startPhase); - } - } - - if (completed) { - LOGGER.debug("control loop scan: transition from state {} to {} completed", controlLoop.getState(), - controlLoop.getOrderedState()); - - controlLoop.setState(controlLoop.getOrderedState().asState()); - controlLoopProvider.saveControlLoop(controlLoop); - - // Clear missed report counter on Control Loop - clearFaultAndCounter(controlLoop); - } else { - LOGGER.debug("control loop scan: transition from state {} to {} not completed", controlLoop.getState(), - controlLoop.getOrderedState()); - - var nextSpNotCompleted = ControlLoopState.UNINITIALISED2PASSIVE.equals(controlLoop.getState()) - || ControlLoopState.PASSIVE2RUNNING.equals(controlLoop.getState()) ? minSpNotCompleted - : maxSpNotCompleted; - - var firstStartPhase = ControlLoopState.UNINITIALISED2PASSIVE.equals(controlLoop.getState()) - || ControlLoopState.PASSIVE2RUNNING.equals(controlLoop.getState()) ? defaultMin : defaultMax; - - if (nextSpNotCompleted != phaseMap.getOrDefault(controlLoop.getKey().asIdentifier(), firstStartPhase)) { - phaseMap.put(controlLoop.getKey().asIdentifier(), nextSpNotCompleted); - sendControlLoopMsg(controlLoop, nextSpNotCompleted); - } else if (counterCheck) { - phaseMap.put(controlLoop.getKey().asIdentifier(), nextSpNotCompleted); - handleCounter(controlLoop, nextSpNotCompleted); - } - } - } - - private void clearFaultAndCounter(ControlLoop controlLoop) { - controlLoopCounter.clear(controlLoop.getKey().asIdentifier()); - phaseMap.clear(); - } - - private void handleCounter(ControlLoop controlLoop, int startPhase) { - ToscaConceptIdentifier id = controlLoop.getKey().asIdentifier(); - if (controlLoopCounter.isFault(id)) { - LOGGER.debug("report ControlLoop fault"); - return; - } - - if (controlLoopCounter.getDuration(id) > controlLoopCounter.getMaxWaitMs()) { - if (controlLoopCounter.count(id)) { - phaseMap.put(id, startPhase); - sendControlLoopMsg(controlLoop, startPhase); - } else { - LOGGER.debug("report ControlLoop fault"); - controlLoopCounter.setFault(id); - } - } - } - - private void sendControlLoopMsg(ControlLoop controlLoop, int startPhase) { - if (ControlLoopState.UNINITIALISED2PASSIVE.equals(controlLoop.getState())) { - LOGGER.debug("retry message ControlLoopUpdate"); - controlLoopUpdatePublisher.send(controlLoop, startPhase); - } else { - LOGGER.debug("retry message ControlLoopStateChange"); - controlLoopStateChangePublisher.send(controlLoop, startPhase); - } - } -} diff --git a/runtime-controlloop/src/main/java/org/onap/policy/clamp/controlloop/runtime/supervision/comm/AbstractParticipantAckPublisher.java b/runtime-controlloop/src/main/java/org/onap/policy/clamp/controlloop/runtime/supervision/comm/AbstractParticipantAckPublisher.java deleted file mode 100644 index 4b4ca9915..000000000 --- a/runtime-controlloop/src/main/java/org/onap/policy/clamp/controlloop/runtime/supervision/comm/AbstractParticipantAckPublisher.java +++ /dev/null @@ -1,62 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * Copyright (C) 2021 Nordix Foundation. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - * SPDX-License-Identifier: Apache-2.0 - * ============LICENSE_END========================================================= - */ - -package org.onap.policy.clamp.controlloop.runtime.supervision.comm; - -import java.util.List; -import javax.ws.rs.core.Response.Status; -import org.onap.policy.clamp.controlloop.common.exception.ControlLoopRuntimeException; -import org.onap.policy.clamp.controlloop.models.messages.dmaap.participant.ParticipantAckMessage; -import org.onap.policy.clamp.controlloop.runtime.config.messaging.Publisher; -import org.onap.policy.common.endpoints.event.comm.TopicSink; -import org.onap.policy.common.endpoints.event.comm.client.TopicSinkClient; - -public abstract class AbstractParticipantAckPublisher implements Publisher { - - private TopicSinkClient topicSinkClient; - private boolean active = false; - - /** - * Method to send Participant message to participants on demand. - * - * @param participantMessage the Participant message - */ - public void send(final E participantMessage) { - if (!active) { - throw new ControlLoopRuntimeException(Status.NOT_ACCEPTABLE, "Not Active!"); - } - topicSinkClient.send(participantMessage); - } - - - @Override - public void active(List topicSinks) { - if (topicSinks.size() != 1) { - throw new IllegalArgumentException("Topic Sink must be one"); - } - this.topicSinkClient = new TopicSinkClient(topicSinks.get(0)); - active = true; - } - - @Override - public void stop() { - active = false; - } -} diff --git a/runtime-controlloop/src/main/java/org/onap/policy/clamp/controlloop/runtime/supervision/comm/AbstractParticipantPublisher.java b/runtime-controlloop/src/main/java/org/onap/policy/clamp/controlloop/runtime/supervision/comm/AbstractParticipantPublisher.java deleted file mode 100644 index 3c87b05b4..000000000 --- a/runtime-controlloop/src/main/java/org/onap/policy/clamp/controlloop/runtime/supervision/comm/AbstractParticipantPublisher.java +++ /dev/null @@ -1,62 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * Copyright (C) 2021 Nordix Foundation. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - * SPDX-License-Identifier: Apache-2.0 - * ============LICENSE_END========================================================= - */ - -package org.onap.policy.clamp.controlloop.runtime.supervision.comm; - -import java.util.List; -import javax.ws.rs.core.Response.Status; -import org.onap.policy.clamp.controlloop.common.exception.ControlLoopRuntimeException; -import org.onap.policy.clamp.controlloop.models.messages.dmaap.participant.ParticipantMessage; -import org.onap.policy.clamp.controlloop.runtime.config.messaging.Publisher; -import org.onap.policy.common.endpoints.event.comm.TopicSink; -import org.onap.policy.common.endpoints.event.comm.client.TopicSinkClient; - -public abstract class AbstractParticipantPublisher implements Publisher { - - private TopicSinkClient topicSinkClient; - private boolean active = false; - - /** - * Method to send Participant message to participants on demand. - * - * @param participantMessage the Participant message - */ - public void send(final E participantMessage) { - if (!active) { - throw new ControlLoopRuntimeException(Status.NOT_ACCEPTABLE, "Not Active!"); - } - topicSinkClient.send(participantMessage); - } - - - @Override - public void active(List topicSinks) { - if (topicSinks.size() != 1) { - throw new IllegalArgumentException("Topic Sink must be one"); - } - this.topicSinkClient = new TopicSinkClient(topicSinks.get(0)); - active = true; - } - - @Override - public void stop() { - active = false; - } -} diff --git a/runtime-controlloop/src/main/java/org/onap/policy/clamp/controlloop/runtime/supervision/comm/ControlLoopStateChangeAckListener.java b/runtime-controlloop/src/main/java/org/onap/policy/clamp/controlloop/runtime/supervision/comm/ControlLoopStateChangeAckListener.java deleted file mode 100644 index c40095bef..000000000 --- a/runtime-controlloop/src/main/java/org/onap/policy/clamp/controlloop/runtime/supervision/comm/ControlLoopStateChangeAckListener.java +++ /dev/null @@ -1,68 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * Copyright (C) 2021 Nordix Foundation. - * Modifications Copyright (C) 2021 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - * SPDX-License-Identifier: Apache-2.0 - * ============LICENSE_END========================================================= - */ - -package org.onap.policy.clamp.controlloop.runtime.supervision.comm; - -import org.onap.policy.clamp.controlloop.models.messages.dmaap.participant.ControlLoopAck; -import org.onap.policy.clamp.controlloop.models.messages.dmaap.participant.ParticipantMessageType; -import org.onap.policy.clamp.controlloop.runtime.config.messaging.Listener; -import org.onap.policy.clamp.controlloop.runtime.supervision.SupervisionHandler; -import org.onap.policy.common.endpoints.event.comm.Topic.CommInfrastructure; -import org.onap.policy.common.endpoints.listeners.ScoListener; -import org.onap.policy.common.utils.coder.StandardCoderObject; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; -import org.springframework.stereotype.Component; - -/** - * Listener for ControlLoopStateChangeAck messages sent by participants. - */ -@Component -public class ControlLoopStateChangeAckListener extends ScoListener implements Listener { - private static final Logger LOGGER = LoggerFactory.getLogger(ControlLoopStateChangeAckListener.class); - - private final SupervisionHandler supervisionHandler; - - /** - * Constructs the object. - */ - public ControlLoopStateChangeAckListener(SupervisionHandler supervisionHandler) { - super(ControlLoopAck.class); - this.supervisionHandler = supervisionHandler; - } - - @Override - public void onTopicEvent(final CommInfrastructure infra, final String topic, final StandardCoderObject sco, - final ControlLoopAck controlLoopStateChangeAckMessage) { - LOGGER.debug("ControlLoopStateChangeAck received from participant - {}", controlLoopStateChangeAckMessage); - supervisionHandler.handleControlLoopStateChangeAckMessage(controlLoopStateChangeAckMessage); - } - - @Override - public ScoListener getScoListener() { - return this; - } - - @Override - public String getType() { - return ParticipantMessageType.CONTROLLOOP_STATECHANGE_ACK.name(); - } -} diff --git a/runtime-controlloop/src/main/java/org/onap/policy/clamp/controlloop/runtime/supervision/comm/ControlLoopStateChangePublisher.java b/runtime-controlloop/src/main/java/org/onap/policy/clamp/controlloop/runtime/supervision/comm/ControlLoopStateChangePublisher.java deleted file mode 100644 index 69d7b73d0..000000000 --- a/runtime-controlloop/src/main/java/org/onap/policy/clamp/controlloop/runtime/supervision/comm/ControlLoopStateChangePublisher.java +++ /dev/null @@ -1,50 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * Copyright (C) 2021 Nordix Foundation. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - * SPDX-License-Identifier: Apache-2.0 - * ============LICENSE_END========================================================= - */ - -package org.onap.policy.clamp.controlloop.runtime.supervision.comm; - -import java.util.UUID; -import org.onap.policy.clamp.controlloop.models.controlloop.concepts.ControlLoop; -import org.onap.policy.clamp.controlloop.models.messages.dmaap.participant.ControlLoopStateChange; -import org.springframework.stereotype.Component; - -/** - * This class is used to send ControlLoopStateChangePublisher messages to participants on DMaaP. - */ -@Component -public class ControlLoopStateChangePublisher - extends AbstractParticipantPublisher { - - /** - * Send ControlLoopStateChange to Participant. - * - * @param controlLoop the ControlLoop - * @param startPhase the startPhase - */ - public void send(ControlLoop controlLoop, int startPhase) { - var clsc = new ControlLoopStateChange(); - clsc.setControlLoopId(controlLoop.getKey().asIdentifier()); - clsc.setMessageId(UUID.randomUUID()); - clsc.setOrderedState(controlLoop.getOrderedState()); - clsc.setStartPhase(startPhase); - - super.send(clsc); - } -} diff --git a/runtime-controlloop/src/main/java/org/onap/policy/clamp/controlloop/runtime/supervision/comm/ControlLoopUpdateAckListener.java b/runtime-controlloop/src/main/java/org/onap/policy/clamp/controlloop/runtime/supervision/comm/ControlLoopUpdateAckListener.java deleted file mode 100644 index b8b5126ad..000000000 --- a/runtime-controlloop/src/main/java/org/onap/policy/clamp/controlloop/runtime/supervision/comm/ControlLoopUpdateAckListener.java +++ /dev/null @@ -1,68 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * Copyright (C) 2021 Nordix Foundation. - * Modifications Copyright (C) 2021 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - * SPDX-License-Identifier: Apache-2.0 - * ============LICENSE_END========================================================= - */ - -package org.onap.policy.clamp.controlloop.runtime.supervision.comm; - -import org.onap.policy.clamp.controlloop.models.messages.dmaap.participant.ControlLoopAck; -import org.onap.policy.clamp.controlloop.models.messages.dmaap.participant.ParticipantMessageType; -import org.onap.policy.clamp.controlloop.runtime.config.messaging.Listener; -import org.onap.policy.clamp.controlloop.runtime.supervision.SupervisionHandler; -import org.onap.policy.common.endpoints.event.comm.Topic.CommInfrastructure; -import org.onap.policy.common.endpoints.listeners.ScoListener; -import org.onap.policy.common.utils.coder.StandardCoderObject; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; -import org.springframework.stereotype.Component; - -/** - * Listener for ControlLoopUpdateAck messages sent by participants. - */ -@Component -public class ControlLoopUpdateAckListener extends ScoListener implements Listener { - private static final Logger LOGGER = LoggerFactory.getLogger(ControlLoopUpdateAckListener.class); - - private final SupervisionHandler supervisionHandler; - - /** - * Constructs the object. - */ - public ControlLoopUpdateAckListener(SupervisionHandler supervisionHandler) { - super(ControlLoopAck.class); - this.supervisionHandler = supervisionHandler; - } - - @Override - public void onTopicEvent(final CommInfrastructure infra, final String topic, final StandardCoderObject sco, - final ControlLoopAck controlLoopUpdateAckMessage) { - LOGGER.debug("ControlLoopUpdateAck message received from participant - {}", controlLoopUpdateAckMessage); - supervisionHandler.handleControlLoopUpdateAckMessage(controlLoopUpdateAckMessage); - } - - @Override - public ScoListener getScoListener() { - return this; - } - - @Override - public String getType() { - return ParticipantMessageType.CONTROLLOOP_UPDATE_ACK.name(); - } -} diff --git a/runtime-controlloop/src/main/java/org/onap/policy/clamp/controlloop/runtime/supervision/comm/ControlLoopUpdatePublisher.java b/runtime-controlloop/src/main/java/org/onap/policy/clamp/controlloop/runtime/supervision/comm/ControlLoopUpdatePublisher.java deleted file mode 100644 index 24f60eafc..000000000 --- a/runtime-controlloop/src/main/java/org/onap/policy/clamp/controlloop/runtime/supervision/comm/ControlLoopUpdatePublisher.java +++ /dev/null @@ -1,91 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * Copyright (C) 2021 Nordix Foundation. - * ================================================================================ - * Modifications Copyright (C) 2021 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - * SPDX-License-Identifier: Apache-2.0 - * ============LICENSE_END========================================================= - */ - -package org.onap.policy.clamp.controlloop.runtime.supervision.comm; - -import java.time.Instant; -import java.util.ArrayList; -import java.util.List; -import java.util.UUID; -import lombok.AllArgsConstructor; -import org.onap.policy.clamp.controlloop.common.utils.CommonUtils; -import org.onap.policy.clamp.controlloop.models.controlloop.concepts.ControlLoop; -import org.onap.policy.clamp.controlloop.models.controlloop.concepts.ControlLoopElement; -import org.onap.policy.clamp.controlloop.models.controlloop.concepts.ParticipantUpdates; -import org.onap.policy.clamp.controlloop.models.controlloop.persistence.provider.ServiceTemplateProvider; -import org.onap.policy.clamp.controlloop.models.messages.dmaap.participant.ControlLoopUpdate; -import org.onap.policy.models.base.PfModelException; -import org.onap.policy.models.tosca.authorative.concepts.ToscaServiceTemplate; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; -import org.springframework.stereotype.Component; - -/** - * This class is used to send ControlLoopUpdate messages to participants on DMaaP. - */ -@Component -@AllArgsConstructor -public class ControlLoopUpdatePublisher extends AbstractParticipantPublisher { - - private static final Logger LOGGER = LoggerFactory.getLogger(ControlLoopUpdatePublisher.class); - private final ServiceTemplateProvider serviceTemplateProvider; - - /** - * Send ControlLoopUpdate to Participant. - * - * @param controlLoop the ControlLoop - */ - public void send(ControlLoop controlLoop) { - send(controlLoop, 0); - } - - /** - * Send ControlLoopUpdate to Participant. - * - * @param controlLoop the ControlLoop - * @param startPhase the Start Phase - */ - public void send(ControlLoop controlLoop, int startPhase) { - var controlLoopUpdateMsg = new ControlLoopUpdate(); - controlLoopUpdateMsg.setStartPhase(startPhase); - controlLoopUpdateMsg.setControlLoopId(controlLoop.getKey().asIdentifier()); - controlLoopUpdateMsg.setMessageId(UUID.randomUUID()); - controlLoopUpdateMsg.setTimestamp(Instant.now()); - ToscaServiceTemplate toscaServiceTemplate; - try { - toscaServiceTemplate = serviceTemplateProvider.getAllServiceTemplates().get(0); - } catch (PfModelException pfme) { - LOGGER.warn("Get of tosca service template failed, cannot send participantupdate", pfme); - return; - } - - List participantUpdates = new ArrayList<>(); - for (ControlLoopElement element : controlLoop.getElements().values()) { - CommonUtils.setServiceTemplatePolicyInfo(element, toscaServiceTemplate); - CommonUtils.prepareParticipantUpdate(element, participantUpdates); - } - controlLoopUpdateMsg.setParticipantUpdatesList(participantUpdates); - - LOGGER.debug("ControlLoopUpdate message sent {}", controlLoopUpdateMsg); - super.send(controlLoopUpdateMsg); - } -} diff --git a/runtime-controlloop/src/main/java/org/onap/policy/clamp/controlloop/runtime/supervision/comm/ParticipantDeregisterAckPublisher.java b/runtime-controlloop/src/main/java/org/onap/policy/clamp/controlloop/runtime/supervision/comm/ParticipantDeregisterAckPublisher.java deleted file mode 100644 index e92b6ee1b..000000000 --- a/runtime-controlloop/src/main/java/org/onap/policy/clamp/controlloop/runtime/supervision/comm/ParticipantDeregisterAckPublisher.java +++ /dev/null @@ -1,45 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * Copyright (C) 2021 Nordix Foundation. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - * SPDX-License-Identifier: Apache-2.0 - * ============LICENSE_END========================================================= - */ - -package org.onap.policy.clamp.controlloop.runtime.supervision.comm; - -import java.util.UUID; -import org.onap.policy.clamp.controlloop.models.messages.dmaap.participant.ParticipantDeregisterAck; -import org.springframework.stereotype.Component; - -/** - * This class is used to send ParticipantDeregisterAck messages to participants on DMaaP. - */ -@Component -public class ParticipantDeregisterAckPublisher extends AbstractParticipantAckPublisher { - - /** - * Sent ParticipantDeregisterAck to Participant. - * - * @param responseTo the original request id in the request. - */ - public void send(UUID responseTo) { - var message = new ParticipantDeregisterAck(); - message.setResponseTo(responseTo); - message.setMessage("Participant Deregister Ack"); - message.setResult(true); - super.send(message); - } -} diff --git a/runtime-controlloop/src/main/java/org/onap/policy/clamp/controlloop/runtime/supervision/comm/ParticipantDeregisterListener.java b/runtime-controlloop/src/main/java/org/onap/policy/clamp/controlloop/runtime/supervision/comm/ParticipantDeregisterListener.java deleted file mode 100644 index b8b209bac..000000000 --- a/runtime-controlloop/src/main/java/org/onap/policy/clamp/controlloop/runtime/supervision/comm/ParticipantDeregisterListener.java +++ /dev/null @@ -1,69 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * Copyright (C) 2021 Nordix Foundation. - * Modifications Copyright (C) 2021 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - * SPDX-License-Identifier: Apache-2.0 - * ============LICENSE_END========================================================= - */ - -package org.onap.policy.clamp.controlloop.runtime.supervision.comm; - -import org.onap.policy.clamp.controlloop.models.messages.dmaap.participant.ParticipantDeregister; -import org.onap.policy.clamp.controlloop.models.messages.dmaap.participant.ParticipantMessageType; -import org.onap.policy.clamp.controlloop.runtime.config.messaging.Listener; -import org.onap.policy.clamp.controlloop.runtime.supervision.SupervisionHandler; -import org.onap.policy.common.endpoints.event.comm.Topic.CommInfrastructure; -import org.onap.policy.common.endpoints.listeners.ScoListener; -import org.onap.policy.common.utils.coder.StandardCoderObject; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; -import org.springframework.stereotype.Component; - -/** - * Listener for ParticipantDeregister messages sent by participants. - */ -@Component -public class ParticipantDeregisterListener extends ScoListener - implements Listener { - private static final Logger LOGGER = LoggerFactory.getLogger(ParticipantDeregisterListener.class); - - private final SupervisionHandler supervisionHandler; - - /** - * Constructs the object. - */ - public ParticipantDeregisterListener(SupervisionHandler supervisionHandler) { - super(ParticipantDeregister.class); - this.supervisionHandler = supervisionHandler; - } - - @Override - public void onTopicEvent(final CommInfrastructure infra, final String topic, final StandardCoderObject sco, - final ParticipantDeregister participantDeregisterMessage) { - LOGGER.debug("ParticipantDeregister message received from participant - {}", participantDeregisterMessage); - supervisionHandler.handleParticipantMessage(participantDeregisterMessage); - } - - @Override - public String getType() { - return ParticipantMessageType.PARTICIPANT_DEREGISTER.name(); - } - - @Override - public ScoListener getScoListener() { - return this; - } -} diff --git a/runtime-controlloop/src/main/java/org/onap/policy/clamp/controlloop/runtime/supervision/comm/ParticipantRegisterAckPublisher.java b/runtime-controlloop/src/main/java/org/onap/policy/clamp/controlloop/runtime/supervision/comm/ParticipantRegisterAckPublisher.java deleted file mode 100644 index 8cbaec8b1..000000000 --- a/runtime-controlloop/src/main/java/org/onap/policy/clamp/controlloop/runtime/supervision/comm/ParticipantRegisterAckPublisher.java +++ /dev/null @@ -1,50 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * Copyright (C) 2021 Nordix Foundation. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - * SPDX-License-Identifier: Apache-2.0 - * ============LICENSE_END========================================================= - */ - -package org.onap.policy.clamp.controlloop.runtime.supervision.comm; - -import java.util.UUID; -import org.onap.policy.clamp.controlloop.models.messages.dmaap.participant.ParticipantRegisterAck; -import org.onap.policy.models.tosca.authorative.concepts.ToscaConceptIdentifier; -import org.springframework.stereotype.Component; - -/** - * This class is used to send ParticipantRegisterAck messages to participants on DMaaP. - */ -@Component -public class ParticipantRegisterAckPublisher extends AbstractParticipantAckPublisher { - - /** - * Send ParticipantRegisterAck to Participant. - * - * @param responseTo the original request id in the request. - * @param participantId the participant Id - * @param participantType the participant Type - */ - public void send(UUID responseTo, ToscaConceptIdentifier participantId, ToscaConceptIdentifier participantType) { - var message = new ParticipantRegisterAck(); - message.setParticipantId(participantId); - message.setParticipantType(participantType); - message.setResponseTo(responseTo); - message.setMessage("Participant Register Ack"); - message.setResult(true); - super.send(message); - } -} diff --git a/runtime-controlloop/src/main/java/org/onap/policy/clamp/controlloop/runtime/supervision/comm/ParticipantRegisterListener.java b/runtime-controlloop/src/main/java/org/onap/policy/clamp/controlloop/runtime/supervision/comm/ParticipantRegisterListener.java deleted file mode 100644 index fdf0bf3f7..000000000 --- a/runtime-controlloop/src/main/java/org/onap/policy/clamp/controlloop/runtime/supervision/comm/ParticipantRegisterListener.java +++ /dev/null @@ -1,69 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * Copyright (C) 2021 Nordix Foundation. - * Modifications Copyright (C) 2021 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - * SPDX-License-Identifier: Apache-2.0 - * ============LICENSE_END========================================================= - */ - -package org.onap.policy.clamp.controlloop.runtime.supervision.comm; - -import org.onap.policy.clamp.controlloop.models.messages.dmaap.participant.ParticipantMessageType; -import org.onap.policy.clamp.controlloop.models.messages.dmaap.participant.ParticipantRegister; -import org.onap.policy.clamp.controlloop.runtime.config.messaging.Listener; -import org.onap.policy.clamp.controlloop.runtime.supervision.SupervisionHandler; -import org.onap.policy.common.endpoints.event.comm.Topic.CommInfrastructure; -import org.onap.policy.common.endpoints.listeners.ScoListener; -import org.onap.policy.common.utils.coder.StandardCoderObject; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; -import org.springframework.stereotype.Component; - -/** - * Listener for ParticipantRegister messages sent by participants. - */ -@Component -public class ParticipantRegisterListener extends ScoListener - implements Listener { - private static final Logger LOGGER = LoggerFactory.getLogger(ParticipantRegisterListener.class); - - private final SupervisionHandler supervisionHandler; - - /** - * Constructs the object. - */ - public ParticipantRegisterListener(SupervisionHandler supervisionHandler) { - super(ParticipantRegister.class); - this.supervisionHandler = supervisionHandler; - } - - @Override - public void onTopicEvent(final CommInfrastructure infra, final String topic, final StandardCoderObject sco, - final ParticipantRegister participantRegisterMessage) { - LOGGER.debug("ParticipantRegister message received from participant - {}", participantRegisterMessage); - supervisionHandler.handleParticipantMessage(participantRegisterMessage); - } - - @Override - public String getType() { - return ParticipantMessageType.PARTICIPANT_REGISTER.name(); - } - - @Override - public ScoListener getScoListener() { - return this; - } -} diff --git a/runtime-controlloop/src/main/java/org/onap/policy/clamp/controlloop/runtime/supervision/comm/ParticipantStatusListener.java b/runtime-controlloop/src/main/java/org/onap/policy/clamp/controlloop/runtime/supervision/comm/ParticipantStatusListener.java deleted file mode 100644 index 43a07e220..000000000 --- a/runtime-controlloop/src/main/java/org/onap/policy/clamp/controlloop/runtime/supervision/comm/ParticipantStatusListener.java +++ /dev/null @@ -1,68 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * Copyright (C) 2021 Nordix Foundation. - * Modifications Copyright (C) 2021 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - * SPDX-License-Identifier: Apache-2.0 - * ============LICENSE_END========================================================= - */ - -package org.onap.policy.clamp.controlloop.runtime.supervision.comm; - -import org.onap.policy.clamp.controlloop.models.messages.dmaap.participant.ParticipantMessageType; -import org.onap.policy.clamp.controlloop.models.messages.dmaap.participant.ParticipantStatus; -import org.onap.policy.clamp.controlloop.runtime.config.messaging.Listener; -import org.onap.policy.clamp.controlloop.runtime.supervision.SupervisionHandler; -import org.onap.policy.common.endpoints.event.comm.Topic.CommInfrastructure; -import org.onap.policy.common.endpoints.listeners.ScoListener; -import org.onap.policy.common.utils.coder.StandardCoderObject; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; -import org.springframework.stereotype.Component; - -/** - * Listener for ParticipantStatus messages sent by participants. - */ -@Component -public class ParticipantStatusListener extends ScoListener implements Listener { - private static final Logger LOGGER = LoggerFactory.getLogger(ParticipantStatusListener.class); - - private final SupervisionHandler supervisionHandler; - - /** - * Constructs the object. - */ - public ParticipantStatusListener(SupervisionHandler supervisionHandler) { - super(ParticipantStatus.class); - this.supervisionHandler = supervisionHandler; - } - - @Override - public void onTopicEvent(final CommInfrastructure infra, final String topic, final StandardCoderObject sco, - final ParticipantStatus participantStatusMessage) { - LOGGER.debug("ParticipantStatus message received from participant - {}", participantStatusMessage); - supervisionHandler.handleParticipantMessage(participantStatusMessage); - } - - @Override - public String getType() { - return ParticipantMessageType.PARTICIPANT_STATUS.name(); - } - - @Override - public ScoListener getScoListener() { - return this; - } -} diff --git a/runtime-controlloop/src/main/java/org/onap/policy/clamp/controlloop/runtime/supervision/comm/ParticipantStatusReqPublisher.java b/runtime-controlloop/src/main/java/org/onap/policy/clamp/controlloop/runtime/supervision/comm/ParticipantStatusReqPublisher.java deleted file mode 100644 index 69d598285..000000000 --- a/runtime-controlloop/src/main/java/org/onap/policy/clamp/controlloop/runtime/supervision/comm/ParticipantStatusReqPublisher.java +++ /dev/null @@ -1,48 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * Copyright (C) 2021 Nordix Foundation. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - * SPDX-License-Identifier: Apache-2.0 - * ============LICENSE_END========================================================= - */ - -package org.onap.policy.clamp.controlloop.runtime.supervision.comm; - -import java.time.Instant; -import org.onap.policy.clamp.controlloop.models.messages.dmaap.participant.ParticipantStatusReq; -import org.onap.policy.models.tosca.authorative.concepts.ToscaConceptIdentifier; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; -import org.springframework.stereotype.Component; - -@Component -public class ParticipantStatusReqPublisher extends AbstractParticipantPublisher { - - private static final Logger LOGGER = LoggerFactory.getLogger(ParticipantStatusReqPublisher.class); - - /** - * Send ParticipantStatusReq to Participant. - * - * @param participantId the participant Id - */ - public void send(ToscaConceptIdentifier participantId) { - ParticipantStatusReq message = new ParticipantStatusReq(); - message.setParticipantId(participantId); - message.setTimestamp(Instant.now()); - - LOGGER.debug("Participant StatusReq sent {}", message); - super.send(message); - } -} diff --git a/runtime-controlloop/src/main/java/org/onap/policy/clamp/controlloop/runtime/supervision/comm/ParticipantUpdateAckListener.java b/runtime-controlloop/src/main/java/org/onap/policy/clamp/controlloop/runtime/supervision/comm/ParticipantUpdateAckListener.java deleted file mode 100644 index fcfa80a9f..000000000 --- a/runtime-controlloop/src/main/java/org/onap/policy/clamp/controlloop/runtime/supervision/comm/ParticipantUpdateAckListener.java +++ /dev/null @@ -1,69 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * Copyright (C) 2021 Nordix Foundation. - * Modifications Copyright (C) 2021 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - * SPDX-License-Identifier: Apache-2.0 - * ============LICENSE_END========================================================= - */ - -package org.onap.policy.clamp.controlloop.runtime.supervision.comm; - -import org.onap.policy.clamp.controlloop.models.messages.dmaap.participant.ParticipantMessageType; -import org.onap.policy.clamp.controlloop.models.messages.dmaap.participant.ParticipantUpdateAck; -import org.onap.policy.clamp.controlloop.runtime.config.messaging.Listener; -import org.onap.policy.clamp.controlloop.runtime.supervision.SupervisionHandler; -import org.onap.policy.common.endpoints.event.comm.Topic.CommInfrastructure; -import org.onap.policy.common.endpoints.listeners.ScoListener; -import org.onap.policy.common.utils.coder.StandardCoderObject; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; -import org.springframework.stereotype.Component; - -/** - * Listener for ParticipantUpdateAck messages sent by participants. - */ -@Component -public class ParticipantUpdateAckListener extends ScoListener - implements Listener { - private static final Logger LOGGER = LoggerFactory.getLogger(ParticipantUpdateAckListener.class); - - private final SupervisionHandler supervisionHandler; - - /** - * Constructs the object. - */ - public ParticipantUpdateAckListener(SupervisionHandler supervisionHandler) { - super(ParticipantUpdateAck.class); - this.supervisionHandler = supervisionHandler; - } - - @Override - public void onTopicEvent(final CommInfrastructure infra, final String topic, final StandardCoderObject sco, - final ParticipantUpdateAck participantUpdateAckMessage) { - LOGGER.debug("ParticipantUpdateAck message received from participant - {}", participantUpdateAckMessage); - supervisionHandler.handleParticipantMessage(participantUpdateAckMessage); - } - - @Override - public String getType() { - return ParticipantMessageType.PARTICIPANT_UPDATE_ACK.name(); - } - - @Override - public ScoListener getScoListener() { - return this; - } -} diff --git a/runtime-controlloop/src/main/java/org/onap/policy/clamp/controlloop/runtime/supervision/comm/ParticipantUpdatePublisher.java b/runtime-controlloop/src/main/java/org/onap/policy/clamp/controlloop/runtime/supervision/comm/ParticipantUpdatePublisher.java deleted file mode 100644 index c6788f12c..000000000 --- a/runtime-controlloop/src/main/java/org/onap/policy/clamp/controlloop/runtime/supervision/comm/ParticipantUpdatePublisher.java +++ /dev/null @@ -1,127 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * Copyright (C) 2021 Nordix Foundation. - * ================================================================================ - * Modifications Copyright (C) 2021 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - * SPDX-License-Identifier: Apache-2.0 - * ============LICENSE_END========================================================= - */ - -package org.onap.policy.clamp.controlloop.runtime.supervision.comm; - -import java.time.Instant; -import java.util.ArrayList; -import java.util.List; -import java.util.Map; -import lombok.AllArgsConstructor; -import org.onap.policy.clamp.controlloop.common.utils.CommonUtils; -import org.onap.policy.clamp.controlloop.models.controlloop.concepts.ParticipantDefinition; -import org.onap.policy.clamp.controlloop.models.controlloop.concepts.ParticipantUtils; -import org.onap.policy.clamp.controlloop.models.controlloop.persistence.provider.ServiceTemplateProvider; -import org.onap.policy.clamp.controlloop.models.messages.dmaap.participant.ParticipantUpdate; -import org.onap.policy.models.base.PfModelException; -import org.onap.policy.models.tosca.authorative.concepts.ToscaConceptIdentifier; -import org.onap.policy.models.tosca.authorative.concepts.ToscaNodeType; -import org.onap.policy.models.tosca.authorative.concepts.ToscaServiceTemplate; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; -import org.springframework.stereotype.Component; - -/** - * This class is used to send ParticipantUpdate messages to participants on DMaaP. - */ -@Component -@AllArgsConstructor -public class ParticipantUpdatePublisher extends AbstractParticipantPublisher { - - private static final Logger LOGGER = LoggerFactory.getLogger(ParticipantUpdatePublisher.class); - - private final ServiceTemplateProvider serviceTemplateProvider; - - /** - * Send ParticipantUpdate to all Participants. - * - * @param name the ToscaServiceTemplate name - * @param version the ToscaServiceTemplate version - */ - public void sendComissioningBroadcast(String name, String version) { - sendCommissioning(name, version, null, null); - } - - /** - * Send ParticipantUpdate to Participant - * if participantType and participantId are null then message is broadcast. - * - * @param name the ToscaServiceTemplate name - * @param version the ToscaServiceTemplate version - * @param participantType the ParticipantType - * @param participantId the ParticipantId - */ - public boolean sendCommissioning(String name, String version, ToscaConceptIdentifier participantType, - ToscaConceptIdentifier participantId) { - var message = new ParticipantUpdate(); - message.setParticipantType(participantType); - message.setParticipantId(participantId); - message.setTimestamp(Instant.now()); - - ToscaServiceTemplate toscaServiceTemplate = null; - Map commonPropertiesMap = null; - try { - var list = serviceTemplateProvider.getServiceTemplateList(name, version); - if (!list.isEmpty()) { - toscaServiceTemplate = list.get(0); - commonPropertiesMap = - serviceTemplateProvider.getCommonOrInstancePropertiesFromNodeTypes(true, toscaServiceTemplate); - } else { - LOGGER.warn("No tosca service template found, cannot send participantupdate {} {}", name, version); - return false; - } - } catch (PfModelException pfme) { - LOGGER.warn("Get of tosca service template failed, cannot send participantupdate", pfme); - return false; - } - - List participantDefinitionUpdates = new ArrayList<>(); - for (var toscaInputEntry : toscaServiceTemplate.getToscaTopologyTemplate().getNodeTemplates().entrySet()) { - if (ParticipantUtils.checkIfNodeTemplateIsControlLoopElement(toscaInputEntry.getValue(), - toscaServiceTemplate)) { - CommonUtils.prepareParticipantDefinitionUpdate( - ParticipantUtils.findParticipantType(toscaInputEntry.getValue().getProperties()), - toscaInputEntry.getKey(), toscaInputEntry.getValue(), - participantDefinitionUpdates, commonPropertiesMap); - } - } - - // Commission the controlloop but sending participantdefinitions to participants - message.setParticipantDefinitionUpdates(participantDefinitionUpdates); - LOGGER.debug("Participant Update sent {}", message); - super.send(message); - return true; - } - - /** - * Send ParticipantUpdate to Participant after that commissioning has been removed. - */ - public void sendDecomisioning() { - var message = new ParticipantUpdate(); - message.setTimestamp(Instant.now()); - // DeCommission the controlloop but deleting participantdefinitions on participants - message.setParticipantDefinitionUpdates(null); - - LOGGER.debug("Participant Update sent {}", message); - super.send(message); - } -} diff --git a/runtime-controlloop/src/main/resources/application.yaml b/runtime-controlloop/src/main/resources/application.yaml deleted file mode 100644 index 3a3ada563..000000000 --- a/runtime-controlloop/src/main/resources/application.yaml +++ /dev/null @@ -1,67 +0,0 @@ -spring: - security: - user: - name: runtimeUser - password: zb!XztG34 - http: - converters: - preferred-json-mapper: gson - datasource: - url: jdbc:mariadb://${mariadb.host:localhost}:${mariadb.port:3306}/controlloop - driverClassName: org.mariadb.jdbc.Driver - username: policy - password: P01icY - hikari: - connectionTimeout: 30000 - idleTimeout: 600000 - maxLifetime: 1800000 - maximumPoolSize: 10 - jpa: - hibernate: - ddl-auto: update - naming: - physical-strategy: org.hibernate.boot.model.naming.PhysicalNamingStrategyStandardImpl - implicit-strategy: org.onap.policy.common.spring.utils.CustomImplicitNamingStrategy - properties: - hibernate: - dialect: org.hibernate.dialect.MariaDB103Dialect - format_sql: true - -security: - enable-csrf: false - -server: - port: 6969 - servlet: - context-path: /onap/controlloop - error: - path: /error - - -runtime: - participantParameters: - heartBeatMs: 20000 - maxStatusWaitMs: 100000 - updateParameters: - maxRetryCount: 4 - maxWaitMs: 20000 - topicParameterGroup: - topicSources: - - - topic: POLICY-CLRUNTIME-PARTICIPANT - servers: - - ${topicServer:localhost} - topicCommInfrastructure: dmaap - fetchTimeout: 15000 - topicSinks: - - - topic: POLICY-CLRUNTIME-PARTICIPANT - servers: - - ${topicServer:localhost} - topicCommInfrastructure: dmaap - -management: - endpoints: - web: - exposure: - include: health, metrics, prometheus diff --git a/runtime-controlloop/src/main/resources/version.txt b/runtime-controlloop/src/main/resources/version.txt deleted file mode 100644 index e11449e5b..000000000 --- a/runtime-controlloop/src/main/resources/version.txt +++ /dev/null @@ -1,4 +0,0 @@ -ONAP Tosca defined control loop -Version: ${project.version} -Built (UTC): ${maven.build.timestamp} -ONAP https://wiki.onap.org diff --git a/runtime-controlloop/src/test/java/org/onap/policy/clamp/controlloop/runtime/commissioning/CommissioningProviderTest.java b/runtime-controlloop/src/test/java/org/onap/policy/clamp/controlloop/runtime/commissioning/CommissioningProviderTest.java deleted file mode 100644 index 843985e7d..000000000 --- a/runtime-controlloop/src/test/java/org/onap/policy/clamp/controlloop/runtime/commissioning/CommissioningProviderTest.java +++ /dev/null @@ -1,221 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * Copyright (C) 2021 Nordix Foundation. - * Modifications Copyright (C) 2021 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - * SPDX-License-Identifier: Apache-2.0 - * ============LICENSE_END========================================================= - */ - -package org.onap.policy.clamp.controlloop.runtime.commissioning; - -import static org.assertj.core.api.Assertions.assertThat; -import static org.mockito.ArgumentMatchers.any; -import static org.mockito.ArgumentMatchers.eq; -import static org.mockito.Mockito.mock; -import static org.mockito.Mockito.verify; -import static org.mockito.Mockito.when; - -import com.fasterxml.jackson.databind.ObjectMapper; -import com.fasterxml.jackson.databind.PropertyNamingStrategies; -import com.fasterxml.jackson.module.jsonSchema.factories.SchemaFactoryWrapper; -import java.util.List; -import java.util.Map; -import org.junit.jupiter.api.Test; -import org.onap.policy.clamp.controlloop.models.controlloop.persistence.provider.ControlLoopProvider; -import org.onap.policy.clamp.controlloop.models.controlloop.persistence.provider.ParticipantProvider; -import org.onap.policy.clamp.controlloop.models.controlloop.persistence.provider.ServiceTemplateProvider; -import org.onap.policy.clamp.controlloop.runtime.instantiation.InstantiationUtils; -import org.onap.policy.common.utils.coder.Coder; -import org.onap.policy.common.utils.coder.StandardCoder; -import org.onap.policy.models.tosca.authorative.concepts.ToscaCapabilityType; -import org.onap.policy.models.tosca.authorative.concepts.ToscaConceptIdentifier; -import org.onap.policy.models.tosca.authorative.concepts.ToscaDataType; -import org.onap.policy.models.tosca.authorative.concepts.ToscaNodeTemplate; -import org.onap.policy.models.tosca.authorative.concepts.ToscaNodeType; -import org.onap.policy.models.tosca.authorative.concepts.ToscaPolicyType; -import org.onap.policy.models.tosca.authorative.concepts.ToscaRelationshipType; -import org.onap.policy.models.tosca.authorative.concepts.ToscaServiceTemplate; -import org.onap.policy.models.tosca.authorative.concepts.ToscaTopologyTemplate; - -class CommissioningProviderTest { - private static final String TOSCA_SERVICE_TEMPLATE_YAML = - "src/test/resources/rest/servicetemplates/pmsh_multiple_cl_tosca.yaml"; - private static final String COMMON_TOSCA_SERVICE_TEMPLATE_YAML = - "src/test/resources/rest/servicetemplates/full-tosca-with-common-properties.yaml"; - - private static final Coder CODER = new StandardCoder(); - private final ObjectMapper mapper = new ObjectMapper(); - - /** - * Test the fetching of control loop definitions (ToscaServiceTemplates). - * - * @throws Exception . - */ - @Test - void testGetControlLoopDefinitions() throws Exception { - var clProvider = mock(ControlLoopProvider.class); - var participantProvider = mock(ParticipantProvider.class); - var serviceTemplateProvider = mock(ServiceTemplateProvider.class); - - CommissioningProvider provider = - new CommissioningProvider(serviceTemplateProvider, clProvider, null, participantProvider); - - List listOfTemplates = provider.getControlLoopDefinitions(null, null); - assertThat(listOfTemplates).isEmpty(); - - when(clProvider.getFilteredNodeTemplates(any())) - .thenReturn(List.of(new ToscaNodeTemplate(), new ToscaNodeTemplate())); - listOfTemplates = provider.getControlLoopDefinitions(null, null); - assertThat(listOfTemplates).hasSize(2); - } - - /** - * Test the creation of control loop definitions (ToscaServiceTemplates). - * - * @throws Exception . - */ - @Test - void testCreateControlLoopDefinitions() throws Exception { - var serviceTemplateProvider = mock(ServiceTemplateProvider.class); - var clProvider = mock(ControlLoopProvider.class); - var participantProvider = mock(ParticipantProvider.class); - - CommissioningProvider provider = - new CommissioningProvider(serviceTemplateProvider, clProvider, null, participantProvider); - - List listOfTemplates = provider.getControlLoopDefinitions(null, null); - assertThat(listOfTemplates).isEmpty(); - - ToscaServiceTemplate serviceTemplate = InstantiationUtils.getToscaServiceTemplate(TOSCA_SERVICE_TEMPLATE_YAML); - when(serviceTemplateProvider.createServiceTemplate(serviceTemplate)).thenReturn(serviceTemplate); - - // Response should return the number of node templates present in the service template - List affectedDefinitions = - provider.createControlLoopDefinitions(serviceTemplate).getAffectedControlLoopDefinitions(); - assertThat(affectedDefinitions).hasSize(13); - - when(clProvider.getFilteredNodeTemplates(any())) - .thenReturn(List.of(new ToscaNodeTemplate(), new ToscaNodeTemplate())); - - listOfTemplates = provider.getControlLoopDefinitions(null, null); - assertThat(listOfTemplates).hasSize(2); - } - - /** - * Test the fetching of a full ToscaServiceTemplate object - as opposed to the reduced template that is being - * tested in the testGetToscaServiceTemplateReduced() test. - * - */ - @Test - void testGetToscaServiceTemplate() throws Exception { - var serviceTemplateProvider = mock(ServiceTemplateProvider.class); - var clProvider = mock(ControlLoopProvider.class); - var participantProvider = mock(ParticipantProvider.class); - - CommissioningProvider provider = - new CommissioningProvider(serviceTemplateProvider, clProvider, null, participantProvider); - ToscaServiceTemplate serviceTemplate = - InstantiationUtils.getToscaServiceTemplate(COMMON_TOSCA_SERVICE_TEMPLATE_YAML); - when(serviceTemplateProvider.createServiceTemplate(serviceTemplate)).thenReturn(serviceTemplate); - - provider.createControlLoopDefinitions(serviceTemplate); - verify(serviceTemplateProvider).createServiceTemplate(serviceTemplate); - - when(serviceTemplateProvider.getToscaServiceTemplate(eq(null), eq(null))).thenReturn(serviceTemplate); - - ToscaServiceTemplate returnedServiceTemplate = provider.getToscaServiceTemplate(null, null); - assertThat(returnedServiceTemplate).isNotNull(); - - Map nodeTemplates = - returnedServiceTemplate.getToscaTopologyTemplate().getNodeTemplates(); - - assertThat(nodeTemplates).hasSize(8); - } - - /** - * Test the fetching of a reduced ToscaServiceTemplate with only some of the objects from the full template. - * The reduced template does not contain: DataTypesAsMap or PolicyTypesAsMap. - * - */ - @Test - void testGetToscaServiceTemplateReduced() throws Exception { - var serviceTemplateProvider = mock(ServiceTemplateProvider.class); - var clProvider = mock(ControlLoopProvider.class); - var participantProvider = mock(ParticipantProvider.class); - - CommissioningProvider provider = - new CommissioningProvider(serviceTemplateProvider, clProvider, null, participantProvider); - ToscaServiceTemplate serviceTemplate = - InstantiationUtils.getToscaServiceTemplate(COMMON_TOSCA_SERVICE_TEMPLATE_YAML); - when(serviceTemplateProvider.createServiceTemplate(serviceTemplate)).thenReturn(serviceTemplate); - - provider.createControlLoopDefinitions(serviceTemplate); - - when(serviceTemplateProvider.getServiceTemplateList(any(), any())).thenReturn(List.of(serviceTemplate)); - - String returnedServiceTemplate = provider.getToscaServiceTemplateReduced(null, null); - assertThat(returnedServiceTemplate).isNotNull(); - ToscaServiceTemplate parsedServiceTemplate = CODER.decode(returnedServiceTemplate, ToscaServiceTemplate.class); - - assertThat(parsedServiceTemplate.getToscaTopologyTemplate().getNodeTemplates()).hasSize(8); - } - - /** - * Tests the different schemas being returned from the schema endpoint. As schemas of the different - * sections of the Tosca Service Templates can be returned by the API, this test must cover all of the - * different sections. - * - */ - @Test - void testGetToscaServiceTemplateSchema() throws Exception { - var serviceTemplateProvider = mock(ServiceTemplateProvider.class); - var clProvider = mock(ControlLoopProvider.class); - var participantProvider = mock(ParticipantProvider.class); - - CommissioningProvider provider = - new CommissioningProvider(serviceTemplateProvider, clProvider, null, participantProvider); - ToscaServiceTemplate serviceTemplate = - InstantiationUtils.getToscaServiceTemplate(COMMON_TOSCA_SERVICE_TEMPLATE_YAML); - when(serviceTemplateProvider.createServiceTemplate(serviceTemplate)).thenReturn(serviceTemplate); - - provider.createControlLoopDefinitions(serviceTemplate); - - mapper.setPropertyNamingStrategy(PropertyNamingStrategies.SNAKE_CASE); - - Map> sections = Map.of("all", ToscaServiceTemplate.class, "data_types", ToscaDataType.class, - "capability_types", ToscaCapabilityType.class, "node_types", ToscaNodeType.class, "relationship_types", - ToscaRelationshipType.class, "policy_types", ToscaPolicyType.class, "topology_template", - ToscaTopologyTemplate.class, "node_templates", List.class); - - for (Map.Entry> entry : sections.entrySet()) { - String returnedServiceTemplateSchema = provider.getToscaServiceTemplateSchema(entry.getKey()); - assertThat(returnedServiceTemplateSchema).isNotNull(); - - var visitor = new SchemaFactoryWrapper(); - - if (entry.getKey().equals("node_templates")) { - mapper.acceptJsonFormatVisitor( - mapper.getTypeFactory().constructCollectionType(List.class, ToscaNodeTemplate.class), visitor); - } else { - mapper.acceptJsonFormatVisitor(mapper.constructType(entry.getValue()), visitor); - } - - var jsonSchema = visitor.finalSchema(); - String localServiceTemplateSchema = mapper.writerWithDefaultPrettyPrinter().writeValueAsString(jsonSchema); - assertThat(localServiceTemplateSchema).isEqualTo(returnedServiceTemplateSchema); - } - } -} diff --git a/runtime-controlloop/src/test/java/org/onap/policy/clamp/controlloop/runtime/commissioning/rest/CommissioningControllerTest.java b/runtime-controlloop/src/test/java/org/onap/policy/clamp/controlloop/runtime/commissioning/rest/CommissioningControllerTest.java deleted file mode 100644 index e4a121439..000000000 --- a/runtime-controlloop/src/test/java/org/onap/policy/clamp/controlloop/runtime/commissioning/rest/CommissioningControllerTest.java +++ /dev/null @@ -1,303 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * Copyright (C) 2021 Nordix Foundation. - * Modifications Copyright (C) 2021 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - * SPDX-License-Identifier: Apache-2.0 - * ============LICENSE_END========================================================= - */ - -package org.onap.policy.clamp.controlloop.runtime.commissioning.rest; - -import static org.assertj.core.api.Assertions.assertThat; -import static org.junit.jupiter.api.Assertions.assertEquals; -import static org.junit.jupiter.api.Assertions.assertNotNull; -import static org.junit.jupiter.api.Assertions.assertNull; -import static org.junit.jupiter.api.Assertions.assertTrue; - -import java.util.List; -import java.util.Map; -import javax.ws.rs.client.Entity; -import javax.ws.rs.client.Invocation; -import javax.ws.rs.core.Response; -import org.junit.jupiter.api.AfterEach; -import org.junit.jupiter.api.BeforeAll; -import org.junit.jupiter.api.BeforeEach; -import org.junit.jupiter.api.Test; -import org.junit.jupiter.api.extension.ExtendWith; -import org.junit.jupiter.api.parallel.Execution; -import org.junit.jupiter.api.parallel.ExecutionMode; -import org.onap.policy.clamp.controlloop.models.controlloop.persistence.provider.ServiceTemplateProvider; -import org.onap.policy.clamp.controlloop.models.messages.rest.commissioning.CommissioningResponse; -import org.onap.policy.clamp.controlloop.runtime.instantiation.InstantiationUtils; -import org.onap.policy.clamp.controlloop.runtime.util.rest.CommonRestController; -import org.onap.policy.models.tosca.authorative.concepts.ToscaNodeTemplate; -import org.onap.policy.models.tosca.authorative.concepts.ToscaServiceTemplate; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.boot.test.context.SpringBootTest; -import org.springframework.boot.test.context.SpringBootTest.WebEnvironment; -import org.springframework.boot.web.server.LocalServerPort; -import org.springframework.test.context.TestPropertySource; -import org.springframework.test.context.junit.jupiter.SpringExtension; - -@ExtendWith(SpringExtension.class) -@SpringBootTest(webEnvironment = WebEnvironment.RANDOM_PORT) -@TestPropertySource(locations = {"classpath:application_test.properties"}) -@Execution(ExecutionMode.SAME_THREAD) -class CommissioningControllerTest extends CommonRestController { - - private static final String TOSCA_SERVICE_TEMPLATE_YAML = - "src/test/resources/rest/servicetemplates/pmsh_multiple_cl_tosca.yaml"; - private static final String COMMON_TOSCA_SERVICE_TEMPLATE_YAML = - "src/test/resources/rest/servicetemplates/full-tosca-with-common-properties.yaml"; - - private static final String COMMISSIONING_ENDPOINT = "commission"; - private static ToscaServiceTemplate serviceTemplate = new ToscaServiceTemplate(); - private static ToscaServiceTemplate commonPropertiesServiceTemplate = new ToscaServiceTemplate(); - - @Autowired - private ServiceTemplateProvider serviceTemplateProvider; - - @LocalServerPort - private int randomServerPort; - - /** - * starts Main and inserts a commissioning template. - * - * @throws Exception if an error occurs - */ - @BeforeAll - public static void setUpBeforeClass() throws Exception { - - serviceTemplate = InstantiationUtils.getToscaServiceTemplate(TOSCA_SERVICE_TEMPLATE_YAML); - commonPropertiesServiceTemplate = - InstantiationUtils.getToscaServiceTemplate(COMMON_TOSCA_SERVICE_TEMPLATE_YAML); - } - - @BeforeEach - public void setUpPort() { - super.setHttpPrefix(randomServerPort); - } - - @AfterEach - public void cleanDatabase() throws Exception { - deleteEntryInDB(); - } - - @Test - void testSwagger() throws Exception { - super.testSwagger(COMMISSIONING_ENDPOINT); - } - - @Test - void testUnauthorizedCreate() throws Exception { - assertUnauthorizedPost(COMMISSIONING_ENDPOINT, Entity.json(serviceTemplate)); - } - - @Test - void testUnauthorizedQuery() throws Exception { - assertUnauthorizedGet(COMMISSIONING_ENDPOINT); - } - - @Test - void testUnauthorizedQueryElements() throws Exception { - assertUnauthorizedGet(COMMISSIONING_ENDPOINT + "/elements"); - } - - @Test - void testUnauthorizedDelete() throws Exception { - assertUnauthorizedDelete(COMMISSIONING_ENDPOINT); - } - - @Test - void testUnauthorizedQueryToscaServiceTemplate() throws Exception { - assertUnauthorizedGet(COMMISSIONING_ENDPOINT + "/toscaservicetemplate"); - } - - @Test - void testUnauthorizedQueryToscaServiceTemplateSchema() throws Exception { - assertUnauthorizedGet(COMMISSIONING_ENDPOINT + "/toscaServiceTemplateSchema"); - } - - @Test - void testUnauthorizedQueryToscaServiceCommonOrInstanceProperties() throws Exception { - assertUnauthorizedGet(COMMISSIONING_ENDPOINT + "/getCommonOrInstanceProperties"); - } - - @Test - void testQueryToscaServiceTemplate() throws Exception { - createFullEntryInDbWithCommonProps(); - - Invocation.Builder invocationBuilder = super.sendRequest(COMMISSIONING_ENDPOINT + "/toscaservicetemplate"); - Response rawresp = invocationBuilder.buildGet().invoke(); - assertEquals(Response.Status.OK.getStatusCode(), rawresp.getStatus()); - ToscaServiceTemplate template = rawresp.readEntity(ToscaServiceTemplate.class); - assertNotNull(template); - assertThat(template.getNodeTypes()).hasSize(8); - - } - - @Test - void testQueryToscaServiceTemplateSchema() throws Exception { - createFullEntryInDbWithCommonProps(); - - Invocation.Builder invocationBuilder = - super.sendRequest(COMMISSIONING_ENDPOINT + "/toscaServiceTemplateSchema"); - Response rawresp = invocationBuilder.buildGet().invoke(); - assertEquals(Response.Status.OK.getStatusCode(), rawresp.getStatus()); - String schema = rawresp.readEntity(String.class); - assertNotNull(schema); - - } - - @Test - void testQueryCommonOrInstanceProperties() throws Exception { - createFullEntryInDbWithCommonProps(); - - Invocation.Builder invocationBuilder = super.sendRequest(COMMISSIONING_ENDPOINT - + "/getCommonOrInstanceProperties" + "?common=true&name=ToscaServiceTemplateSimple&version=1.0.0"); - Response rawresp = invocationBuilder.buildGet().invoke(); - assertEquals(Response.Status.OK.getStatusCode(), rawresp.getStatus()); - - @SuppressWarnings("unchecked") - Map commonProperties = rawresp.readEntity(Map.class); - - assertNotNull(commonProperties); - assertThat(commonProperties).hasSize(6); - - } - - @Test - void testCreateBadRequest() throws Exception { - Invocation.Builder invocationBuilder = super.sendRequest(COMMISSIONING_ENDPOINT); - Response resp = invocationBuilder.post(Entity.json("NotToscaServiceTempalte")); - - assertThat(Response.Status.INTERNAL_SERVER_ERROR.getStatusCode()).isEqualTo(resp.getStatus()); - CommissioningResponse commissioningResponse = resp.readEntity(CommissioningResponse.class); - assertThat(commissioningResponse.getErrorDetails()).isNotNull(); - assertThat(commissioningResponse.getAffectedControlLoopDefinitions()).isNull(); - } - - @Test - void testCreate() throws Exception { - Invocation.Builder invocationBuilder = super.sendRequest(COMMISSIONING_ENDPOINT); - Response resp = invocationBuilder.post(Entity.json(serviceTemplate)); - assertEquals(Response.Status.OK.getStatusCode(), resp.getStatus()); - CommissioningResponse commissioningResponse = resp.readEntity(CommissioningResponse.class); - - assertNotNull(commissioningResponse); - assertNull(commissioningResponse.getErrorDetails()); - // Response should return the number of node templates present in the service template - assertThat(commissioningResponse.getAffectedControlLoopDefinitions()).hasSize(13); - for (String nodeTemplateName : serviceTemplate.getToscaTopologyTemplate().getNodeTemplates().keySet()) { - assertTrue(commissioningResponse.getAffectedControlLoopDefinitions().stream() - .anyMatch(ac -> ac.getName().equals(nodeTemplateName))); - } - - } - - @Test - void testQuery_NoResultWithThisName() throws Exception { - createEntryInDB(); - - Invocation.Builder invocationBuilder = super.sendRequest(COMMISSIONING_ENDPOINT + "?name=noResultWithThisName"); - Response rawresp = invocationBuilder.buildGet().invoke(); - assertEquals(Response.Status.OK.getStatusCode(), rawresp.getStatus()); - List entityList = rawresp.readEntity(List.class); - assertThat(entityList).isEmpty(); - - } - - @Test - void testQuery() throws Exception { - createEntryInDB(); - - Invocation.Builder invocationBuilder = super.sendRequest(COMMISSIONING_ENDPOINT); - Response rawresp = invocationBuilder.buildGet().invoke(); - assertEquals(Response.Status.OK.getStatusCode(), rawresp.getStatus()); - List entityList = rawresp.readEntity(List.class); - assertNotNull(entityList); - assertThat(entityList).hasSize(2); - - } - - @Test - void testQueryElementsBadRequest() throws Exception { - createEntryInDB(); - - // Call get elements with no info - Invocation.Builder invocationBuilder = super.sendRequest(COMMISSIONING_ENDPOINT + "/elements"); - Response resp = invocationBuilder.buildGet().invoke(); - assertEquals(Response.Status.NOT_ACCEPTABLE.getStatusCode(), resp.getStatus()); - - } - - @Test - void testQueryElements() throws Exception { - createEntryInDB(); - - Invocation.Builder invocationBuilder = super.sendRequest( - COMMISSIONING_ENDPOINT + "/elements" + "?name=org.onap.domain.pmsh.PMSHControlLoopDefinition"); - Response rawresp = invocationBuilder.buildGet().invoke(); - assertEquals(Response.Status.OK.getStatusCode(), rawresp.getStatus()); - List entityList = rawresp.readEntity(List.class); - assertNotNull(entityList); - assertThat(entityList).hasSize(4); - - } - - @Test - void testDeleteBadRequest() throws Exception { - createEntryInDB(); - - Invocation.Builder invocationBuilder = super.sendRequest(COMMISSIONING_ENDPOINT); - // Call delete with no info - Response resp = invocationBuilder.delete(); - assertEquals(Response.Status.BAD_REQUEST.getStatusCode(), resp.getStatus()); - - } - - @Test - void testDelete() throws Exception { - var serviceTemplateCreated = createEntryInDB(); - - Invocation.Builder invocationBuilder = super.sendRequest(COMMISSIONING_ENDPOINT + "?name=" - + serviceTemplateCreated.getName() + "&version=" + serviceTemplateCreated.getVersion()); - // Call delete with no info - Response resp = invocationBuilder.delete(); - assertEquals(Response.Status.OK.getStatusCode(), resp.getStatus()); - - List templatesInDB = serviceTemplateProvider.getAllServiceTemplates(); - assertThat(templatesInDB).isEmpty(); - } - - private synchronized ToscaServiceTemplate createEntryInDB() throws Exception { - deleteEntryInDB(); - return serviceTemplateProvider.createServiceTemplate(serviceTemplate); - } - - // Delete entries from the DB after relevant tests - private synchronized void deleteEntryInDB() throws Exception { - var list = serviceTemplateProvider.getAllServiceTemplates(); - if (!list.isEmpty()) { - serviceTemplateProvider.deleteServiceTemplate(list.get(0).getName(), list.get(0).getVersion()); - } - } - - private synchronized void createFullEntryInDbWithCommonProps() throws Exception { - deleteEntryInDB(); - serviceTemplateProvider.createServiceTemplate(commonPropertiesServiceTemplate); - } -} diff --git a/runtime-controlloop/src/test/java/org/onap/policy/clamp/controlloop/runtime/config/messaging/MessageDispatcherActivatorTest.java b/runtime-controlloop/src/test/java/org/onap/policy/clamp/controlloop/runtime/config/messaging/MessageDispatcherActivatorTest.java deleted file mode 100644 index 8dbc710dd..000000000 --- a/runtime-controlloop/src/test/java/org/onap/policy/clamp/controlloop/runtime/config/messaging/MessageDispatcherActivatorTest.java +++ /dev/null @@ -1,102 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * Copyright (C) 2021 Nordix Foundation. - * Modifications Copyright (C) 2021 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - * SPDX-License-Identifier: Apache-2.0 - * ============LICENSE_END========================================================= - */ - -package org.onap.policy.clamp.controlloop.runtime.config.messaging; - -import static org.assertj.core.api.Assertions.assertThatIllegalStateException; -import static org.junit.jupiter.api.Assertions.assertFalse; -import static org.junit.jupiter.api.Assertions.assertTrue; -import static org.mockito.ArgumentMatchers.any; -import static org.mockito.ArgumentMatchers.anyList; -import static org.mockito.Mockito.mock; -import static org.mockito.Mockito.spy; -import static org.mockito.Mockito.times; -import static org.mockito.Mockito.verify; -import static org.mockito.Mockito.when; - -import java.util.List; -import org.junit.jupiter.api.Test; -import org.onap.policy.clamp.controlloop.models.messages.dmaap.participant.ParticipantStatus; -import org.onap.policy.clamp.controlloop.runtime.main.parameters.ClRuntimeParameterGroup; -import org.onap.policy.clamp.controlloop.runtime.supervision.comm.ParticipantStatusListener; -import org.onap.policy.clamp.controlloop.runtime.util.CommonTestData; -import org.onap.policy.common.utils.coder.Coder; -import org.onap.policy.common.utils.coder.StandardCoder; -import org.onap.policy.common.utils.coder.StandardCoderObject; - -/** - * Class to perform unit test of {@link MessageDispatcherActivator}}. - * - */ -class MessageDispatcherActivatorTest { - - private static final Coder CODER = new StandardCoder(); - - private static final String TOPIC_FIRST = "TOPIC1"; - private static final String TOPIC_SECOND = "TOPIC2"; - - @Test - void testStartAndStop() throws Exception { - ClRuntimeParameterGroup parameterGroup = CommonTestData.geParameterGroup("dbtest"); - - var publisherFirst = spy(mock(Publisher.class)); - var publisherSecond = spy(mock(Publisher.class)); - var publishers = List.of(publisherFirst, publisherSecond); - - var listenerFirst = spy(mock(ParticipantStatusListener.class)); - when(listenerFirst.getType()).thenReturn(TOPIC_FIRST); - when(listenerFirst.getScoListener()).thenReturn(listenerFirst); - - var listenerSecond = spy(mock(ParticipantStatusListener.class)); - when(listenerSecond.getType()).thenReturn(TOPIC_SECOND); - when(listenerSecond.getScoListener()).thenReturn(listenerSecond); - - List> listeners = List.of(listenerFirst, listenerSecond); - - try (var activator = new MessageDispatcherActivator(parameterGroup, publishers, listeners)) { - - assertFalse(activator.isAlive()); - activator.start(); - assertTrue(activator.isAlive()); - - // repeat start - should throw an exception - assertThatIllegalStateException().isThrownBy(() -> activator.start()); - assertTrue(activator.isAlive()); - verify(publisherFirst, times(1)).active(anyList()); - verify(publisherSecond, times(1)).active(anyList()); - - StandardCoderObject sco = CODER.decode("{messageType:" + TOPIC_FIRST + "}", StandardCoderObject.class); - activator.getMsgDispatcher().onTopicEvent(null, "msg", sco); - verify(listenerFirst, times(1)).onTopicEvent(any(), any(), any()); - - sco = CODER.decode("{messageType:" + TOPIC_SECOND + "}", StandardCoderObject.class); - activator.getMsgDispatcher().onTopicEvent(null, "msg", sco); - verify(listenerSecond, times(1)).onTopicEvent(any(), any(), any()); - - activator.stop(); - assertFalse(activator.isAlive()); - - // repeat stop - should throw an exception - assertThatIllegalStateException().isThrownBy(() -> activator.stop()); - assertFalse(activator.isAlive()); - } - } -} diff --git a/runtime-controlloop/src/test/java/org/onap/policy/clamp/controlloop/runtime/instantiation/ControlLoopInstantiationProviderTest.java b/runtime-controlloop/src/test/java/org/onap/policy/clamp/controlloop/runtime/instantiation/ControlLoopInstantiationProviderTest.java deleted file mode 100644 index ba1cc0813..000000000 --- a/runtime-controlloop/src/test/java/org/onap/policy/clamp/controlloop/runtime/instantiation/ControlLoopInstantiationProviderTest.java +++ /dev/null @@ -1,378 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * Copyright (C) 2021 Nordix Foundation. - * Modifications Copyright (C) 2021 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - * SPDX-License-Identifier: Apache-2.0 - * ============LICENSE_END========================================================= - */ - -package org.onap.policy.clamp.controlloop.runtime.instantiation; - -import static org.assertj.core.api.Assertions.assertThat; -import static org.assertj.core.api.Assertions.assertThatThrownBy; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertNull; -import static org.mockito.ArgumentMatchers.anyString; -import static org.mockito.Mockito.mock; -import static org.mockito.Mockito.verify; -import static org.mockito.Mockito.when; - -import java.io.IOException; -import java.util.List; -import java.util.Optional; -import org.junit.jupiter.api.BeforeAll; -import org.junit.jupiter.api.Test; -import org.mockito.Mockito; -import org.onap.policy.clamp.controlloop.common.exception.ControlLoopRuntimeException; -import org.onap.policy.clamp.controlloop.models.controlloop.concepts.ControlLoop; -import org.onap.policy.clamp.controlloop.models.controlloop.concepts.ControlLoopOrderedState; -import org.onap.policy.clamp.controlloop.models.controlloop.concepts.ControlLoopState; -import org.onap.policy.clamp.controlloop.models.controlloop.concepts.ControlLoops; -import org.onap.policy.clamp.controlloop.models.controlloop.persistence.provider.ControlLoopProvider; -import org.onap.policy.clamp.controlloop.models.controlloop.persistence.provider.ParticipantProvider; -import org.onap.policy.clamp.controlloop.models.messages.rest.instantiation.InstantiationCommand; -import org.onap.policy.clamp.controlloop.models.messages.rest.instantiation.InstantiationResponse; -import org.onap.policy.clamp.controlloop.runtime.commissioning.CommissioningProvider; -import org.onap.policy.clamp.controlloop.runtime.supervision.SupervisionHandler; -import org.onap.policy.clamp.controlloop.runtime.util.CommonTestData; -import org.onap.policy.models.tosca.authorative.concepts.ToscaConceptIdentifier; -import org.onap.policy.models.tosca.authorative.concepts.ToscaNodeTemplate; -import org.onap.policy.models.tosca.authorative.concepts.ToscaServiceTemplate; - -/** - * Class to perform unit test of {@link ControlLoopInstantiationProvider}}. - * - */ -class ControlLoopInstantiationProviderTest { - private static final String ID_NAME = "PMSH_Instance1"; - private static final String ID_VERSION = "1.2.3"; - private static final String CL_INSTANTIATION_CREATE_JSON = "src/test/resources/rest/controlloops/ControlLoops.json"; - private static final String CL_INSTANTIATION_UPDATE_JSON = - "src/test/resources/rest/controlloops/ControlLoopsUpdate.json"; - private static final String CL_INSTANTIATION_CHANGE_STATE_JSON = - "src/test/resources/rest/controlloops/PassiveCommand.json"; - private static final String CL_INSTANTIATION_DEFINITION_NAME_NOT_FOUND_JSON = - "src/test/resources/rest/controlloops/ControlLoopElementsNotFound.json"; - private static final String CL_INSTANTIATION_CONTROLLOOP_DEFINITION_NOT_FOUND_JSON = - "src/test/resources/rest/controlloops/ControlLoopsNotFound.json"; - private static final String TOSCA_TEMPLATE_YAML = - "src/test/resources/rest/servicetemplates/pmsh_multiple_cl_tosca.yaml"; - private static final String CONTROL_LOOP_NOT_FOUND = "Control Loop not found"; - private static final String DELETE_BAD_REQUEST = "Control Loop State is still %s"; - private static final String ORDERED_STATE_INVALID = "ordered state invalid or not specified on command"; - private static final String CONTROLLOOP_ELEMENT_NAME_NOT_FOUND = - "\"ControlLoops\" INVALID, item has status INVALID\n" - + " \"entry org.onap.domain.pmsh.PMSHControlLoopDefinition\" INVALID, item has status INVALID\n" - + " \"entry org.onap.domain.pmsh.DCAEMicroservice\" INVALID, Not FOUND\n" - + " \"entry org.onap.domain.pmsh.PMSHControlLoopDefinition\" INVALID, item has status INVALID\n" - + " \"entry org.onap.domain.pmsh.DCAEMicroservice\" INVALID, Not FOUND\n"; - - private static final String CONTROLLOOP_DEFINITION_NOT_FOUND = "\"ControlLoops\" INVALID, item has status INVALID\n" - + " \"entry org.onap.domain.PMSHControlLoopDefinition\" INVALID, item has status INVALID\n" - + " item \"ControlLoop\" value \"org.onap.domain.PMSHControlLoopDefinition\" INVALID," - + " Commissioned control loop definition not FOUND\n" - + " \"entry org.onap.domain.PMSHControlLoopDefinition\" INVALID, item has status INVALID\n" - + " item \"ControlLoop\" value \"org.onap.domain.PMSHControlLoopDefinition\" INVALID," - + " Commissioned control loop definition not FOUND\n"; - - private static ToscaServiceTemplate serviceTemplate = new ToscaServiceTemplate(); - - @BeforeAll - public static void setUpBeforeClass() throws Exception { - serviceTemplate = InstantiationUtils.getToscaServiceTemplate(TOSCA_TEMPLATE_YAML); - } - - @Test - void testIntanceResponses() throws Exception { - var participantProvider = Mockito.mock(ParticipantProvider.class); - var clProvider = mock(ControlLoopProvider.class); - var supervisionHandler = mock(SupervisionHandler.class); - var commissioningProvider = mock(CommissioningProvider.class); - - when(commissioningProvider.getAllToscaServiceTemplate()).thenReturn(List.of(serviceTemplate)); - when(commissioningProvider.getToscaServiceTemplate(ID_NAME, ID_VERSION)).thenReturn(serviceTemplate); - - var instantiationProvider = new ControlLoopInstantiationProvider(clProvider, commissioningProvider, - supervisionHandler, participantProvider); - var instancePropertyList = instantiationProvider.createInstanceProperties(serviceTemplate); - assertNull(instancePropertyList.getErrorDetails()); - var id = new ToscaConceptIdentifier(ID_NAME, ID_VERSION); - assertEquals(id, instancePropertyList.getAffectedInstanceProperties().get(0)); - - ControlLoops controlLoops = - InstantiationUtils.getControlLoopsFromResource(CL_INSTANTIATION_CREATE_JSON, "Crud"); - var controlLoop = controlLoops.getControlLoopList().get(0); - controlLoop.setName(ID_NAME); - controlLoop.setVersion(ID_VERSION); - when(clProvider.getControlLoops(ID_NAME, ID_VERSION)).thenReturn(List.of(controlLoop)); - - var instanceOrderState = instantiationProvider.getInstantiationOrderState(ID_NAME, ID_VERSION); - assertEquals(ControlLoopOrderedState.UNINITIALISED, instanceOrderState.getOrderedState()); - assertEquals(ID_NAME, instanceOrderState.getControlLoopIdentifierList().get(0).getName()); - - when(clProvider.findControlLoop(ID_NAME, ID_VERSION)).thenReturn(Optional.of(controlLoop)); - when(clProvider.deleteControlLoop(ID_NAME, ID_VERSION)).thenReturn(controlLoop); - - var instanceResponse = instantiationProvider.deleteInstanceProperties(ID_NAME, ID_VERSION); - assertEquals(ID_NAME, instanceResponse.getAffectedControlLoops().get(0).getName()); - - } - - @Test - void testInstantiationCrud() throws Exception { - var participantProvider = Mockito.mock(ParticipantProvider.class); - var participants = CommonTestData.createParticipants(); - when(participantProvider.getParticipants()).thenReturn(participants); - - var commissioningProvider = mock(CommissioningProvider.class); - var toscaNodeTemplate1 = new ToscaNodeTemplate(); - toscaNodeTemplate1.setName("org.onap.domain.pmsh.PMSH_MonitoringPolicyControlLoopElement"); - toscaNodeTemplate1.setVersion("1.2.3"); - when(commissioningProvider.getControlLoopDefinitions(anyString(), anyString())) - .thenReturn(List.of(toscaNodeTemplate1)); - - var toscaNodeTemplate2 = new ToscaNodeTemplate(); - toscaNodeTemplate2.setName("org.onap.domain.pmsh.PMSH_OperationalPolicyControlLoopElement"); - toscaNodeTemplate2.setVersion("1.2.3"); - var toscaNodeTemplate3 = new ToscaNodeTemplate(); - toscaNodeTemplate3.setName("org.onap.domain.pmsh.PMSH_CDS_ControlLoopElement"); - toscaNodeTemplate3.setVersion("1.2.3"); - var toscaNodeTemplate4 = new ToscaNodeTemplate(); - toscaNodeTemplate4.setName("org.onap.domain.pmsh.PMSH_DCAEMicroservice"); - toscaNodeTemplate4.setVersion("1.2.3"); - - when(commissioningProvider.getControlLoopElementDefinitions(toscaNodeTemplate1)) - .thenReturn(List.of(toscaNodeTemplate1, toscaNodeTemplate2, toscaNodeTemplate3, toscaNodeTemplate4)); - - var supervisionHandler = mock(SupervisionHandler.class); - var clProvider = mock(ControlLoopProvider.class); - var instantiationProvider = new ControlLoopInstantiationProvider(clProvider, commissioningProvider, - supervisionHandler, participantProvider); - ControlLoops controlLoopsCreate = - InstantiationUtils.getControlLoopsFromResource(CL_INSTANTIATION_CREATE_JSON, "Crud"); - InstantiationResponse instantiationResponse = instantiationProvider.createControlLoops(controlLoopsCreate); - InstantiationUtils.assertInstantiationResponse(instantiationResponse, controlLoopsCreate); - - verify(clProvider).saveControlLoops(controlLoopsCreate.getControlLoopList()); - - for (var controlLoop : controlLoopsCreate.getControlLoopList()) { - when(clProvider.getControlLoops(controlLoop.getName(), controlLoop.getVersion())) - .thenReturn(List.of(controlLoop)); - - ControlLoops controlLoopsGet = - instantiationProvider.getControlLoops(controlLoop.getName(), controlLoop.getVersion()); - assertThat(controlLoopsGet.getControlLoopList()).hasSize(1); - assertThat(controlLoop).isEqualTo(controlLoopsGet.getControlLoopList().get(0)); - } - - ControlLoops controlLoopsUpdate = - InstantiationUtils.getControlLoopsFromResource(CL_INSTANTIATION_UPDATE_JSON, "Crud"); - - instantiationResponse = instantiationProvider.updateControlLoops(controlLoopsUpdate); - InstantiationUtils.assertInstantiationResponse(instantiationResponse, controlLoopsUpdate); - - verify(clProvider).saveControlLoops(controlLoopsUpdate.getControlLoopList()); - - for (var controlLoop : controlLoopsUpdate.getControlLoopList()) { - when(clProvider.findControlLoop(controlLoop.getKey().asIdentifier())).thenReturn(Optional.of(controlLoop)); - when(clProvider.findControlLoop(controlLoop.getName(), controlLoop.getVersion())) - .thenReturn(Optional.of(controlLoop)); - when(clProvider.deleteControlLoop(controlLoop.getName(), controlLoop.getVersion())).thenReturn(controlLoop); - } - - InstantiationCommand instantiationCommand = - InstantiationUtils.getInstantiationCommandFromResource(CL_INSTANTIATION_CHANGE_STATE_JSON, "Crud"); - instantiationResponse = instantiationProvider.issueControlLoopCommand(instantiationCommand); - InstantiationUtils.assertInstantiationResponse(instantiationResponse, instantiationCommand); - - verify(supervisionHandler).triggerControlLoopSupervision(instantiationCommand.getControlLoopIdentifierList()); - - // in order to delete a controlLoop the state must be UNINITIALISED - controlLoopsCreate.getControlLoopList().forEach(cl -> cl.setState(ControlLoopState.UNINITIALISED)); - instantiationProvider.updateControlLoops(controlLoopsCreate); - - for (ControlLoop controlLoop : controlLoopsCreate.getControlLoopList()) { - instantiationProvider.deleteControlLoop(controlLoop.getName(), controlLoop.getVersion()); - - verify(clProvider).deleteControlLoop(controlLoop.getName(), controlLoop.getVersion()); - } - } - - @Test - void testInstantiationDelete() throws Exception { - - ControlLoops controlLoops = - InstantiationUtils.getControlLoopsFromResource(CL_INSTANTIATION_CREATE_JSON, "Delete"); - - ControlLoop controlLoop0 = controlLoops.getControlLoopList().get(0); - var participantProvider = Mockito.mock(ParticipantProvider.class); - var clProvider = mock(ControlLoopProvider.class); - var supervisionHandler = mock(SupervisionHandler.class); - var commissioningProvider = mock(CommissioningProvider.class); - - var instantiationProvider = new ControlLoopInstantiationProvider(clProvider, commissioningProvider, - supervisionHandler, participantProvider); - - assertThatThrownBy( - () -> instantiationProvider.deleteControlLoop(controlLoop0.getName(), controlLoop0.getVersion())) - .hasMessageMatching(CONTROL_LOOP_NOT_FOUND); - - for (ControlLoopState state : ControlLoopState.values()) { - if (!ControlLoopState.UNINITIALISED.equals(state)) { - assertThatDeleteThrownBy(controlLoops, state); - } - } - controlLoop0.setState(ControlLoopState.UNINITIALISED); - - for (ControlLoop controlLoop : controlLoops.getControlLoopList()) { - when(clProvider.findControlLoop(controlLoop.getName(), controlLoop.getVersion())) - .thenReturn(Optional.of(controlLoop)); - when(clProvider.deleteControlLoop(controlLoop.getName(), controlLoop.getVersion())).thenReturn(controlLoop); - - instantiationProvider.deleteControlLoop(controlLoop.getName(), controlLoop.getVersion()); - } - } - - private void assertThatDeleteThrownBy(ControlLoops controlLoops, ControlLoopState state) throws Exception { - ControlLoop controlLoop = controlLoops.getControlLoopList().get(0); - controlLoop.setState(state); - var participantProvider = Mockito.mock(ParticipantProvider.class); - var clProvider = mock(ControlLoopProvider.class); - var supervisionHandler = mock(SupervisionHandler.class); - var commissioningProvider = mock(CommissioningProvider.class); - - var instantiationProvider = new ControlLoopInstantiationProvider(clProvider, commissioningProvider, - supervisionHandler, participantProvider); - - when(clProvider.findControlLoop(controlLoop.getName(), controlLoop.getVersion())) - .thenReturn(Optional.of(controlLoop)); - - assertThatThrownBy( - () -> instantiationProvider.deleteControlLoop(controlLoop.getName(), controlLoop.getVersion())) - .hasMessageMatching(String.format(DELETE_BAD_REQUEST, state)); - } - - @Test - void testCreateControlLoops_NoDuplicates() throws Exception { - var commissioningProvider = mock(CommissioningProvider.class); - - var toscaNodeTemplate1 = new ToscaNodeTemplate(); - toscaNodeTemplate1.setName("org.onap.domain.pmsh.PMSH_MonitoringPolicyControlLoopElement"); - toscaNodeTemplate1.setVersion("1.2.3"); - when(commissioningProvider.getControlLoopDefinitions(anyString(), anyString())) - .thenReturn(List.of(toscaNodeTemplate1)); - - var toscaNodeTemplate2 = new ToscaNodeTemplate(); - toscaNodeTemplate2.setName("org.onap.domain.pmsh.PMSH_OperationalPolicyControlLoopElement"); - toscaNodeTemplate2.setVersion("1.2.3"); - var toscaNodeTemplate3 = new ToscaNodeTemplate(); - toscaNodeTemplate3.setName("org.onap.domain.pmsh.PMSH_CDS_ControlLoopElement"); - toscaNodeTemplate3.setVersion("1.2.3"); - var toscaNodeTemplate4 = new ToscaNodeTemplate(); - toscaNodeTemplate4.setName("org.onap.domain.pmsh.PMSH_DCAEMicroservice"); - toscaNodeTemplate4.setVersion("1.2.3"); - - when(commissioningProvider.getControlLoopElementDefinitions(toscaNodeTemplate1)) - .thenReturn(List.of(toscaNodeTemplate1, toscaNodeTemplate2, toscaNodeTemplate3, toscaNodeTemplate4)); - - ControlLoops controlLoopsCreate = - InstantiationUtils.getControlLoopsFromResource(CL_INSTANTIATION_CREATE_JSON, "NoDuplicates"); - - var clProvider = mock(ControlLoopProvider.class); - var participantProvider = Mockito.mock(ParticipantProvider.class); - var supervisionHandler = mock(SupervisionHandler.class); - - var instantiationProvider = new ControlLoopInstantiationProvider(clProvider, commissioningProvider, - supervisionHandler, participantProvider); - - InstantiationResponse instantiationResponse = instantiationProvider.createControlLoops(controlLoopsCreate); - InstantiationUtils.assertInstantiationResponse(instantiationResponse, controlLoopsCreate); - - when(clProvider.findControlLoop(controlLoopsCreate.getControlLoopList().get(0).getKey().asIdentifier())) - .thenReturn(Optional.of(controlLoopsCreate.getControlLoopList().get(0))); - - assertThatThrownBy(() -> instantiationProvider.createControlLoops(controlLoopsCreate)).hasMessageMatching( - controlLoopsCreate.getControlLoopList().get(0).getKey().asIdentifier() + " already defined"); - } - - @Test - void testCreateControlLoops_CommissionedClElementNotFound() throws Exception { - var toscaNodeTemplate1 = new ToscaNodeTemplate(); - toscaNodeTemplate1.setName("org.onap.domain.pmsh.PMSH_MonitoringPolicyControlLoopElement"); - toscaNodeTemplate1.setVersion("1.2.3"); - - var toscaNodeTemplate2 = new ToscaNodeTemplate(); - toscaNodeTemplate2.setName("org.onap.domain.pmsh.PMSH_OperationalPolicyControlLoopElement"); - toscaNodeTemplate2.setVersion("1.2.3"); - var toscaNodeTemplate3 = new ToscaNodeTemplate(); - toscaNodeTemplate3.setName("org.onap.domain.pmsh.PMSH_CDS_ControlLoopElement"); - toscaNodeTemplate3.setVersion("1.2.3"); - var commissioningProvider = mock(CommissioningProvider.class); - ControlLoops controlLoops = InstantiationUtils - .getControlLoopsFromResource(CL_INSTANTIATION_DEFINITION_NAME_NOT_FOUND_JSON, "ClElementNotFound"); - - when(commissioningProvider.getControlLoopDefinitions( - controlLoops.getControlLoopList().get(0).getDefinition().getName(), - controlLoops.getControlLoopList().get(0).getDefinition().getVersion())) - .thenReturn(List.of(toscaNodeTemplate1)); - - when(commissioningProvider.getControlLoopElementDefinitions(toscaNodeTemplate1)) - .thenReturn(List.of(toscaNodeTemplate1, toscaNodeTemplate2, toscaNodeTemplate3)); - - var clProvider = mock(ControlLoopProvider.class); - var participantProvider = mock(ParticipantProvider.class); - var supervisionHandler = mock(SupervisionHandler.class); - var provider = new ControlLoopInstantiationProvider(clProvider, commissioningProvider, supervisionHandler, - participantProvider); - - assertThatThrownBy(() -> provider.createControlLoops(controlLoops)) - .hasMessageMatching(CONTROLLOOP_ELEMENT_NAME_NOT_FOUND); - - assertThatThrownBy(() -> provider.updateControlLoops(controlLoops)) - .hasMessageMatching(CONTROLLOOP_ELEMENT_NAME_NOT_FOUND); - } - - @Test - void testCreateControlLoops_CommissionedClNotFound() throws Exception { - ControlLoops controlLoops = InstantiationUtils - .getControlLoopsFromResource(CL_INSTANTIATION_CONTROLLOOP_DEFINITION_NOT_FOUND_JSON, "ClNotFound"); - - var participantProvider = Mockito.mock(ParticipantProvider.class); - var clProvider = mock(ControlLoopProvider.class); - var supervisionHandler = mock(SupervisionHandler.class); - var commissioningProvider = mock(CommissioningProvider.class); - var provider = new ControlLoopInstantiationProvider(clProvider, commissioningProvider, supervisionHandler, - participantProvider); - - assertThatThrownBy(() -> provider.createControlLoops(controlLoops)) - .hasMessageMatching(CONTROLLOOP_DEFINITION_NOT_FOUND); - - assertThatThrownBy(() -> provider.updateControlLoops(controlLoops)) - .hasMessageMatching(CONTROLLOOP_DEFINITION_NOT_FOUND); - } - - @Test - void testIssueControlLoopCommand_OrderedStateInvalid() throws ControlLoopRuntimeException, IOException { - var participantProvider = Mockito.mock(ParticipantProvider.class); - var clProvider = mock(ControlLoopProvider.class); - var supervisionHandler = mock(SupervisionHandler.class); - var commissioningProvider = mock(CommissioningProvider.class); - var instantiationProvider = new ControlLoopInstantiationProvider(clProvider, commissioningProvider, - supervisionHandler, participantProvider); - assertThatThrownBy(() -> instantiationProvider.issueControlLoopCommand(new InstantiationCommand())) - .hasMessageMatching(ORDERED_STATE_INVALID); - } -} diff --git a/runtime-controlloop/src/test/java/org/onap/policy/clamp/controlloop/runtime/instantiation/InstantiationUtils.java b/runtime-controlloop/src/test/java/org/onap/policy/clamp/controlloop/runtime/instantiation/InstantiationUtils.java deleted file mode 100644 index 5aa68657c..000000000 --- a/runtime-controlloop/src/test/java/org/onap/policy/clamp/controlloop/runtime/instantiation/InstantiationUtils.java +++ /dev/null @@ -1,141 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * Copyright (C) 2021 Nordix Foundation. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - * SPDX-License-Identifier: Apache-2.0 - * ============LICENSE_END========================================================= - */ - -package org.onap.policy.clamp.controlloop.runtime.instantiation; - -import static org.assertj.core.api.Assertions.assertThat; -import static org.junit.jupiter.api.Assertions.assertEquals; -import static org.junit.jupiter.api.Assertions.assertTrue; -import static org.junit.jupiter.api.Assertions.fail; - -import java.io.File; -import org.onap.policy.clamp.controlloop.models.controlloop.concepts.ControlLoop; -import org.onap.policy.clamp.controlloop.models.controlloop.concepts.ControlLoops; -import org.onap.policy.clamp.controlloop.models.messages.rest.instantiation.InstantiationCommand; -import org.onap.policy.clamp.controlloop.models.messages.rest.instantiation.InstantiationResponse; -import org.onap.policy.common.utils.coder.Coder; -import org.onap.policy.common.utils.coder.CoderException; -import org.onap.policy.common.utils.coder.StandardCoder; -import org.onap.policy.common.utils.coder.StandardYamlCoder; -import org.onap.policy.common.utils.resources.ResourceUtils; -import org.onap.policy.models.tosca.authorative.concepts.ToscaConceptIdentifier; -import org.onap.policy.models.tosca.authorative.concepts.ToscaServiceTemplate; - -/** - * Utility methods supporting tests for Instantiation. - */ -public class InstantiationUtils { - - private static final Coder CODER = new StandardCoder(); - private static final StandardYamlCoder YAML_TRANSLATOR = new StandardYamlCoder(); - - /** - * Gets the ControlLoops from Resource. - * - * @param path path of the resource - * @param suffix suffix to add to all names in ControlLoops - * @return the ControlLoops from Resource - * @throws CoderException if an error occurs - */ - public static ControlLoops getControlLoopsFromResource(final String path, final String suffix) - throws CoderException { - ControlLoops controlLoops = CODER.decode(new File(path), ControlLoops.class); - - // add suffix to all names - controlLoops.getControlLoopList().forEach(controlLoop -> controlLoop.setName(controlLoop.getName() + suffix)); - return controlLoops; - } - - /** - * Gets InstantiationCommand from Resource. - * - * @param path path of the resource - * @param suffix suffix to add to all names in ControlLoops - * @return the InstantiationCommand - * @throws CoderException if an error occurs - */ - public static InstantiationCommand getInstantiationCommandFromResource(final String path, final String suffix) - throws CoderException { - InstantiationCommand instantiationCommand = CODER.decode(new File(path), InstantiationCommand.class); - - // add suffix to all names - instantiationCommand.getControlLoopIdentifierList().forEach(cl -> cl.setName(cl.getName() + suffix)); - return instantiationCommand; - } - - /** - * Assert that Instantiation Response contains proper ControlLoops. - * - * @param response InstantiationResponse - * @param controlLoops ControlLoops - */ - public static void assertInstantiationResponse(InstantiationResponse response, ControlLoops controlLoops) { - assertThat(response).isNotNull(); - assertThat(response.getErrorDetails()).isNull(); - assertThat(response.getAffectedControlLoops().size()).isEqualTo(controlLoops.getControlLoopList().size()); - for (ControlLoop controlLoop : controlLoops.getControlLoopList()) { - assertTrue(response.getAffectedControlLoops().stream() - .filter(ac -> ac.equals(controlLoop.getKey().asIdentifier())).findAny().isPresent()); - } - } - - /** - * Assert that Instantiation Response contains proper ControlLoops. - * - * @param response InstantiationResponse - * @param command InstantiationCommand - */ - public static void assertInstantiationResponse(InstantiationResponse response, InstantiationCommand command) { - assertThat(response).isNotNull(); - assertEquals(response.getAffectedControlLoops().size(), command.getControlLoopIdentifierList().size()); - for (ToscaConceptIdentifier toscaConceptIdentifier : command.getControlLoopIdentifierList()) { - assertTrue(response.getAffectedControlLoops().stream() - .filter(ac -> ac.compareTo(toscaConceptIdentifier) == 0).findAny().isPresent()); - } - } - - /** - * Assert that Instantiation Response contains ControlLoop equals to controlLoop. - * - * @param response InstantiationResponse - * @param controlLoop ControlLoop - */ - public static void assertInstantiationResponse(InstantiationResponse response, ControlLoop controlLoop) { - assertThat(response).isNotNull(); - assertThat(response.getErrorDetails()).isNull(); - assertEquals(1, response.getAffectedControlLoops().size()); - assertEquals(0, response.getAffectedControlLoops().get(0).compareTo(controlLoop.getKey().asIdentifier())); - } - - /** - * Get ToscaServiceTemplate from resource. - * - * @param path path of the resource - */ - public static ToscaServiceTemplate getToscaServiceTemplate(String path) { - - try { - return YAML_TRANSLATOR.decode(ResourceUtils.getResourceAsStream(path), ToscaServiceTemplate.class); - } catch (CoderException e) { - fail("Cannot read or decode " + path); - return null; - } - } -} diff --git a/runtime-controlloop/src/test/java/org/onap/policy/clamp/controlloop/runtime/instantiation/rest/InstantiationControllerTest.java b/runtime-controlloop/src/test/java/org/onap/policy/clamp/controlloop/runtime/instantiation/rest/InstantiationControllerTest.java deleted file mode 100644 index 9cc0195d9..000000000 --- a/runtime-controlloop/src/test/java/org/onap/policy/clamp/controlloop/runtime/instantiation/rest/InstantiationControllerTest.java +++ /dev/null @@ -1,527 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * Copyright (C) 2021 Nordix Foundation. - * Modifications Copyright (C) 2021 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - * SPDX-License-Identifier: Apache-2.0 - * ============LICENSE_END========================================================= - */ - -package org.onap.policy.clamp.controlloop.runtime.instantiation.rest; - -import static org.assertj.core.api.Assertions.assertThat; -import static org.junit.jupiter.api.Assertions.assertEquals; -import static org.junit.jupiter.api.Assertions.assertNotNull; -import static org.junit.jupiter.api.Assertions.assertNull; - -import javax.ws.rs.client.Entity; -import javax.ws.rs.client.Invocation; -import javax.ws.rs.core.Response; -import org.junit.jupiter.api.AfterEach; -import org.junit.jupiter.api.BeforeAll; -import org.junit.jupiter.api.BeforeEach; -import org.junit.jupiter.api.Test; -import org.junit.jupiter.api.extension.ExtendWith; -import org.onap.policy.clamp.controlloop.models.controlloop.concepts.ControlLoop; -import org.onap.policy.clamp.controlloop.models.controlloop.concepts.ControlLoopOrderedState; -import org.onap.policy.clamp.controlloop.models.controlloop.concepts.ControlLoops; -import org.onap.policy.clamp.controlloop.models.controlloop.persistence.provider.ParticipantProvider; -import org.onap.policy.clamp.controlloop.models.controlloop.persistence.provider.ServiceTemplateProvider; -import org.onap.policy.clamp.controlloop.models.controlloop.persistence.repository.ControlLoopRepository; -import org.onap.policy.clamp.controlloop.models.messages.rest.instantiation.ControlLoopOrderStateResponse; -import org.onap.policy.clamp.controlloop.models.messages.rest.instantiation.ControlLoopPrimedResponse; -import org.onap.policy.clamp.controlloop.models.messages.rest.instantiation.InstancePropertiesResponse; -import org.onap.policy.clamp.controlloop.models.messages.rest.instantiation.InstantiationCommand; -import org.onap.policy.clamp.controlloop.models.messages.rest.instantiation.InstantiationResponse; -import org.onap.policy.clamp.controlloop.runtime.instantiation.ControlLoopInstantiationProvider; -import org.onap.policy.clamp.controlloop.runtime.instantiation.InstantiationUtils; -import org.onap.policy.clamp.controlloop.runtime.main.rest.InstantiationController; -import org.onap.policy.clamp.controlloop.runtime.util.CommonTestData; -import org.onap.policy.clamp.controlloop.runtime.util.rest.CommonRestController; -import org.onap.policy.models.tosca.authorative.concepts.ToscaConceptIdentifier; -import org.onap.policy.models.tosca.authorative.concepts.ToscaServiceTemplate; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.boot.test.context.SpringBootTest; -import org.springframework.boot.test.context.SpringBootTest.WebEnvironment; -import org.springframework.boot.web.server.LocalServerPort; -import org.springframework.test.context.TestPropertySource; -import org.springframework.test.context.junit.jupiter.SpringExtension; - -/** - * Class to perform unit test of {@link InstantiationController}}. - * - */ -@ExtendWith(SpringExtension.class) -@SpringBootTest(webEnvironment = WebEnvironment.RANDOM_PORT) -@TestPropertySource(locations = {"classpath:application_test.properties"}) -class InstantiationControllerTest extends CommonRestController { - - private static final String ID_NAME = "PMSH_Instance1"; - private static final String ID_VERSION = "1.2.3"; - - private static final String CL_INSTANTIATION_CREATE_JSON = "src/test/resources/rest/controlloops/ControlLoops.json"; - - private static final String CL_INSTANTIATION_UPDATE_JSON = - "src/test/resources/rest/controlloops/ControlLoopsUpdate.json"; - - private static final String CL_INSTANTIATION_CHANGE_STATE_JSON = - "src/test/resources/rest/controlloops/PassiveCommand.json"; - - private static final String TOSCA_TEMPLATE_YAML = - "src/test/resources/rest/servicetemplates/pmsh_multiple_cl_tosca.yaml"; - - private static final String INSTANTIATION_ENDPOINT = "instantiation"; - private static final String INSTANTIATION_COMMAND_ENDPOINT = "instantiation/command"; - private static final String PRIMING_ENDPOINT = "controlLoopPriming"; - private static final String INSTANTIATION_PROPERTIES = "instanceProperties"; - private static final String INSTANTIATION_STATE = "instantiationState"; - - private static ToscaServiceTemplate serviceTemplate = new ToscaServiceTemplate(); - - @Autowired - private ControlLoopRepository controlLoopRepository; - - @Autowired - private ServiceTemplateProvider serviceTemplateProvider; - - @Autowired - private ControlLoopInstantiationProvider instantiationProvider; - - @Autowired - private ParticipantProvider participantProvider; - - @LocalServerPort - private int randomServerPort; - - @BeforeAll - public static void setUpBeforeClass() throws Exception { - serviceTemplate = InstantiationUtils.getToscaServiceTemplate(TOSCA_TEMPLATE_YAML); - } - - @BeforeEach - public void populateDb() throws Exception { - createEntryInDB(); - } - - @BeforeEach - public void setUpPort() { - super.setHttpPrefix(randomServerPort); - } - - @AfterEach - public void cleanDatabase() throws Exception { - deleteEntryInDB(); - } - - @Test - void testSwagger() throws Exception { - super.testSwagger(INSTANTIATION_ENDPOINT); - } - - @Test - void testCreate_Unauthorized() throws Exception { - ControlLoops controlLoops = - InstantiationUtils.getControlLoopsFromResource(CL_INSTANTIATION_CREATE_JSON, "Unauthorized"); - - assertUnauthorizedPost(INSTANTIATION_ENDPOINT, Entity.json(controlLoops)); - } - - @Test - void testQuery_Unauthorized() throws Exception { - assertUnauthorizedGet(INSTANTIATION_ENDPOINT); - } - - @Test - void testUpdate_Unauthorized() throws Exception { - ControlLoops controlLoops = - InstantiationUtils.getControlLoopsFromResource(CL_INSTANTIATION_UPDATE_JSON, "Unauthorized"); - - assertUnauthorizedPut(INSTANTIATION_ENDPOINT, Entity.json(controlLoops)); - } - - @Test - void testDelete_Unauthorized() throws Exception { - assertUnauthorizedDelete(INSTANTIATION_ENDPOINT); - } - - @Test - void testCommand_Unauthorized() throws Exception { - InstantiationCommand instantiationCommand = InstantiationUtils - .getInstantiationCommandFromResource(CL_INSTANTIATION_CHANGE_STATE_JSON, "Unauthorized"); - - assertUnauthorizedPut(INSTANTIATION_COMMAND_ENDPOINT, Entity.json(instantiationCommand)); - } - - @Test - void testCreate() throws Exception { - - ControlLoops controlLoopsFromRsc = - InstantiationUtils.getControlLoopsFromResource(CL_INSTANTIATION_CREATE_JSON, "Create"); - - Invocation.Builder invocationBuilder = super.sendRequest(INSTANTIATION_ENDPOINT); - Response resp = invocationBuilder.post(Entity.json(controlLoopsFromRsc)); - assertEquals(Response.Status.OK.getStatusCode(), resp.getStatus()); - InstantiationResponse instResponse = resp.readEntity(InstantiationResponse.class); - InstantiationUtils.assertInstantiationResponse(instResponse, controlLoopsFromRsc); - - for (ControlLoop controlLoopFromRsc : controlLoopsFromRsc.getControlLoopList()) { - ControlLoops controlLoopsFromDb = instantiationProvider - .getControlLoops(controlLoopFromRsc.getKey().getName(), controlLoopFromRsc.getKey().getVersion()); - - assertNotNull(controlLoopsFromDb); - assertThat(controlLoopsFromDb.getControlLoopList()).hasSize(1); - assertEquals(controlLoopFromRsc, controlLoopsFromDb.getControlLoopList().get(0)); - } - - invocationBuilder = - super.sendRequest(PRIMING_ENDPOINT + "?name=" + "PMSHInstance0Create" + "&version=" + "1.0.1"); - Response rawresp = invocationBuilder.buildGet().invoke(); - assertEquals(Response.Status.OK.getStatusCode(), rawresp.getStatus()); - ControlLoopPrimedResponse primResponse = rawresp.readEntity(ControlLoopPrimedResponse.class); - assertEquals(false, primResponse.getPrimedControlLoopsList().get(0).isPrimed()); - } - - @Test - void testCreateBadRequest() throws Exception { - - ControlLoops controlLoopsFromRsc = - InstantiationUtils.getControlLoopsFromResource(CL_INSTANTIATION_CREATE_JSON, "CreateBadRequest"); - - Invocation.Builder invocationBuilder = super.sendRequest(INSTANTIATION_ENDPOINT); - Response resp = invocationBuilder.post(Entity.json(controlLoopsFromRsc)); - assertEquals(Response.Status.OK.getStatusCode(), resp.getStatus()); - - // testing Bad Request: CL already defined - resp = invocationBuilder.post(Entity.json(controlLoopsFromRsc)); - assertEquals(Response.Status.BAD_REQUEST.getStatusCode(), resp.getStatus()); - InstantiationResponse instResponse = resp.readEntity(InstantiationResponse.class); - assertNotNull(instResponse.getErrorDetails()); - assertNull(instResponse.getAffectedControlLoops()); - } - - @Test - void testQuery_NoResultWithThisName() throws Exception { - Invocation.Builder invocationBuilder = super.sendRequest(INSTANTIATION_ENDPOINT + "?name=noResultWithThisName"); - Response rawresp = invocationBuilder.buildGet().invoke(); - assertEquals(Response.Status.OK.getStatusCode(), rawresp.getStatus()); - ControlLoops resp = rawresp.readEntity(ControlLoops.class); - assertThat(resp.getControlLoopList()).isEmpty(); - } - - @Test - void testQuery() throws Exception { - - var controlLoops = InstantiationUtils.getControlLoopsFromResource(CL_INSTANTIATION_CREATE_JSON, "Query"); - instantiationProvider.createControlLoops(controlLoops); - - for (ControlLoop controlLoopFromRsc : controlLoops.getControlLoopList()) { - Invocation.Builder invocationBuilder = - super.sendRequest(INSTANTIATION_ENDPOINT + "?name=" + controlLoopFromRsc.getKey().getName()); - Response rawresp = invocationBuilder.buildGet().invoke(); - assertEquals(Response.Status.OK.getStatusCode(), rawresp.getStatus()); - ControlLoops controlLoopsQuery = rawresp.readEntity(ControlLoops.class); - assertNotNull(controlLoopsQuery); - assertThat(controlLoopsQuery.getControlLoopList()).hasSize(1); - assertEquals(controlLoopFromRsc, controlLoopsQuery.getControlLoopList().get(0)); - } - } - - @Test - void testUpdate() throws Exception { - - ControlLoops controlLoopsCreate = - InstantiationUtils.getControlLoopsFromResource(CL_INSTANTIATION_CREATE_JSON, "Update"); - - var controlLoops = InstantiationUtils.getControlLoopsFromResource(CL_INSTANTIATION_UPDATE_JSON, "Update"); - instantiationProvider.createControlLoops(controlLoopsCreate); - - Invocation.Builder invocationBuilder = super.sendRequest(INSTANTIATION_ENDPOINT); - Response resp = invocationBuilder.put(Entity.json(controlLoops)); - assertEquals(Response.Status.OK.getStatusCode(), resp.getStatus()); - - InstantiationResponse instResponse = resp.readEntity(InstantiationResponse.class); - InstantiationUtils.assertInstantiationResponse(instResponse, controlLoops); - - for (ControlLoop controlLoopUpdate : controlLoops.getControlLoopList()) { - ControlLoops controlLoopsFromDb = instantiationProvider - .getControlLoops(controlLoopUpdate.getKey().getName(), controlLoopUpdate.getKey().getVersion()); - - assertNotNull(controlLoopsFromDb); - assertThat(controlLoopsFromDb.getControlLoopList()).hasSize(1); - assertEquals(controlLoopUpdate, controlLoopsFromDb.getControlLoopList().get(0)); - } - } - - @Test - void testDelete_NoResultWithThisName() throws Exception { - Invocation.Builder invocationBuilder = - super.sendRequest(INSTANTIATION_ENDPOINT + "?name=noResultWithThisName&version=1.0.1"); - Response resp = invocationBuilder.delete(); - assertEquals(Response.Status.NOT_FOUND.getStatusCode(), resp.getStatus()); - InstantiationResponse instResponse = resp.readEntity(InstantiationResponse.class); - assertNotNull(instResponse.getErrorDetails()); - assertNull(instResponse.getAffectedControlLoops()); - } - - @Test - void testDelete() throws Exception { - - ControlLoops controlLoopsFromRsc = - InstantiationUtils.getControlLoopsFromResource(CL_INSTANTIATION_CREATE_JSON, "Delete"); - - instantiationProvider.createControlLoops(controlLoopsFromRsc); - - for (ControlLoop controlLoopFromRsc : controlLoopsFromRsc.getControlLoopList()) { - Invocation.Builder invocationBuilder = super.sendRequest(INSTANTIATION_ENDPOINT + "?name=" - + controlLoopFromRsc.getKey().getName() + "&version=" + controlLoopFromRsc.getKey().getVersion()); - Response resp = invocationBuilder.delete(); - assertEquals(Response.Status.OK.getStatusCode(), resp.getStatus()); - InstantiationResponse instResponse = resp.readEntity(InstantiationResponse.class); - InstantiationUtils.assertInstantiationResponse(instResponse, controlLoopFromRsc); - - ControlLoops controlLoopsFromDb = instantiationProvider - .getControlLoops(controlLoopFromRsc.getKey().getName(), controlLoopFromRsc.getKey().getVersion()); - assertThat(controlLoopsFromDb.getControlLoopList()).isEmpty(); - } - } - - @Test - void testDeleteBadRequest() throws Exception { - - ControlLoops controlLoopsFromRsc = - InstantiationUtils.getControlLoopsFromResource(CL_INSTANTIATION_CREATE_JSON, "DelBadRequest"); - - instantiationProvider.createControlLoops(controlLoopsFromRsc); - - for (ControlLoop controlLoopFromRsc : controlLoopsFromRsc.getControlLoopList()) { - Invocation.Builder invocationBuilder = super.sendRequest(INSTANTIATION_ENDPOINT + "?name=" - + controlLoopFromRsc.getKey().getName()); - Response resp = invocationBuilder.delete(); - assertEquals(Response.Status.BAD_REQUEST.getStatusCode(), resp.getStatus()); - } - } - - @Test - void testCreateInstanceProperties() throws Exception { - Invocation.Builder invocationBuilder = super.sendRequest(INSTANTIATION_PROPERTIES); - Response resp = invocationBuilder.post(Entity.json(serviceTemplate)); - assertEquals(Response.Status.OK.getStatusCode(), resp.getStatus()); - var instancePropertyList = resp.readEntity(InstancePropertiesResponse.class); - assertNull(instancePropertyList.getErrorDetails()); - var id = new ToscaConceptIdentifier(ID_NAME, ID_VERSION); - assertEquals(id, instancePropertyList.getAffectedInstanceProperties().get(0)); - - invocationBuilder = super.sendRequest(INSTANTIATION_ENDPOINT); - resp = invocationBuilder.get(); - assertEquals(Response.Status.OK.getStatusCode(), resp.getStatus()); - var controlLoopsGet = resp.readEntity(ControlLoops.class); - assertThat(controlLoopsGet.getControlLoopList()).hasSize(1); - } - - @Test - void testDeleteInstanceProperties() throws Exception { - Invocation.Builder invocationBuilder = super.sendRequest(INSTANTIATION_PROPERTIES); - Response resp = invocationBuilder.post(Entity.json(serviceTemplate)); - assertEquals(Response.Status.OK.getStatusCode(), resp.getStatus()); - - invocationBuilder = super.sendRequest(INSTANTIATION_PROPERTIES + "?name=" + ID_NAME + "&version=" + ID_VERSION); - resp = invocationBuilder.delete(); - assertEquals(Response.Status.OK.getStatusCode(), resp.getStatus()); - var instanceResponse = resp.readEntity(InstantiationResponse.class); - assertEquals(ID_NAME, instanceResponse.getAffectedControlLoops().get(0).getName()); - ControlLoops controlLoopsGet = instantiationProvider.getControlLoops(ID_NAME, ID_VERSION); - assertThat(controlLoopsGet.getControlLoopList()).isEmpty(); - } - - @Test - void testDeleteInstancePropertiesBadRequest() throws Exception { - Invocation.Builder invocationBuilder = super.sendRequest(INSTANTIATION_PROPERTIES); - Response resp = invocationBuilder.post(Entity.json(serviceTemplate)); - assertEquals(Response.Status.OK.getStatusCode(), resp.getStatus()); - - invocationBuilder = super.sendRequest(INSTANTIATION_PROPERTIES + "?name=" + ID_NAME); - resp = invocationBuilder.delete(); - assertEquals(Response.Status.BAD_REQUEST.getStatusCode(), resp.getStatus()); - } - - @Test - void testDeleteInstancePropertiesPassiveMode() throws Exception { - Invocation.Builder invocationBuilder = super.sendRequest(INSTANTIATION_PROPERTIES); - Response resp = invocationBuilder.post(Entity.json(serviceTemplate)); - assertEquals(Response.Status.OK.getStatusCode(), resp.getStatus()); - - var controlLoops = InstantiationUtils.getControlLoopsFromResource(CL_INSTANTIATION_CREATE_JSON, "Command"); - instantiationProvider.createControlLoops(controlLoops); - - var participants = CommonTestData.createParticipants(); - for (var participant : participants) { - participantProvider.saveParticipant(participant); - } - - InstantiationCommand command = - InstantiationUtils.getInstantiationCommandFromResource(CL_INSTANTIATION_CHANGE_STATE_JSON, "Command"); - - invocationBuilder = super.sendRequest(INSTANTIATION_COMMAND_ENDPOINT); - resp = invocationBuilder.put(Entity.json(command)); - assertEquals(Response.Status.ACCEPTED.getStatusCode(), resp.getStatus()); - InstantiationResponse instResponse = resp.readEntity(InstantiationResponse.class); - InstantiationUtils.assertInstantiationResponse(instResponse, command); - - // check passive state on DB and delete properties - for (ToscaConceptIdentifier toscaConceptIdentifier : command.getControlLoopIdentifierList()) { - ControlLoops controlLoopsGet = instantiationProvider.getControlLoops(toscaConceptIdentifier.getName(), - toscaConceptIdentifier.getVersion()); - assertThat(controlLoopsGet.getControlLoopList()).hasSize(1); - assertEquals(command.getOrderedState(), controlLoopsGet.getControlLoopList().get(0).getOrderedState()); - - invocationBuilder = super.sendRequest(INSTANTIATION_PROPERTIES + "?name=" - + toscaConceptIdentifier.getName() + "&version=" + toscaConceptIdentifier.getVersion()); - resp = invocationBuilder.delete(); - assertEquals(Response.Status.BAD_REQUEST.getStatusCode(), resp.getStatus()); - } - } - - @Test - void testCommand_NotFound1() throws Exception { - Invocation.Builder invocationBuilder = super.sendRequest(INSTANTIATION_COMMAND_ENDPOINT); - Response resp = invocationBuilder.put(Entity.json(new InstantiationCommand())); - assertEquals(Response.Status.BAD_REQUEST.getStatusCode(), resp.getStatus()); - } - - @Test - void testCommand_NotFound2() throws Exception { - InstantiationCommand command = - InstantiationUtils.getInstantiationCommandFromResource(CL_INSTANTIATION_CHANGE_STATE_JSON, "Command"); - command.setOrderedState(null); - - Invocation.Builder invocationBuilder = super.sendRequest(INSTANTIATION_COMMAND_ENDPOINT); - Response resp = invocationBuilder.put(Entity.json(command)); - assertEquals(Response.Status.BAD_REQUEST.getStatusCode(), resp.getStatus()); - } - - @Test - void testCommand() throws Exception { - var controlLoops = InstantiationUtils.getControlLoopsFromResource(CL_INSTANTIATION_CREATE_JSON, "Command"); - instantiationProvider.createControlLoops(controlLoops); - - var participants = CommonTestData.createParticipants(); - for (var participant : participants) { - participantProvider.saveParticipant(participant); - } - - InstantiationCommand command = - InstantiationUtils.getInstantiationCommandFromResource(CL_INSTANTIATION_CHANGE_STATE_JSON, "Command"); - - Invocation.Builder invocationBuilder = super.sendRequest(INSTANTIATION_COMMAND_ENDPOINT); - Response resp = invocationBuilder.put(Entity.json(command)); - assertEquals(Response.Status.ACCEPTED.getStatusCode(), resp.getStatus()); - InstantiationResponse instResponse = resp.readEntity(InstantiationResponse.class); - InstantiationUtils.assertInstantiationResponse(instResponse, command); - - // check passive state on DB - for (ToscaConceptIdentifier toscaConceptIdentifier : command.getControlLoopIdentifierList()) { - ControlLoops controlLoopsGet = instantiationProvider.getControlLoops(toscaConceptIdentifier.getName(), - toscaConceptIdentifier.getVersion()); - assertThat(controlLoopsGet.getControlLoopList()).hasSize(1); - assertEquals(command.getOrderedState(), controlLoopsGet.getControlLoopList().get(0).getOrderedState()); - } - } - - @Test - void testIntanceProperties() throws Exception { - Invocation.Builder invocationBuilder = super.sendRequest(INSTANTIATION_PROPERTIES); - Response resp = invocationBuilder.post(Entity.json(serviceTemplate)); - assertEquals(Response.Status.OK.getStatusCode(), resp.getStatus()); - var instancePropertyList = resp.readEntity(InstancePropertiesResponse.class); - assertNull(instancePropertyList.getErrorDetails()); - var id = new ToscaConceptIdentifier(ID_NAME, ID_VERSION); - assertEquals(id, instancePropertyList.getAffectedInstanceProperties().get(0)); - - invocationBuilder = super.sendRequest(INSTANTIATION_STATE + "?name=" + ID_NAME + "&version=" + ID_VERSION); - resp = invocationBuilder.buildGet().invoke(); - assertEquals(Response.Status.OK.getStatusCode(), resp.getStatus()); - var instanceOrderState = resp.readEntity(ControlLoopOrderStateResponse.class); - assertEquals(ControlLoopOrderedState.UNINITIALISED, instanceOrderState.getOrderedState()); - assertEquals(ID_NAME, instanceOrderState.getControlLoopIdentifierList().get(0).getName()); - ControlLoops controlLoopsGet = instantiationProvider.getControlLoops(ID_NAME, ID_VERSION); - assertThat(controlLoopsGet.getControlLoopList()).hasSize(1); - - invocationBuilder = super.sendRequest(INSTANTIATION_PROPERTIES + "?name=" + ID_NAME + "&version=" + ID_VERSION); - resp = invocationBuilder.delete(); - assertEquals(Response.Status.OK.getStatusCode(), resp.getStatus()); - var instanceResponse = resp.readEntity(InstantiationResponse.class); - assertEquals(ID_NAME, instanceResponse.getAffectedControlLoops().get(0).getName()); - controlLoopsGet = instantiationProvider.getControlLoops(ID_NAME, ID_VERSION); - assertThat(controlLoopsGet.getControlLoopList()).isEmpty(); - } - - @Test - void testChangeOrderStateFromUninitializedPassiveMode() throws Exception { - Invocation.Builder invocationBuilder = super.sendRequest(INSTANTIATION_PROPERTIES); - Response resp = invocationBuilder.post(Entity.json(serviceTemplate)); - assertEquals(Response.Status.OK.getStatusCode(), resp.getStatus()); - - var controlLoops = InstantiationUtils.getControlLoopsFromResource(CL_INSTANTIATION_CREATE_JSON, - "CommandPassive"); - instantiationProvider.createControlLoops(controlLoops); - - var participants = CommonTestData.createParticipants(); - for (var participant : participants) { - participantProvider.saveParticipant(participant); - } - - InstantiationCommand command = - InstantiationUtils.getInstantiationCommandFromResource(CL_INSTANTIATION_CHANGE_STATE_JSON, - "CommandPassive"); - - invocationBuilder = super.sendRequest(INSTANTIATION_COMMAND_ENDPOINT); - resp = invocationBuilder.put(Entity.json(command)); - assertEquals(Response.Status.ACCEPTED.getStatusCode(), resp.getStatus()); - InstantiationResponse instResponse = resp.readEntity(InstantiationResponse.class); - InstantiationUtils.assertInstantiationResponse(instResponse, command); - } - - @Test - void testChangeOrderStateWithoutRegisteredParticipants() throws Exception { - Invocation.Builder invocationBuilder = super.sendRequest(INSTANTIATION_PROPERTIES); - Response resp = invocationBuilder.post(Entity.json(serviceTemplate)); - assertEquals(Response.Status.OK.getStatusCode(), resp.getStatus()); - - var controlLoops = InstantiationUtils.getControlLoopsFromResource(CL_INSTANTIATION_CREATE_JSON, - "CommandPassive"); - instantiationProvider.createControlLoops(controlLoops); - - InstantiationCommand command = - InstantiationUtils.getInstantiationCommandFromResource(CL_INSTANTIATION_CHANGE_STATE_JSON, - "CommandPassive"); - - invocationBuilder = super.sendRequest(INSTANTIATION_COMMAND_ENDPOINT); - resp = invocationBuilder.put(Entity.json(command)); - assertEquals(Response.Status.BAD_REQUEST.getStatusCode(), resp.getStatus()); - } - - private synchronized void deleteEntryInDB() throws Exception { - controlLoopRepository.deleteAll(); - var list = serviceTemplateProvider.getAllServiceTemplates(); - if (!list.isEmpty()) { - serviceTemplateProvider.deleteServiceTemplate(list.get(0).getName(), list.get(0).getVersion()); - } - } - - private synchronized void createEntryInDB() throws Exception { - deleteEntryInDB(); - serviceTemplateProvider.createServiceTemplate(serviceTemplate); - } -} diff --git a/runtime-controlloop/src/test/java/org/onap/policy/clamp/controlloop/runtime/main/rest/ActuatorControllerTest.java b/runtime-controlloop/src/test/java/org/onap/policy/clamp/controlloop/runtime/main/rest/ActuatorControllerTest.java deleted file mode 100644 index 433e914ae..000000000 --- a/runtime-controlloop/src/test/java/org/onap/policy/clamp/controlloop/runtime/main/rest/ActuatorControllerTest.java +++ /dev/null @@ -1,91 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * Copyright (C) 2021 Nordix Foundation. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - * SPDX-License-Identifier: Apache-2.0 - * ============LICENSE_END========================================================= - */ - -package org.onap.policy.clamp.controlloop.runtime.main.rest; - -import static org.junit.jupiter.api.Assertions.assertEquals; - -import javax.ws.rs.client.Invocation; -import javax.ws.rs.core.Response; -import org.junit.jupiter.api.BeforeEach; -import org.junit.jupiter.api.Test; -import org.junit.jupiter.api.extension.ExtendWith; -import org.onap.policy.clamp.controlloop.runtime.util.rest.CommonRestController; -import org.springframework.boot.test.autoconfigure.actuate.metrics.AutoConfigureMetrics; -import org.springframework.boot.test.context.SpringBootTest; -import org.springframework.boot.test.context.SpringBootTest.WebEnvironment; -import org.springframework.boot.web.server.LocalServerPort; -import org.springframework.test.context.TestPropertySource; -import org.springframework.test.context.junit.jupiter.SpringExtension; - -@AutoConfigureMetrics -@ExtendWith(SpringExtension.class) -@SpringBootTest(webEnvironment = WebEnvironment.RANDOM_PORT) -@TestPropertySource(locations = {"classpath:application_test.properties"}) -class ActuatorControllerTest extends CommonRestController { - - private static final String HEALTH_ENDPOINT = "health"; - private static final String METRICS_ENDPOINT = "metrics"; - private static final String PROMETHEUS_ENDPOINT = "prometheus"; - - @LocalServerPort - private int randomServerPort; - - @BeforeEach - public void setUpPort() { - super.setHttpPrefix(randomServerPort); - } - - @Test - void testGetHealth_Unauthorized() throws Exception { - assertUnauthorizedActGet(HEALTH_ENDPOINT); - } - - @Test - void testGetMetrics_Unauthorized() throws Exception { - assertUnauthorizedActGet(METRICS_ENDPOINT); - } - - @Test - void testGetPrometheus_Unauthorized() throws Exception { - assertUnauthorizedActGet(PROMETHEUS_ENDPOINT); - } - - @Test - void testGetHealth() throws Exception { - Invocation.Builder invocationBuilder = super.sendActRequest(HEALTH_ENDPOINT); - Response rawresp = invocationBuilder.buildGet().invoke(); - assertEquals(Response.Status.OK.getStatusCode(), rawresp.getStatus()); - } - - @Test - void testGetMetrics() throws Exception { - Invocation.Builder invocationBuilder = super.sendActRequest(METRICS_ENDPOINT); - Response rawresp = invocationBuilder.buildGet().invoke(); - assertEquals(Response.Status.OK.getStatusCode(), rawresp.getStatus()); - } - - @Test - void testGePrometheus() throws Exception { - Invocation.Builder invocationBuilder = super.sendActRequest(PROMETHEUS_ENDPOINT); - Response rawresp = invocationBuilder.buildGet().invoke(); - assertEquals(Response.Status.OK.getStatusCode(), rawresp.getStatus()); - } -} diff --git a/runtime-controlloop/src/test/java/org/onap/policy/clamp/controlloop/runtime/monitoring/TestMonitoringProvider.java b/runtime-controlloop/src/test/java/org/onap/policy/clamp/controlloop/runtime/monitoring/TestMonitoringProvider.java deleted file mode 100644 index cbc4c7104..000000000 --- a/runtime-controlloop/src/test/java/org/onap/policy/clamp/controlloop/runtime/monitoring/TestMonitoringProvider.java +++ /dev/null @@ -1,319 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * Copyright (C) 2021 Nordix Foundation. - * Modifications Copyright (C) 2021 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - * SPDX-License-Identifier: Apache-2.0 - * ============LICENSE_END========================================================= - */ - -package org.onap.policy.clamp.controlloop.runtime.monitoring; - -import static org.assertj.core.api.Assertions.assertThat; -import static org.assertj.core.api.Assertions.assertThatThrownBy; -import static org.junit.jupiter.api.Assertions.assertEquals; -import static org.mockito.ArgumentMatchers.any; -import static org.mockito.ArgumentMatchers.anyMap; -import static org.mockito.ArgumentMatchers.eq; -import static org.mockito.Mockito.mock; -import static org.mockito.Mockito.when; - -import java.io.File; -import java.time.Instant; -import java.util.LinkedHashMap; -import java.util.List; -import java.util.Map; -import java.util.Optional; -import java.util.UUID; -import javax.ws.rs.core.Response; -import org.junit.jupiter.api.BeforeAll; -import org.junit.jupiter.api.Test; -import org.mockito.Mockito; -import org.onap.policy.clamp.controlloop.models.controlloop.concepts.ClElementStatisticsList; -import org.onap.policy.clamp.controlloop.models.controlloop.concepts.ControlLoop; -import org.onap.policy.clamp.controlloop.models.controlloop.concepts.ControlLoopElement; -import org.onap.policy.clamp.controlloop.models.controlloop.concepts.ParticipantStatisticsList; -import org.onap.policy.clamp.controlloop.models.controlloop.persistence.provider.ClElementStatisticsProvider; -import org.onap.policy.clamp.controlloop.models.controlloop.persistence.provider.ControlLoopProvider; -import org.onap.policy.clamp.controlloop.models.controlloop.persistence.provider.ParticipantStatisticsProvider; -import org.onap.policy.common.utils.coder.Coder; -import org.onap.policy.common.utils.coder.CoderException; -import org.onap.policy.common.utils.coder.StandardCoder; -import org.onap.policy.models.base.PfModelRuntimeException; -import org.onap.policy.models.tosca.authorative.concepts.ToscaConceptIdentifier; - -class TestMonitoringProvider { - - private static final String CL_PARTICIPANT_STATISTICS_JSON = - "src/test/resources/rest/monitoring/TestParticipantStatistics.json"; - private static final String INVALID_PARTICIPANT_JSON_INPUT = - "src/test/resources/rest/monitoring/TestParticipantStatistics_Invalid.json"; - private static final String CL_ELEMENT_STATISTICS_JSON = - "src/test/resources/rest/monitoring/TestClElementStatistics.json"; - private static final String INVALID_CL_ELEMENT_JSON_INPUT = - "src/test/resources/rest/monitoring/TestClElementStatistics_Invalid.json"; - private static final Coder CODER = new StandardCoder(); - - private static final String STAT_LIST_IS_NULL = ".*StatisticsList is marked .*ull but is null"; - private static final String PARTICIPANT_STAT_LIST_IS_NULL = - "participantStatisticsList is marked .*null but is null"; - private static final String NAME_IS_NULL = "name is marked .*null but is null"; - private static final String CL_LIST_IS_NULL = "clElementStatisticsList is marked .*null but is null"; - private static final String ID_VERSION1 = "1.001"; - private static final String ID_VERSION2 = "1.002"; - private static final String ID_NAME1 = "name1"; - private static final String ID_NAME2 = "name2"; - private static final String SORT_DESC = "DESC"; - private static final String ID_NAME3 = "testCLName"; - private static final String ID_INVALID_NAME = "invalidCLName"; - private static ParticipantStatisticsList inputParticipantStatistics; - private static ParticipantStatisticsList invalidParticipantInput; - private static ClElementStatisticsList inputClElementStatistics; - private static ClElementStatisticsList invalidClElementInput; - - @BeforeAll - public static void beforeSetupStatistics() throws CoderException { - // Reading input json for statistics data - inputParticipantStatistics = - CODER.decode(new File(CL_PARTICIPANT_STATISTICS_JSON), ParticipantStatisticsList.class); - invalidParticipantInput = - CODER.decode(new File(INVALID_PARTICIPANT_JSON_INPUT), ParticipantStatisticsList.class); - inputClElementStatistics = CODER.decode(new File(CL_ELEMENT_STATISTICS_JSON), ClElementStatisticsList.class); - invalidClElementInput = CODER.decode(new File(INVALID_CL_ELEMENT_JSON_INPUT), ClElementStatisticsList.class); - } - - @Test - void testCreateParticipantStatistics() throws Exception { - var participantStatisticsProvider = mock(ParticipantStatisticsProvider.class); - var clElementStatisticsProvider = mock(ClElementStatisticsProvider.class); - var clProvider = mock(ControlLoopProvider.class); - MonitoringProvider provider = - new MonitoringProvider(participantStatisticsProvider, clElementStatisticsProvider, clProvider); - - when(participantStatisticsProvider.createParticipantStatistics(any())) - .thenReturn(inputParticipantStatistics.getStatisticsList()); - - when(participantStatisticsProvider.createParticipantStatistics(eq(null))) - .thenThrow(new PfModelRuntimeException(Response.Status.BAD_REQUEST, PARTICIPANT_STAT_LIST_IS_NULL)); - - // Creating statistics data in db with null input - - assertThatThrownBy(() -> { - provider.createParticipantStatistics(null); - }).hasMessageMatching(STAT_LIST_IS_NULL); - - assertThatThrownBy(() -> { - provider.createParticipantStatistics(invalidParticipantInput.getStatisticsList()); - }).hasMessageMatching(PARTICIPANT_STAT_LIST_IS_NULL); - - // Creating statistics data from input json - ParticipantStatisticsList createResponse = - provider.createParticipantStatistics(inputParticipantStatistics.getStatisticsList()); - - assertThat(createResponse.getStatisticsList()).hasSize(3); - assertEquals(createResponse.getStatisticsList().toString().replaceAll("\\s+", ""), - inputParticipantStatistics.getStatisticsList().toString().replaceAll("\\s+", "")); - } - - @Test - void testGetParticipantStatistics() throws Exception { - var participantStatisticsProvider = mock(ParticipantStatisticsProvider.class); - when(participantStatisticsProvider.getFilteredParticipantStatistics(eq(ID_NAME1), any(), any(), any(), eq(null), - eq(SORT_DESC), eq(0))).thenReturn(List.of(inputParticipantStatistics.getStatisticsList().get(0))); - - when(participantStatisticsProvider.getFilteredParticipantStatistics(eq(ID_NAME1), any(), - eq(Instant.parse("2021-01-11T12:00:00.000Z")), eq(Instant.parse("2021-01-11T16:00:00.000Z")), eq(null), - eq(SORT_DESC), eq(0))).thenReturn(List.of()); - - when(participantStatisticsProvider.getFilteredParticipantStatistics(eq(ID_NAME2), any(), any(), any(), eq(null), - eq(SORT_DESC), eq(1))).thenReturn(List.of(inputParticipantStatistics.getStatisticsList().get(2))); - - var clProvider = mock(ControlLoopProvider.class); - var clElementStatisticsProvider = mock(ClElementStatisticsProvider.class); - MonitoringProvider provider = - new MonitoringProvider(participantStatisticsProvider, clElementStatisticsProvider, clProvider); - provider.createParticipantStatistics(inputParticipantStatistics.getStatisticsList()); - - assertThatThrownBy(() -> { - provider.fetchFilteredParticipantStatistics(null, null, 0, null, null); - }).hasMessageMatching(NAME_IS_NULL); - - // Fetch specific statistics record with name, version and record count - ParticipantStatisticsList getResponse = - provider.fetchFilteredParticipantStatistics(ID_NAME2, ID_VERSION1, 1, null, null); - assertThat(getResponse.getStatisticsList()).hasSize(1); - assertEquals(getResponse.getStatisticsList().get(0).toString().replaceAll("\\s+", ""), - inputParticipantStatistics.getStatisticsList().get(2).toString().replaceAll("\\s+", "")); - - // Fetch statistics using timestamp - getResponse = provider.fetchFilteredParticipantStatistics(ID_NAME1, ID_VERSION1, 0, null, - Instant.parse("2021-01-10T15:00:00.000Z")); - assertThat(getResponse.getStatisticsList()).hasSize(1); - - getResponse = provider.fetchFilteredParticipantStatistics(ID_NAME1, ID_VERSION1, 0, - Instant.parse("2021-01-11T12:00:00.000Z"), Instant.parse("2021-01-11T16:00:00.000Z")); - - assertThat(getResponse.getStatisticsList()).isEmpty(); - } - - @Test - void testCreateClElementStatistics() throws Exception { - var clElementStatisticsProvider = mock(ClElementStatisticsProvider.class); - when(clElementStatisticsProvider.createClElementStatistics(any())) - .thenReturn(inputClElementStatistics.getClElementStatistics()); - - when(clElementStatisticsProvider.createClElementStatistics(eq(null))) - .thenThrow(new PfModelRuntimeException(Response.Status.BAD_REQUEST, CL_LIST_IS_NULL)); - - var clProvider = mock(ControlLoopProvider.class); - - var participantStatisticsProvider = mock(ParticipantStatisticsProvider.class); - MonitoringProvider provider = - new MonitoringProvider(participantStatisticsProvider, clElementStatisticsProvider, clProvider); - // Creating statistics data in db with null input - assertThatThrownBy(() -> { - provider.createClElementStatistics(null); - }).hasMessageMatching(STAT_LIST_IS_NULL); - - assertThatThrownBy(() -> { - provider.createClElementStatistics(invalidClElementInput.getClElementStatistics()); - }).hasMessageMatching(CL_LIST_IS_NULL); - - // Creating clElement statistics data from input json - ClElementStatisticsList createResponse = - provider.createClElementStatistics(inputClElementStatistics.getClElementStatistics()); - - assertThat(createResponse.getClElementStatistics()).hasSize(4); - assertEquals(createResponse.getClElementStatistics().toString().replaceAll("\\s+", ""), - inputClElementStatistics.getClElementStatistics().toString().replaceAll("\\s+", "")); - } - - @Test - void testGetClElementStatistics() throws Exception { - var participantStatisticsProvider = mock(ParticipantStatisticsProvider.class); - var clElementStatisticsProvider = mock(ClElementStatisticsProvider.class); - var clProvider = mock(ControlLoopProvider.class); - - when(clElementStatisticsProvider.getFilteredClElementStatistics(eq(ID_NAME1), any(), any(), any(), anyMap(), - eq(SORT_DESC), eq(0))) - .thenReturn(List.of(inputClElementStatistics.getClElementStatistics().get(0), - inputClElementStatistics.getClElementStatistics().get(1))); - - when(clElementStatisticsProvider.getFilteredClElementStatistics(eq(ID_NAME1), any(), any(), any(), anyMap(), - eq(SORT_DESC), eq(0))) - .thenReturn(List.of(inputClElementStatistics.getClElementStatistics().get(0), - inputClElementStatistics.getClElementStatistics().get(1))); - - MonitoringProvider provider = - new MonitoringProvider(participantStatisticsProvider, clElementStatisticsProvider, clProvider); - assertThatThrownBy(() -> { - provider.fetchFilteredClElementStatistics(null, null, null, null, null, 0); - }).hasMessageMatching(NAME_IS_NULL); - - provider.createClElementStatistics(inputClElementStatistics.getClElementStatistics()); - - ClElementStatisticsList getResponse = - provider.fetchFilteredClElementStatistics(ID_NAME1, null, null, null, null, 0); - - assertThat(getResponse.getClElementStatistics()).hasSize(2); - assertEquals(getResponse.getClElementStatistics().get(0).toString().replaceAll("\\s+", ""), - inputClElementStatistics.getClElementStatistics().get(0).toString().replaceAll("\\s+", "")); - - // Fetch specific statistics record with name, id and record count - getResponse = provider.fetchFilteredClElementStatistics(ID_NAME1, ID_VERSION1, - "709c62b3-8918-41b9-a747-d21eb79c6c20", null, null, 0); - assertThat(getResponse.getClElementStatistics()).hasSize(2); - - // Fetch statistics using timestamp - getResponse = provider.fetchFilteredClElementStatistics(ID_NAME1, ID_VERSION1, null, - Instant.parse("2021-01-10T13:45:00.000Z"), null, 0); - assertThat(getResponse.getClElementStatistics()).hasSize(2); - } - - @Test - void testGetParticipantStatsPerCL() throws Exception { - var participantStatisticsProvider = mock(ParticipantStatisticsProvider.class); - var clElementStatisticsProvider = mock(ClElementStatisticsProvider.class); - var mockClProvider = Mockito.mock(ControlLoopProvider.class); - var provider = - new MonitoringProvider(participantStatisticsProvider, clElementStatisticsProvider, mockClProvider); - - provider.createParticipantStatistics(inputParticipantStatistics.getStatisticsList()); - - var controlLoop = new ControlLoop(); - var element = new ControlLoopElement(); - element.setParticipantId(new ToscaConceptIdentifier(ID_NAME1, ID_VERSION1)); - controlLoop.setElements(Map.of(UUID.randomUUID(), element)); - when(mockClProvider.findControlLoop(new ToscaConceptIdentifier(ID_NAME2, ID_VERSION1))) - .thenReturn(Optional.of(controlLoop)); - - when(participantStatisticsProvider.getFilteredParticipantStatistics(eq(ID_NAME1), eq(ID_VERSION1), any(), any(), - eq(null), eq(SORT_DESC), eq(0))) - .thenReturn(List.of(inputParticipantStatistics.getStatisticsList().get(0), - inputParticipantStatistics.getStatisticsList().get(1))); - - ParticipantStatisticsList getResponse = provider.fetchParticipantStatsPerControlLoop(ID_NAME2, ID_VERSION1); - assertThat(getResponse.getStatisticsList()).hasSize(2); - assertEquals(getResponse.getStatisticsList().get(0).toString().replaceAll("\\s+", ""), - inputParticipantStatistics.getStatisticsList().get(0).toString().replaceAll("\\s+", "")); - assertThat(provider.fetchParticipantStatsPerControlLoop(ID_INVALID_NAME, ID_VERSION2).getStatisticsList()) - .isEmpty(); - } - - @Test - void testClElementStatsPerCL() throws Exception { - // Setup a dummy Control loop data - var mockClElement = new ControlLoopElement(); - mockClElement.setId(inputClElementStatistics.getClElementStatistics().get(0).getId()); - mockClElement.setParticipantId(new ToscaConceptIdentifier( - inputClElementStatistics.getClElementStatistics().get(0).getParticipantId().getName(), - inputClElementStatistics.getClElementStatistics().get(0).getParticipantId().getVersion())); - var mockCL = new ControlLoop(); - mockCL.setElements(new LinkedHashMap<>()); - mockCL.getElements().put(mockClElement.getId(), mockClElement); - - var participantStatisticsProvider = mock(ParticipantStatisticsProvider.class); - var clElementStatisticsProvider = mock(ClElementStatisticsProvider.class); - var mockClProvider = Mockito.mock(ControlLoopProvider.class); - var monitoringProvider = - new MonitoringProvider(participantStatisticsProvider, clElementStatisticsProvider, mockClProvider); - - // Mock controlloop data to be returned for the given CL Id - when(mockClProvider.findControlLoop(new ToscaConceptIdentifier(ID_NAME3, ID_VERSION1))) - .thenReturn(Optional.of(mockCL)); - - when(clElementStatisticsProvider.getFilteredClElementStatistics(eq(ID_NAME1), eq(ID_VERSION1), any(), any(), - anyMap(), eq(SORT_DESC), eq(0))) - .thenReturn(List.of(inputClElementStatistics.getClElementStatistics().get(0), - inputClElementStatistics.getClElementStatistics().get(1))); - - monitoringProvider.createClElementStatistics(inputClElementStatistics.getClElementStatistics()); - - ClElementStatisticsList getResponse = - monitoringProvider.fetchClElementStatsPerControlLoop(ID_NAME3, ID_VERSION1); - - assertThat(getResponse.getClElementStatistics()).hasSize(2); - assertEquals(getResponse.getClElementStatistics().get(1).toString().replaceAll("\\s+", ""), - inputClElementStatistics.getClElementStatistics().get(1).toString().replaceAll("\\s+", "")); - - assertThat(monitoringProvider.fetchClElementStatsPerControlLoop(ID_INVALID_NAME, ID_VERSION2) - .getClElementStatistics()).isEmpty(); - - Map clElementIds = - monitoringProvider.getAllClElementsIdPerControlLoop(ID_NAME3, ID_VERSION1); - assertThat(clElementIds) - .containsKey(inputClElementStatistics.getClElementStatistics().get(0).getId().toString()); - } -} diff --git a/runtime-controlloop/src/test/java/org/onap/policy/clamp/controlloop/runtime/monitoring/rest/MonitoringQueryControllerTest.java b/runtime-controlloop/src/test/java/org/onap/policy/clamp/controlloop/runtime/monitoring/rest/MonitoringQueryControllerTest.java deleted file mode 100644 index eaf824623..000000000 --- a/runtime-controlloop/src/test/java/org/onap/policy/clamp/controlloop/runtime/monitoring/rest/MonitoringQueryControllerTest.java +++ /dev/null @@ -1,242 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * Copyright (C) 2021 Nordix Foundation. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - * SPDX-License-Identifier: Apache-2.0 - * ============LICENSE_END========================================================= - */ - -package org.onap.policy.clamp.controlloop.runtime.monitoring.rest; - -import static org.assertj.core.api.Assertions.assertThat; -import static org.junit.jupiter.api.Assertions.assertEquals; -import static org.junit.jupiter.api.Assertions.assertNotNull; - -import java.io.File; -import java.time.Instant; -import javax.ws.rs.client.Invocation; -import javax.ws.rs.core.Response; -import org.junit.jupiter.api.BeforeAll; -import org.junit.jupiter.api.BeforeEach; -import org.junit.jupiter.api.Test; -import org.junit.jupiter.api.extension.ExtendWith; -import org.onap.policy.clamp.controlloop.models.controlloop.concepts.ClElementStatisticsList; -import org.onap.policy.clamp.controlloop.models.controlloop.concepts.ParticipantStatisticsList; -import org.onap.policy.clamp.controlloop.runtime.monitoring.MonitoringProvider; -import org.onap.policy.clamp.controlloop.runtime.util.rest.CommonRestController; -import org.onap.policy.common.utils.coder.Coder; -import org.onap.policy.common.utils.coder.StandardCoder; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.boot.test.context.SpringBootTest; -import org.springframework.boot.test.context.SpringBootTest.WebEnvironment; -import org.springframework.boot.web.server.LocalServerPort; -import org.springframework.test.context.TestPropertySource; -import org.springframework.test.context.junit.jupiter.SpringExtension; - -@ExtendWith(SpringExtension.class) -@SpringBootTest(webEnvironment = WebEnvironment.RANDOM_PORT) -@TestPropertySource(locations = {"classpath:application_test.properties"}) -class MonitoringQueryControllerTest extends CommonRestController { - - private static final String CL_PARTICIPANT_STATISTICS_JSON = - "src/test/resources/rest/monitoring/TestParticipantStatistics.json"; - private static final String CL_ELEMENT_STATISTICS_JSON = - "src/test/resources/rest/monitoring/TestClElementStatistics.json"; - - private static final Coder CODER = new StandardCoder(); - - private static ParticipantStatisticsList inputParticipantStatistics; - private static ClElementStatisticsList inputClElementStatistics; - - private static ParticipantStatisticsList participantStatisticsList; - private static ClElementStatisticsList clElementStatisticsList; - - private static final String CLELEMENT_STATS_ENDPOINT = "monitoring/clelement"; - private static final String PARTICIPANT_STATS_ENDPOINT = "monitoring/participant"; - private static final String PARTICIPANT_STATS_PER_CL_ENDPOINT = "monitoring/participants/controlloop"; - private static final String CLELEMENT_STATS_PER_CL_ENDPOINT = "monitoring/clelements/controlloop"; - - @Autowired - private MonitoringProvider monitoringProvider; - - @LocalServerPort - private int randomServerPort; - - /** - * starts Main. - * - * @throws Exception if an error occurs - */ - @BeforeAll - public static void setUpBeforeAll() throws Exception { - - inputParticipantStatistics = - CODER.decode(new File(CL_PARTICIPANT_STATISTICS_JSON), ParticipantStatisticsList.class); - inputClElementStatistics = CODER.decode(new File(CL_ELEMENT_STATISTICS_JSON), ClElementStatisticsList.class); - } - - @BeforeEach - public void setUpBeforeEach() throws Exception { - super.setHttpPrefix(randomServerPort); - - // Insert Participant statistics to DB - participantStatisticsList = - monitoringProvider.createParticipantStatistics(inputParticipantStatistics.getStatisticsList()); - // Insert CL Element statistics to DB - clElementStatisticsList = - monitoringProvider.createClElementStatistics(inputClElementStatistics.getClElementStatistics()); - } - - @Test - void testQuery_Unauthorized_for_ClElementStats() throws Exception { - assertUnauthorizedGet(CLELEMENT_STATS_ENDPOINT); - } - - @Test - void testQuery_Unauthorized_for_ClParticipantStats() throws Exception { - assertUnauthorizedGet(PARTICIPANT_STATS_ENDPOINT); - } - - @Test - void testQuery_Unauthorized_for_ParticipantStatsPerCl() throws Exception { - assertUnauthorizedGet(PARTICIPANT_STATS_PER_CL_ENDPOINT); - } - - @Test - void testQuery_Unauthorized_for_ClElementStatsPerCl() throws Exception { - assertUnauthorizedGet(CLELEMENT_STATS_PER_CL_ENDPOINT); - } - - @Test - void testSwagger_ClStats() throws Exception { - super.testSwagger(CLELEMENT_STATS_ENDPOINT); - super.testSwagger(PARTICIPANT_STATS_ENDPOINT); - super.testSwagger(CLELEMENT_STATS_PER_CL_ENDPOINT); - super.testSwagger(PARTICIPANT_STATS_PER_CL_ENDPOINT); - } - - @Test - void testClElementStatisticsEndpoint() throws Exception { - // Filter statistics only based on participant Id and UUID - Invocation.Builder invokeRequest1 = super.sendRequest(CLELEMENT_STATS_ENDPOINT + "?name=" - + clElementStatisticsList.getClElementStatistics().get(0).getParticipantId().getName() + "&version=" - + clElementStatisticsList.getClElementStatistics().get(0).getParticipantId().getVersion() + "&id=" - + clElementStatisticsList.getClElementStatistics().get(0).getId().toString()); - Response response1 = invokeRequest1.buildGet().invoke(); - assertEquals(Response.Status.OK.getStatusCode(), response1.getStatus()); - - ClElementStatisticsList result1 = response1.readEntity(ClElementStatisticsList.class); - - assertNotNull(result1); - assertThat(result1.getClElementStatistics()).hasSize(2); - - var clElementStat0 = clElementStatisticsList.getClElementStatistics().get(0); - for (var clElement : result1.getClElementStatistics()) { - assertEquals(clElement.getParticipantId().asConceptKey(), clElementStat0.getParticipantId().asConceptKey()); - assertEquals(clElement.getId(), clElementStat0.getId()); - } - - // Filter statistics based on timestamp - Invocation.Builder invokeRequest2 = super.sendRequest(CLELEMENT_STATS_ENDPOINT + "?name=" - + clElementStatisticsList.getClElementStatistics().get(1).getParticipantId().getName() + "&version=" - + clElementStatisticsList.getClElementStatistics().get(1).getParticipantId().getVersion() - + "&startTime=" + Instant.parse("2021-01-10T13:00:00.000Z") + "&endTime=" - + Instant.parse("2021-01-10T14:00:00.000Z")); - Response response2 = invokeRequest2.buildGet().invoke(); - assertEquals(Response.Status.OK.getStatusCode(), response2.getStatus()); - ClElementStatisticsList result2 = response2.readEntity(ClElementStatisticsList.class); - - assertNotNull(result2); - assertThat(result2.getClElementStatistics()).hasSize(1); - assertEquals(result2.getClElementStatistics().get(0), clElementStat0); - } - - @Test - void testClElementStats_BadRequest() throws Exception { - Invocation.Builder invokeRequest1 = super.sendRequest(CLELEMENT_STATS_ENDPOINT + "?version=1.0.0"); - Response response1 = invokeRequest1.buildGet().invoke(); - assertEquals(Response.Status.INTERNAL_SERVER_ERROR.getStatusCode(), response1.getStatus()); - } - - @Test - void testParticipantStatisticsEndpoint() throws Exception { - - // Filter statistics only based on participant Id - Invocation.Builder invokeRequest1 = super.sendRequest(PARTICIPANT_STATS_ENDPOINT + "?name=" - + participantStatisticsList.getStatisticsList().get(0).getParticipantId().getName() + "&version=" - + participantStatisticsList.getStatisticsList().get(0).getParticipantId().getVersion()); - Response response1 = invokeRequest1.buildGet().invoke(); - assertEquals(Response.Status.OK.getStatusCode(), response1.getStatus()); - ParticipantStatisticsList result1 = response1.readEntity(ParticipantStatisticsList.class); - - assertNotNull(result1); - assertThat(result1.getStatisticsList()).hasSize(2); - assertThat(result1.getStatisticsList()).contains(participantStatisticsList.getStatisticsList().get(0)); - - // Filter statistics based on timestamp - Invocation.Builder invokeRequest2 = super.sendRequest(PARTICIPANT_STATS_ENDPOINT + "?name=" - + participantStatisticsList.getStatisticsList().get(1).getParticipantId().getName() + "&version=" - + participantStatisticsList.getStatisticsList().get(1).getParticipantId().getVersion() + "&startTime=" - + Instant.parse("2021-01-10T13:00:00.000Z") + "&endTime=" + Instant.parse("2021-01-10T14:00:00.000Z")); - Response response2 = invokeRequest2.buildGet().invoke(); - assertEquals(Response.Status.OK.getStatusCode(), response2.getStatus()); - ParticipantStatisticsList result2 = response2.readEntity(ParticipantStatisticsList.class); - - assertNotNull(result2); - assertThat(result2.getStatisticsList()).hasSize(1); - assertEquals(result2.getStatisticsList().get(0), participantStatisticsList.getStatisticsList().get(0)); - } - - @Test - void testParticipantStats_BadRequest() throws Exception { - Invocation.Builder invokeRequest1 = super.sendRequest(PARTICIPANT_STATS_ENDPOINT + "?version=0.0"); - Response response1 = invokeRequest1.buildGet().invoke(); - assertEquals(Response.Status.INTERNAL_SERVER_ERROR.getStatusCode(), response1.getStatus()); - } - - @Test - void testParticipantStatsPerClEndpoint() throws Exception { - Invocation.Builder invokeRequest1 = - super.sendRequest(PARTICIPANT_STATS_PER_CL_ENDPOINT + "?name=dummyName&version=1.001"); - Response response1 = invokeRequest1.buildGet().invoke(); - assertEquals(Response.Status.OK.getStatusCode(), response1.getStatus()); - ParticipantStatisticsList result1 = response1.readEntity(ParticipantStatisticsList.class); - assertThat(result1.getStatisticsList()).isEmpty(); - } - - @Test - void testParticipantStatsPerCl_BadRequest() throws Exception { - Invocation.Builder invokeRequest1 = super.sendRequest(PARTICIPANT_STATS_PER_CL_ENDPOINT); - Response response1 = invokeRequest1.buildGet().invoke(); - assertEquals(Response.Status.INTERNAL_SERVER_ERROR.getStatusCode(), response1.getStatus()); - } - - @Test - void testClElementStatisticsPerClEndpoint() throws Exception { - Invocation.Builder invokeRequest1 = - super.sendRequest(CLELEMENT_STATS_PER_CL_ENDPOINT + "?name=dummyName&version=1.001"); - Response response1 = invokeRequest1.buildGet().invoke(); - assertEquals(Response.Status.OK.getStatusCode(), response1.getStatus()); - ClElementStatisticsList result1 = response1.readEntity(ClElementStatisticsList.class); - assertThat(result1.getClElementStatistics()).isEmpty(); - } - - @Test - void testClElementStatsPerCl_BadRequest() throws Exception { - Invocation.Builder invokeRequest1 = super.sendRequest(CLELEMENT_STATS_PER_CL_ENDPOINT); - Response response1 = invokeRequest1.buildGet().invoke(); - assertEquals(Response.Status.INTERNAL_SERVER_ERROR.getStatusCode(), response1.getStatus()); - } -} diff --git a/runtime-controlloop/src/test/java/org/onap/policy/clamp/controlloop/runtime/supervision/HandleCounterTest.java b/runtime-controlloop/src/test/java/org/onap/policy/clamp/controlloop/runtime/supervision/HandleCounterTest.java deleted file mode 100644 index 51f3b4a32..000000000 --- a/runtime-controlloop/src/test/java/org/onap/policy/clamp/controlloop/runtime/supervision/HandleCounterTest.java +++ /dev/null @@ -1,84 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * Copyright (C) 2021 Nordix Foundation. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - * SPDX-License-Identifier: Apache-2.0 - * ============LICENSE_END========================================================= - */ - -package org.onap.policy.clamp.controlloop.runtime.supervision; - -import static org.assertj.core.api.Assertions.assertThat; - -import org.junit.jupiter.api.Test; - -class HandleCounterTest { - - private static final int ID = 1; - - @Test - void testCount() { - var handleCounter = new HandleCounter(); - handleCounter.setMaxRetryCount(2); - assertThat(handleCounter.count(ID)).isTrue(); - assertThat(handleCounter.getCounter(ID)).isEqualTo(1); - assertThat(handleCounter.count(ID)).isTrue(); - assertThat(handleCounter.getCounter(ID)).isEqualTo(2); - assertThat(handleCounter.count(ID)).isFalse(); - assertThat(handleCounter.getCounter(ID)).isEqualTo(2); - - handleCounter.clear(ID); - assertThat(handleCounter.count(ID)).isTrue(); - assertThat(handleCounter.getCounter(ID)).isEqualTo(1); - } - - @Test - void testFault() { - var handleCounter = new HandleCounter(); - handleCounter.setFault(ID); - assertThat(handleCounter.isFault(ID)).isTrue(); - handleCounter.clear(ID); - assertThat(handleCounter.isFault(ID)).isFalse(); - } - - @Test - void testDuration() throws InterruptedException { - - var handleCounter = new HandleCounter() { - long epochMilli = 0; - - @Override - protected long getEpochMilli() { - return epochMilli; - } - }; - handleCounter.epochMilli = 100; - var result = handleCounter.getDuration(ID); - assertThat(result).isZero(); - - handleCounter.epochMilli += 100; - result = handleCounter.getDuration(ID); - assertThat(result).isEqualTo(100); - - handleCounter.epochMilli += 100; - result = handleCounter.getDuration(ID); - assertThat(result).isEqualTo(200); - - handleCounter.epochMilli += 100; - handleCounter.clear(ID); - result = handleCounter.getDuration(ID); - assertThat(result).isZero(); - } -} diff --git a/runtime-controlloop/src/test/java/org/onap/policy/clamp/controlloop/runtime/supervision/SupervisionAspectTest.java b/runtime-controlloop/src/test/java/org/onap/policy/clamp/controlloop/runtime/supervision/SupervisionAspectTest.java deleted file mode 100644 index f5ab9f28d..000000000 --- a/runtime-controlloop/src/test/java/org/onap/policy/clamp/controlloop/runtime/supervision/SupervisionAspectTest.java +++ /dev/null @@ -1,66 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * Copyright (C) 2021 Nordix Foundation. - * Modifications Copyright (C) 2021 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - * SPDX-License-Identifier: Apache-2.0 - * ============LICENSE_END========================================================= - */ - -package org.onap.policy.clamp.controlloop.runtime.supervision; - -import static org.mockito.Mockito.mock; -import static org.mockito.Mockito.spy; -import static org.mockito.Mockito.timeout; -import static org.mockito.Mockito.verify; - -import org.junit.jupiter.api.Test; -import org.onap.policy.clamp.controlloop.models.messages.dmaap.participant.ParticipantStatus; -import org.onap.policy.models.tosca.authorative.concepts.ToscaConceptIdentifier; - -class SupervisionAspectTest { - - @Test - void testSchedule() throws Exception { - var supervisionScanner = spy(mock(SupervisionScanner.class)); - try (var supervisionAspect = new SupervisionAspect(supervisionScanner)) { - supervisionAspect.schedule(); - verify(supervisionScanner, timeout(500)).run(true); - } - } - - @Test - void testDoCheck() throws Exception { - var supervisionScanner = spy(mock(SupervisionScanner.class)); - try (var supervisionAspect = new SupervisionAspect(supervisionScanner)) { - supervisionAspect.doCheck(); - supervisionAspect.doCheck(); - verify(supervisionScanner, timeout(500).times(2)).run(false); - } - } - - @Test - void testHandleParticipantStatus() throws Exception { - var supervisionScanner = spy(mock(SupervisionScanner.class)); - var participantStatusMessage = new ParticipantStatus(); - var identifier = new ToscaConceptIdentifier("abc", "1.0.0"); - participantStatusMessage.setParticipantId(identifier); - - try (var supervisionAspect = new SupervisionAspect(supervisionScanner)) { - supervisionAspect.handleParticipantStatus(participantStatusMessage); - verify(supervisionScanner, timeout(500)).handleParticipantStatus(identifier); - } - } -} diff --git a/runtime-controlloop/src/test/java/org/onap/policy/clamp/controlloop/runtime/supervision/SupervisionHandlerTest.java b/runtime-controlloop/src/test/java/org/onap/policy/clamp/controlloop/runtime/supervision/SupervisionHandlerTest.java deleted file mode 100644 index 21a826743..000000000 --- a/runtime-controlloop/src/test/java/org/onap/policy/clamp/controlloop/runtime/supervision/SupervisionHandlerTest.java +++ /dev/null @@ -1,307 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * Copyright (C) 2021 Nordix Foundation. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - * SPDX-License-Identifier: Apache-2.0 - * ============LICENSE_END========================================================= - */ - -package org.onap.policy.clamp.controlloop.runtime.supervision; - -import static org.assertj.core.api.Assertions.assertThatThrownBy; -import static org.mockito.ArgumentMatchers.any; -import static org.mockito.ArgumentMatchers.anyList; -import static org.mockito.Mockito.mock; -import static org.mockito.Mockito.verify; -import static org.mockito.Mockito.when; - -import java.util.List; -import java.util.Map; -import java.util.Optional; -import java.util.UUID; -import org.junit.jupiter.api.Test; -import org.mockito.Mockito; -import org.onap.policy.clamp.controlloop.common.exception.ControlLoopException; -import org.onap.policy.clamp.controlloop.models.controlloop.concepts.ControlLoop; -import org.onap.policy.clamp.controlloop.models.controlloop.concepts.ControlLoopOrderedState; -import org.onap.policy.clamp.controlloop.models.controlloop.concepts.Participant; -import org.onap.policy.clamp.controlloop.models.controlloop.concepts.ParticipantHealthStatus; -import org.onap.policy.clamp.controlloop.models.controlloop.concepts.ParticipantState; -import org.onap.policy.clamp.controlloop.models.controlloop.concepts.ParticipantStatistics; -import org.onap.policy.clamp.controlloop.models.controlloop.persistence.provider.ControlLoopProvider; -import org.onap.policy.clamp.controlloop.models.controlloop.persistence.provider.ParticipantProvider; -import org.onap.policy.clamp.controlloop.models.controlloop.persistence.provider.ServiceTemplateProvider; -import org.onap.policy.clamp.controlloop.models.messages.dmaap.participant.ControlLoopAck; -import org.onap.policy.clamp.controlloop.models.messages.dmaap.participant.ParticipantDeregister; -import org.onap.policy.clamp.controlloop.models.messages.dmaap.participant.ParticipantMessageType; -import org.onap.policy.clamp.controlloop.models.messages.dmaap.participant.ParticipantRegister; -import org.onap.policy.clamp.controlloop.models.messages.dmaap.participant.ParticipantStatus; -import org.onap.policy.clamp.controlloop.models.messages.dmaap.participant.ParticipantUpdateAck; -import org.onap.policy.clamp.controlloop.runtime.instantiation.InstantiationUtils; -import org.onap.policy.clamp.controlloop.runtime.monitoring.MonitoringProvider; -import org.onap.policy.clamp.controlloop.runtime.supervision.comm.ControlLoopStateChangePublisher; -import org.onap.policy.clamp.controlloop.runtime.supervision.comm.ControlLoopUpdatePublisher; -import org.onap.policy.clamp.controlloop.runtime.supervision.comm.ParticipantDeregisterAckPublisher; -import org.onap.policy.clamp.controlloop.runtime.supervision.comm.ParticipantRegisterAckPublisher; -import org.onap.policy.clamp.controlloop.runtime.supervision.comm.ParticipantUpdatePublisher; -import org.onap.policy.common.utils.coder.CoderException; -import org.onap.policy.models.base.PfModelException; -import org.onap.policy.models.tosca.authorative.concepts.ToscaConceptIdentifier; - -class SupervisionHandlerTest { - private static final String TOSCA_TEMPLATE_YAML = - "src/test/resources/rest/servicetemplates/tosca-for-smoke-testing.yaml"; - private static final String CL_INSTANTIATION_CREATE_JSON = "src/test/resources/rest/controlloops/ControlLoops.json"; - private static final ToscaConceptIdentifier identifier = new ToscaConceptIdentifier("PMSHInstance0Crud", "1.0.1"); - private static final ToscaConceptIdentifier participantId = new ToscaConceptIdentifier("ParticipantId", "1.0.0"); - private static final ToscaConceptIdentifier participantType = - new ToscaConceptIdentifier("ParticipantType", "1.0.0"); - - @Test - void testTriggerControlLoopSupervisionEmpty() throws ControlLoopException, PfModelException, CoderException { - var handler = createSupervisionHandler(mock(ControlLoopProvider.class), mock(ParticipantProvider.class), - mock(MonitoringProvider.class), mock(ParticipantRegisterAckPublisher.class), - mock(ParticipantDeregisterAckPublisher.class), mock(ControlLoopUpdatePublisher.class), - mock(ParticipantUpdatePublisher.class), ControlLoopOrderedState.PASSIVE); - - assertThatThrownBy(() -> handler.triggerControlLoopSupervision(List.of())) - .hasMessageMatching("The list of control loops for supervision is empty"); - } - - @Test - void testTriggerControlLoopSupervision() throws ControlLoopException, PfModelException, CoderException { - var controlLoopProvider = mock(ControlLoopProvider.class); - var controlLoopUpdatePublisher = mock(ControlLoopUpdatePublisher.class); - var handler = createSupervisionHandler(controlLoopProvider, mock(ParticipantProvider.class), - mock(MonitoringProvider.class), mock(ParticipantRegisterAckPublisher.class), - mock(ParticipantDeregisterAckPublisher.class), controlLoopUpdatePublisher, - mock(ParticipantUpdatePublisher.class), ControlLoopOrderedState.PASSIVE); - - handler.triggerControlLoopSupervision(List.of(identifier)); - - verify(controlLoopUpdatePublisher).send(any(ControlLoop.class)); - verify(controlLoopProvider).saveControlLoop(any(ControlLoop.class)); - } - - @Test - void testTriggerControlLoopUninitialised() throws ControlLoopException, PfModelException, CoderException { - var controlLoopProvider = mock(ControlLoopProvider.class); - var controlLoopUpdatePublisher = mock(ControlLoopUpdatePublisher.class); - var handler = createSupervisionHandler(controlLoopProvider, mock(ParticipantProvider.class), - mock(MonitoringProvider.class), mock(ParticipantRegisterAckPublisher.class), - mock(ParticipantDeregisterAckPublisher.class), controlLoopUpdatePublisher, - mock(ParticipantUpdatePublisher.class), ControlLoopOrderedState.UNINITIALISED); - - assertThatThrownBy(() -> handler.triggerControlLoopSupervision(List.of(identifier))) - .hasMessageMatching("Control loop is already in state UNINITIALISED"); - } - - @Test - void testTriggerControlLoopRunning() throws ControlLoopException, PfModelException, CoderException { - var controlLoopProvider = mock(ControlLoopProvider.class); - var controlLoopUpdatePublisher = mock(ControlLoopUpdatePublisher.class); - var handler = createSupervisionHandler(controlLoopProvider, mock(ParticipantProvider.class), - mock(MonitoringProvider.class), mock(ParticipantRegisterAckPublisher.class), - mock(ParticipantDeregisterAckPublisher.class), controlLoopUpdatePublisher, - mock(ParticipantUpdatePublisher.class), ControlLoopOrderedState.RUNNING); - - assertThatThrownBy(() -> handler.triggerControlLoopSupervision(List.of(identifier))) - .hasMessageMatching("Control loop can't transition from state UNINITIALISED to state RUNNING"); - } - - @Test - void testHandleControlLoopStateChangeAckMessage() throws PfModelException, CoderException { - var controlLoopProvider = mock(ControlLoopProvider.class); - var handler = createSupervisionHandler(controlLoopProvider, mock(ParticipantProvider.class), - mock(MonitoringProvider.class), mock(ParticipantRegisterAckPublisher.class), - mock(ParticipantDeregisterAckPublisher.class), mock(ControlLoopUpdatePublisher.class), - mock(ParticipantUpdatePublisher.class), ControlLoopOrderedState.PASSIVE); - var controlLoopAckMessage = new ControlLoopAck(ParticipantMessageType.CONTROLLOOP_STATECHANGE_ACK); - controlLoopAckMessage.setControlLoopResultMap(Map.of()); - controlLoopAckMessage.setControlLoopId(identifier); - - handler.handleControlLoopStateChangeAckMessage(controlLoopAckMessage); - - verify(controlLoopProvider).saveControlLoop(any(ControlLoop.class)); - } - - @Test - void testHandleControlLoopUpdateAckMessage() throws PfModelException, CoderException { - var controlLoopAckMessage = new ControlLoopAck(ParticipantMessageType.CONTROLLOOP_UPDATE_ACK); - controlLoopAckMessage.setParticipantId(participantId); - controlLoopAckMessage.setParticipantType(participantType); - controlLoopAckMessage.setControlLoopResultMap(Map.of()); - controlLoopAckMessage.setControlLoopId(identifier); - var controlLoopProvider = mock(ControlLoopProvider.class); - var handler = createSupervisionHandler(controlLoopProvider, mock(ParticipantProvider.class), - mock(MonitoringProvider.class), mock(ParticipantRegisterAckPublisher.class), - mock(ParticipantDeregisterAckPublisher.class), mock(ControlLoopUpdatePublisher.class), - mock(ParticipantUpdatePublisher.class), ControlLoopOrderedState.PASSIVE); - - handler.handleControlLoopUpdateAckMessage(controlLoopAckMessage); - - verify(controlLoopProvider).saveControlLoop(any(ControlLoop.class)); - } - - @Test - void testHandleParticipantDeregister() throws PfModelException, CoderException { - var participant = new Participant(); - participant.setName(participantId.getName()); - participant.setVersion(participantId.getVersion()); - participant.setParticipantType(participantType); - - var participantProvider = mock(ParticipantProvider.class); - when(participantProvider.findParticipant(participantId.getName(), participantId.getVersion())) - .thenReturn(Optional.of(participant)); - - var participantDeregisterMessage = new ParticipantDeregister(); - participantDeregisterMessage.setMessageId(UUID.randomUUID()); - participantDeregisterMessage.setParticipantId(participantId); - participantDeregisterMessage.setParticipantType(participantType); - var participantDeregisterAckPublisher = mock(ParticipantDeregisterAckPublisher.class); - var handler = createSupervisionHandler(mock(ControlLoopProvider.class), participantProvider, - mock(MonitoringProvider.class), mock(ParticipantRegisterAckPublisher.class), - participantDeregisterAckPublisher, mock(ControlLoopUpdatePublisher.class), - mock(ParticipantUpdatePublisher.class), ControlLoopOrderedState.PASSIVE); - - handler.handleParticipantMessage(participantDeregisterMessage); - - verify(participantProvider).saveParticipant(any()); - verify(participantDeregisterAckPublisher).send(participantDeregisterMessage.getMessageId()); - } - - @Test - void testHandleParticipantRegister() throws PfModelException, CoderException { - var participant = new Participant(); - participant.setName(participantId.getName()); - participant.setVersion(participantId.getVersion()); - participant.setParticipantType(participantType); - - var participantRegisterMessage = new ParticipantRegister(); - participantRegisterMessage.setMessageId(UUID.randomUUID()); - participantRegisterMessage.setParticipantId(participantId); - participantRegisterMessage.setParticipantType(participantType); - var participantProvider = mock(ParticipantProvider.class); - var participantRegisterAckPublisher = mock(ParticipantRegisterAckPublisher.class); - var handler = createSupervisionHandler(mock(ControlLoopProvider.class), participantProvider, - mock(MonitoringProvider.class), participantRegisterAckPublisher, - mock(ParticipantDeregisterAckPublisher.class), mock(ControlLoopUpdatePublisher.class), - mock(ParticipantUpdatePublisher.class), ControlLoopOrderedState.PASSIVE); - - handler.handleParticipantMessage(participantRegisterMessage); - - verify(participantProvider).saveParticipant(any()); - verify(participantRegisterAckPublisher).send(participantRegisterMessage.getMessageId(), participantId, - participantType); - } - - @Test - void testParticipantUpdateAck() throws PfModelException, CoderException { - var participant = new Participant(); - participant.setName(participantId.getName()); - participant.setVersion(participantId.getVersion()); - participant.setParticipantType(participantType); - - var participantProvider = mock(ParticipantProvider.class); - when(participantProvider.findParticipant(participantId.getName(), participantId.getVersion())) - .thenReturn(Optional.of(participant)); - - var participantUpdateAckMessage = new ParticipantUpdateAck(); - participantUpdateAckMessage.setParticipantId(participantId); - participantUpdateAckMessage.setParticipantType(participantType); - participantUpdateAckMessage.setState(ParticipantState.PASSIVE); - var handler = createSupervisionHandler(mock(ControlLoopProvider.class), participantProvider, - mock(MonitoringProvider.class), mock(ParticipantRegisterAckPublisher.class), - mock(ParticipantDeregisterAckPublisher.class), mock(ControlLoopUpdatePublisher.class), - mock(ParticipantUpdatePublisher.class), ControlLoopOrderedState.PASSIVE); - - handler.handleParticipantMessage(participantUpdateAckMessage); - - verify(participantProvider).saveParticipant(any()); - } - - @Test - void testHandleParticipantStatus() throws PfModelException, CoderException { - var participantStatusMessage = new ParticipantStatus(); - participantStatusMessage.setParticipantId(participantId); - participantStatusMessage.setParticipantType(participantType); - participantStatusMessage.setState(ParticipantState.PASSIVE); - participantStatusMessage.setHealthStatus(ParticipantHealthStatus.HEALTHY); - participantStatusMessage.setParticipantStatistics(new ParticipantStatistics()); - - var participantProvider = mock(ParticipantProvider.class); - var monitoringProvider = mock(MonitoringProvider.class); - var handler = createSupervisionHandler(mock(ControlLoopProvider.class), participantProvider, monitoringProvider, - mock(ParticipantRegisterAckPublisher.class), mock(ParticipantDeregisterAckPublisher.class), - mock(ControlLoopUpdatePublisher.class), mock(ParticipantUpdatePublisher.class), - ControlLoopOrderedState.PASSIVE); - handler.handleParticipantMessage(participantStatusMessage); - - verify(participantProvider).saveParticipant(any()); - verify(monitoringProvider).createParticipantStatistics(anyList()); - } - - @Test - void testHandleSendCommissionMessage() throws PfModelException, CoderException { - var participantUpdatePublisher = mock(ParticipantUpdatePublisher.class); - var handler = createSupervisionHandler(mock(ControlLoopProvider.class), mock(ParticipantProvider.class), - mock(MonitoringProvider.class), mock(ParticipantRegisterAckPublisher.class), - mock(ParticipantDeregisterAckPublisher.class), mock(ControlLoopUpdatePublisher.class), - participantUpdatePublisher, ControlLoopOrderedState.PASSIVE); - handler.handleSendCommissionMessage(participantId.getName(), participantId.getVersion()); - - verify(participantUpdatePublisher).sendComissioningBroadcast(participantId.getName(), - participantId.getVersion()); - } - - @Test - void testHandleSendDeCommissionMessage() throws PfModelException, CoderException { - var participantUpdatePublisher = mock(ParticipantUpdatePublisher.class); - var handler = createSupervisionHandler(mock(ControlLoopProvider.class), mock(ParticipantProvider.class), - mock(MonitoringProvider.class), mock(ParticipantRegisterAckPublisher.class), - mock(ParticipantDeregisterAckPublisher.class), mock(ControlLoopUpdatePublisher.class), - participantUpdatePublisher, ControlLoopOrderedState.PASSIVE); - handler.handleSendDeCommissionMessage(); - - verify(participantUpdatePublisher).sendDecomisioning(); - } - - private SupervisionHandler createSupervisionHandler(ControlLoopProvider controlLoopProvider, - ParticipantProvider participantProvider, MonitoringProvider monitoringProvider, - ParticipantRegisterAckPublisher participantRegisterAckPublisher, - ParticipantDeregisterAckPublisher participantDeregisterAckPublisher, - ControlLoopUpdatePublisher controlLoopUpdatePublisher, - ParticipantUpdatePublisher participantUpdatePublisher, - ControlLoopOrderedState orderedState) throws PfModelException, CoderException { - var controlLoopsCreate = InstantiationUtils.getControlLoopsFromResource(CL_INSTANTIATION_CREATE_JSON, "Crud"); - - var controlLoop = controlLoopsCreate.getControlLoopList().get(0); - controlLoop.setOrderedState(orderedState); - - when(controlLoopProvider.findControlLoop(identifier)).thenReturn(Optional.of(controlLoop)); - when(controlLoopProvider.getControlLoop(identifier)).thenReturn(controlLoop); - - var serviceTemplateProvider = Mockito.mock(ServiceTemplateProvider.class); - when(serviceTemplateProvider.getServiceTemplateList(any(), any())) - .thenReturn(List.of(InstantiationUtils.getToscaServiceTemplate(TOSCA_TEMPLATE_YAML))); - - var controlLoopStateChangePublisher = mock(ControlLoopStateChangePublisher.class); - - return new SupervisionHandler(controlLoopProvider, participantProvider, monitoringProvider, - serviceTemplateProvider, controlLoopUpdatePublisher, controlLoopStateChangePublisher, - participantRegisterAckPublisher, participantDeregisterAckPublisher, participantUpdatePublisher); - - } -} diff --git a/runtime-controlloop/src/test/java/org/onap/policy/clamp/controlloop/runtime/supervision/SupervisionScannerTest.java b/runtime-controlloop/src/test/java/org/onap/policy/clamp/controlloop/runtime/supervision/SupervisionScannerTest.java deleted file mode 100644 index b7a3fe005..000000000 --- a/runtime-controlloop/src/test/java/org/onap/policy/clamp/controlloop/runtime/supervision/SupervisionScannerTest.java +++ /dev/null @@ -1,214 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * Copyright (C) 2021 Nordix Foundation. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - * SPDX-License-Identifier: Apache-2.0 - * ============LICENSE_END========================================================= - */ - -package org.onap.policy.clamp.controlloop.runtime.supervision; - -import static org.mockito.ArgumentMatchers.any; -import static org.mockito.ArgumentMatchers.anyInt; -import static org.mockito.Mockito.mock; -import static org.mockito.Mockito.times; -import static org.mockito.Mockito.verify; -import static org.mockito.Mockito.when; - -import java.util.List; -import org.junit.jupiter.api.BeforeAll; -import org.junit.jupiter.api.Test; -import org.onap.policy.clamp.controlloop.models.controlloop.concepts.ControlLoop; -import org.onap.policy.clamp.controlloop.models.controlloop.concepts.ControlLoopOrderedState; -import org.onap.policy.clamp.controlloop.models.controlloop.concepts.ControlLoopState; -import org.onap.policy.clamp.controlloop.models.controlloop.concepts.Participant; -import org.onap.policy.clamp.controlloop.models.controlloop.concepts.ParticipantHealthStatus; -import org.onap.policy.clamp.controlloop.models.controlloop.concepts.ParticipantState; -import org.onap.policy.clamp.controlloop.models.controlloop.persistence.provider.ControlLoopProvider; -import org.onap.policy.clamp.controlloop.models.controlloop.persistence.provider.ParticipantProvider; -import org.onap.policy.clamp.controlloop.models.controlloop.persistence.provider.ServiceTemplateProvider; -import org.onap.policy.clamp.controlloop.runtime.instantiation.InstantiationUtils; -import org.onap.policy.clamp.controlloop.runtime.supervision.comm.ControlLoopStateChangePublisher; -import org.onap.policy.clamp.controlloop.runtime.supervision.comm.ControlLoopUpdatePublisher; -import org.onap.policy.clamp.controlloop.runtime.supervision.comm.ParticipantStatusReqPublisher; -import org.onap.policy.clamp.controlloop.runtime.supervision.comm.ParticipantUpdatePublisher; -import org.onap.policy.clamp.controlloop.runtime.util.CommonTestData; -import org.onap.policy.common.utils.coder.CoderException; -import org.onap.policy.models.base.PfModelException; -import org.onap.policy.models.tosca.authorative.concepts.ToscaConceptIdentifier; -import org.onap.policy.models.tosca.authorative.concepts.ToscaServiceTemplate; - -class SupervisionScannerTest { - - private static final String TOSCA_SERVICE_TEMPLATE_YAML = - "src/test/resources/rest/servicetemplates/tosca-for-smoke-testing.yaml"; - private static final String CONTROLLOOP_JSON = "src/test/resources/rest/controlloops/ControlLoopsSmoke.json"; - - private static ServiceTemplateProvider serviceTemplateProvider = mock(ServiceTemplateProvider.class); - - @BeforeAll - public static void setUpBeforeAll() throws Exception { - ToscaServiceTemplate serviceTemplate = InstantiationUtils.getToscaServiceTemplate(TOSCA_SERVICE_TEMPLATE_YAML); - when(serviceTemplateProvider.getAllServiceTemplates()).thenReturn(List.of(serviceTemplate)); - } - - @Test - void testScannerOrderedStateEqualsToState() throws PfModelException, CoderException { - var controlLoopProvider = mock(ControlLoopProvider.class); - var controlLoopStateChangePublisher = mock(ControlLoopStateChangePublisher.class); - var controlLoopUpdatePublisher = mock(ControlLoopUpdatePublisher.class); - var participantProvider = mock(ParticipantProvider.class); - var participantStatusReqPublisher = mock(ParticipantStatusReqPublisher.class); - var participantUpdatePublisher = mock(ParticipantUpdatePublisher.class); - var clRuntimeParameterGroup = CommonTestData.geParameterGroup("dbScanner"); - - var controlLoops = - InstantiationUtils.getControlLoopsFromResource(CONTROLLOOP_JSON, "Crud").getControlLoopList(); - when(controlLoopProvider.getControlLoops()).thenReturn(controlLoops); - - var supervisionScanner = new SupervisionScanner(controlLoopProvider, serviceTemplateProvider, - controlLoopStateChangePublisher, controlLoopUpdatePublisher, participantProvider, - participantStatusReqPublisher, participantUpdatePublisher, clRuntimeParameterGroup); - supervisionScanner.run(false); - - verify(controlLoopProvider, times(0)).saveControlLoop(any(ControlLoop.class)); - } - - @Test - void testScannerOrderedStateDifferentToState() throws PfModelException, CoderException { - var controlLoops = - InstantiationUtils.getControlLoopsFromResource(CONTROLLOOP_JSON, "Crud").getControlLoopList(); - controlLoops.get(0).setState(ControlLoopState.UNINITIALISED2PASSIVE); - controlLoops.get(0).setOrderedState(ControlLoopOrderedState.UNINITIALISED); - var controlLoopProvider = mock(ControlLoopProvider.class); - when(controlLoopProvider.getControlLoops()).thenReturn(controlLoops); - - var controlLoopUpdatePublisher = mock(ControlLoopUpdatePublisher.class); - var controlLoopStateChangePublisher = mock(ControlLoopStateChangePublisher.class); - var participantProvider = mock(ParticipantProvider.class); - var participantStatusReqPublisher = mock(ParticipantStatusReqPublisher.class); - var participantUpdatePublisher = mock(ParticipantUpdatePublisher.class); - var clRuntimeParameterGroup = CommonTestData.geParameterGroup("dbScanner"); - - var supervisionScanner = new SupervisionScanner(controlLoopProvider, serviceTemplateProvider, - controlLoopStateChangePublisher, controlLoopUpdatePublisher, participantProvider, - participantStatusReqPublisher, participantUpdatePublisher, clRuntimeParameterGroup); - supervisionScanner.run(false); - - verify(controlLoopProvider, times(1)).saveControlLoop(any(ControlLoop.class)); - } - - @Test - void testScanner() throws PfModelException { - var controlLoopProvider = mock(ControlLoopProvider.class); - var controlLoop = new ControlLoop(); - when(controlLoopProvider.getControlLoops()).thenReturn(List.of(controlLoop)); - - var participantProvider = mock(ParticipantProvider.class); - var participant = new Participant(); - participant.setName("Participant0"); - participant.setVersion("1.0.0"); - when(participantProvider.getParticipants(null, null)).thenReturn(List.of(participant)); - - var controlLoopUpdatePublisher = mock(ControlLoopUpdatePublisher.class); - var participantStatusReqPublisher = mock(ParticipantStatusReqPublisher.class); - var controlLoopStateChangePublisher = mock(ControlLoopStateChangePublisher.class); - var participantUpdatePublisher = mock(ParticipantUpdatePublisher.class); - var clRuntimeParameterGroup = CommonTestData.geParameterGroup("dbScanner"); - - var supervisionScanner = new SupervisionScanner(controlLoopProvider, serviceTemplateProvider, - controlLoopStateChangePublisher, controlLoopUpdatePublisher, participantProvider, - participantStatusReqPublisher, participantUpdatePublisher, clRuntimeParameterGroup); - - supervisionScanner.handleParticipantStatus(participant.getKey().asIdentifier()); - supervisionScanner.run(true); - verify(controlLoopProvider, times(0)).saveControlLoop(any(ControlLoop.class)); - verify(participantStatusReqPublisher, times(0)).send(any(ToscaConceptIdentifier.class)); - } - - @Test - void testSendControlLoopMsgUpdate() throws PfModelException, CoderException { - var controlLoops = - InstantiationUtils.getControlLoopsFromResource(CONTROLLOOP_JSON, "Crud").getControlLoopList(); - controlLoops.get(0).setState(ControlLoopState.UNINITIALISED2PASSIVE); - controlLoops.get(0).setOrderedState(ControlLoopOrderedState.PASSIVE); - for (var element : controlLoops.get(0).getElements().values()) { - if ("org.onap.domain.database.Http_PMSHMicroserviceControlLoopElement" - .equals(element.getDefinition().getName())) { - element.setOrderedState(ControlLoopOrderedState.PASSIVE); - element.setState(ControlLoopState.UNINITIALISED); - } else { - element.setOrderedState(ControlLoopOrderedState.PASSIVE); - element.setState(ControlLoopState.PASSIVE); - } - } - - var controlLoopProvider = mock(ControlLoopProvider.class); - when(controlLoopProvider.getControlLoops()).thenReturn(controlLoops); - - var participantProvider = mock(ParticipantProvider.class); - var controlLoopUpdatePublisher = mock(ControlLoopUpdatePublisher.class); - var participantStatusReqPublisher = mock(ParticipantStatusReqPublisher.class); - var controlLoopStateChangePublisher = mock(ControlLoopStateChangePublisher.class); - var participantUpdatePublisher = mock(ParticipantUpdatePublisher.class); - var clRuntimeParameterGroup = CommonTestData.geParameterGroup("dbScanner"); - - var supervisionScanner = new SupervisionScanner(controlLoopProvider, serviceTemplateProvider, - controlLoopStateChangePublisher, controlLoopUpdatePublisher, participantProvider, - participantStatusReqPublisher, participantUpdatePublisher, clRuntimeParameterGroup); - - supervisionScanner.run(false); - - verify(controlLoopUpdatePublisher).send(any(ControlLoop.class), anyInt()); - } - - @Test - void testScanParticipant() throws PfModelException { - var controlLoopProvider = mock(ControlLoopProvider.class); - var controlLoop = new ControlLoop(); - when(controlLoopProvider.getControlLoops()).thenReturn(List.of(controlLoop)); - - var clRuntimeParameterGroup = CommonTestData.geParameterGroup("dbScanParticipant"); - clRuntimeParameterGroup.getParticipantParameters().getUpdateParameters().setMaxWaitMs(-1); - clRuntimeParameterGroup.getParticipantParameters().setMaxStatusWaitMs(-1); - - var participant = new Participant(); - participant.setName("Participant0"); - participant.setVersion("1.0.0"); - participant.setHealthStatus(ParticipantHealthStatus.HEALTHY); - participant.setParticipantState(ParticipantState.ACTIVE); - participant.setDefinition(new ToscaConceptIdentifier("unknown", "0.0.0")); - participant.setParticipantType(new ToscaConceptIdentifier("ParticipantType1", "1.0.0")); - var participantProvider = mock(ParticipantProvider.class); - when(participantProvider.getParticipants()).thenReturn(List.of(participant)); - - var controlLoopUpdatePublisher = mock(ControlLoopUpdatePublisher.class); - var participantStatusReqPublisher = mock(ParticipantStatusReqPublisher.class); - var controlLoopStateChangePublisher = mock(ControlLoopStateChangePublisher.class); - var participantUpdatePublisher = mock(ParticipantUpdatePublisher.class); - - var supervisionScanner = new SupervisionScanner(controlLoopProvider, serviceTemplateProvider, - controlLoopStateChangePublisher, controlLoopUpdatePublisher, participantProvider, - participantStatusReqPublisher, participantUpdatePublisher, clRuntimeParameterGroup); - - supervisionScanner.handleParticipantStatus(participant.getKey().asIdentifier()); - supervisionScanner.run(true); - verify(participantStatusReqPublisher).send(any(ToscaConceptIdentifier.class)); - verify(participantProvider).saveParticipant(any()); - - supervisionScanner.run(true); - verify(participantProvider, times(2)).saveParticipant(any()); - } -} diff --git a/runtime-controlloop/src/test/java/org/onap/policy/clamp/controlloop/runtime/supervision/comm/SupervisionMessagesTest.java b/runtime-controlloop/src/test/java/org/onap/policy/clamp/controlloop/runtime/supervision/comm/SupervisionMessagesTest.java deleted file mode 100644 index a465aa254..000000000 --- a/runtime-controlloop/src/test/java/org/onap/policy/clamp/controlloop/runtime/supervision/comm/SupervisionMessagesTest.java +++ /dev/null @@ -1,225 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * Copyright (C) 2021 Nordix Foundation. - * Modifications Copyright (C) 2021 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - * SPDX-License-Identifier: Apache-2.0 - * ============LICENSE_END========================================================= - */ - -package org.onap.policy.clamp.controlloop.runtime.supervision.comm; - -import static org.assertj.core.api.Assertions.assertThatCode; -import static org.assertj.core.api.Assertions.assertThatThrownBy; -import static org.mockito.ArgumentMatchers.anyString; -import static org.mockito.Mockito.mock; -import static org.mockito.Mockito.times; -import static org.mockito.Mockito.verify; - -import java.time.Instant; -import java.util.Collections; -import java.util.List; -import java.util.UUID; -import org.junit.jupiter.api.BeforeAll; -import org.junit.jupiter.api.Test; -import org.mockito.Mockito; -import org.onap.policy.clamp.controlloop.models.controlloop.concepts.ControlLoop; -import org.onap.policy.clamp.controlloop.models.controlloop.concepts.ControlLoopState; -import org.onap.policy.clamp.controlloop.models.controlloop.persistence.provider.ClElementStatisticsProvider; -import org.onap.policy.clamp.controlloop.models.controlloop.persistence.provider.ControlLoopProvider; -import org.onap.policy.clamp.controlloop.models.controlloop.persistence.provider.ParticipantProvider; -import org.onap.policy.clamp.controlloop.models.controlloop.persistence.provider.ParticipantStatisticsProvider; -import org.onap.policy.clamp.controlloop.models.controlloop.persistence.provider.ServiceTemplateProvider; -import org.onap.policy.clamp.controlloop.models.messages.dmaap.participant.ParticipantDeregister; -import org.onap.policy.clamp.controlloop.models.messages.dmaap.participant.ParticipantDeregisterAck; -import org.onap.policy.clamp.controlloop.models.messages.dmaap.participant.ParticipantRegisterAck; -import org.onap.policy.clamp.controlloop.models.messages.dmaap.participant.ParticipantUpdateAck; -import org.onap.policy.clamp.controlloop.runtime.monitoring.MonitoringProvider; -import org.onap.policy.clamp.controlloop.runtime.supervision.SupervisionHandler; -import org.onap.policy.clamp.controlloop.runtime.util.rest.CommonRestController; -import org.onap.policy.common.endpoints.event.comm.Topic.CommInfrastructure; -import org.onap.policy.common.endpoints.event.comm.TopicSink; -import org.onap.policy.models.base.PfModelException; -import org.onap.policy.models.tosca.authorative.concepts.ToscaConceptIdentifier; - -class SupervisionMessagesTest extends CommonRestController { - - private static final String NOT_ACTIVE = "Not Active!"; - private static final Object lockit = new Object(); - private static final CommInfrastructure INFRA = CommInfrastructure.NOOP; - private static final String TOPIC = "my-topic"; - private static SupervisionHandler supervisionHandler; - - /** - * setup Db Provider Parameters. - * - * @throws PfModelException if an error occurs - */ - @BeforeAll - public static void setupDbProviderParameters() throws PfModelException { - var clProvider = mock(ControlLoopProvider.class); - var participantStatisticsProvider = mock(ParticipantStatisticsProvider.class); - var clElementStatisticsProvider = mock(ClElementStatisticsProvider.class); - var monitoringProvider = - new MonitoringProvider(participantStatisticsProvider, clElementStatisticsProvider, clProvider); - var participantProvider = mock(ParticipantProvider.class); - var serviceTemplateProvider = Mockito.mock(ServiceTemplateProvider.class); - var controlLoopUpdatePublisher = Mockito.mock(ControlLoopUpdatePublisher.class); - var controlLoopStateChangePublisher = Mockito.mock(ControlLoopStateChangePublisher.class); - var participantRegisterAckPublisher = Mockito.mock(ParticipantRegisterAckPublisher.class); - var participantDeregisterAckPublisher = Mockito.mock(ParticipantDeregisterAckPublisher.class); - var participantUpdatePublisher = Mockito.mock(ParticipantUpdatePublisher.class); - supervisionHandler = new SupervisionHandler(clProvider, participantProvider, monitoringProvider, - serviceTemplateProvider, controlLoopUpdatePublisher, controlLoopStateChangePublisher, - participantRegisterAckPublisher, participantDeregisterAckPublisher, participantUpdatePublisher); - } - - @Test - void testSendParticipantRegisterAck() throws Exception { - final ParticipantRegisterAck participantRegisterAckMsg = new ParticipantRegisterAck(); - participantRegisterAckMsg.setMessage("ParticipantRegisterAck message"); - participantRegisterAckMsg.setResponseTo(UUID.randomUUID()); - participantRegisterAckMsg.setResult(true); - - synchronized (lockit) { - ParticipantRegisterAckPublisher clRegisterAckPublisher = new ParticipantRegisterAckPublisher(); - clRegisterAckPublisher.active(List.of(Mockito.mock(TopicSink.class))); - assertThatCode(() -> clRegisterAckPublisher.send(participantRegisterAckMsg)).doesNotThrowAnyException(); - } - } - - @Test - void testReceiveParticipantDeregister() throws Exception { - final ParticipantDeregister participantDeregisterMsg = new ParticipantDeregister(); - participantDeregisterMsg.setParticipantId(getParticipantId()); - participantDeregisterMsg.setTimestamp(Instant.now()); - participantDeregisterMsg.setParticipantType(getParticipantType()); - - synchronized (lockit) { - ParticipantDeregisterListener participantDeregisterListener = - new ParticipantDeregisterListener(supervisionHandler); - assertThatCode( - () -> participantDeregisterListener.onTopicEvent(INFRA, TOPIC, null, participantDeregisterMsg)) - .doesNotThrowAnyException(); - } - } - - @Test - void testSendParticipantDeregisterAck() throws Exception { - final ParticipantDeregisterAck participantDeregisterAckMsg = new ParticipantDeregisterAck(); - participantDeregisterAckMsg.setMessage("ParticipantDeregisterAck message"); - participantDeregisterAckMsg.setResponseTo(UUID.randomUUID()); - participantDeregisterAckMsg.setResult(true); - - synchronized (lockit) { - ParticipantDeregisterAckPublisher clDeregisterAckPublisher = new ParticipantDeregisterAckPublisher(); - clDeregisterAckPublisher.active(Collections.singletonList(Mockito.mock(TopicSink.class))); - assertThatCode(() -> clDeregisterAckPublisher.send(participantDeregisterAckMsg)).doesNotThrowAnyException(); - } - } - - @Test - void testReceiveParticipantUpdateAckMessage() throws Exception { - final ParticipantUpdateAck participantUpdateAckMsg = new ParticipantUpdateAck(); - participantUpdateAckMsg.setMessage("ParticipantUpdateAck message"); - participantUpdateAckMsg.setResponseTo(UUID.randomUUID()); - participantUpdateAckMsg.setResult(true); - participantUpdateAckMsg.setParticipantId(getParticipantId()); - participantUpdateAckMsg.setParticipantType(getParticipantType()); - - synchronized (lockit) { - ParticipantUpdateAckListener participantUpdateAckListener = - new ParticipantUpdateAckListener(supervisionHandler); - assertThatCode(() -> participantUpdateAckListener.onTopicEvent(INFRA, TOPIC, null, participantUpdateAckMsg)) - .doesNotThrowAnyException(); - } - } - - @Test - void testSendControlLoopStateChangePublisherNotActive() { - var publisher = new ControlLoopStateChangePublisher(); - assertThatThrownBy(() -> publisher.send(getControlLoop(), 0)).hasMessage(NOT_ACTIVE); - } - - @Test - void testSendControlLoopStateChangePublisher() { - var publisher = new ControlLoopStateChangePublisher(); - var topicSink = mock(TopicSink.class); - publisher.active(List.of(topicSink)); - publisher.send(getControlLoop(), 0); - verify(topicSink).send(anyString()); - } - - @Test - void testParticipantUpdatePublisherDecomisioning() { - var publisher = new ParticipantUpdatePublisher(mock(ServiceTemplateProvider.class)); - var topicSink = mock(TopicSink.class); - publisher.active(List.of(topicSink)); - publisher.sendDecomisioning(); - verify(topicSink).send(anyString()); - } - - @Test - void testParticipantUpdatePublisherComissioning() { - var publisher = new ParticipantUpdatePublisher(mock(ServiceTemplateProvider.class)); - var topicSink = mock(TopicSink.class); - publisher.active(List.of(topicSink)); - publisher.sendComissioningBroadcast("NAME", "1.0.0"); - verify(topicSink, times(0)).send(anyString()); - } - - @Test - void testParticipantStatusReqPublisher() { - var publisher = new ParticipantStatusReqPublisher(); - var topicSink = mock(TopicSink.class); - publisher.active(List.of(topicSink)); - publisher.send(getParticipantId()); - verify(topicSink).send(anyString()); - } - - @Test - void testParticipantRegisterAckPublisher() { - var publisher = new ParticipantRegisterAckPublisher(); - var topicSink = mock(TopicSink.class); - publisher.active(List.of(topicSink)); - publisher.send(UUID.randomUUID(), getParticipantId(), getParticipantType()); - verify(topicSink).send(anyString()); - } - - @Test - void testParticipantDeregisterAckPublisher() { - var publisher = new ParticipantDeregisterAckPublisher(); - var topicSink = mock(TopicSink.class); - publisher.active(List.of(topicSink)); - publisher.send(UUID.randomUUID()); - verify(topicSink).send(anyString()); - } - - private ControlLoop getControlLoop() { - var controlLoop = new ControlLoop(); - controlLoop.setName("NAME"); - controlLoop.setVersion("0.0.1"); - controlLoop.setState(ControlLoopState.UNINITIALISED); - return controlLoop; - } - - private ToscaConceptIdentifier getParticipantId() { - return new ToscaConceptIdentifier("org.onap.PM_Policy", "1.0.0"); - } - - private ToscaConceptIdentifier getParticipantType() { - return new ToscaConceptIdentifier("org.onap.policy.controlloop.PolicyControlLoopParticipant", "2.3.1"); - } -} diff --git a/runtime-controlloop/src/test/java/org/onap/policy/clamp/controlloop/runtime/util/CommonTestData.java b/runtime-controlloop/src/test/java/org/onap/policy/clamp/controlloop/runtime/util/CommonTestData.java deleted file mode 100644 index 13d30e401..000000000 --- a/runtime-controlloop/src/test/java/org/onap/policy/clamp/controlloop/runtime/util/CommonTestData.java +++ /dev/null @@ -1,123 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * Copyright (C) 2021 Nordix Foundation. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - * SPDX-License-Identifier: Apache-2.0 - * ============LICENSE_END========================================================= - */ - -package org.onap.policy.clamp.controlloop.runtime.util; - -import java.util.List; -import javax.ws.rs.core.Response.Status; -import org.onap.policy.clamp.controlloop.common.exception.ControlLoopRuntimeException; -import org.onap.policy.clamp.controlloop.models.controlloop.concepts.Participant; -import org.onap.policy.clamp.controlloop.runtime.main.parameters.ClRuntimeParameterGroup; -import org.onap.policy.common.utils.coder.Coder; -import org.onap.policy.common.utils.coder.CoderException; -import org.onap.policy.common.utils.coder.StandardCoder; -import org.onap.policy.common.utils.resources.ResourceUtils; -import org.onap.policy.models.base.PfModelException; -import org.onap.policy.models.base.PfModelRuntimeException; -import org.onap.policy.models.provider.PolicyModelsProvider; -import org.onap.policy.models.provider.PolicyModelsProviderFactory; -import org.onap.policy.models.provider.PolicyModelsProviderParameters; -import org.onap.policy.models.tosca.authorative.concepts.ToscaConceptIdentifier; - -/** - * Class to hold/create all parameters for test cases. - * - */ -public class CommonTestData { - private static final Coder CODER = new StandardCoder(); - - /** - * Gets the standard Control Loop parameters. - * - * @param dbName the database name - * @return the standard Control Loop parameters - * @throws ControlLoopRuntimeException on errors reading the control loop parameters - */ - public static ClRuntimeParameterGroup geParameterGroup(final String dbName) { - try { - return CODER.convert(getParameterGroupAsString(dbName), ClRuntimeParameterGroup.class); - - } catch (CoderException e) { - throw new ControlLoopRuntimeException(Status.NOT_ACCEPTABLE, "cannot read Control Loop parameters", e); - } - } - - /** - * Gets the standard Control Loop parameters, as a String. - * - * @param dbName the database name - * @return the standard Control Loop parameters as string - */ - public static String getParameterGroupAsString(final String dbName) { - return ResourceUtils.getResourceAsString("src/test/resources/parameters/TestParameters.json") - .replace("${dbName}", "jdbc:h2:mem:" + dbName); - } - - /** - * Create a new PolicyModelsProvider. - * - * @param databaseProviderParameters the database Provider Parameters - * @return a new PolicyModelsProvider - */ - public static PolicyModelsProvider getPolicyModelsProvider( - PolicyModelsProviderParameters databaseProviderParameters) { - try { - return new PolicyModelsProviderFactory().createPolicyModelsProvider(databaseProviderParameters); - } catch (PfModelException e) { - throw new PfModelRuntimeException(e); - } - } - - /** - * Create a List of Participants. - * - * @return a List of Participants - */ - public static List createParticipants() { - var participant1 = createParticipant( - new ToscaConceptIdentifier("org.onap.dcae.controlloop.DCAEMicroserviceControlLoopParticipant", "2.3.4"), - new ToscaConceptIdentifier("org.onap.dcae.controlloop.DCAEMicroserviceControlLoopParticipant", - "2.3.4")); - var participant2 = createParticipant( - new ToscaConceptIdentifier("org.onap.policy.controlloop.PolicyControlLoopParticipant", "2.3.1"), - new ToscaConceptIdentifier("org.onap.policy.controlloop.PolicyControlLoopParticipant", "2.3.1")); - var participant3 = createParticipant( - new ToscaConceptIdentifier("org.onap.ccsdk.cds.controlloop.CdsControlLoopParticipant", "2.2.1"), - new ToscaConceptIdentifier("org.onap.ccsdk.cds.controlloop.CdsControlLoopParticipant", "2.2.1")); - return List.of(participant1, participant2, participant3); - } - - /** - * Create a new Participant. - * - * @param participantType the participant Type - * @param participantId the participant id - * @return a new Participant - */ - public static Participant createParticipant(ToscaConceptIdentifier participantType, - ToscaConceptIdentifier participantId) { - var participant = new Participant(); - participant.setDefinition(participantId); - participant.setParticipantType(participantType); - participant.setName(participantId.getName()); - participant.setVersion(participantId.getVersion()); - return participant; - } -} diff --git a/runtime-controlloop/src/test/java/org/onap/policy/clamp/controlloop/runtime/util/rest/CommonRestController.java b/runtime-controlloop/src/test/java/org/onap/policy/clamp/controlloop/runtime/util/rest/CommonRestController.java deleted file mode 100644 index 70b0608d6..000000000 --- a/runtime-controlloop/src/test/java/org/onap/policy/clamp/controlloop/runtime/util/rest/CommonRestController.java +++ /dev/null @@ -1,201 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * Copyright (C) 2021 Nordix Foundation. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - * SPDX-License-Identifier: Apache-2.0 - * ============LICENSE_END========================================================= - */ - -package org.onap.policy.clamp.controlloop.runtime.util.rest; - -import static org.assertj.core.api.Assertions.assertThat; -import static org.junit.Assert.assertEquals; - -import javax.ws.rs.client.Client; -import javax.ws.rs.client.ClientBuilder; -import javax.ws.rs.client.Entity; -import javax.ws.rs.client.Invocation; -import javax.ws.rs.client.WebTarget; -import javax.ws.rs.core.MediaType; -import javax.ws.rs.core.Response; -import org.glassfish.jersey.client.ClientProperties; -import org.glassfish.jersey.client.authentication.HttpAuthenticationFeature; -import org.onap.policy.common.gson.GsonMessageBodyHandler; -import org.onap.policy.common.utils.network.NetworkUtil; - -/** - * Class to perform Rest unit tests. - * - */ -public class CommonRestController { - - public static final String SELF = NetworkUtil.getHostname(); - public static final String CONTEXT_PATH = "onap/controlloop"; - public static final String ENDPOINT_PREFIX = CONTEXT_PATH + "/v2/"; - public static final String ACTUATOR_ENDPOINT = CONTEXT_PATH + "/actuator/"; - - private static String httpPrefix; - - /** - * Verifies that an endpoint appears within the swagger response. - * - * @param endpoint the endpoint of interest - * @throws Exception if an error occurs - */ - protected void testSwagger(final String endpoint) throws Exception { - final Invocation.Builder invocationBuilder = sendRequest("api-docs"); - final String resp = invocationBuilder.get(String.class); - - assertThat(resp).contains(endpoint); - } - - /** - * Sends a request to an endpoint. - * - * @param endpoint the target endpoint - * @return a request builder - * @throws Exception if an error occurs - */ - protected Invocation.Builder sendRequest(final String endpoint) throws Exception { - return sendFqeRequest(httpPrefix + ENDPOINT_PREFIX + endpoint, true); - } - - /** - * Sends a request to an actuator endpoint. - * - * @param endpoint the target endpoint - * @return a request builder - * @throws Exception if an error occurs - */ - protected Invocation.Builder sendActRequest(final String endpoint) throws Exception { - return sendFqeRequest(httpPrefix + ACTUATOR_ENDPOINT + endpoint, true); - } - - /** - * Sends a request to an Rest Api endpoint, without any authorization header. - * - * @param endpoint the target endpoint - * @return a request builder - * @throws Exception if an error occurs - */ - protected Invocation.Builder sendNoAuthRequest(final String endpoint) throws Exception { - return sendFqeRequest(httpPrefix + ENDPOINT_PREFIX + endpoint, false); - } - - /** - * Sends a request to an actuator endpoint, without any authorization header. - * - * @param endpoint the target endpoint - * @return a request builder - * @throws Exception if an error occurs - */ - protected Invocation.Builder sendNoAuthActRequest(final String endpoint) throws Exception { - return sendFqeRequest(httpPrefix + ACTUATOR_ENDPOINT + endpoint, false); - } - - /** - * Sends a request to a fully qualified endpoint. - * - * @param fullyQualifiedEndpoint the fully qualified target endpoint - * @param includeAuth if authorization header should be included - * @return a request builder - * @throws Exception if an error occurs - */ - protected Invocation.Builder sendFqeRequest(final String fullyQualifiedEndpoint, boolean includeAuth) - throws Exception { - final Client client = ClientBuilder.newBuilder().build(); - - client.property(ClientProperties.METAINF_SERVICES_LOOKUP_DISABLE, "true"); - client.register(GsonMessageBodyHandler.class); - - if (includeAuth) { - client.register(HttpAuthenticationFeature.basic("runtimeUser", "zb!XztG34")); - } - - final WebTarget webTarget = client.target(fullyQualifiedEndpoint); - - return webTarget.request(MediaType.APPLICATION_JSON, MediaType.TEXT_PLAIN); - } - - /** - * Assert that POST call is Unauthorized. - * - * @param endPoint the endpoint - * @param entity the entity ofthe body - * @throws Exception if an error occurs - */ - protected void assertUnauthorizedPost(final String endPoint, final Entity entity) throws Exception { - Response rawresp = sendNoAuthRequest(endPoint).post(entity); - assertEquals(Response.Status.UNAUTHORIZED.getStatusCode(), rawresp.getStatus()); - } - - /** - * Assert that PUT call is Unauthorized. - * - * @param endPoint the endpoint - * @param entity the entity ofthe body - * @throws Exception if an error occurs - */ - protected void assertUnauthorizedPut(final String endPoint, final Entity entity) throws Exception { - Response rawresp = sendNoAuthRequest(endPoint).put(entity); - assertEquals(Response.Status.UNAUTHORIZED.getStatusCode(), rawresp.getStatus()); - } - - /** - * Assert that GET call is Unauthorized. - * - * @param endPoint the endpoint - * @throws Exception if an error occurs - */ - protected void assertUnauthorizedGet(final String endPoint) throws Exception { - Response rawresp = sendNoAuthRequest(endPoint).buildGet().invoke(); - assertEquals(Response.Status.UNAUTHORIZED.getStatusCode(), rawresp.getStatus()); - } - - /** - * Assert that GET call to actuator endpoint is Unauthorized. - * - * @param endPoint the endpoint - * @throws Exception if an error occurs - */ - protected void assertUnauthorizedActGet(final String endPoint) throws Exception { - Response rawresp = sendNoAuthActRequest(endPoint).buildGet().invoke(); - assertEquals(Response.Status.UNAUTHORIZED.getStatusCode(), rawresp.getStatus()); - } - - /** - * Assert that DELETE call is Unauthorized. - * - * @param endPoint the endpoint - * @throws Exception if an error occurs - */ - protected void assertUnauthorizedDelete(final String endPoint) throws Exception { - Response rawresp = sendNoAuthRequest(endPoint).delete(); - assertEquals(Response.Status.UNAUTHORIZED.getStatusCode(), rawresp.getStatus()); - } - - /** - * Set Up httpPrefix. - * - * @param port the port - */ - protected void setHttpPrefix(int port) { - httpPrefix = "http://" + SELF + ":" + port + "/"; - } - - protected String getHttpPrefix() { - return httpPrefix; - } -} diff --git a/runtime-controlloop/src/test/resources/application_test.properties b/runtime-controlloop/src/test/resources/application_test.properties deleted file mode 100644 index 52c372d5e..000000000 --- a/runtime-controlloop/src/test/resources/application_test.properties +++ /dev/null @@ -1,37 +0,0 @@ -spring.security.user.name=runtimeUser -spring.security.user.password=zb!XztG34 -security.enable-csrf=false - -spring.datasource.url=jdbc:h2:mem:testdb -spring.datasource.driverClassName=org.h2.Driver -spring.datasource.username=policy -spring.datasource.password=P01icY - -spring.datasource.hikari.connectionTimeout=30000 -spring.datasource.hikari.idleTimeout=600000 -spring.datasource.hikari.maxLifetime=1800000 -spring.datasource.hikari.maximumPoolSize=3 - -spring.jpa.hibernate.naming.physical-strategy=org.hibernate.boot.model.naming.PhysicalNamingStrategyStandardImpl -spring.jpa.hibernate.naming.implicit-strategy=org.onap.policy.common.spring.utils.CustomImplicitNamingStrategy -spring.jpa.hibernate.ddl-auto=create -spring.jpa.properties.hibernate.dialect=org.hibernate.dialect.HSQLDialect -spring.jpa.properties.hibernate.format_sql=true - -server.port=6969 -server.servlet.context-path=/onap/controlloop -server.error.path=/error - -runtime.participantParameters.heartBeatMs=20000 -runtime.participantParameters.maxStatusWaitMs=100000 -runtime.participantParameters.updateParameters.maxRetryCount=3 -runtime.participantParameters.updateParameters.maxWaitMs=20000 -runtime.topicParameterGroup.topicSources[0].topic=POLICY-CLRUNTIME-PARTICIPANT -runtime.topicParameterGroup.topicSources[0].servers[0]=localhost -runtime.topicParameterGroup.topicSources[0].topicCommInfrastructure=dmaap -runtime.topicParameterGroup.topicSources[0].fetchTimeout=15000 -runtime.topicParameterGroup.topicSinks[0].topic=POLICY-CLRUNTIME-PARTICIPANT -runtime.topicParameterGroup.topicSinks[0].servers[0]=localhost -runtime.topicParameterGroup.topicSinks[0].topicCommInfrastructure=dmaap - -management.endpoints.web.exposure.include=health,metrics,prometheus diff --git a/runtime-controlloop/src/test/resources/parameters/TestParameters.json b/runtime-controlloop/src/test/resources/parameters/TestParameters.json deleted file mode 100644 index 6d16f4853..000000000 --- a/runtime-controlloop/src/test/resources/parameters/TestParameters.json +++ /dev/null @@ -1,44 +0,0 @@ -{ - "name": "ControlLoopRuntimeGroup", - "supervisionScannerIntervalSec": 1000, - "participantClUpdateIntervalSec": 1000, - "participantClStateChangeIntervalSec": 1000, - "participantParameters": { - "heartBeatMs": 120000, - "maxStatusWaitMs": 100000, - "updateParameters": { - "maxRetryCount": 1, - "maxWaitMs": 30000 - } - }, - "databaseProviderParameters": { - "name": "PolicyProviderParameterGroup", - "implementation": "org.onap.policy.models.provider.impl.DatabasePolicyModelsProviderImpl", - "databaseDriver": "org.h2.Driver", - "databaseUrl": "${dbName}", - "databaseUser": "policy", - "databasePassword": "P01icY", - "persistenceUnit": "InstantiationTests" - }, - "topicParameterGroup": { - "topicSources": [ - { - "topic": "POLICY-CLRUNTIME-PARTICIPANT", - "servers": [ - "localhost" - ], - "topicCommInfrastructure": "dmaap", - "fetchTimeout": 15000 - } - ], - "topicSinks": [ - { - "topic": "POLICY-CLRUNTIME-PARTICIPANT", - "servers": [ - "localhost" - ], - "topicCommInfrastructure": "dmaap" - } - ] - } -} diff --git a/runtime-controlloop/src/test/resources/parameters/logback-test.xml b/runtime-controlloop/src/test/resources/parameters/logback-test.xml deleted file mode 100644 index e00c36baa..000000000 --- a/runtime-controlloop/src/test/resources/parameters/logback-test.xml +++ /dev/null @@ -1,42 +0,0 @@ - - - - - - Apex - - - - - - - %d %contextName [%t] %level %logger{36} - %msg%n - - - - - - - - - - - diff --git a/runtime-controlloop/src/test/resources/rest/controlloops/ControlLoopElementsNotFound.json b/runtime-controlloop/src/test/resources/rest/controlloops/ControlLoopElementsNotFound.json deleted file mode 100644 index faea7cd48..000000000 --- a/runtime-controlloop/src/test/resources/rest/controlloops/ControlLoopElementsNotFound.json +++ /dev/null @@ -1,142 +0,0 @@ -{ - "controlLoopList": [ - { - "name": "PMSHInstance0", - "version": "1.0.1", - "definition": { - "name": "org.onap.domain.pmsh.PMSHControlLoopDefinition", - "version": "1.2.3" - }, - "state": "UNINITIALISED", - "orderedState": "UNINITIALISED", - "description": "PMSH control loop instance 0", - "elements": { - "709c62b3-8918-41b9-a747-d21eb79c6c20": { - "id": "709c62b3-8918-41b9-a747-d21eb79c6c20", - "definition": { - "name": "org.onap.domain.pmsh.DCAEMicroservice", - "version": "1.2.3" - }, - "participantType": { - "name": "org.onap.dcae.controlloop.DCAEMicroserviceControlLoopParticipant", - "version": "2.3.4" - }, - "state": "UNINITIALISED", - "orderedState": "UNINITIALISED", - "description": "DCAE Control Loop Element for the PMSH instance 0 control loop" - }, - "709c62b3-8918-41b9-a747-d21eb79c6c21": { - "id": "709c62b3-8918-41b9-a747-d21eb79c6c21", - "definition": { - "name": "org.onap.domain.pmsh.PMSH_MonitoringPolicyControlLoopElement", - "version": "1.2.3" - }, - "participantType": { - "name": "org.onap.policy.controlloop.PolicyControlLoopParticipant", - "version": "2.3.1" - }, - "state": "UNINITIALISED", - "orderedState": "UNINITIALISED", - "description": "Monitoring Policy Control Loop Element for the PMSH instance 0 control loop" - }, - "709c62b3-8918-41b9-a747-d21eb79c6c22": { - "id": "709c62b3-8918-41b9-a747-d21eb79c6c22", - "definition": { - "name": "org.onap.domain.pmsh.PMSH_OperationalPolicyControlLoopElement", - "version": "1.2.3" - }, - "participantType": { - "name": "org.onap.policy.controlloop.PolicyControlLoopParticipant", - "version": "2.3.1" - }, - "state": "UNINITIALISED", - "orderedState": "UNINITIALISED", - "description": "Operational Policy Control Loop Element for the PMSH instance 0 control loop" - }, - "709c62b3-8918-41b9-a747-d21eb79c6c23": { - "id": "709c62b3-8918-41b9-a747-d21eb79c6c23", - "definition": { - "name": "org.onap.domain.pmsh.PMSH_CDS_ControlLoopElement", - "version": "1.2.3" - }, - "participantType": { - "name": "org.onap.ccsdk.cds.controlloop.CdsControlLoopParticipant", - "version": "2.2.1" - }, - "state": "UNINITIALISED", - "orderedState": "UNINITIALISED", - "description": "CDS Control Loop Element for the PMSH instance 0 control loop" - } - } - }, - { - "name": "PMSHInstance1", - "version": "1.0.1", - "definition": { - "name": "org.onap.domain.pmsh.PMSHControlLoopDefinition", - "version": "1.2.3" - }, - "state": "UNINITIALISED", - "orderedState": "UNINITIALISED", - "description": "PMSH control loop instance 1", - "elements": { - "709c62b3-8918-41b9-a747-d21eb79c6c24": { - "id": "709c62b3-8918-41b9-a747-e21eb79c6c24", - "definition": { - "name": "org.onap.domain.pmsh.DCAEMicroservice", - "version": "1.2.3" - }, - "participantType": { - "name": "org.onap.dcae.controlloop.DCAEMicroserviceControlLoopParticipant", - "version": "2.3.4" - }, - "state": "UNINITIALISED", - "orderedState": "UNINITIALISED", - "description": "DCAE Control Loop Element for the PMSH instance 1 control loop" - }, - "709c62b3-8918-41b9-a747-d21eb79c6c25": { - "id": "709c62b3-8918-41b9-a747-e21eb79c6c25", - "definition": { - "name": "org.onap.domain.pmsh.PMSH_MonitoringPolicyControlLoopElement", - "version": "1.2.3" - }, - "participantType": { - "name": "org.onap.policy.controlloop.PolicyControlLoopParticipant", - "version": "2.3.1" - }, - "state": "UNINITIALISED", - "orderedState": "UNINITIALISED", - "description": "Monitoring Policy Control Loop Element for the PMSH instance 1 control loop" - }, - "709c62b3-8918-41b9-a747-d21eb79c6c26": { - "id": "709c62b3-8918-41b9-a747-e21eb79c6c26", - "definition": { - "name": "org.onap.domain.pmsh.PMSH_OperationalPolicyControlLoopElement", - "version": "1.2.3" - }, - "participantType": { - "name": "org.onap.policy.controlloop.PolicyControlLoopParticipant", - "version": "2.3.1" - }, - "state": "UNINITIALISED", - "orderedState": "UNINITIALISED", - "description": "Operational Policy Control Loop Element for the PMSH instance 1 control loop" - }, - "709c62b3-8918-41b9-a747-d21eb79c6c27": { - "id": "709c62b3-8918-41b9-a747-e21eb79c6c27", - "definition": { - "name": "org.onap.domain.pmsh.PMSH_CDS_ControlLoopElement", - "version": "1.2.3" - }, - "participantType": { - "name": "org.onap.ccsdk.cds.controlloop.CdsControlLoopParticipant", - "version": "2.2.1" - }, - "state": "UNINITIALISED", - "orderedState": "UNINITIALISED", - "description": "CDS Control Loop Element for the PMSH instance 1 control loop" - } - } - } - ] -} diff --git a/runtime-controlloop/src/test/resources/rest/controlloops/ControlLoops.json b/runtime-controlloop/src/test/resources/rest/controlloops/ControlLoops.json deleted file mode 100644 index 64443ff62..000000000 --- a/runtime-controlloop/src/test/resources/rest/controlloops/ControlLoops.json +++ /dev/null @@ -1,174 +0,0 @@ -{ - "controlLoopList": [ - { - "name": "PMSHInstance0", - "version": "1.0.1", - "definition": { - "name": "org.onap.domain.pmsh.PMSHControlLoopDefinition", - "version": "1.2.3" - }, - "state": "UNINITIALISED", - "orderedState": "UNINITIALISED", - "description": "PMSH control loop instance 0", - "elements": { - "709c62b3-8918-41b9-a747-d21eb79c6c20": { - "id": "709c62b3-8918-41b9-a747-d21eb79c6c20", - "definition": { - "name": "org.onap.domain.pmsh.PMSH_DCAEMicroservice", - "version": "1.2.3" - }, - "participantId": { - "name": "org.onap.dcae.controlloop.DCAEMicroserviceControlLoopParticipant", - "version": "2.3.4" - }, - "participantType": { - "name": "org.onap.dcae.controlloop.DCAEMicroserviceControlLoopParticipant", - "version": "2.3.4" - }, - "state": "UNINITIALISED", - "orderedState": "UNINITIALISED", - "description": "DCAE Control Loop Element for the PMSH instance 0 control loop" - }, - "709c62b3-8918-41b9-a747-d21eb79c6c21": { - "id": "709c62b3-8918-41b9-a747-d21eb79c6c21", - "definition": { - "name": "org.onap.domain.pmsh.PMSH_MonitoringPolicyControlLoopElement", - "version": "1.2.3" - }, - "participantId": { - "name": "org.onap.policy.controlloop.PolicyControlLoopParticipant", - "version": "2.3.1" - }, - "participantType": { - "name": "org.onap.policy.controlloop.PolicyControlLoopParticipant", - "version": "2.3.1" - }, - "state": "UNINITIALISED", - "orderedState": "UNINITIALISED", - "description": "Monitoring Policy Control Loop Element for the PMSH instance 0 control loop" - }, - "709c62b3-8918-41b9-a747-d21eb79c6c22": { - "id": "709c62b3-8918-41b9-a747-d21eb79c6c22", - "definition": { - "name": "org.onap.domain.pmsh.PMSH_OperationalPolicyControlLoopElement", - "version": "1.2.3" - }, - "participantId": { - "name": "org.onap.policy.controlloop.PolicyControlLoopParticipant", - "version": "2.3.1" - }, - "participantType": { - "name": "org.onap.policy.controlloop.PolicyControlLoopParticipant", - "version": "2.3.1" - }, - "state": "UNINITIALISED", - "orderedState": "UNINITIALISED", - "description": "Operational Policy Control Loop Element for the PMSH instance 0 control loop" - }, - "709c62b3-8918-41b9-a747-d21eb79c6c23": { - "id": "709c62b3-8918-41b9-a747-d21eb79c6c23", - "definition": { - "name": "org.onap.domain.pmsh.PMSH_CDS_ControlLoopElement", - "version": "1.2.3" - }, - "participantId": { - "name": "org.onap.ccsdk.cds.controlloop.CdsControlLoopParticipant", - "version": "2.2.1" - }, - "participantType": { - "name": "org.onap.ccsdk.cds.controlloop.CdsControlLoopParticipant", - "version": "2.2.1" - }, - "state": "UNINITIALISED", - "orderedState": "UNINITIALISED", - "description": "CDS Control Loop Element for the PMSH instance 0 control loop" - } - } - }, - { - "name": "PMSHInstance1", - "version": "1.0.1", - "definition": { - "name": "org.onap.domain.pmsh.PMSHControlLoopDefinition", - "version": "1.2.3" - }, - "state": "UNINITIALISED", - "orderedState": "UNINITIALISED", - "description": "PMSH control loop instance 1", - "elements": { - "709c62b3-8918-41b9-a747-d21eb79c6c24": { - "id": "709c62b3-8918-41b9-a747-e21eb79c6c24", - "definition": { - "name": "org.onap.domain.pmsh.PMSH_DCAEMicroservice", - "version": "1.2.3" - }, - "participantId": { - "name": "org.onap.dcae.controlloop.DCAEMicroserviceControlLoopParticipant", - "version": "2.3.4" - }, - "participantType": { - "name": "org.onap.dcae.controlloop.DCAEMicroserviceControlLoopParticipant", - "version": "2.3.4" - }, - "state": "UNINITIALISED", - "orderedState": "UNINITIALISED", - "description": "DCAE Control Loop Element for the PMSH instance 1 control loop" - }, - "709c62b3-8918-41b9-a747-d21eb79c6c25": { - "id": "709c62b3-8918-41b9-a747-e21eb79c6c25", - "definition": { - "name": "org.onap.domain.pmsh.PMSH_MonitoringPolicyControlLoopElement", - "version": "1.2.3" - }, - "participantId": { - "name": "org.onap.policy.controlloop.PolicyControlLoopParticipant", - "version": "2.3.1" - }, - "participantType": { - "name": "org.onap.policy.controlloop.PolicyControlLoopParticipant", - "version": "2.3.1" - }, - "state": "UNINITIALISED", - "orderedState": "UNINITIALISED", - "description": "Monitoring Policy Control Loop Element for the PMSH instance 1 control loop" - }, - "709c62b3-8918-41b9-a747-d21eb79c6c26": { - "id": "709c62b3-8918-41b9-a747-e21eb79c6c26", - "definition": { - "name": "org.onap.domain.pmsh.PMSH_OperationalPolicyControlLoopElement", - "version": "1.2.3" - }, - "participantId": { - "name": "org.onap.policy.controlloop.PolicyControlLoopParticipant", - "version": "2.3.1" - }, - "participantType": { - "name": "org.onap.policy.controlloop.PolicyControlLoopParticipant", - "version": "2.3.1" - }, - "state": "UNINITIALISED", - "orderedState": "UNINITIALISED", - "description": "Operational Policy Control Loop Element for the PMSH instance 1 control loop" - }, - "709c62b3-8918-41b9-a747-d21eb79c6c27": { - "id": "709c62b3-8918-41b9-a747-e21eb79c6c27", - "definition": { - "name": "org.onap.domain.pmsh.PMSH_CDS_ControlLoopElement", - "version": "1.2.3" - }, - "participantId": { - "name": "org.onap.ccsdk.cds.controlloop.CdsControlLoopParticipant", - "version": "2.2.1" - }, - "participantType": { - "name": "org.onap.ccsdk.cds.controlloop.CdsControlLoopParticipant", - "version": "2.2.1" - }, - "state": "UNINITIALISED", - "orderedState": "UNINITIALISED", - "description": "CDS Control Loop Element for the PMSH instance 1 control loop" - } - } - } - ] -} diff --git a/runtime-controlloop/src/test/resources/rest/controlloops/ControlLoopsNotFound.json b/runtime-controlloop/src/test/resources/rest/controlloops/ControlLoopsNotFound.json deleted file mode 100644 index 9e9767472..000000000 --- a/runtime-controlloop/src/test/resources/rest/controlloops/ControlLoopsNotFound.json +++ /dev/null @@ -1,142 +0,0 @@ -{ - "controlLoopList": [ - { - "name": "PMSHInstance0", - "version": "1.0.1", - "definition": { - "name": "org.onap.domain.PMSHControlLoopDefinition", - "version": "1.2.3" - }, - "state": "UNINITIALISED", - "orderedState": "UNINITIALISED", - "description": "PMSH control loop instance 0", - "elements": { - "709c62b3-8918-41b9-a747-d21eb79c6c20": { - "id": "709c62b3-8918-41b9-a747-d21eb79c6c20", - "definition": { - "name": "org.onap.domain.pmsh.PMSH_DCAEMicroservice", - "version": "1.2.3" - }, - "participantType": { - "name": "org.onap.dcae.controlloop.DCAEMicroserviceControlLoopParticipant", - "version": "2.3.4" - }, - "state": "UNINITIALISED", - "orderedState": "UNINITIALISED", - "description": "DCAE Control Loop Element for the PMSH instance 0 control loop" - }, - "709c62b3-8918-41b9-a747-d21eb79c6c21": { - "id": "709c62b3-8918-41b9-a747-d21eb79c6c21", - "definition": { - "name": "org.onap.domain.pmsh.PMSH_MonitoringPolicyControlLoopElement", - "version": "1.2.3" - }, - "participantType": { - "name": "org.onap.policy.controlloop.PolicyControlLoopParticipant", - "version": "2.3.1" - }, - "state": "UNINITIALISED", - "orderedState": "UNINITIALISED", - "description": "Monitoring Policy Control Loop Element for the PMSH instance 0 control loop" - }, - "709c62b3-8918-41b9-a747-d21eb79c6c22": { - "id": "709c62b3-8918-41b9-a747-d21eb79c6c22", - "definition": { - "name": "org.onap.domain.pmsh.PMSH_OperationalPolicyControlLoopElement", - "version": "1.2.3" - }, - "participantType": { - "name": "org.onap.policy.controlloop.PolicyControlLoopParticipant", - "version": "2.3.1" - }, - "state": "UNINITIALISED", - "orderedState": "UNINITIALISED", - "description": "Operational Policy Control Loop Element for the PMSH instance 0 control loop" - }, - "709c62b3-8918-41b9-a747-d21eb79c6c23": { - "id": "709c62b3-8918-41b9-a747-d21eb79c6c23", - "definition": { - "name": "org.onap.domain.pmsh.PMSH_CDS_ControlLoopElement", - "version": "1.2.3" - }, - "participantType": { - "name": "org.onap.ccsdk.cds.controlloop.CdsControlLoopParticipant", - "version": "2.2.1" - }, - "state": "UNINITIALISED", - "orderedState": "UNINITIALISED", - "description": "CDS Control Loop Element for the PMSH instance 0 control loop" - } - } - }, - { - "name": "PMSHInstance1", - "version": "1.0.1", - "definition": { - "name": "org.onap.domain.PMSHControlLoopDefinition", - "version": "1.2.3" - }, - "state": "UNINITIALISED", - "orderedState": "UNINITIALISED", - "description": "PMSH control loop instance 1", - "elements": { - "709c62b3-8918-41b9-a747-d21eb79c6c24": { - "id": "709c62b3-8918-41b9-a747-e21eb79c6c24", - "definition": { - "name": "org.onap.domain.pmsh.PMSH_DCAEMicroservice", - "version": "1.2.3" - }, - "participantType": { - "name": "org.onap.dcae.controlloop.DCAEMicroserviceControlLoopParticipant", - "version": "2.3.4" - }, - "state": "UNINITIALISED", - "orderedState": "UNINITIALISED", - "description": "DCAE Control Loop Element for the PMSH instance 1 control loop" - }, - "709c62b3-8918-41b9-a747-d21eb79c6c25": { - "id": "709c62b3-8918-41b9-a747-e21eb79c6c25", - "definition": { - "name": "org.onap.domain.pmsh.PMSH_MonitoringPolicyControlLoopElement", - "version": "1.2.3" - }, - "participantType": { - "name": "org.onap.policy.controlloop.PolicyControlLoopParticipant", - "version": "2.3.1" - }, - "state": "UNINITIALISED", - "orderedState": "UNINITIALISED", - "description": "Monitoring Policy Control Loop Element for the PMSH instance 1 control loop" - }, - "709c62b3-8918-41b9-a747-d21eb79c6c26": { - "id": "709c62b3-8918-41b9-a747-e21eb79c6c26", - "definition": { - "name": "org.onap.domain.pmsh.PMSH_OperationalPolicyControlLoopElement", - "version": "1.2.3" - }, - "participantType": { - "name": "org.onap.policy.controlloop.PolicyControlLoopParticipant", - "version": "2.3.1" - }, - "state": "UNINITIALISED", - "orderedState": "UNINITIALISED", - "description": "Operational Policy Control Loop Element for the PMSH instance 1 control loop" - }, - "709c62b3-8918-41b9-a747-d21eb79c6c27": { - "id": "709c62b3-8918-41b9-a747-e21eb79c6c27", - "definition": { - "name": "org.onap.domain.pmsh.PMSH_CDS_ControlLoopElement", - "version": "1.2.3" - }, - "participantType": { - "name": "org.onap.ccsdk.cds.controlloop.CdsControlLoopParticipant", - "version": "2.2.1" - }, - "state": "UNINITIALISED", - "orderedState": "UNINITIALISED", - "description": "CDS Control Loop Element for the PMSH instance 1 control loop" - } - } - } - ] -} diff --git a/runtime-controlloop/src/test/resources/rest/controlloops/ControlLoopsSmoke.json b/runtime-controlloop/src/test/resources/rest/controlloops/ControlLoopsSmoke.json deleted file mode 100644 index 47f379b84..000000000 --- a/runtime-controlloop/src/test/resources/rest/controlloops/ControlLoopsSmoke.json +++ /dev/null @@ -1,174 +0,0 @@ -{ - "controlLoopList": [ - { - "name": "PMSHInstance0", - "version": "1.0.1", - "definition": { - "name": "org.onap.domain.pmsh.PMSHControlLoopDefinition", - "version": "1.2.3" - }, - "state": "UNINITIALISED", - "orderedState": "UNINITIALISED", - "description": "PMSH control loop instance 0", - "elements": { - "709c62b3-8918-41b9-a747-d21eb79c6c20": { - "id": "709c62b3-8918-41b9-a747-d21eb79c6c20", - "definition": { - "name": "org.onap.domain.database.Http_PMSHMicroserviceControlLoopElement", - "version": "1.2.3" - }, - "participantId": { - "name": "org.onap.dcae.controlloop.DCAEMicroserviceControlLoopParticipant", - "version": "2.3.4" - }, - "participantType": { - "name": "org.onap.dcae.controlloop.DCAEMicroserviceControlLoopParticipant", - "version": "2.3.4" - }, - "state": "UNINITIALISED", - "orderedState": "UNINITIALISED", - "description": "DCAE Control Loop Element for the PMSH instance 0 control loop" - }, - "709c62b3-8918-41b9-a747-d21eb79c6c21": { - "id": "709c62b3-8918-41b9-a747-d21eb79c6c21", - "definition": { - "name": "org.onap.domain.pmsh.PMSH_MonitoringPolicyControlLoopElement", - "version": "1.2.3" - }, - "participantId": { - "name": "org.onap.policy.controlloop.PolicyControlLoopParticipant", - "version": "2.3.1" - }, - "participantType": { - "name": "org.onap.policy.controlloop.PolicyControlLoopParticipant", - "version": "2.3.1" - }, - "state": "UNINITIALISED", - "orderedState": "UNINITIALISED", - "description": "Monitoring Policy Control Loop Element for the PMSH instance 0 control loop" - }, - "709c62b3-8918-41b9-a747-d21eb79c6c22": { - "id": "709c62b3-8918-41b9-a747-d21eb79c6c22", - "definition": { - "name": "org.onap.domain.pmsh.PMSH_OperationalPolicyControlLoopElement", - "version": "1.2.3" - }, - "participantId": { - "name": "org.onap.policy.controlloop.PolicyControlLoopParticipant", - "version": "2.3.1" - }, - "participantType": { - "name": "org.onap.policy.controlloop.PolicyControlLoopParticipant", - "version": "2.3.1" - }, - "state": "UNINITIALISED", - "orderedState": "UNINITIALISED", - "description": "Operational Policy Control Loop Element for the PMSH instance 0 control loop" - }, - "709c62b3-8918-41b9-a747-d21eb79c6c23": { - "id": "709c62b3-8918-41b9-a747-d21eb79c6c23", - "definition": { - "name": "org.onap.domain.database.PMSH_K8SMicroserviceControlLoopElement", - "version": "1.2.3" - }, - "participantId": { - "name": "org.onap.ccsdk.cds.controlloop.CdsControlLoopParticipant", - "version": "2.2.1" - }, - "participantType": { - "name": "org.onap.ccsdk.cds.controlloop.CdsControlLoopParticipant", - "version": "2.2.1" - }, - "state": "UNINITIALISED", - "orderedState": "UNINITIALISED", - "description": "CDS Control Loop Element for the PMSH instance 0 control loop" - } - } - }, - { - "name": "PMSHInstance1", - "version": "1.0.1", - "definition": { - "name": "org.onap.domain.pmsh.PMSHControlLoopDefinition", - "version": "1.2.3" - }, - "state": "UNINITIALISED", - "orderedState": "UNINITIALISED", - "description": "PMSH control loop instance 1", - "elements": { - "709c62b3-8918-41b9-a747-d21eb79c6c24": { - "id": "709c62b3-8918-41b9-a747-e21eb79c6c24", - "definition": { - "name": "org.onap.domain.pmsh.PMSH_DCAEMicroservice", - "version": "1.2.3" - }, - "participantId": { - "name": "org.onap.dcae.controlloop.DCAEMicroserviceControlLoopParticipant", - "version": "2.3.4" - }, - "participantType": { - "name": "org.onap.dcae.controlloop.DCAEMicroserviceControlLoopParticipant", - "version": "2.3.4" - }, - "state": "UNINITIALISED", - "orderedState": "UNINITIALISED", - "description": "DCAE Control Loop Element for the PMSH instance 1 control loop" - }, - "709c62b3-8918-41b9-a747-d21eb79c6c25": { - "id": "709c62b3-8918-41b9-a747-e21eb79c6c25", - "definition": { - "name": "org.onap.domain.pmsh.PMSH_MonitoringPolicyControlLoopElement", - "version": "1.2.3" - }, - "participantId": { - "name": "org.onap.policy.controlloop.PolicyControlLoopParticipant", - "version": "2.3.1" - }, - "participantType": { - "name": "org.onap.policy.controlloop.PolicyControlLoopParticipant", - "version": "2.3.1" - }, - "state": "UNINITIALISED", - "orderedState": "UNINITIALISED", - "description": "Monitoring Policy Control Loop Element for the PMSH instance 1 control loop" - }, - "709c62b3-8918-41b9-a747-d21eb79c6c26": { - "id": "709c62b3-8918-41b9-a747-e21eb79c6c26", - "definition": { - "name": "org.onap.domain.pmsh.PMSH_OperationalPolicyControlLoopElement", - "version": "1.2.3" - }, - "participantId": { - "name": "org.onap.policy.controlloop.PolicyControlLoopParticipant", - "version": "2.3.1" - }, - "participantType": { - "name": "org.onap.policy.controlloop.PolicyControlLoopParticipant", - "version": "2.3.1" - }, - "state": "UNINITIALISED", - "orderedState": "UNINITIALISED", - "description": "Operational Policy Control Loop Element for the PMSH instance 1 control loop" - }, - "709c62b3-8918-41b9-a747-d21eb79c6c27": { - "id": "709c62b3-8918-41b9-a747-e21eb79c6c27", - "definition": { - "name": "org.onap.domain.pmsh.PMSH_CDS_ControlLoopElement", - "version": "1.2.3" - }, - "participantId": { - "name": "org.onap.ccsdk.cds.controlloop.CdsControlLoopParticipant", - "version": "2.2.1" - }, - "participantType": { - "name": "org.onap.ccsdk.cds.controlloop.CdsControlLoopParticipant", - "version": "2.2.1" - }, - "state": "UNINITIALISED", - "orderedState": "UNINITIALISED", - "description": "CDS Control Loop Element for the PMSH instance 1 control loop" - } - } - } - ] -} diff --git a/runtime-controlloop/src/test/resources/rest/controlloops/ControlLoopsUpdate.json b/runtime-controlloop/src/test/resources/rest/controlloops/ControlLoopsUpdate.json deleted file mode 100644 index b09e46fe7..000000000 --- a/runtime-controlloop/src/test/resources/rest/controlloops/ControlLoopsUpdate.json +++ /dev/null @@ -1,174 +0,0 @@ -{ - "controlLoopList": [ - { - "name": "PMSHInstance0", - "version": "1.0.1", - "definition": { - "name": "org.onap.domain.pmsh.PMSHControlLoopDefinition", - "version": "1.2.3" - }, - "state": "UNINITIALISED", - "orderedState": "UNINITIALISED", - "description": "PMSH control loop instance 1", - "elements": { - "709c62b3-8918-41b9-a747-d21eb79c6c21": { - "id": "709c62b3-8918-41b9-a747-d21eb79c6c21", - "definition": { - "name": "org.onap.domain.pmsh.PMSH_DCAEMicroservice", - "version": "1.2.3" - }, - "participantId": { - "name": "org.onap.dcae.controlloop.DCAEMicroserviceControlLoopParticipant", - "version": "2.3.4" - }, - "participantType": { - "name": "org.onap.dcae.controlloop.DCAEMicroserviceControlLoopParticipant", - "version": "2.3.4" - }, - "state": "UNINITIALISED", - "orderedState": "UNINITIALISED", - "description": "DCAE Control Loop Element for the PMSH instance 0 control loop" - }, - "709c62b3-8918-41b9-a747-d21eb79c6c22": { - "id": "709c62b3-8918-41b9-a747-d21eb79c6c22", - "definition": { - "name": "org.onap.domain.pmsh.PMSH_MonitoringPolicyControlLoopElement", - "version": "1.2.3" - }, - "participantId": { - "name": "org.onap.policy.controlloop.PolicyControlLoopParticipant", - "version": "2.3.1" - }, - "participantType": { - "name": "org.onap.policy.controlloop.PolicyControlLoopParticipant", - "version": "2.3.1" - }, - "state": "UNINITIALISED", - "orderedState": "UNINITIALISED", - "description": "Monitoring Policy Control Loop Element for the PMSH instance 0 control loop" - }, - "709c62b3-8918-41b9-a747-d21eb79c6c23": { - "id": "709c62b3-8918-41b9-a747-d21eb79c6c23", - "definition": { - "name": "org.onap.domain.pmsh.PMSH_MonitoringPolicyControlLoopElement", - "version": "1.2.3" - }, - "participantId": { - "name": "org.onap.policy.controlloop.PolicyControlLoopParticipant", - "version": "2.3.1" - }, - "participantType": { - "name": "org.onap.policy.controlloop.PolicyControlLoopParticipant", - "version": "2.3.1" - }, - "state": "UNINITIALISED", - "orderedState": "UNINITIALISED", - "description": "Operational Policy Control Loop Element for the PMSH instance 0 control loop" - }, - "709c62b3-8918-41b9-a747-d21eb79c6c24": { - "id": "709c62b3-8918-41b9-a747-d21eb79c6c24", - "definition": { - "name": "org.onap.domain.pmsh.PMSH_CDS_ControlLoopElement", - "version": "1.2.3" - }, - "participantId": { - "name": "org.onap.ccsdk.cds.controlloop.CdsControlLoopParticipant", - "version": "2.2.1" - }, - "participantType": { - "name": "org.onap.ccsdk.cds.controlloop.CdsControlLoopParticipant", - "version": "2.2.1" - }, - "state": "UNINITIALISED", - "orderedState": "UNINITIALISED", - "description": "CDS Control Loop Element for the PMSH instance 0 control loop" - } - } - }, - { - "name": "PMSHInstance1", - "version": "1.0.1", - "definition": { - "name": "org.onap.domain.pmsh.PMSHControlLoopDefinition", - "version": "1.2.3" - }, - "state": "UNINITIALISED", - "orderedState": "UNINITIALISED", - "description": "PMSH control loop instance 1", - "elements": { - "709c62b3-8918-41b9-a747-d21eb79c6c25": { - "id": "709c62b3-8918-41b9-a747-e21eb79c6c25", - "definition": { - "name": "org.onap.domain.pmsh.PMSH_DCAEMicroservice", - "version": "1.2.3" - }, - "participantId": { - "name": "org.onap.dcae.controlloop.DCAEMicroserviceControlLoopParticipant", - "version": "2.3.4" - }, - "participantType": { - "name": "org.onap.dcae.controlloop.DCAEMicroserviceControlLoopParticipant", - "version": "2.3.4" - }, - "state": "UNINITIALISED", - "orderedState": "UNINITIALISED", - "description": "DCAE Control Loop Element for the PMSH instance 1 control loop" - }, - "709c62b3-8918-41b9-a747-d21eb79c6c26": { - "id": "709c62b3-8918-41b9-a747-e21eb79c6c26", - "definition": { - "name": "org.onap.domain.pmsh.PMSH_MonitoringPolicyControlLoopElement", - "version": "1.2.3" - }, - "participantId": { - "name": "org.onap.policy.controlloop.PolicyControlLoopParticipant", - "version": "2.3.1" - }, - "participantType": { - "name": "org.onap.policy.controlloop.PolicyControlLoopParticipant", - "version": "2.3.1" - }, - "state": "UNINITIALISED", - "orderedState": "UNINITIALISED", - "description": "Monitoring Policy Control Loop Element for the PMSH instance 1 control loop" - }, - "709c62b3-8918-41b9-a747-d21eb79c6c27": { - "id": "709c62b3-8918-41b9-a747-e21eb79c6c27", - "definition": { - "name": "org.onap.domain.pmsh.PMSH_MonitoringPolicyControlLoopElement", - "version": "1.2.3" - }, - "participantId": { - "name": "org.onap.policy.controlloop.PolicyControlLoopParticipant", - "version": "2.3.1" - }, - "participantType": { - "name": "org.onap.policy.controlloop.PolicyControlLoopParticipant", - "version": "2.3.1" - }, - "state": "UNINITIALISED", - "orderedState": "UNINITIALISED", - "description": "Operational Policy Control Loop Element for the PMSH instance 1 control loop" - }, - "709c62b3-8918-41b9-a747-d21eb79c6c28": { - "id": "709c62b3-8918-41b9-a747-e21eb79c6c28", - "definition": { - "name": "org.onap.domain.pmsh.PMSH_CDS_ControlLoopElement", - "version": "1.2.3" - }, - "participantId": { - "name": "org.onap.ccsdk.cds.controlloop.CdsControlLoopParticipant", - "version": "2.2.1" - }, - "participantType": { - "name": "org.onap.ccsdk.cds.controlloop.CdsControlLoopParticipant", - "version": "2.2.1" - }, - "state": "UNINITIALISED", - "orderedState": "UNINITIALISED", - "description": "CDS Control Loop Element for the PMSH instance 1 control loop" - } - } - } - ] -} diff --git a/runtime-controlloop/src/test/resources/rest/controlloops/ControlLoopsVersionNotMatches.json b/runtime-controlloop/src/test/resources/rest/controlloops/ControlLoopsVersionNotMatches.json deleted file mode 100644 index 76131afc1..000000000 --- a/runtime-controlloop/src/test/resources/rest/controlloops/ControlLoopsVersionNotMatches.json +++ /dev/null @@ -1,142 +0,0 @@ -{ - "controlLoopList": [ - { - "name": "PMSHInstance0", - "version": "1.0.1", - "definition": { - "name": "org.onap.domain.pmsh.PMSHControlLoopDefinition", - "version": "1.2.3" - }, - "state": "UNINITIALISED", - "orderedState": "UNINITIALISED", - "description": "PMSH control loop instance 0", - "elements": { - "709c62b3-8918-41b9-a747-d21eb79c6c20": { - "id": "709c62b3-8918-41b9-a747-d21eb79c6c20", - "definition": { - "name": "org.onap.domain.pmsh.PMSH_DCAEMicroservice", - "version": "1.0.0" - }, - "participantType": { - "name": "org.onap.dcae.controlloop.DCAEMicroserviceControlLoopParticipant", - "version": "2.3.4" - }, - "state": "UNINITIALISED", - "orderedState": "UNINITIALISED", - "description": "DCAE Control Loop Element for the PMSH instance 0 control loop" - }, - "709c62b3-8918-41b9-a747-d21eb79c6c21": { - "id": "709c62b3-8918-41b9-a747-d21eb79c6c21", - "definition": { - "name": "org.onap.domain.pmsh.PMSH_MonitoringPolicyControlLoopElement", - "version": "1.2.3" - }, - "participantType": { - "name": "org.onap.policy.controlloop.PolicyControlLoopParticipant", - "version": "2.3.1" - }, - "state": "UNINITIALISED", - "orderedState": "UNINITIALISED", - "description": "Monitoring Policy Control Loop Element for the PMSH instance 0 control loop" - }, - "709c62b3-8918-41b9-a747-d21eb79c6c22": { - "id": "709c62b3-8918-41b9-a747-d21eb79c6c22", - "definition": { - "name": "org.onap.domain.pmsh.PMSH_OperationalPolicyControlLoopElement", - "version": "1.2.3" - }, - "participantType": { - "name": "org.onap.policy.controlloop.PolicyControlLoopParticipant", - "version": "2.3.1" - }, - "state": "UNINITIALISED", - "orderedState": "UNINITIALISED", - "description": "Operational Policy Control Loop Element for the PMSH instance 0 control loop" - }, - "709c62b3-8918-41b9-a747-d21eb79c6c23": { - "id": "709c62b3-8918-41b9-a747-d21eb79c6c23", - "definition": { - "name": "org.onap.domain.pmsh.PMSH_CDS_ControlLoopElement", - "version": "1.2.3" - }, - "participantType": { - "name": "org.onap.ccsdk.cds.controlloop.CdsControlLoopParticipant", - "version": "2.2.1" - }, - "state": "UNINITIALISED", - "orderedState": "UNINITIALISED", - "description": "CDS Control Loop Element for the PMSH instance 0 control loop" - } - } - }, - { - "name": "PMSHInstance1", - "version": "1.0.1", - "definition": { - "name": "org.onap.domain.pmsh.PMSHControlLoopDefinition", - "version": "1.2.3" - }, - "state": "UNINITIALISED", - "orderedState": "UNINITIALISED", - "description": "PMSH control loop instance 1", - "elements": { - "709c62b3-8918-41b9-a747-d21eb79c6c24": { - "id": "709c62b3-8918-41b9-a747-e21eb79c6c24", - "definition": { - "name": "org.onap.domain.pmsh.PMSH_DCAEMicroservice", - "version": "1.0.0" - }, - "participantType": { - "name": "org.onap.dcae.controlloop.DCAEMicroserviceControlLoopParticipant", - "version": "2.3.4" - }, - "state": "UNINITIALISED", - "orderedState": "UNINITIALISED", - "description": "DCAE Control Loop Element for the PMSH instance 1 control loop" - }, - "709c62b3-8918-41b9-a747-d21eb79c6c25": { - "id": "709c62b3-8918-41b9-a747-e21eb79c6c25", - "definition": { - "name": "org.onap.domain.pmsh.PMSH_MonitoringPolicyControlLoopElement", - "version": "1.2.3" - }, - "participantType": { - "name": "org.onap.policy.controlloop.PolicyControlLoopParticipant", - "version": "2.3.1" - }, - "state": "UNINITIALISED", - "orderedState": "UNINITIALISED", - "description": "Monitoring Policy Control Loop Element for the PMSH instance 1 control loop" - }, - "709c62b3-8918-41b9-a747-d21eb79c6c26": { - "id": "709c62b3-8918-41b9-a747-e21eb79c6c26", - "definition": { - "name": "org.onap.domain.pmsh.PMSH_OperationalPolicyControlLoopElement", - "version": "1.2.3" - }, - "participantType": { - "name": "org.onap.policy.controlloop.PolicyControlLoopParticipant", - "version": "2.3.1" - }, - "state": "UNINITIALISED", - "orderedState": "UNINITIALISED", - "description": "Operational Policy Control Loop Element for the PMSH instance 1 control loop" - }, - "709c62b3-8918-41b9-a747-d21eb79c6c27": { - "id": "709c62b3-8918-41b9-a747-e21eb79c6c27", - "definition": { - "name": "org.onap.domain.pmsh.PMSH_CDS_ControlLoopElement", - "version": "1.2.3" - }, - "participantType": { - "name": "org.onap.ccsdk.cds.controlloop.CdsControlLoopParticipant", - "version": "2.2.1" - }, - "state": "UNINITIALISED", - "orderedState": "UNINITIALISED", - "description": "CDS Control Loop Element for the PMSH instance 1 control loop" - } - } - } - ] -} diff --git a/runtime-controlloop/src/test/resources/rest/controlloops/PassiveCommand.json b/runtime-controlloop/src/test/resources/rest/controlloops/PassiveCommand.json deleted file mode 100644 index 9c87e43b6..000000000 --- a/runtime-controlloop/src/test/resources/rest/controlloops/PassiveCommand.json +++ /dev/null @@ -1,13 +0,0 @@ -{ - "orderedState": "PASSIVE", - "controlLoopIdentifierList": [ - { - "name": "PMSHInstance0", - "version": "1.0.1" - }, - { - "name": "PMSHInstance1", - "version": "1.0.1" - } - ] -} diff --git a/runtime-controlloop/src/test/resources/rest/monitoring/TestClElementStatistics.json b/runtime-controlloop/src/test/resources/rest/monitoring/TestClElementStatistics.json deleted file mode 100644 index 21a048ff0..000000000 --- a/runtime-controlloop/src/test/resources/rest/monitoring/TestClElementStatistics.json +++ /dev/null @@ -1,44 +0,0 @@ -{ - "clElementStatistics":[ - { - "participantId":{ - "name":"name1", - "version":"1.001" - }, - "id": "709c62b3-8918-41b9-a747-d21eb79c6c20", - "timeStamp": "2021-01-10T13:45:00.000Z", - "controlLoopState": "UNINITIALISED", - "clElementUptime":250 - }, - { - "participantId":{ - "name":"name1", - "version":"1.001" - }, - "id": "709c62b3-8918-41b9-a747-d21eb79c6c20", - "timeStamp": "2021-01-10T15:45:00.000Z", - "controlLoopState": "UNINITIALISED", - "clElementUptime":450 - }, - { - "participantId":{ - "name":"name2", - "version":"1.001" - }, - "id": "709c62b3-8918-41b9-a747-d21eb79c6c21", - "timeStamp": "2021-01-10T14:25:00.000Z", - "controlLoopState": "UNINITIALISED", - "clElementUptime":330 - }, - { - "participantId":{ - "name":"name2", - "version":"1.001" - }, - "id": "709c62b3-8918-41b9-a747-d21eb79c6c21", - "timeStamp": "2021-01-10T16:35:00.000Z", - "controlLoopState": "UNINITIALISED", - "clElementUptime":650 - } - ] -} \ No newline at end of file diff --git a/runtime-controlloop/src/test/resources/rest/monitoring/TestClElementStatistics_Invalid.json b/runtime-controlloop/src/test/resources/rest/monitoring/TestClElementStatistics_Invalid.json deleted file mode 100644 index 2cf2619bf..000000000 --- a/runtime-controlloop/src/test/resources/rest/monitoring/TestClElementStatistics_Invalid.json +++ /dev/null @@ -1,13 +0,0 @@ -{ - "clElementStatisticsList":[ - { - "participantId":{ - "name":"name1", - "version":"1.001" - }, - "id": "709c62b3-8918-41b9-a747-d21eb79c6c20", - "controlLoopState": "UNINITIALISED", - "clElementUptime":250 - } - ] -} \ No newline at end of file diff --git a/runtime-controlloop/src/test/resources/rest/monitoring/TestParticipantStatistics.json b/runtime-controlloop/src/test/resources/rest/monitoring/TestParticipantStatistics.json deleted file mode 100644 index acd88e24b..000000000 --- a/runtime-controlloop/src/test/resources/rest/monitoring/TestParticipantStatistics.json +++ /dev/null @@ -1,46 +0,0 @@ -{ - "statisticsList":[ - { - "participantId":{ - "name":"name1", - "version":"1.001" - }, - "timeStamp": "2021-01-10T13:45:00.000Z", - "state": "PASSIVE", - "healthStatus": "HEALTHY", - "eventCount":250, - "lastExecutionTime":100, - "averageExecutionTime":90, - "upTime":1000, - "lastStart":3000 - }, - { - "participantId":{ - "name":"name1", - "version":"1.001" - }, - "timeStamp": "2021-01-10T15:45:00.000Z", - "state": "PASSIVE", - "healthStatus": "HEALTHY", - "eventCount":262, - "lastExecutionTime":100, - "averageExecutionTime":90, - "upTime":2000, - "lastStart":3000 - }, - { - "participantId":{ - "name":"name2", - "version":"1.001" - }, - "timeStamp": "2021-01-27T14:25:00.000Z", - "state": "PASSIVE", - "healthStatus": "HEALTHY", - "eventCount":245, - "lastExecutionTime":1020, - "averageExecutionTime":85, - "upTime":1050, - "lastStart":3100 - } - ] -} \ No newline at end of file diff --git a/runtime-controlloop/src/test/resources/rest/monitoring/TestParticipantStatistics_Invalid.json b/runtime-controlloop/src/test/resources/rest/monitoring/TestParticipantStatistics_Invalid.json deleted file mode 100644 index 7281822f0..000000000 --- a/runtime-controlloop/src/test/resources/rest/monitoring/TestParticipantStatistics_Invalid.json +++ /dev/null @@ -1,16 +0,0 @@ -{ - "participantStatisticsList":[ - { - "participantId":{ - "name":"name3", - "version":"1.001" - }, - "state": "PASSIVE", - "eventCount":250, - "lastExecutionTime":100, - "averageExecutionTime":90, - "upTime":1000, - "lastStart":3000 - } - ] -} \ No newline at end of file diff --git a/runtime-controlloop/src/test/resources/rest/servicetemplates/PMSHMultipleCLTosca.yaml b/runtime-controlloop/src/test/resources/rest/servicetemplates/PMSHMultipleCLTosca.yaml deleted file mode 100644 index 9acff1356..000000000 --- a/runtime-controlloop/src/test/resources/rest/servicetemplates/PMSHMultipleCLTosca.yaml +++ /dev/null @@ -1,232 +0,0 @@ -tosca_definitions_version: tosca_simple_yaml_1_3 -data_types: - onap.datatypes.ToscaConceptIdentifier: - derived_from: tosca.datatypes.Root - properties: - name: - type: string - required: true - version: - type: string - required: true -node_types: - org.onap.policy.clamp.controlloop.Participant: - version: 1.0.1 - derived_from: tosca.nodetypes.Root - properties: - provider: - type: string - requred: false - org.onap.policy.clamp.controlloop.ControlLoopElement: - version: 1.0.1 - derived_from: tosca.nodetypes.Root - properties: - provider: - type: string - requred: false - participantType: - type: onap.datatypes.ToscaConceptIdentifier - requred: true - startPhase: - type: integer - required: false - constraints: - - greater-or-equal: 0 - metadata: - common: true - description: A value indicating the start phase in which this control loop element will be started, the - first start phase is zero. Control Loop Elements are started in their start_phase order and stopped - in reverse start phase order. Control Loop Elements with the same start phase are started and - stopped simultaneously - org.onap.policy.clamp.controlloop.ControlLoop: - version: 1.0.1 - derived_from: tosca.nodetypes.Root - properties: - provider: - type: string - requred: false - elements: - type: list - required: true - entry_schema: - type: onap.datatypes.ToscaConceptIdentifier - org.onap.policy.clamp.controlloop.DCAEMicroserviceControlLoopElement: - version: 1.0.1 - derived_from: org.onap.policy.clamp.controlloop.ControlLoopElement - properties: - dcae_blueprint_id: - type: onap.datatypes.ToscaConceptIdentifier - requred: true - org.onap.policy.clamp.controlloop.PolicyTypeControlLoopElement: - version: 1.0.1 - derived_from: org.onap.policy.clamp.controlloop.ControlLoopElement - properties: - policy_type_id: - type: onap.datatypes.ToscaConceptIdentifier - requred: true - org.onap.policy.clamp.controlloop.CDSControlLoopElement: - version: 1.0.1 - derived_from: org.onap.policy.clamp.controlloop.ControlLoopElement - properties: - cds_blueprint_id: - type: onap.datatypes.ToscaConceptIdentifier - requred: true -topology_template: - node_templates: - org.onap.dcae.controlloop.DCAEMicroserviceControlLoopParticipant: - version: 2.3.4 - type: org.onap.policy.clamp.controlloop.Participant - type_version: 1.0.1 - description: Participant for DCAE microservices - properties: - provider: ONAP - org.onap.policy.controlloop.PolicyControlLoopParticipant: - version: 2.2.1 - type: org.onap.policy.clamp.controlloop.Participant - type_version: 1.0.1 - description: Participant for DCAE microservices - properties: - provider: ONAP - org.onap.ccsdk.cds.controlloop.CdsControlLoopParticipant: - version: 2.2.1 - type: org.onap.policy.clamp.controlloop.Participant - type_version: 1.0.1 - description: Participant for DCAE microservices - properties: - provider: ONAP - org.onap.domain.pmsh.PMSH_DCAEMicroservice: - version: 1.2.3 - type: org.onap.policy.clamp.controlloop.DCAEMicroserviceControlLoopElement - type_version: 1.0.0 - description: Control loop element for the DCAE microservice for Performance Management Subscription Handling - properties: - provider: Ericsson - participantType: - name: org.onap.dcae.controlloop.DCAEMicroserviceControlLoopParticipant - version: 2.3.4 - dcae_blueprint_id: - name: org.onap.dcae.blueprints.PMSHBlueprint - version: 1.0.0 - org.onap.domain.pmsh.PMSH_MonitoringPolicyControlLoopElement: - version: 1.2.3 - type: org.onap.policy.clamp.controlloop.PolicyTypeControlLoopElement - type_version: 1.0.0 - description: Control loop element for the monitoring policy for Performance Management Subscription Handling - properties: - provider: Ericsson - participantType: - name: org.onap.policy.controlloop.PolicyControlLoopParticipant - version: 2.2.1 - policy_type_id: - name: onap.policies.monitoring.pm-subscription-handler - version: 1.0.0 - org.onap.domain.pmsh.PMSH_OperationalPolicyControlLoopElement: - version: 1.2.3 - type: org.onap.policy.clamp.controlloop.PolicyTypeControlLoopElement - type_version: 1.0.0 - description: Control loop element for the operational policy for Performance Management Subscription Handling - properties: - provider: Ericsson - participantType: - name: org.onap.policy.controlloop.PolicyControlLoopParticipant - version: 2.2.1 - policy_type_id: - name: onap.policies.operational.pm-subscription-handler - version: 1.0.0 - org.onap.domain.pmsh.PMSH_CDS_ControlLoopElement: - version: 1.2.3 - type: org.onap.policy.clamp.controlloop.ControlLoopElement - type_version: 1.0.0 - description: Control loop element for CDS for Performance Management Subscription Handling - properties: - provider: Ericsson - participantType: - name: org.onap.ccsdk.cds.controlloop.CdsControlLoopParticipant - version: 3.2.1 - cds_blueprint_id: - name: org.onap.ccsdk.cds.PMSHCdsBlueprint - version: 1.0.0 - org.onap.domain.pmsh.PMSHControlLoopDefinition: - version: 1.2.3 - type: org.onap.policy.clamp.controlloop.ControlLoop - type_version: 1.0.0 - description: Control loop for Performance Management Subscription Handling - properties: - provider: Ericsson - elements: - - name: org.onap.domain.pmsh.PMSH_DCAEMicroservice - version: 1.2.3 - - name: org.onap.domain.pmsh.PMSH_MonitoringPolicyControlLoopElement - version: 1.2.3 - - name: org.onap.domain.pmsh.PMSH_OperationalPolicyControlLoopElement - version: 1.2.3 - - name: org.onap.domain.pmsh.PMSH_CDS_ControlLoopElement - version: 1.2.3 - org.onap.domain.pmsh.PMSD_DCAEMicroservice: - version: 1.2.3 - type: org.onap.policy.clamp.controlloop.DCAEMicroserviceControlLoopElement - type_version: 1.0.0 - description: Control loop element for the DCAE microservice for Performance Management Subscription Handling - properties: - provider: Ericsson - participantType: - name: org.onap.dcae.controlloop.DCAEMicroserviceControlLoopParticipant - version: 2.3.4 - dcae_blueprint_id: - name: org.onap.dcae.blueprints.PMSDBlueprint - version: 1.0.0 - org.onap.domain.pmsh.PMSD_MonitoringPolicyControlLoopElement: - version: 1.2.3 - type: org.onap.policy.clamp.controlloop.PolicyTypeControlLoopElement - type_version: 1.0.0 - description: Control loop element for the monitoring policy for Performance Management Subscription Handling - properties: - provider: Ericsson - participantType: - name: org.onap.policy.controlloop.PolicyControlLoopParticipant - version: 2.2.1 - policy_type_id: - name: onap.policies.monitoring.pm-subscription-handler - version: 1.0.0 - org.onap.domain.pmsh.PMSD_OperationalPolicyControlLoopElement: - version: 1.2.3 - type: org.onap.policy.clamp.controlloop.PolicyTypeControlLoopElement - type_version: 1.0.0 - description: Control loop element for the operational policy for Performance Management Subscription Handling - properties: - provider: Ericsson - participantType: - name: org.onap.policy.controlloop.PolicyControlLoopParticipant - version: 2.2.1 - policy_type_id: - name: onap.policies.operational.pm-subscription-handler - version: 1.0.0 - org.onap.domain.pmsh.PMSD_CDS_ControlLoopElement: - version: 1.2.3 - type: org.onap.policy.clamp.controlloop.ControlLoopElement - type_version: 1.0.0 - description: Control loop element for CDS for Performance Management Subscription Handling - properties: - provider: Ericsson - participantType: - name: org.onap.ccsdk.cds.controlloop.CdsControlLoopParticipant - version: 3.2.1 - cds_blueprint_id: - name: org.onap.ccsdk.cds.PMSDCdsBlueprint - version: 1.0.0 - org.onap.domain.pmsh.PMSDControlLoopDefinition: - version: 1.2.3 - type: org.onap.policy.clamp.controlloop.ControlLoop - type_version: 1.0.0 - description: Control loop for Performance Management Subscription Handling - properties: - provider: Ericsson - elements: - - name: org.onap.domain.pmsh.PMSD_DCAEMicroservice - version: 1.2.3 - - name: org.onap.domain.pmsh.PMSD_MonitoringPolicyControlLoopElement - version: 1.2.3 - - name: org.onap.domain.pmsh.PMSD_OperationalPolicyControlLoopElement - version: 1.2.3 - - name: org.onap.domain.pmsh.PMSD_CDS_ControlLoopElement - version: 1.2.3 diff --git a/runtime-controlloop/src/test/resources/rest/servicetemplates/full-tosca-with-common-properties.yaml b/runtime-controlloop/src/test/resources/rest/servicetemplates/full-tosca-with-common-properties.yaml deleted file mode 100644 index 4dd4f95ae..000000000 --- a/runtime-controlloop/src/test/resources/rest/servicetemplates/full-tosca-with-common-properties.yaml +++ /dev/null @@ -1,3546 +0,0 @@ -tosca_definitions_version: tosca_simple_yaml_1_1_0 -data_types: - onap.datatypes.ToscaConceptIdentifier: - derived_from: tosca.datatypes.Root - properties: - name: - type: string - required: true - version: - type: string - required: true - org.onap.datatypes.policy.clamp.controlloop.DCAEMicroserviceControlLoopElementConsulInfo: - name: org.onap.datatypes.policy.clamp.controlloop.DCAEMicroserviceControlLoopElementConsulInfo - version: 0.0.0 - derived_from: tosca.datatypes.Root - properties: - consulUrl: - name: consulUrl - type: string - typeVersion: 0.0.0 - description: Consul url for this entry - required: true - consul_body: - name: consulBody - type: string - typeVersion: 0.0.0 - description: Body of Consul entry - required: true - onap.datatype.controlloop.Target: - derived_from: tosca.datatypes.Root - description: Definition for a entity in A&AI to perform a control loop operation on - properties: - targetType: - type: string - description: Category for the target type - required: true - constraints: - - valid_values: - - VNF - - VM - - VFMODULE - - PNF - entityIds: - type: map - description: | - Map of values that identify the resource. If none are provided, it is assumed that the - entity that generated the ONSET event will be the target. - required: false - metadata: - clamp_possible_values: ClampExecution:CSAR_RESOURCES - entry_schema: - type: string - onap.datatype.controlloop.Actor: - derived_from: tosca.datatypes.Root - description: An actor/operation/target definition - properties: - actor: - type: string - description: The actor performing the operation. - required: true - metadata: - clamp_possible_values: Dictionary:DefaultActors,ClampExecution:CDS/actor - operation: - type: string - description: The operation the actor is performing. - metadata: - clamp_possible_values: Dictionary:DefaultOperations,ClampExecution:CDS/operation - required: true - target: - type: onap.datatype.controlloop.Target - description: The resource the operation should be performed on. - required: true - payload: - type: map - description: Name/value pairs of payload information passed by Policy to the actor - required: false - metadata: - clamp_possible_values: ClampExecution:CDS/payload - entry_schema: - type: string - onap.datatype.controlloop.Operation: - derived_from: tosca.datatypes.Root - description: An operation supported by an actor - properties: - id: - type: string - description: Unique identifier for the operation - required: true - description: - type: string - description: A user-friendly description of the intent for the operation - required: false - operation: - type: onap.datatype.controlloop.Actor - description: The definition of the operation to be performed. - required: true - timeout: - type: integer - description: The amount of time for the actor to perform the operation. - required: true - retries: - type: integer - description: The number of retries the actor should attempt to perform the operation. - required: true - default: 0 - success: - type: string - description: Points to the operation to invoke on success. A value of "final_success" indicates and end to the operation. - required: false - default: final_success - failure: - type: string - description: Points to the operation to invoke on Actor operation failure. - required: false - default: final_failure - failure_timeout: - type: string - description: Points to the operation to invoke when the time out for the operation occurs. - required: false - default: final_failure_timeout - failure_retries: - type: string - description: Points to the operation to invoke when the current operation has exceeded its max retries. - required: false - default: final_failure_retries - failure_exception: - type: string - description: Points to the operation to invoke when the current operation causes an exception. - required: false - default: final_failure_exception - failure_guard: - type: string - description: Points to the operation to invoke when the current operation is blocked due to guard policy enforcement. - required: false - default: final_failure_guard - onap.datatypes.monitoring.managedObjectDNsBasic: - constraints: [] - properties: - DN: - name: DN - type: string - typeVersion: 0.0.0 - description: Managed object distinguished name - required: true - constraints: [] - metadata: {} - name: onap.datatypes.monitoring.managedObjectDNsBasic - version: 0.0.0 - derived_from: tosca.datatypes.Root - metadata: {} - onap.datatypes.monitoring.managedObjectDNsBasics: - constraints: [] - properties: - managedObjectDNsBasic: - name: managedObjectDNsBasic - type: map - typeVersion: 0.0.0 - description: Managed object distinguished name object - required: true - constraints: [] - entry_schema: - type: onap.datatypes.monitoring.managedObjectDNsBasic - typeVersion: 0.0.0 - constraints: [] - metadata: {} - name: onap.datatypes.monitoring.managedObjectDNsBasics - version: 0.0.0 - derived_from: tosca.datatypes.Root - metadata: {} - onap.datatypes.monitoring.measurementGroup: - constraints: [] - properties: - measurementTypes: - name: measurementTypes - type: list - typeVersion: 0.0.0 - description: List of measurement types - required: true - constraints: [] - entry_schema: - type: onap.datatypes.monitoring.measurementTypes - typeVersion: 0.0.0 - constraints: [] - metadata: {} - managedObjectDNsBasic: - name: managedObjectDNsBasic - type: list - typeVersion: 0.0.0 - description: List of managed object distinguished names - required: true - constraints: [] - entry_schema: - type: onap.datatypes.monitoring.managedObjectDNsBasics - typeVersion: 0.0.0 - constraints: [] - metadata: {} - name: onap.datatypes.monitoring.measurementGroup - version: 0.0.0 - derived_from: tosca.datatypes.Root - metadata: {} - onap.datatypes.monitoring.measurementGroups: - constraints: [] - properties: - measurementGroup: - name: measurementGroup - type: map - typeVersion: 0.0.0 - description: Measurement Group - required: true - constraints: [] - entry_schema: - type: onap.datatypes.monitoring.measurementGroup - typeVersion: 0.0.0 - constraints: [] - metadata: {} - name: onap.datatypes.monitoring.measurementGroups - version: 0.0.0 - derived_from: tosca.datatypes.Root - metadata: {} - onap.datatypes.monitoring.measurementType: - constraints: [] - properties: - measurementType: - name: measurementType - type: string - typeVersion: 0.0.0 - description: Measurement type - required: true - constraints: [] - metadata: {} - name: onap.datatypes.monitoring.measurementType - version: 0.0.0 - derived_from: tosca.datatypes.Root - metadata: {} - onap.datatypes.monitoring.measurementTypes: - constraints: [] - properties: - measurementType: - name: measurementType - type: map - typeVersion: 0.0.0 - description: Measurement type object - required: true - constraints: [] - entry_schema: - type: onap.datatypes.monitoring.measurementType - typeVersion: 0.0.0 - constraints: [] - metadata: {} - name: onap.datatypes.monitoring.measurementTypes - version: 0.0.0 - derived_from: tosca.datatypes.Root - metadata: {} - onap.datatypes.monitoring.nfFilter: - constraints: [] - properties: - modelNames: - name: modelNames - type: list - typeVersion: 0.0.0 - description: List of model names - required: true - constraints: [] - entry_schema: - type: string - typeVersion: 0.0.0 - constraints: [] - metadata: {} - modelInvariantIDs: - name: modelInvariantIDs - type: list - typeVersion: 0.0.0 - description: List of model invariant IDs - required: true - constraints: [] - entry_schema: - type: string - typeVersion: 0.0.0 - constraints: [] - metadata: {} - modelVersionIDs: - name: modelVersionIDs - type: list - typeVersion: 0.0.0 - description: List of model version IDs - required: true - constraints: [] - entry_schema: - type: string - typeVersion: 0.0.0 - constraints: [] - metadata: {} - nfNames: - name: nfNames - type: list - typeVersion: 0.0.0 - description: List of network functions - required: true - constraints: [] - entry_schema: - type: string - typeVersion: 0.0.0 - constraints: [] - metadata: {} - name: onap.datatypes.monitoring.nfFilter - version: 0.0.0 - derived_from: tosca.datatypes.Root - metadata: {} - onap.datatypes.monitoring.subscription: - constraints: [] - properties: - measurementGroups: - name: measurementGroups - type: list - typeVersion: 0.0.0 - description: Measurement Groups - required: true - constraints: [] - entry_schema: - type: onap.datatypes.monitoring.measurementGroups - typeVersion: 0.0.0 - constraints: [] - metadata: {} - fileBasedGP: - name: fileBasedGP - type: integer - typeVersion: 0.0.0 - description: File based granularity period - required: true - constraints: [] - metadata: {} - fileLocation: - name: fileLocation - type: string - typeVersion: 0.0.0 - description: ROP file location - required: true - constraints: [] - metadata: {} - subscriptionName: - name: subscriptionName - type: string - typeVersion: 0.0.0 - description: Name of the subscription - required: true - constraints: [] - metadata: {} - administrativeState: - name: administrativeState - type: string - typeVersion: 0.0.0 - description: State of the subscription - required: true - constraints: - - valid_values: - - LOCKED - - UNLOCKED - metadata: {} - nfFilter: - name: nfFilter - type: map - typeVersion: 0.0.0 - description: Network function filter - required: true - constraints: [] - entry_schema: - type: onap.datatypes.monitoring.nfFilter - typeVersion: 0.0.0 - constraints: [] - metadata: {} - name: onap.datatypes.monitoring.subscription - version: 0.0.0 - derived_from: tosca.datatypes.Root - metadata: {} -policy_types: - onap.policies.Monitoring: - derived_from: tosca.policies.Root - description: a base policy type for all policies that govern monitoring provisioning - version: 1.0.0 - name: onap.policies.Monitoring - onap.policies.Sirisha: - derived_from: tosca.policies.Root - description: a base policy type for all policies that govern monitoring provisioning - version: 1.0.0 - name: onap.policies.Sirisha - onap.policies.monitoring.dcae-pm-subscription-handler: - properties: - pmsh_policy: - name: pmsh_policy - type: onap.datatypes.monitoring.subscription - typeVersion: 0.0.0 - description: PMSH Policy JSON - required: false - constraints: [] - metadata: {} - name: onap.policies.monitoring.dcae-pm-subscription-handler - version: 1.0.0 - derived_from: onap.policies.Monitoring - metadata: {} - onap.policies.controlloop.operational.Common: - derived_from: tosca.policies.Root - version: 1.0.0 - name: onap.policies.controlloop.operational.Common - description: | - Operational Policy for Control Loop execution. Originated in Frankfurt to support TOSCA Compliant - Policy Types. This does NOT support the legacy Policy YAML policy type. - properties: - id: - type: string - description: The unique control loop id. - required: true - timeout: - type: integer - description: | - Overall timeout for executing all the operations. This timeout should equal or exceed the total - timeout for each operation listed. - required: true - abatement: - type: boolean - description: Whether an abatement event message will be expected for the control loop from DCAE. - required: true - default: false - trigger: - type: string - description: Initial operation to execute upon receiving an Onset event message for the Control Loop. - required: true - operations: - type: list - description: List of operations to be performed when Control Loop is triggered. - required: true - entry_schema: - type: onap.datatype.controlloop.Operation - onap.policies.controlloop.operational.common.Apex: - derived_from: onap.policies.controlloop.operational.Common - type_version: 1.0.0 - version: 1.0.0 - name: onap.policies.controlloop.operational.common.Apex - description: Operational policies for Apex PDP - properties: - engineServiceParameters: - type: string - description: The engine parameters like name, instanceCount, policy implementation, parameters etc. - required: true - eventInputParameters: - type: string - description: The event input parameters. - required: true - eventOutputParameters: - type: string - description: The event output parameters. - required: true - javaProperties: - type: string - description: Name/value pairs of properties to be set for APEX if needed. - required: false -node_types: - org.onap.policy.clamp.controlloop.Participant: - version: 1.0.1 - derived_from: tosca.nodetypes.Root - properties: - provider: - type: string - requred: false - org.onap.policy.clamp.controlloop.ControlLoopElement: - version: 1.0.1 - derived_from: tosca.nodetypes.Root - properties: - provider: - type: string - required: false - metadata: - common: true - description: Specifies the organization that provides the control loop element - participantType: - type: onap.datatypes.ToscaConceptIdentifier - required: true - metadata: - common: true - description: The identity of the participant type that hosts this type of Control Loop Element - startPhase: - type: integer - required: false - constraints: - - greater_or_equal: 0 - metadata: - common: true - description: A value indicating the start phase in which this control loop element will be started, the - first start phase is zero. Control Loop Elements are started in their start_phase order and stopped - in reverse start phase order. Control Loop Elements with the same start phase are started and - stopped simultaneously - uninitializedToPassiveTimeout: - type: integer - required: false - constraints: - - greater_or_equal: 0 - default: 60 - metadata: - common: true - description: The maximum time in seconds to wait for a state chage from uninitialized to passive - passiveToRunningTimeout: - type: integer - required: false - constraints: - - greater_or_equal: 0 - default: 60 - metadata: - common: true - description: The maximum time in seconds to wait for a state chage from passive to running - runningToPassiveTimeout: - type: integer - required: false - constraints: - - greater_or_equal: 0 - default: 60 - metadata: - common: true - description: The maximum time in seconds to wait for a state chage from running to passive - passiveToUninitializedTimeout: - type: integer - required: false - constraints: - - greater_or_equal: 0 - default: 60 - metadata: - common: true - description: The maximum time in seconds to wait for a state chage from passive to uninitialized - org.onap.policy.clamp.controlloop.ControlLoop: - version: 1.0.1 - derived_from: tosca.nodetypes.Root - properties: - provider: - type: string - required: false - metadata: - common: true - description: Specifies the organization that provides the control loop element - elements: - type: list - required: true - metadata: - common: true - entry_schema: - type: onap.datatypes.ToscaConceptIdentifier - description: Specifies a list of control loop element definitions that make up this control loop definition - org.onap.policy.clamp.controlloop.DCAEMicroserviceControlLoopElement: - version: 1.0.1 - derived_from: org.onap.policy.clamp.controlloop.ControlLoopElement - properties: - dcae_blueprint_id: - type: onap.datatypes.ToscaConceptIdentifier - requred: false - dcae_blueprint: - type: onap.dcae.cloudify_blueprint - requred: false - consul_info: - type: list - required: false - entry_schema: - type: org.onap.datatypes.policy.clamp.controlloop.DCAEMicroserviceControlLoopElementConsulInfo - org.onap.policy.clamp.controlloop.PolicyControlLoopElement: - version: 1.0.1 - derived_from: org.onap.policy.clamp.controlloop.ControlLoopElement - properties: - policy_type_id: - type: onap.datatypes.ToscaConceptIdentifier - requred: true - policy_id: - type: onap.datatypes.ToscaConceptIdentifier - requred: false - org.onap.policy.clamp.controlloop.DerivedPolicyControlLoopElement: - version: 1.0.1 - derived_from: org.onap.policy.clamp.controlloop.PolicyControlLoopElement - properties: - policy_type_id: - type: onap.datatypes.ToscaConceptIdentifier - requred: true - policy_id: - type: onap.datatypes.ToscaConceptIdentifier - requred: false - org.onap.policy.clamp.controlloop.DerivedDerivedPolicyControlLoopElement: - version: 1.0.1 - derived_from: org.onap.policy.clamp.controlloop.DerivedPolicyControlLoopElement - properties: - policy_type_id: - type: onap.datatypes.ToscaConceptIdentifier - requred: true - policy_id: - type: onap.datatypes.ToscaConceptIdentifier - requred: false - org.onap.policy.clamp.controlloop.CDSControlLoopElement: - version: 1.0.1 - derived_from: org.onap.policy.clamp.controlloop.ControlLoopElement - properties: - cds_blueprint_id: - type: onap.datatypes.ToscaConceptIdentifier - requred: true -topology_template: - inputs: - pmsh_monitoring_policy: - type: onap.datatypes.ToscaConceptIdentifier - description: The ID of the PMSH monitoring policy to use - default: - name: MICROSERVICE_vLoadBalancerMS_v1_0_dcae-pm-subscription-handler_1_0_0test - version: 1.0.0 - pmsh_operational_policy: - type: onap.datatypes.ToscaConceptIdentifier - description: The ID of the PMSH operational policy to use - default: - name: operational.apex.pmcontrol - version: 1.0.0 - node_templates: - org.onap.dcae.controlloop.DCAEMicroserviceControlLoopParticipant: - version: 2.3.4 - type: org.onap.policy.clamp.controlloop.Participant - type_version: 1.0.1 - description: Participant for DCAE microservices - properties: - provider: ONAP - org.onap.policy.controlloop.PolicyControlLoopParticipant: - version: 2.3.1 - type: org.onap.policy.clamp.controlloop.Participant - type_version: 1.0.1 - description: Participant for DCAE microservices - properties: - provider: ONAP - org.onap.domain.pmsh.PMSH_DCAEMicroservice: - version: 1.2.3 - type: org.onap.policy.clamp.controlloop.DCAEMicroserviceControlLoopElement - type_version: 1.0.0 - description: Control loop element for the DCAE microservice for Performance Management Subscription Handling - properties: - provider: Ericsson - participantType: - name: org.onap.dcae.controlloop.DCAEMicroserviceControlLoopParticipant - version: 2.3.4 - dcae_blueprint: - tosca_definitions_version: cloudify_dsl_1_3 - imports: - - https://www.getcloudify.org/spec/cloudify/4.5.5/types.yaml - - plugin:k8splugin?version=3.7.0 - - plugin:pgaas?version=1.3.0 - - plugin:clamppolicyplugin?version=1.1.0 - inputs: - tag_version: - type: string - description: Docker image to be used - default: nexus3.onap.org:10001/onap/org.onap.dcaegen2.services.pmsh:1.1.2 - replicas: - type: integer - description: Number of instances - default: 1 - operational_policy_name: - type: string - default: operational.apex.pmcontrol - control_loop_name: - type: string - default: pmsh-control-loop - pmsh_publish_topic_name: - type: string - default: unauthenticated.DCAE_CL_OUTPUT - policy_feedback_topic_name: - type: string - default: unauthenticated.PMSH_CL_INPUT - aai_notification_topic_name: - type: string - default: AAI-EVENT - publisher_client_role: - type: string - description: Client role to request secure access to topic - default: org.onap.dcae.pmPublisher - subscriber_client_role: - type: string - description: Client role to request secure access to topic - default: org.onap.dcae.pmSubscriber - dcae_location: - type: string - description: DCAE location for the subscriber, used to set up routing - default: san-francisco - cpu_limit: - type: string - default: 1000m - cpu_request: - type: string - default: 1000m - memory_limit: - type: string - default: 1024Mi - memory_request: - type: string - default: 1024Mi - pgaas_cluster_name: - type: string - default: dcae-pg-primary.onap - enable_tls: - type: boolean - default: true - protocol: - type: string - description: PMSH protocol. If enable_tls is false, set to http - default: https - policy_model_id: - type: string - default: onap.policies.monitoring.dcae-pm-subscription-handler - policy_id: - type: string - default: MICROSERVICE_vLoadBalancerMS_v1_0_dcae-pm-subscription-handler_1_0_0test - node_templates: - pgaasvm: - type: dcae.nodes.pgaas.database - properties: - writerfqdn: - get_input: pgaas_cluster_name - name: pmsh - pmsh: - type: dcae.nodes.ContainerizedServiceComponentUsingDmaap - interfaces: - cloudify.interfaces.lifecycle: - create: - inputs: - ports: - - '8443:0' - envs: - PMSH_PG_URL: - get_attribute: - - pgaasvm - - admin - - host - PMSH_PG_PASSWORD: - get_attribute: - - pgaasvm - - admin - - password - PMSH_PG_USERNAME: - get_attribute: - - pgaasvm - - admin - - user - PMSH_DB_NAME: - get_attribute: - - pgaasvm - - admin - - database - relationships: - - target: pmsh-policy - type: cloudify.relationships.depends_on - properties: - service_component_type: dcae-pmsh - service_component_name_override: dcae-pmsh - application_config: - enable_tls: - get_input: enable_tls - aaf_identity: dcae@dcae.onap.org - aaf_password: demo123456! - operational_policy_name: - get_input: operational_policy_name - control_loop_name: - get_input: control_loop_name - cert_path: /opt/app/pmsh/etc/certs/cert.pem - key_path: /opt/app/pmsh/etc/certs/key.pem - ca_cert_path: /opt/app/pmsh/etc/certs/cacert.pem - streams_publishes: - policy_pm_publisher: - type: message_router - dmaap_info: - topic_url: - concat: - - http://message-router:3904/events/ - - get_input: pmsh_publish_topic_name - streams_subscribes: - policy_pm_subscriber: - type: message_router - dmaap_info: - topic_url: - concat: - - http://message-router:3904/events/ - - get_input: policy_feedback_topic_name - aai_subscriber: - type: message_router - dmaap_info: - topic_url: - concat: - - http://message-router:3904/events/ - - get_input: aai_notification_topic_name - resource_config: - limits: - cpu: - get_input: cpu_limit - memory: - get_input: memory_limit - requests: - cpu: - get_input: cpu_request - memory: - get_input: memory_request - docker_config: - healthcheck: - endpoint: /healthcheck - interval: 15s - timeout: 1s - type: - get_input: protocol - image: - get_input: tag_version - replicas: - get_input: replicas - log_info: - log_directory: /var/log/ONAP/dcaegen2/services/pmsh - tls_info: - cert_directory: /opt/app/pmsh/etc/certs - use_tls: - get_input: enable_tls - pmsh-policy: - type: clamp.nodes.policy - properties: - policy_model_id: - get_input: policy_model_id - policy_id: - get_input: policy_id - consul_info: - - consulUrl: http://consul:31321/v1/kv/dcae-pmsh:policy - consulBody: - subscription: - subscriptionName: subscriptiona - administrativeState: UNLOCKED - fileBasedGP: 15 - fileLocation: /pm/pm.xml - nfFilter: - nfNames: - - ^pnf1.* - modelInvariantIDs: - - 5845y423-g654-6fju-po78-8n53154532k6 - - 7129e420-d396-4efb-af02-6b83499b12f8 - modelVersionIDs: - - e80a6ae3-cafd-4d24-850d-e14c084a5ca9 - measurementGroups: - - measurementGroup: - measurementTypes: - - measurementType: countera - - measurementType: counterb - managedObjectDNsBasic: - - DN: dna - - DN: dnb - - measurementGroup: - measurementTypes: - - measurementType: counterc - - measurementType: counterd - managedObjectDNsBasic: - - DN: dnc - - DN: dnd - org.onap.domain.pmsh.PMSH_MonitoringPolicyControlLoopElement: - version: 1.2.3 - type: org.onap.policy.clamp.controlloop.PolicyControlLoopElement - type_version: 1.0.0 - description: Control loop element for the monitoring policy for Performance Management Subscription Handling - properties: - provider: Ericsson - participantType: - name: org.onap.policy.controlloop.PolicyControlLoopParticipant - version: 2.3.1 - policy_type_id: - name: onap.policies.monitoring.pm-subscription-handler - version: 1.0.0 - policy_id: - get_input: pmsh_monitoring_policy - org.onap.domain.pmsh.PMSH_OperationalPolicyControlLoopElement: - version: 1.2.3 - type: org.onap.policy.clamp.controlloop.PolicyControlLoopElement - type_version: 1.0.0 - description: Control loop element for the operational policy for Performance Management Subscription Handling - properties: - provider: Ericsson - participantType: - name: org.onap.policy.controlloop.PolicyControlLoopParticipant - version: 2.3.1 - policy_type_id: - name: onap.policies.operational.pm-subscription-handler - version: 1.0.0 - policy_id: - get_input: pmsh_operational_policy - org.onap.domain.pmsh.DerivedPolicyControlLoopElement: - version: 1.2.3 - type: org.onap.policy.clamp.controlloop.DerivedPolicyControlLoopElement - type_version: 1.0.0 - description: Control loop for Performance Management Subscription Handling - properties: - provider: Ericsson - elements: - - name: org.onap.domain.pmsh.PMSH_DCAEMicroservice - version: 1.2.3 - - name: org.onap.domain.pmsh.PMSH_MonitoringPolicyControlLoopElement - version: 1.2.3 - - name: org.onap.domain.pmsh.PMSH_OperationalPolicyControlLoopElement - version: 1.2.3 - org.onap.domain.pmsh.DerivedDerivedPolicyControlLoopElement: - version: 1.2.3 - type: org.onap.policy.clamp.controlloop.DerivedDerivedPolicyControlLoopElement - type_version: 1.0.0 - description: Control loop for Performance Management Subscription Handling - properties: - provider: Ericsson Software Technologies - elements: - - name: org.onap.domain.pmsh.PMSH_DerivedTestMicroservice - version: 1.2.3 - org.onap.domain.pmsh.PMSHControlLoopDefinition: - version: 1.2.3 - type: org.onap.policy.clamp.controlloop.ControlLoop - type_version: 1.0.0 - description: Control loop for Performance Management Subscription Handling - properties: - provider: Ericsson - elements: - - name: org.onap.domain.pmsh.PMSH_DCAEMicroservice - version: 1.2.3 - - name: org.onap.domain.pmsh.PMSH_MonitoringPolicyControlLoopElement - version: 1.2.3 - - name: org.onap.domain.pmsh.PMSH_OperationalPolicyControlLoopElement - version: 1.2.3 - policies: - - MICROSERVICE_vLoadBalancerMS_v1_0_dcae-pm-subscription-handler_1_0_0test: - type: onap.policies.monitoring.dcae-pm-subscription-handler - type_version: 1.0.0 - name: MICROSERVICE_vLoadBalancerMS_v1_0_dcae-pm-subscription-handler_1_0_0test - version: 1.0.0 - metadata: - policy-id: MICROSERVICE_vLoadBalancerMS_v1_0_dcae-pm-subscription-handler_1_0_0test - policy-version: 1.0.0 - properties: - pmsh_policy: - fileBasedGP: 15 - fileLocation: /pm/pm.xml - subscriptionName: subscriptiona - administrativeState: UNLOCKED - nfFilter: - onap.datatypes.monitoring.nfFilter: - modelVersionIDs: - - e80a6ae3-cafd-4d24-850d-e14c084a5ca9 - modelInvariantIDs: - - 5845y423-g654-6fju-po78-8n53154532k6 - - 7129e420-d396-4efb-af02-6b83499b12f8 - modelNames: [] - nfNames: - - '"^pnf1.*"' - measurementGroups: - - measurementGroup: - onap.datatypes.monitoring.measurementGroup: - measurementTypes: - - measurementType: - onap.datatypes.monitoring.measurementType: - measurementType: countera - - measurementType: - onap.datatypes.monitoring.measurementType: - measurementType: counterb - managedObjectDNsBasic: - - managedObjectDNsBasic: - onap.datatypes.monitoring.managedObjectDNsBasic: - DN: dna - - managedObjectDNsBasic: - onap.datatypes.monitoring.managedObjectDNsBasic: - DN: dnb - - measurementGroup: - onap.datatypes.monitoring.measurementGroup: - measurementTypes: - - measurementType: - onap.datatypes.monitoring.measurementType: - measurementType: counterc - - measurementType: - onap.datatypes.monitoring.measurementType: - measurementType: counterd - managedObjectDNsBasic: - - managedObjectDNsBasic: - onap.datatypes.monitoring.managedObjectDNsBasic: - DN: dnc - - managedObjectDNsBasic: - onap.datatypes.monitoring.managedObjectDNsBasic: - DN: dnd - - operational.apex.pmcontrol: - type: onap.policies.controlloop.operational.common.Apex - type_version: 1.0.0 - version: 1.0.0 - metadata: - policy-id: operational.apex.pmcontrol - policy-version: 1 - properties: - engineServiceParameters: - name: MyApexEngine - version: 0.0.1 - id: 45 - instanceCount: 2 - deploymentPort: 12561 - policy_type_impl: - apexPolicyModel: - key: - name: PMControlPolicy - version: 0.0.1 - keyInformation: - key: - name: PMControlPolicy_KeyInfo - version: 0.0.1 - keyInfoMap: - entry: - - key: - name: CDSActionIdentifiersType - version: 0.0.1 - value: - key: - name: CDSActionIdentifiersType - version: 0.0.1 - UUID: 6e5fa19b-14df-37e3-a4ae-8c537e861a82 - description: Generated description for concept referred to by key "CDSActionIdentifiersType:0.0.1" - - key: - name: CDSCreateResponseEvent - version: 0.0.1 - value: - key: - name: CDSCreateResponseEvent - version: 0.0.1 - UUID: 14b29e38-ac75-3273-aa4e-8583c0aa7dad - description: Generated description for concept referred to by key "CDSCreateResponseEvent:0.0.1" - - key: - name: CDSCreateResponsePayloadType - version: 0.0.1 - value: - key: - name: CDSCreateResponsePayloadType - version: 0.0.1 - UUID: 04573f8f-e772-30a5-b1d9-d7318d4a1e13 - description: Generated description for concept referred to by key "CDSCreateResponsePayloadType:0.0.1" - - key: - name: CDSCreateResponsePolicy - version: 0.0.1 - value: - key: - name: CDSCreateResponsePolicy - version: 0.0.1 - UUID: e126c965-fc09-3bfe-8f55-70f380a4a49c - description: Generated description for concept referred to by key "CDSCreateResponsePolicy:0.0.1" - - key: - name: CDSCreateResponseTask - version: 0.0.1 - value: - key: - name: CDSCreateResponseTask - version: 0.0.1 - UUID: 6165ee82-afd2-3aab-a517-f00b3f2461d2 - description: Generated description for concept referred to by key "CDSCreateResponseTask:0.0.1" - - key: - name: CDSCreateSubscriptionPayloadType - version: 0.0.1 - value: - key: - name: CDSCreateSubscriptionPayloadType - version: 0.0.1 - UUID: 8350ac5e-c157-38b9-9614-a0f93a830e60 - description: Generated description for concept referred to by key "CDSCreateSubscriptionPayloadType:0.0.1" - - key: - name: CDSCreateSubscriptionRequestEvent - version: 0.0.1 - value: - key: - name: CDSCreateSubscriptionRequestEvent - version: 0.0.1 - UUID: cfa325ba-226b-3a31-9183-ec43e2b6e9a2 - description: Generated description for concept referred to by key "CDSCreateSubscriptionRequestEvent:0.0.1" - - key: - name: CDSDeleteResponseEvent - version: 0.0.1 - value: - key: - name: CDSDeleteResponseEvent - version: 0.0.1 - UUID: 8be9c0fa-7437-3841-aff2-b3cec6ae3bd8 - description: Generated description for concept referred to by key "CDSDeleteResponseEvent:0.0.1" - - key: - name: CDSDeleteResponsePayloadType - version: 0.0.1 - value: - key: - name: CDSDeleteResponsePayloadType - version: 0.0.1 - UUID: 3fbfe0c9-152e-34d3-a504-09cd13c058d0 - description: Generated description for concept referred to by key "CDSDeleteResponsePayloadType:0.0.1" - - key: - name: CDSDeleteResponsePolicy - version: 0.0.1 - value: - key: - name: CDSDeleteResponsePolicy - version: 0.0.1 - UUID: a780251c-edd5-3132-b865-04313246b43c - description: Generated description for concept referred to by key "CDSDeleteResponsePolicy:0.0.1" - - key: - name: CDSDeleteResponseTask - version: 0.0.1 - value: - key: - name: CDSDeleteResponseTask - version: 0.0.1 - UUID: afce4555-3aa3-3521-a7d8-ee8cdf0d3efc - description: Generated description for concept referred to by key "CDSDeleteResponseTask:0.0.1" - - key: - name: CDSDeleteSubscriptionPayloadType - version: 0.0.1 - value: - key: - name: CDSDeleteSubscriptionPayloadType - version: 0.0.1 - UUID: 12658406-9147-3c9d-a38c-5ad5e30b092b - description: Generated description for concept referred to by key "CDSDeleteSubscriptionPayloadType:0.0.1" - - key: - name: CDSDeleteSubscriptionRequestEvent - version: 0.0.1 - value: - key: - name: CDSDeleteSubscriptionRequestEvent - version: 0.0.1 - UUID: 24380c95-9289-36e6-8cbf-0edefa15ccd9 - description: Generated description for concept referred to by key "CDSDeleteSubscriptionRequestEvent:0.0.1" - - key: - name: CDSRequestCommonHeaderType - version: 0.0.1 - value: - key: - name: CDSRequestCommonHeaderType - version: 0.0.1 - UUID: 35590ac0-062c-39f1-8786-b4ff716e30b1 - description: Generated description for concept referred to by key "CDSRequestCommonHeaderType:0.0.1" - - key: - name: CDSResponseCommonHeaderType - version: 0.0.1 - value: - key: - name: CDSResponseCommonHeaderType - version: 0.0.1 - UUID: dd7e1805-885a-350b-aaf9-ed541321ae3c - description: Generated description for concept referred to by key "CDSResponseCommonHeaderType:0.0.1" - - key: - name: CDSResponseStatusEvent - version: 0.0.1 - value: - key: - name: CDSResponseStatusEvent - version: 0.0.1 - UUID: 7986e21b-32f7-302e-9554-31f21b673493 - description: Generated description for concept referred to by key "CDSResponseStatusEvent:0.0.1" - - key: - name: CDSResponseStatusType - version: 0.0.1 - value: - key: - name: CDSResponseStatusType - version: 0.0.1 - UUID: 92b8a2cf-344e-3ce1-8cc0-2b7d3cb695fa - description: Generated description for concept referred to by key "CDSResponseStatusType:0.0.1" - - key: - name: CreateSubscriptionPayloadEvent - version: 0.0.1 - value: - key: - name: CreateSubscriptionPayloadEvent - version: 0.0.1 - UUID: 92162397-1a8e-3a3f-a469-d2af7700af4a - description: Generated description for concept referred to by key "CreateSubscriptionPayloadEvent:0.0.1" - - key: - name: CreateSubscriptionPayloadTask - version: 0.0.1 - value: - key: - name: CreateSubscriptionPayloadTask - version: 0.0.1 - UUID: bc0c69f0-52ed-38ea-b468-ae4a6fd1730d - description: Generated description for concept referred to by key "CreateSubscriptionPayloadTask:0.0.1" - - key: - name: CreateSubscriptionRequestTask - version: 0.0.1 - value: - key: - name: CreateSubscriptionRequestTask - version: 0.0.1 - UUID: 89cb75e9-f06c-30d3-b4ff-698d45f63869 - description: Generated description for concept referred to by key "CreateSubscriptionRequestTask:0.0.1" - - key: - name: DeleteSubscriptionPayloadEvent - version: 0.0.1 - value: - key: - name: DeleteSubscriptionPayloadEvent - version: 0.0.1 - UUID: 994fa441-04ab-33bb-832d-1cd12ab5d074 - description: Generated description for concept referred to by key "DeleteSubscriptionPayloadEvent:0.0.1" - - key: - name: DeleteSubscriptionPayloadTask - version: 0.0.1 - value: - key: - name: DeleteSubscriptionPayloadTask - version: 0.0.1 - UUID: 0f519117-5fea-3e4b-941f-8f778100465f - description: Generated description for concept referred to by key "DeleteSubscriptionPayloadTask:0.0.1" - - key: - name: DeleteSubscriptionRequestTask - version: 0.0.1 - value: - key: - name: DeleteSubscriptionRequestTask - version: 0.0.1 - UUID: acb772fe-d442-39e3-98f9-b1080caf4150 - description: Generated description for concept referred to by key "DeleteSubscriptionRequestTask:0.0.1" - - key: - name: MRResponseEvent - version: 0.0.1 - value: - key: - name: MRResponseEvent - version: 0.0.1 - UUID: 13c747a3-6bae-3bcf-9c80-b152e01dc194 - description: Generated description for concept referred to by key "MRResponseEvent:0.0.1" - - key: - name: PMControlPolicy - version: 0.0.1 - value: - key: - name: PMControlPolicy - version: 0.0.1 - UUID: acf1e55c-7bc5-3bd5-975a-0ca54afcd8a4 - description: Generated description for concept referred to by key "PMControlPolicy:0.0.1" - - key: - name: PMControlPolicy_Albums - version: 0.0.1 - value: - key: - name: PMControlPolicy_Albums - version: 0.0.1 - UUID: b38ad204-c2c8-32f4-9b5a-dda0aeb0145b - description: Generated description for concept referred to by key "PMControlPolicy_Albums:0.0.1" - - key: - name: PMControlPolicy_Events - version: 0.0.1 - value: - key: - name: PMControlPolicy_Events - version: 0.0.1 - UUID: be3871a0-c42a-3113-a066-82d192840eca - description: Generated description for concept referred to by key "PMControlPolicy_Events:0.0.1" - - key: - name: PMControlPolicy_KeyInfo - version: 0.0.1 - value: - key: - name: PMControlPolicy_KeyInfo - version: 0.0.1 - UUID: ced37634-28a4-3178-b7f6-2980794927b0 - description: Generated description for concept referred to by key "PMControlPolicy_KeyInfo:0.0.1" - - key: - name: PMControlPolicy_Policies - version: 0.0.1 - value: - key: - name: PMControlPolicy_Policies - version: 0.0.1 - UUID: be3d180d-ef9c-3a75-8e9c-84271a038bed - description: Generated description for concept referred to by key "PMControlPolicy_Policies:0.0.1" - - key: - name: PMControlPolicy_Schemas - version: 0.0.1 - value: - key: - name: PMControlPolicy_Schemas - version: 0.0.1 - UUID: e61973f1-189c-39e5-82f6-0d3afe298a20 - description: Generated description for concept referred to by key "PMControlPolicy_Schemas:0.0.1" - - key: - name: PMControlPolicy_Tasks - version: 0.0.1 - value: - key: - name: PMControlPolicy_Tasks - version: 0.0.1 - UUID: 5658adb3-2962-30a3-a241-fae75bb8eb4a - description: Generated description for concept referred to by key "PMControlPolicy_Tasks:0.0.1" - - key: - name: PMSubscriptionAlbum - version: 0.0.1 - value: - key: - name: PMSubscriptionAlbum - version: 0.0.1 - UUID: c2bd6f0d-6854-317a-9be2-97c08338428c - description: Generated description for concept referred to by key "PMSubscriptionAlbum:0.0.1" - - key: - name: PMSubscriptionOutputEvent - version: 0.0.1 - value: - key: - name: PMSubscriptionOutputEvent - version: 0.0.1 - UUID: 992b7819-9f69-3aa0-bb0f-6e45ea15ce05 - description: Generated description for concept referred to by key "PMSubscriptionOutputEvent:0.0.1" - - key: - name: PMSubscriptionType - version: 0.0.1 - value: - key: - name: PMSubscriptionType - version: 0.0.1 - UUID: 73c1c397-4fc3-357f-93b6-a8ad707fbaae - description: Generated description for concept referred to by key "PMSubscriptionType:0.0.1" - - key: - name: ReceiveEventPolicy - version: 0.0.1 - value: - key: - name: ReceiveEventPolicy - version: 0.0.1 - UUID: 568b7345-9de1-36d3-b6a3-9b857e6809a1 - description: Generated description for concept referred to by key "ReceiveEventPolicy:0.0.1" - - key: - name: ReceiveSubscriptionTask - version: 0.0.1 - value: - key: - name: ReceiveSubscriptionTask - version: 0.0.1 - UUID: f596afc8-100c-35eb-92c8-352355ea457d - description: Generated description for concept referred to by key "ReceiveSubscriptionTask:0.0.1" - - key: - name: SimpleIntType - version: 0.0.1 - value: - key: - name: SimpleIntType - version: 0.0.1 - UUID: 153791fd-ae0a-36a7-88a5-309a7936415d - description: Generated description for concept referred to by key "SimpleIntType:0.0.1" - - key: - name: SimpleStringType - version: 0.0.1 - value: - key: - name: SimpleStringType - version: 0.0.1 - UUID: 8a4957cf-9493-3a76-8c22-a208e23259af - description: Generated description for concept referred to by key "SimpleStringType:0.0.1" - - key: - name: SubscriptionStatusType - version: 0.0.1 - value: - key: - name: SubscriptionStatusType - version: 0.0.1 - UUID: 597643b1-9db1-31ce-85d0-e1c63c43b30b - description: Generated description for concept referred to by key "SubscriptionStatusType:0.0.1" - - key: - name: SubscriptionType - version: 0.0.1 - value: - key: - name: SubscriptionType - version: 0.0.1 - UUID: 184547bb-7d64-3cb2-a273-d7185102c5ce - description: Generated description for concept referred to by key "SubscriptionType:0.0.1" - - key: - name: UUIDType - version: 0.0.1 - value: - key: - name: UUIDType - version: 0.0.1 - UUID: 6a8cc68e-dfc8-3403-9c6d-071c886b319c - description: Generated description for concept referred to by key "UUIDType:0.0.1" - - key: - name: pmsh-operational-policy - version: 0.0.1 - value: - key: - name: pmsh-operational-policy - version: 0.0.1 - UUID: fdf2c9ff-6422-3ea6-b6b6-49b12116265d - description: Generated description for concept referred to by key "pmsh-operational-policy:0.0.1" - policies: - key: - name: PMControlPolicy_Policies - version: 0.0.1 - policyMap: - entry: - - key: - name: CDSCreateResponsePolicy - version: 0.0.1 - value: - policyKey: - name: CDSCreateResponsePolicy - version: 0.0.1 - template: Freestyle - state: - entry: - - key: CDSCreateResponseState - value: - stateKey: - parentKeyName: CDSCreateResponsePolicy - parentKeyVersion: 0.0.1 - parentLocalName: 'NULL' - localName: CDSCreateResponseState - trigger: - name: CDSCreateResponseEvent - version: 0.0.1 - stateOutputs: - entry: - - key: ResponseOutput - value: - key: - parentKeyName: CDSCreateResponsePolicy - parentKeyVersion: 0.0.1 - parentLocalName: CDSCreateResponseState - localName: ResponseOutput - outgoingEvent: - name: CDSResponseStatusEvent - version: 0.0.1 - nextState: - parentKeyName: 'NULL' - parentKeyVersion: 0.0.0 - parentLocalName: 'NULL' - localName: 'NULL' - contextAlbumReference: [] - taskSelectionLogic: - key: 'NULL' - logicFlavour: UNDEFINED - logic: '' - stateFinalizerLogicMap: - entry: [] - defaultTask: - name: CDSCreateResponseTask - version: 0.0.1 - taskReferences: - entry: - - key: - name: CDSCreateResponseTask - version: 0.0.1 - value: - key: - parentKeyName: CDSCreateResponsePolicy - parentKeyVersion: 0.0.1 - parentLocalName: CDSCreateResponseState - localName: CDSCreateResponsePolicy - outputType: DIRECT - output: - parentKeyName: CDSCreateResponsePolicy - parentKeyVersion: 0.0.1 - parentLocalName: CDSCreateResponseState - localName: ResponseOutput - firstState: CDSCreateResponseState - - key: - name: CDSDeleteResponsePolicy - version: 0.0.1 - value: - policyKey: - name: CDSDeleteResponsePolicy - version: 0.0.1 - template: Freestyle - state: - entry: - - key: CDSDeleteResponseState - value: - stateKey: - parentKeyName: CDSDeleteResponsePolicy - parentKeyVersion: 0.0.1 - parentLocalName: 'NULL' - localName: CDSDeleteResponseState - trigger: - name: CDSDeleteResponseEvent - version: 0.0.1 - stateOutputs: - entry: - - key: ResponseOutput - value: - key: - parentKeyName: CDSDeleteResponsePolicy - parentKeyVersion: 0.0.1 - parentLocalName: CDSDeleteResponseState - localName: ResponseOutput - outgoingEvent: - name: CDSResponseStatusEvent - version: 0.0.1 - nextState: - parentKeyName: 'NULL' - parentKeyVersion: 0.0.0 - parentLocalName: 'NULL' - localName: 'NULL' - contextAlbumReference: [] - taskSelectionLogic: - key: 'NULL' - logicFlavour: UNDEFINED - logic: '' - stateFinalizerLogicMap: - entry: [] - defaultTask: - name: CDSDeleteResponseTask - version: 0.0.1 - taskReferences: - entry: - - key: - name: CDSDeleteResponseTask - version: 0.0.1 - value: - key: - parentKeyName: CDSDeleteResponsePolicy - parentKeyVersion: 0.0.1 - parentLocalName: CDSDeleteResponseState - localName: CDSDeleteResponsePolicy - outputType: DIRECT - output: - parentKeyName: CDSDeleteResponsePolicy - parentKeyVersion: 0.0.1 - parentLocalName: CDSDeleteResponseState - localName: ResponseOutput - firstState: CDSDeleteResponseState - - key: - name: ReceiveEventPolicy - version: 0.0.1 - value: - policyKey: - name: ReceiveEventPolicy - version: 0.0.1 - template: Freestyle - state: - entry: - - key: CreateOrDeleteState - value: - stateKey: - parentKeyName: ReceiveEventPolicy - parentKeyVersion: 0.0.1 - parentLocalName: 'NULL' - localName: CreateOrDeleteState - trigger: - name: PMSubscriptionOutputEvent - version: 0.0.1 - stateOutputs: - entry: - - key: CreateSubscriptionPayload - value: - key: - parentKeyName: ReceiveEventPolicy - parentKeyVersion: 0.0.1 - parentLocalName: CreateOrDeleteState - localName: CreateSubscriptionPayload - outgoingEvent: - name: CreateSubscriptionPayloadEvent - version: 0.0.1 - nextState: - parentKeyName: ReceiveEventPolicy - parentKeyVersion: 0.0.1 - parentLocalName: 'NULL' - localName: CreateSubscription - - key: DeleteSubscriptionPayload - value: - key: - parentKeyName: ReceiveEventPolicy - parentKeyVersion: 0.0.1 - parentLocalName: CreateOrDeleteState - localName: DeleteSubscriptionPayload - outgoingEvent: - name: DeleteSubscriptionPayloadEvent - version: 0.0.1 - nextState: - parentKeyName: ReceiveEventPolicy - parentKeyVersion: 0.0.1 - parentLocalName: 'NULL' - localName: DeleteSubscription - contextAlbumReference: - - name: PMSubscriptionAlbum - version: 0.0.1 - taskSelectionLogic: - key: TaskSelectionLogic - logicFlavour: JAVASCRIPT - logic: |- - /* - * ============LICENSE_START======================================================= - * Copyright (C) 2020 Nordix. 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); - - var pmSubscriptionInfo = executor.getContextAlbum("PMSubscriptionAlbum").get(executor.inFields.get("albumID").toString()) - var changeType = pmSubscriptionInfo.get("changeType").toString() - - executor.logger.info("Change Type is " + changeType) - - if ("CREATE".equals(changeType)) { - executor.logger.info("Choosing to create a subscription") - executor.subject.getTaskKey("CreateSubscriptionPayloadTask").copyTo(executor.selectedTask); - } - else if ("DELETE".equals(changeType)) { - executor.logger.info("Choosing to delete a subscription") - executor.subject.getTaskKey("DeleteSubscriptionPayloadTask").copyTo(executor.selectedTask); - } - - //var returnValue = executor.isTrue; - true; - stateFinalizerLogicMap: - entry: [] - defaultTask: - name: CreateSubscriptionPayloadTask - version: 0.0.1 - taskReferences: - entry: - - key: - name: CreateSubscriptionPayloadTask - version: 0.0.1 - value: - key: - parentKeyName: ReceiveEventPolicy - parentKeyVersion: 0.0.1 - parentLocalName: CreateOrDeleteState - localName: ReceiveEventPolicy - outputType: DIRECT - output: - parentKeyName: ReceiveEventPolicy - parentKeyVersion: 0.0.1 - parentLocalName: CreateOrDeleteState - localName: CreateSubscriptionPayload - - key: - name: DeleteSubscriptionPayloadTask - version: 0.0.1 - value: - key: - parentKeyName: ReceiveEventPolicy - parentKeyVersion: 0.0.1 - parentLocalName: CreateOrDeleteState - localName: ReceiveEventPolicy - outputType: DIRECT - output: - parentKeyName: ReceiveEventPolicy - parentKeyVersion: 0.0.1 - parentLocalName: CreateOrDeleteState - localName: DeleteSubscriptionPayload - - key: CreateSubscription - value: - stateKey: - parentKeyName: ReceiveEventPolicy - parentKeyVersion: 0.0.1 - parentLocalName: 'NULL' - localName: CreateSubscription - trigger: - name: CreateSubscriptionPayloadEvent - version: 0.0.1 - stateOutputs: - entry: - - key: IssueCreateSubscriptionRequestOutput - value: - key: - parentKeyName: ReceiveEventPolicy - parentKeyVersion: 0.0.1 - parentLocalName: CreateSubscription - localName: IssueCreateSubscriptionRequestOutput - outgoingEvent: - name: CDSCreateSubscriptionRequestEvent - version: 0.0.1 - nextState: - parentKeyName: 'NULL' - parentKeyVersion: 0.0.0 - parentLocalName: 'NULL' - localName: 'NULL' - contextAlbumReference: - - name: PMSubscriptionAlbum - version: 0.0.1 - taskSelectionLogic: - key: 'NULL' - logicFlavour: UNDEFINED - logic: '' - stateFinalizerLogicMap: - entry: [] - defaultTask: - name: CreateSubscriptionRequestTask - version: 0.0.1 - taskReferences: - entry: - - key: - name: CreateSubscriptionRequestTask - version: 0.0.1 - value: - key: - parentKeyName: ReceiveEventPolicy - parentKeyVersion: 0.0.1 - parentLocalName: CreateSubscription - localName: ReceiveEventPolicy - outputType: DIRECT - output: - parentKeyName: ReceiveEventPolicy - parentKeyVersion: 0.0.1 - parentLocalName: CreateSubscription - localName: IssueCreateSubscriptionRequestOutput - - key: DeleteSubscription - value: - stateKey: - parentKeyName: ReceiveEventPolicy - parentKeyVersion: 0.0.1 - parentLocalName: 'NULL' - localName: DeleteSubscription - trigger: - name: DeleteSubscriptionPayloadEvent - version: 0.0.1 - stateOutputs: - entry: - - key: IssueDeleteSubscriptionRequestOutput - value: - key: - parentKeyName: ReceiveEventPolicy - parentKeyVersion: 0.0.1 - parentLocalName: DeleteSubscription - localName: IssueDeleteSubscriptionRequestOutput - outgoingEvent: - name: CDSDeleteSubscriptionRequestEvent - version: 0.0.1 - nextState: - parentKeyName: 'NULL' - parentKeyVersion: 0.0.0 - parentLocalName: 'NULL' - localName: 'NULL' - contextAlbumReference: - - name: PMSubscriptionAlbum - version: 0.0.1 - taskSelectionLogic: - key: 'NULL' - logicFlavour: UNDEFINED - logic: '' - stateFinalizerLogicMap: - entry: [] - defaultTask: - name: DeleteSubscriptionRequestTask - version: 0.0.1 - taskReferences: - entry: - - key: - name: DeleteSubscriptionRequestTask - version: 0.0.1 - value: - key: - parentKeyName: ReceiveEventPolicy - parentKeyVersion: 0.0.1 - parentLocalName: DeleteSubscription - localName: ReceiveEventPolicy - outputType: DIRECT - output: - parentKeyName: ReceiveEventPolicy - parentKeyVersion: 0.0.1 - parentLocalName: DeleteSubscription - localName: IssueDeleteSubscriptionRequestOutput - - key: ReceiveSubscriptionState - value: - stateKey: - parentKeyName: ReceiveEventPolicy - parentKeyVersion: 0.0.1 - parentLocalName: 'NULL' - localName: ReceiveSubscriptionState - trigger: - name: pmsh-operational-policy - version: 0.0.1 - stateOutputs: - entry: - - key: ReceivePMSubscriptionOutput - value: - key: - parentKeyName: ReceiveEventPolicy - parentKeyVersion: 0.0.1 - parentLocalName: ReceiveSubscriptionState - localName: ReceivePMSubscriptionOutput - outgoingEvent: - name: PMSubscriptionOutputEvent - version: 0.0.1 - nextState: - parentKeyName: ReceiveEventPolicy - parentKeyVersion: 0.0.1 - parentLocalName: 'NULL' - localName: CreateOrDeleteState - contextAlbumReference: - - name: PMSubscriptionAlbum - version: 0.0.1 - taskSelectionLogic: - key: 'NULL' - logicFlavour: UNDEFINED - logic: '' - stateFinalizerLogicMap: - entry: [] - defaultTask: - name: ReceiveSubscriptionTask - version: 0.0.1 - taskReferences: - entry: - - key: - name: ReceiveSubscriptionTask - version: 0.0.1 - value: - key: - parentKeyName: ReceiveEventPolicy - parentKeyVersion: 0.0.1 - parentLocalName: ReceiveSubscriptionState - localName: ReceiveEventPolicy - outputType: DIRECT - output: - parentKeyName: ReceiveEventPolicy - parentKeyVersion: 0.0.1 - parentLocalName: ReceiveSubscriptionState - localName: ReceivePMSubscriptionOutput - firstState: ReceiveSubscriptionState - tasks: - key: - name: PMControlPolicy_Tasks - version: 0.0.1 - taskMap: - entry: - - key: - name: CDSCreateResponseTask - version: 0.0.1 - value: - key: - name: CDSCreateResponseTask - version: 0.0.1 - inputFields: - entry: - - key: actionIdentifiers - value: - key: actionIdentifiers - fieldSchemaKey: - name: CDSActionIdentifiersType - version: 0.0.1 - optional: false - - key: commonHeader - value: - key: commonHeader - fieldSchemaKey: - name: CDSResponseCommonHeaderType - version: 0.0.1 - optional: false - - key: payload - value: - key: payload - fieldSchemaKey: - name: CDSCreateResponsePayloadType - version: 0.0.1 - optional: false - - key: status - value: - key: status - fieldSchemaKey: - name: CDSResponseStatusType - version: 0.0.1 - optional: false - outputFields: - entry: - - key: status - value: - key: status - fieldSchemaKey: - name: SubscriptionStatusType - version: 0.0.1 - optional: false - taskParameters: - entry: [] - contextAlbumReference: - - name: PMSubscriptionAlbum - version: 0.0.1 - taskLogic: - key: TaskLogic - logicFlavour: JAVASCRIPT - logic: |- - /* - * ============LICENSE_START======================================================= - * Copyright (C) 2020 Nordix. 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); - - var commonHeader = executor.inFields.get("commonHeader") - var response = executor.inFields.get("payload") - var albumID = commonHeader.get("requestId") - - var pmSubscriptionInfo = executor.getContextAlbum("PMSubscriptionAlbum").get(albumID.toString()); - var responseStatus = executor.subject.getOutFieldSchemaHelper("status").createNewInstance(); - - responseStatus.put("subscriptionName", pmSubscriptionInfo.get("subscription").get("subscriptionName")) - responseStatus.put("nfName", pmSubscriptionInfo.get("nfName")) - responseStatus.put("changeType", pmSubscriptionInfo.get("changeType")) - - var status = response.get(pmSubscriptionInfo.get("changeType").toLowerCase() + "_DasH_subscription_DasH_response").get("odl_DasH_response").get("status") - - executor.logger.info("RESPONSE STATUS = " + status) - - if(status == "success") { - responseStatus.put("message", "success") - } else { - responseStatus.put("message", "failed") - } - - executor.outFields.put("status", responseStatus) - - //var returnValue = executor.isTrue; - true; - - key: - name: CDSDeleteResponseTask - version: 0.0.1 - value: - key: - name: CDSDeleteResponseTask - version: 0.0.1 - inputFields: - entry: - - key: actionIdentifiers - value: - key: actionIdentifiers - fieldSchemaKey: - name: CDSActionIdentifiersType - version: 0.0.1 - optional: false - - key: commonHeader - value: - key: commonHeader - fieldSchemaKey: - name: CDSResponseCommonHeaderType - version: 0.0.1 - optional: false - - key: payload - value: - key: payload - fieldSchemaKey: - name: CDSDeleteResponsePayloadType - version: 0.0.1 - optional: false - - key: status - value: - key: status - fieldSchemaKey: - name: CDSResponseStatusType - version: 0.0.1 - optional: false - outputFields: - entry: - - key: status - value: - key: status - fieldSchemaKey: - name: SubscriptionStatusType - version: 0.0.1 - optional: false - taskParameters: - entry: [] - contextAlbumReference: - - name: PMSubscriptionAlbum - version: 0.0.1 - taskLogic: - key: TaskLogic - logicFlavour: JAVASCRIPT - logic: |- - /* - * ============LICENSE_START======================================================= - * Copyright (C) 2020 Nordix. 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); - - var commonHeader = executor.inFields.get("commonHeader") - var response = executor.inFields.get("payload") - var albumID = commonHeader.get("requestId") - - var pmSubscriptionInfo = executor.getContextAlbum("PMSubscriptionAlbum").get(albumID.toString()); - var responseStatus = executor.subject.getOutFieldSchemaHelper("status").createNewInstance(); - - responseStatus.put("subscriptionName", pmSubscriptionInfo.get("subscription").get("subscriptionName")) - responseStatus.put("nfName", pmSubscriptionInfo.get("nfName")) - responseStatus.put("changeType", pmSubscriptionInfo.get("changeType")) - - var status = response.get(pmSubscriptionInfo.get("changeType").toLowerCase() + "_DasH_subscription_DasH_response").get("odl_DasH_response").get("status") - - executor.logger.info("RESPONSE STATUS = " + status) - - if(status == "success") { - responseStatus.put("message", "success") - } else { - responseStatus.put("message", "failed") - } - - executor.outFields.put("status", responseStatus) - - //var returnValue = executor.isTrue; - true; - - key: - name: CreateSubscriptionPayloadTask - version: 0.0.1 - value: - key: - name: CreateSubscriptionPayloadTask - version: 0.0.1 - inputFields: - entry: - - key: albumID - value: - key: albumID - fieldSchemaKey: - name: UUIDType - version: 0.0.1 - optional: false - outputFields: - entry: - - key: albumID - value: - key: albumID - fieldSchemaKey: - name: UUIDType - version: 0.0.1 - optional: false - - key: payload - value: - key: payload - fieldSchemaKey: - name: CDSCreateSubscriptionPayloadType - version: 0.0.1 - optional: false - taskParameters: - entry: [] - contextAlbumReference: - - name: PMSubscriptionAlbum - version: 0.0.1 - taskLogic: - key: TaskLogic - logicFlavour: JAVASCRIPT - logic: |- - /* - * ============LICENSE_START======================================================= - * Copyright (C) 2020 Nordix. 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); - - var pmSubscriptionInfo = executor.getContextAlbum("PMSubscriptionAlbum").get(executor.inFields.get("albumID").toString()) - - var changeType = pmSubscriptionInfo.get("changeType").toLowerCase() - - var payloadProperties = executor.subject.getOutFieldSchemaHelper("payload").createNewSubInstance(changeType + "_DasH_subscription_DasH_properties_record"); - - payloadProperties.put("nfName", pmSubscriptionInfo.get("nfName")) - payloadProperties.put("subscriptionName", pmSubscriptionInfo.get("subscription").get("subscriptionName")) - payloadProperties.put("administrativeState", pmSubscriptionInfo.get("subscription").get("administrativeState")) - payloadProperties.put("fileBasedGP", pmSubscriptionInfo.get("subscription").get("fileBasedGP").toString()) - payloadProperties.put("fileLocation", pmSubscriptionInfo.get("subscription").get("fileLocation")) - payloadProperties.put("measurementGroups", pmSubscriptionInfo.get("subscription").get("measurementGroups")) - - var payloadEntry = executor.subject.getOutFieldSchemaHelper("payload").createNewSubInstance("CDSRequestPayloadEntry"); - payloadEntry.put(changeType + "_DasH_subscription_DasH_properties", payloadProperties) - - var payload = executor.subject.getOutFieldSchemaHelper("payload").createNewInstance(); - payload.put(changeType + "_DasH_subscription_DasH_request", payloadEntry); - - executor.outFields.put("albumID", executor.inFields.get("albumID")) - executor.outFields.put("payload", payload); - - //var returnValue = executor.isTrue; - true; - - key: - name: CreateSubscriptionRequestTask - version: 0.0.1 - value: - key: - name: CreateSubscriptionRequestTask - version: 0.0.1 - inputFields: - entry: - - key: albumID - value: - key: albumID - fieldSchemaKey: - name: UUIDType - version: 0.0.1 - optional: false - - key: payload - value: - key: payload - fieldSchemaKey: - name: CDSCreateSubscriptionPayloadType - version: 0.0.1 - optional: false - outputFields: - entry: - - key: actionIdentifiers - value: - key: actionIdentifiers - fieldSchemaKey: - name: CDSActionIdentifiersType - version: 0.0.1 - optional: false - - key: commonHeader - value: - key: commonHeader - fieldSchemaKey: - name: CDSRequestCommonHeaderType - version: 0.0.1 - optional: false - - key: payload - value: - key: payload - fieldSchemaKey: - name: CDSCreateSubscriptionPayloadType - version: 0.0.1 - optional: false - taskParameters: - entry: [] - contextAlbumReference: - - name: PMSubscriptionAlbum - version: 0.0.1 - taskLogic: - key: TaskLogic - logicFlavour: JAVASCRIPT - logic: |- - /* - * ============LICENSE_START======================================================= - * Copyright (C) 2020 Nordix. 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); - - var pmSubscriptionInfo = executor.getContextAlbum("PMSubscriptionAlbum").get(executor.inFields.get("albumID").toString()) - - var changeType = pmSubscriptionInfo.get("changeType").toLowerCase() - var blueprintName = pmSubscriptionInfo.get("blueprintName").toLowerCase() - var blueprintVersion = pmSubscriptionInfo.get("blueprintVersion").toLowerCase() - var payload = executor.inFields.get("payload") - var actionName = changeType + "-subscription" - - var commonHeader = executor.subject.getOutFieldSchemaHelper("commonHeader").createNewInstance(); - commonHeader.put("originatorId", "sdnc"); - commonHeader.put("requestId", executor.inFields.get("albumID").toString()); - commonHeader.put("subRequestId", "sub-123456-1000"); - - var actionIdentifiers = executor.subject.getOutFieldSchemaHelper("actionIdentifiers").createNewInstance(); - actionIdentifiers.put("actionName", actionName); - actionIdentifiers.put("blueprintName", blueprintName); - actionIdentifiers.put("blueprintVersion", blueprintVersion); - actionIdentifiers.put("mode", "sync"); - - executor.outFields.put("commonHeader", commonHeader); - executor.outFields.put("actionIdentifiers", actionIdentifiers); - executor.outFields.put("payload", payload); - - //var returnValue = executor.isTrue; - true; - - key: - name: DeleteSubscriptionPayloadTask - version: 0.0.1 - value: - key: - name: DeleteSubscriptionPayloadTask - version: 0.0.1 - inputFields: - entry: - - key: albumID - value: - key: albumID - fieldSchemaKey: - name: UUIDType - version: 0.0.1 - optional: false - outputFields: - entry: - - key: albumID - value: - key: albumID - fieldSchemaKey: - name: UUIDType - version: 0.0.1 - optional: false - - key: payload - value: - key: payload - fieldSchemaKey: - name: CDSDeleteSubscriptionPayloadType - version: 0.0.1 - optional: false - taskParameters: - entry: [] - contextAlbumReference: - - name: PMSubscriptionAlbum - version: 0.0.1 - taskLogic: - key: TaskLogic - logicFlavour: JAVASCRIPT - logic: |- - /* - * ============LICENSE_START======================================================= - * Copyright (C) 2020 Nordix. 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); - - var pmSubscriptionInfo = executor.getContextAlbum("PMSubscriptionAlbum").get(executor.inFields.get("albumID").toString()) - - var changeType = pmSubscriptionInfo.get("changeType").toLowerCase() - - var payloadProperties = executor.subject.getOutFieldSchemaHelper("payload").createNewSubInstance(changeType + "_DasH_subscription_DasH_properties_record"); - - payloadProperties.put("nfName", pmSubscriptionInfo.get("nfName")) - payloadProperties.put("subscriptionName", pmSubscriptionInfo.get("subscription").get("subscriptionName")) - payloadProperties.put("administrativeState", pmSubscriptionInfo.get("subscription").get("administrativeState")) - payloadProperties.put("fileBasedGP", pmSubscriptionInfo.get("subscription").get("fileBasedGP").toString()) - payloadProperties.put("fileLocation", pmSubscriptionInfo.get("subscription").get("fileLocation")) - payloadProperties.put("measurementGroups", pmSubscriptionInfo.get("subscription").get("measurementGroups")) - - var payloadEntry = executor.subject.getOutFieldSchemaHelper("payload").createNewSubInstance("CDSRequestPayloadEntry"); - payloadEntry.put(changeType + "_DasH_subscription_DasH_properties", payloadProperties) - - var payload = executor.subject.getOutFieldSchemaHelper("payload").createNewInstance(); - payload.put(changeType + "_DasH_subscription_DasH_request", payloadEntry); - - executor.outFields.put("albumID", executor.inFields.get("albumID")) - executor.outFields.put("payload", payload); - - //var returnValue = executor.isTrue; - true; - - key: - name: DeleteSubscriptionRequestTask - version: 0.0.1 - value: - key: - name: DeleteSubscriptionRequestTask - version: 0.0.1 - inputFields: - entry: - - key: albumID - value: - key: albumID - fieldSchemaKey: - name: UUIDType - version: 0.0.1 - optional: false - - key: payload - value: - key: payload - fieldSchemaKey: - name: CDSDeleteSubscriptionPayloadType - version: 0.0.1 - optional: false - outputFields: - entry: - - key: actionIdentifiers - value: - key: actionIdentifiers - fieldSchemaKey: - name: CDSActionIdentifiersType - version: 0.0.1 - optional: false - - key: commonHeader - value: - key: commonHeader - fieldSchemaKey: - name: CDSRequestCommonHeaderType - version: 0.0.1 - optional: false - - key: payload - value: - key: payload - fieldSchemaKey: - name: CDSDeleteSubscriptionPayloadType - version: 0.0.1 - optional: false - taskParameters: - entry: [] - contextAlbumReference: - - name: PMSubscriptionAlbum - version: 0.0.1 - taskLogic: - key: TaskLogic - logicFlavour: JAVASCRIPT - logic: |- - /* - * ============LICENSE_START======================================================= - * Copyright (C) 2020 Nordix. 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); - - var pmSubscriptionInfo = executor.getContextAlbum("PMSubscriptionAlbum").get(executor.inFields.get("albumID").toString()) - - var changeType = pmSubscriptionInfo.get("changeType").toLowerCase() - var blueprintName = pmSubscriptionInfo.get("blueprintName").toLowerCase() - var blueprintVersion = pmSubscriptionInfo.get("blueprintVersion").toLowerCase() - var payload = executor.inFields.get("payload") - var actionName = changeType + "-subscription" - - var commonHeader = executor.subject.getOutFieldSchemaHelper("commonHeader").createNewInstance(); - commonHeader.put("originatorId", "sdnc"); - commonHeader.put("requestId", executor.inFields.get("albumID").toString()); - commonHeader.put("subRequestId", "sub-123456-1000"); - - var actionIdentifiers = executor.subject.getOutFieldSchemaHelper("actionIdentifiers").createNewInstance(); - actionIdentifiers.put("actionName", actionName); - actionIdentifiers.put("blueprintName", blueprintName); - actionIdentifiers.put("blueprintVersion", blueprintVersion); - actionIdentifiers.put("mode", "sync"); - - executor.outFields.put("commonHeader", commonHeader); - executor.outFields.put("actionIdentifiers", actionIdentifiers); - executor.outFields.put("payload", payload); - - //var returnValue = executor.isTrue; - true; - - key: - name: ReceiveSubscriptionTask - version: 0.0.1 - value: - key: - name: ReceiveSubscriptionTask - version: 0.0.1 - inputFields: - entry: - - key: blueprintName - value: - key: blueprintName - fieldSchemaKey: - name: SimpleStringType - version: 0.0.1 - optional: false - - key: blueprintVersion - value: - key: blueprintVersion - fieldSchemaKey: - name: SimpleStringType - version: 0.0.1 - optional: false - - key: changeType - value: - key: changeType - fieldSchemaKey: - name: SimpleStringType - version: 0.0.1 - optional: false - - key: closedLoopControlName - value: - key: closedLoopControlName - fieldSchemaKey: - name: SimpleStringType - version: 0.0.1 - optional: false - - key: nfName - value: - key: nfName - fieldSchemaKey: - name: SimpleStringType - version: 0.0.1 - optional: false - - key: policyName - value: - key: policyName - fieldSchemaKey: - name: SimpleStringType - version: 0.0.1 - optional: false - - key: subscription - value: - key: subscription - fieldSchemaKey: - name: SubscriptionType - version: 0.0.1 - optional: false - outputFields: - entry: - - key: albumID - value: - key: albumID - fieldSchemaKey: - name: UUIDType - version: 0.0.1 - optional: false - taskParameters: - entry: [] - contextAlbumReference: - - name: PMSubscriptionAlbum - version: 0.0.1 - taskLogic: - key: TaskLogic - logicFlavour: JAVASCRIPT - logic: |- - /* - * ============LICENSE_START======================================================= - * Copyright (C) 2020 Nordix. 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========================================================= - */ - var uuidType = java.util.UUID; - - executor.logger.info(executor.subject.id); - - //albumID will be used to fetch info from our album later - var albumID = uuidType.randomUUID(); - var pmSubscriptionInfo = executor.getContextAlbum("PMSubscriptionAlbum").getSchemaHelper().createNewInstance(); - var returnValue = true; - - if(executor.inFields.get("policyName") != null) { - executor.logger.info("nfName in receive sub event " + executor.inFields.get("nfName")); - - var changeType = executor.inFields.get("changeType") - var nfName = executor.inFields.get("nfName") - var policyName = executor.inFields.get("policyName") - var closedLoopControlName = executor.inFields.get("closedLoopControlName") - var subscription = executor.inFields.get("subscription") - var blueprintName = executor.inFields.get("blueprintName") - var blueprintVersion = executor.inFields.get("blueprintVersion") - - pmSubscriptionInfo.put("nfName", executor.inFields.get("nfName")); - pmSubscriptionInfo.put("changeType", executor.inFields.get("changeType")) - pmSubscriptionInfo.put("policyName", executor.inFields.get("policyName")) - pmSubscriptionInfo.put("closedLoopControlName", executor.inFields.get("closedLoopControlName")) - pmSubscriptionInfo.put("subscription", subscription) - pmSubscriptionInfo.put("blueprintName", blueprintName) - pmSubscriptionInfo.put("blueprintVersion", blueprintVersion) - - - executor.getContextAlbum("PMSubscriptionAlbum").put(albumID.toString(), pmSubscriptionInfo); - - executor.outFields.put("albumID", albumID) - } else { - executor.message = "Received invalid event" - returnValue = false; - } - - returnValue; - events: - key: - name: PMControlPolicy_Events - version: 0.0.1 - eventMap: - entry: - - key: - name: CDSCreateResponseEvent - version: 0.0.1 - value: - key: - name: CDSCreateResponseEvent - version: 0.0.1 - nameSpace: org.onap.policy.apex.onap.pmcontrol - source: CDS - target: APEX - parameter: - entry: - - key: actionIdentifiers - value: - key: actionIdentifiers - fieldSchemaKey: - name: CDSActionIdentifiersType - version: 0.0.1 - optional: false - - key: commonHeader - value: - key: commonHeader - fieldSchemaKey: - name: CDSResponseCommonHeaderType - version: 0.0.1 - optional: false - - key: payload - value: - key: payload - fieldSchemaKey: - name: CDSCreateResponsePayloadType - version: 0.0.1 - optional: false - - key: status - value: - key: status - fieldSchemaKey: - name: CDSResponseStatusType - version: 0.0.1 - optional: false - - key: - name: CDSCreateSubscriptionRequestEvent - version: 0.0.1 - value: - key: - name: CDSCreateSubscriptionRequestEvent - version: 0.0.1 - nameSpace: org.onap.policy.apex.onap.pmcontrol - source: APEX - target: APEX - parameter: - entry: - - key: actionIdentifiers - value: - key: actionIdentifiers - fieldSchemaKey: - name: CDSActionIdentifiersType - version: 0.0.1 - optional: false - - key: commonHeader - value: - key: commonHeader - fieldSchemaKey: - name: CDSRequestCommonHeaderType - version: 0.0.1 - optional: false - - key: payload - value: - key: payload - fieldSchemaKey: - name: CDSCreateSubscriptionPayloadType - version: 0.0.1 - optional: false - - key: - name: CDSDeleteResponseEvent - version: 0.0.1 - value: - key: - name: CDSDeleteResponseEvent - version: 0.0.1 - nameSpace: org.onap.policy.apex.onap.pmcontrol - source: CDS - target: APEX - parameter: - entry: - - key: actionIdentifiers - value: - key: actionIdentifiers - fieldSchemaKey: - name: CDSActionIdentifiersType - version: 0.0.1 - optional: false - - key: commonHeader - value: - key: commonHeader - fieldSchemaKey: - name: CDSResponseCommonHeaderType - version: 0.0.1 - optional: false - - key: payload - value: - key: payload - fieldSchemaKey: - name: CDSDeleteResponsePayloadType - version: 0.0.1 - optional: false - - key: status - value: - key: status - fieldSchemaKey: - name: CDSResponseStatusType - version: 0.0.1 - optional: false - - key: - name: CDSDeleteSubscriptionRequestEvent - version: 0.0.1 - value: - key: - name: CDSDeleteSubscriptionRequestEvent - version: 0.0.1 - nameSpace: org.onap.policy.apex.onap.pmcontrol - source: APEX - target: APEX - parameter: - entry: - - key: actionIdentifiers - value: - key: actionIdentifiers - fieldSchemaKey: - name: CDSActionIdentifiersType - version: 0.0.1 - optional: false - - key: commonHeader - value: - key: commonHeader - fieldSchemaKey: - name: CDSRequestCommonHeaderType - version: 0.0.1 - optional: false - - key: payload - value: - key: payload - fieldSchemaKey: - name: CDSDeleteSubscriptionPayloadType - version: 0.0.1 - optional: false - - key: - name: CDSResponseStatusEvent - version: 0.0.1 - value: - key: - name: CDSResponseStatusEvent - version: 0.0.1 - nameSpace: org.onap.policy.apex.onap.pmcontrol - source: APEX - target: DCAE - parameter: - entry: - - key: status - value: - key: status - fieldSchemaKey: - name: SubscriptionStatusType - version: 0.0.1 - optional: false - - key: - name: CreateSubscriptionPayloadEvent - version: 0.0.1 - value: - key: - name: CreateSubscriptionPayloadEvent - version: 0.0.1 - nameSpace: org.onap.policy.apex.onap.pmcontrol - source: APEX - target: APEX - parameter: - entry: - - key: albumID - value: - key: albumID - fieldSchemaKey: - name: UUIDType - version: 0.0.1 - optional: false - - key: payload - value: - key: payload - fieldSchemaKey: - name: CDSCreateSubscriptionPayloadType - version: 0.0.1 - optional: false - - key: - name: DeleteSubscriptionPayloadEvent - version: 0.0.1 - value: - key: - name: DeleteSubscriptionPayloadEvent - version: 0.0.1 - nameSpace: org.onap.policy.apex.onap.pmcontrol - source: APEX - target: APEX - parameter: - entry: - - key: albumID - value: - key: albumID - fieldSchemaKey: - name: UUIDType - version: 0.0.1 - optional: false - - key: payload - value: - key: payload - fieldSchemaKey: - name: CDSDeleteSubscriptionPayloadType - version: 0.0.1 - optional: false - - key: - name: MRResponseEvent - version: 0.0.1 - value: - key: - name: MRResponseEvent - version: 0.0.1 - nameSpace: org.onap.policy.apex.onap.pmcontrol - source: DCAE - target: APEX - parameter: - entry: - - key: count - value: - key: count - fieldSchemaKey: - name: SimpleIntType - version: 0.0.1 - optional: false - - key: serverTimeMs - value: - key: serverTimeMs - fieldSchemaKey: - name: SimpleIntType - version: 0.0.1 - optional: false - - key: - name: PMSubscriptionOutputEvent - version: 0.0.1 - value: - key: - name: PMSubscriptionOutputEvent - version: 0.0.1 - nameSpace: org.onap.policy.apex.onap.pmcontrol - source: APEX - target: APEX - parameter: - entry: - - key: albumID - value: - key: albumID - fieldSchemaKey: - name: UUIDType - version: 0.0.1 - optional: false - - key: - name: pmsh-operational-policy - version: 0.0.1 - value: - key: - name: pmsh-operational-policy - version: 0.0.1 - nameSpace: org.onap.policy.apex.onap.pmcontrol - source: DCAE - target: APEX - parameter: - entry: - - key: blueprintName - value: - key: blueprintName - fieldSchemaKey: - name: SimpleStringType - version: 0.0.1 - optional: false - - key: blueprintVersion - value: - key: blueprintVersion - fieldSchemaKey: - name: SimpleStringType - version: 0.0.1 - optional: false - - key: changeType - value: - key: changeType - fieldSchemaKey: - name: SimpleStringType - version: 0.0.1 - optional: false - - key: closedLoopControlName - value: - key: closedLoopControlName - fieldSchemaKey: - name: SimpleStringType - version: 0.0.1 - optional: false - - key: nfName - value: - key: nfName - fieldSchemaKey: - name: SimpleStringType - version: 0.0.1 - optional: false - - key: policyName - value: - key: policyName - fieldSchemaKey: - name: SimpleStringType - version: 0.0.1 - optional: false - - key: subscription - value: - key: subscription - fieldSchemaKey: - name: SubscriptionType - version: 0.0.1 - optional: false - albums: - key: - name: PMControlPolicy_Albums - version: 0.0.1 - albums: - entry: - - key: - name: PMSubscriptionAlbum - version: 0.0.1 - value: - key: - name: PMSubscriptionAlbum - version: 0.0.1 - scope: policy - isWritable: true - itemSchema: - name: PMSubscriptionType - version: 0.0.1 - schemas: - key: - name: PMControlPolicy_Schemas - version: 0.0.1 - schemas: - entry: - - key: - name: CDSActionIdentifiersType - version: 0.0.1 - value: - key: - name: CDSActionIdentifiersType - version: 0.0.1 - schemaFlavour: Avro - schemaDefinition: |- - { - "type": "record", - "name": "ActionIdentifiers_Type", - "namespace": "org.onap.policy.apex.onap.helloworld", - "fields": [ - { - "name": "actionName", - "type": "string" - }, - { - "name": "blueprintName", - "type": "string" - }, - { - "name": "blueprintVersion", - "type": "string" - }, - { - "name": "mode", - "type": "string" - } - ] - } - - key: - name: CDSCreateResponsePayloadType - version: 0.0.1 - value: - key: - name: CDSCreateResponsePayloadType - version: 0.0.1 - schemaFlavour: Avro - schemaDefinition: |- - { - "name": "CreateResponsePayloadEntry", - "type": "record", - "namespace": "org.onap.policy.apex.onap.helloworld", - "fields": [ - { - "name": "create_DasH_subscription_DasH_response", - "type": { - "name": "create_DasH_subscription_DasH_response", - "type": "record", - "fields": [ - { - "name": "odl_DasH_response", - "type": { - "name": "odl_DasH_response", - "type": "record", - "fields": [ - { - "name": "status", - "type": "string" - } - ] - } - } - ] - } - } - ] - } - - key: - name: CDSCreateSubscriptionPayloadType - version: 0.0.1 - value: - key: - name: CDSCreateSubscriptionPayloadType - version: 0.0.1 - schemaFlavour: Avro - schemaDefinition: |- - { - "type": "map", - "values": { - "type": "record", - "name": "CDSRequestPayloadEntry", - "fields": [ - { - "name": "create_DasH_subscription_DasH_properties", - "type": { - "name": "create_DasH_subscription_DasH_properties_record", - "type": "record", - "fields": [ - { - "name": "nfName", - "type": "string" - }, - { - "name": "subscriptionName", - "type": "string" - }, - { - "name": "administrativeState", - "type": "string" - }, - { - "name": "fileBasedGP", - "type": "string" - }, - { - "name": "fileLocation", - "type": "string" - }, - { - "name": "measurementGroups", - "type": { - "type": "array", - "items": { - "name": "measurementGroups_record", - "type": "record", - "fields": [ - { - "name": "measurementGroup", - "type": { - "name": "measurementGroup", - "type": "record", - "fields": [ - { - "name": "measurementTypes", - "type": { - "type": "array", - "items": { - "name": "measurementTypes_record", - "type": "record", - "fields": [ - { - "name": "measurementType", - "type": "string" - } - ] - } - } - }, - { - "name": "managedObjectDNsBasic", - "type": { - "type": "array", - "items": { - "name": "managedObjectDNsBasic_record", - "type": "record", - "fields": [ - { - "name": "DN", - "type": "string" - } - ] - } - } - } - ] - } - } - ] - } - } - } - ] - } - } - ] - } - } - - key: - name: CDSDeleteResponsePayloadType - version: 0.0.1 - value: - key: - name: CDSDeleteResponsePayloadType - version: 0.0.1 - schemaFlavour: Avro - schemaDefinition: |- - { - "name": "DeleteResponsePayloadEntry", - "type": "record", - "namespace": "com.acme.avro", - "fields": [ - { - "name": "delete_DasH_subscription_DasH_response", - "type": { - "name": "delete_DasH_subscription_DasH_response", - "type": "record", - "fields": [ - { - "name": "odl_DasH_response", - "type": { - "name": "odl_DasH_response", - "type": "record", - "fields": [ - { - "name": "status", - "type": "string" - } - ] - } - } - ] - } - } - ] - } - - key: - name: CDSDeleteSubscriptionPayloadType - version: 0.0.1 - value: - key: - name: CDSDeleteSubscriptionPayloadType - version: 0.0.1 - schemaFlavour: Avro - schemaDefinition: |- - { - "type": "map", - "values": { - "type": "record", - "name": "CDSRequestPayloadEntry", - "fields": [ - { - "name": "delete_DasH_subscription_DasH_properties", - "type": { - "name": "delete_DasH_subscription_DasH_properties_record", - "type": "record", - "fields": [ - { - "name": "nfName", - "type": "string" - }, - { - "name": "subscriptionName", - "type": "string" - }, - { - "name": "administrativeState", - "type": "string" - }, - { - "name": "fileBasedGP", - "type": "string" - }, - { - "name": "fileLocation", - "type": "string" - }, - { - "name": "measurementGroups", - "type": { - "type": "array", - "items": { - "name": "measurementGroups_record", - "type": "record", - "fields": [ - { - "name": "measurementGroup", - "type": { - "name": "measurementGroup", - "type": "record", - "fields": [ - { - "name": "measurementTypes", - "type": { - "type": "array", - "items": { - "name": "measurementTypes_record", - "type": "record", - "fields": [ - { - "name": "measurementType", - "type": "string" - } - ] - } - } - }, - { - "name": "managedObjectDNsBasic", - "type": { - "type": "array", - "items": { - "name": "managedObjectDNsBasic_record", - "type": "record", - "fields": [ - { - "name": "DN", - "type": "string" - } - ] - } - } - } - ] - } - } - ] - } - } - } - ] - } - } - ] - } - } - - key: - name: CDSRequestCommonHeaderType - version: 0.0.1 - value: - key: - name: CDSRequestCommonHeaderType - version: 0.0.1 - schemaFlavour: Avro - schemaDefinition: |- - { - "type": "record", - "name": "RequestCommonHeader_Type", - "namespace": "org.onap.policy.apex.onap.helloworld", - "fields": [ - { - "name": "originatorId", - "type": "string" - }, - { - "name": "requestId", - "type": "string" - }, - { - "name": "subRequestId", - "type": "string" - } - ] - } - - key: - name: CDSResponseCommonHeaderType - version: 0.0.1 - value: - key: - name: CDSResponseCommonHeaderType - version: 0.0.1 - schemaFlavour: Avro - schemaDefinition: |- - { - "type": "record", - "name": "ResponseCommonHeader_Type", - "namespace": "org.onap.policy.apex.onap.helloworld", - "fields": [ - { - "name": "originatorId", - "type": "string" - }, - { - "name": "requestId", - "type": "string" - }, - { - "name": "subRequestId", - "type": "string" - }, - { - "name": "timestamp", - "type": "string" - }, - { - "name": "flags", - "type": ["null", "string"] - } - ] - } - - key: - name: CDSResponseStatusType - version: 0.0.1 - value: - key: - name: CDSResponseStatusType - version: 0.0.1 - schemaFlavour: Avro - schemaDefinition: |- - { - "type": "record", - "name": "ResponseStatus_Type", - "namespace": "org.onap.policy.apex.onap.helloworld", - "fields": [ - { - "name": "code", - "type": "int" - }, - { - "name": "eventType", - "type": "string" - }, - { - "name": "timestamp", - "type": "string" - }, - { - "name": "message", - "type": "string" - } - ] - } - - key: - name: PMSubscriptionType - version: 0.0.1 - value: - key: - name: PMSubscriptionType - version: 0.0.1 - schemaFlavour: Avro - schemaDefinition: "{\n\t\"name\": \"PMSubscription\",\n\t\"type\": \"record\",\n\t\"namespace\": \"\ - org.onap.policy.apex.onap.pmcontrol\",\n\t\"fields\": [\n {\n \"name\": \"nfName\"\ - ,\n \"type\": \"string\"\n },\n\t {\n\t\t\t\"name\": \"changeType\",\n\t\t\t\"\ - type\": \"string\"\n\t\t},\n\t\t{\n\t\t\t\"name\": \"closedLoopControlName\",\n\t\t\t\"type\": \"\ - string\"\n\t\t},\n\t\t{\n\t\t\t\"name\": \"policyName\",\n\t\t\t\"type\": \"string\"\n\t\t},\n\t\t\ - {\n\t\t \"name\": \"blueprintName\",\n\t\t \"type\": \"string\"\n\t\t},\n\t\t{\n\t\t \"name\"\ - : \"blueprintVersion\",\n\t\t \"type\": \"string\"\n\t\t},\n\t\t{\n\t\t\t\"name\": \"subscription\"\ - ,\n\t\t\t\"type\": {\n\t\t\t\t\"name\": \"subscription\",\n\t\t\t\t\"type\": \"record\",\n\t\t\t\t\ - \"fields\": [{\n\t\t\t\t\t\t\"name\": \"subscriptionName\",\n\t\t\t\t\t\t\"type\": \"string\"\n\t\t\ - \t\t\t},\n\t\t\t\t\t{\n\t\t\t\t\t\t\"name\": \"administrativeState\",\n\t\t\t\t\t\t\"type\": \"string\"\ - \n\t\t\t\t\t},\n\t\t\t\t\t{\n\t\t\t\t\t\t\"name\": \"fileBasedGP\",\n\t\t\t\t\t\t\"type\": \"int\"\ - \n\t\t\t\t\t},\n\t\t\t\t\t{\n\t\t\t\t\t\t\"name\": \"fileLocation\",\n\t\t\t\t\t\t\"type\": \"string\"\ - \n\t\t\t\t\t},\n\t\t\t\t\t{\n\t\t\t\t\t\t\"name\": \"measurementGroups\",\n\t\t\t\t\t\t\"type\": {\n\ - \t\t\t\t\t\t\t\"type\": \"array\",\n\t\t\t\t\t\t\t\"items\": {\n\t\t\t\t\t\t\t\t\"name\": \"Measurement_Groups_Type\"\ - ,\n\t\t\t\t\t\t\t\t\"type\": \"record\",\n\t\t\t\t\t\t\t\t\"fields\": [{\n\t\t\t\t\t\t\t\t\t\"name\"\ - : \"measurementGroup\",\n\t\t\t\t\t\t\t\t\t\"type\": {\n\t\t\t\t\t\t\t\t\t\t\"name\": \"Measurement_Group_Type\"\ - ,\n\t\t\t\t\t\t\t\t\t\t\"type\": \"record\",\n\t\t\t\t\t\t\t\t\t\t\"fields\": [{\n\t\t\t\t\t\t\t\t\ - \t\t\t\t\"name\": \"measurementTypes\",\n\t\t\t\t\t\t\t\t\t\t\t\t\"type\": {\n\t\t\t\t\t\t\t\t\t\t\ - \t\t\t\"type\": \"array\",\n\t\t\t\t\t\t\t\t\t\t\t\t\t\"items\": {\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\"\ - name\": \"Measurement_Types_Type\",\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\"type\": \"record\",\n\t\t\t\t\t\ - \t\t\t\t\t\t\t\t\t\"fields\": [{\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\"name\": \"measurementType\",\n\t\ - \t\t\t\t\t\t\t\t\t\t\t\t\t\t\"type\": \"string\"\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t}]\n\t\t\t\t\t\t\t\t\ - \t\t\t\t\t}\n\t\t\t\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\t\t\t\t{\n\t\t\t\t\ - \t\t\t\t\t\t\t\t\"name\": \"managedObjectDNsBasic\",\n\t\t\t\t\t\t\t\t\t\t\t\t\"type\": {\n\t\t\t\t\ - \t\t\t\t\t\t\t\t\t\"type\": \"array\",\n\t\t\t\t\t\t\t\t\t\t\t\t\t\"items\": {\n\t\t\t\t\t\t\t\t\t\ - \t\t\t\t\t\"name\": \"Managed_Object_Dns_Basic_Type\",\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\"type\": \"record\"\ - ,\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\"fields\": [{\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\"name\": \"DN\",\n\t\ - \t\t\t\t\t\t\t\t\t\t\t\t\t\t\"type\": \"string\"\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t}]\n\t\t\t\t\t\t\t\t\ - \t\t\t\t\t}\n\t\t\t\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\t\t]\n\t\t\t\t\t\ - \t\t\t\t}\n\t\t\t\t\t\t\t\t}]\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t]\n\t\t\t}\n\t\ - \t}\n\t]\n}" - - key: - name: SimpleIntType - version: 0.0.1 - value: - key: - name: SimpleIntType - version: 0.0.1 - schemaFlavour: Java - schemaDefinition: java.lang.Integer - - key: - name: SimpleStringType - version: 0.0.1 - value: - key: - name: SimpleStringType - version: 0.0.1 - schemaFlavour: Java - schemaDefinition: java.lang.String - - key: - name: SubscriptionStatusType - version: 0.0.1 - value: - key: - name: SubscriptionStatusType - version: 0.0.1 - schemaFlavour: Avro - schemaDefinition: |- - { - "type": "record", - "name": "ActivateSubscriptionStatus_Type", - "namespace": "org.onap.policy.apex.onap.helloworld", - "fields": [ - { - "name": "subscriptionName", - "type": "string" - }, - { - "name": "nfName", - "type": "string" - }, - { - "name": "changeType", - "type": "string" - }, - { - "name": "message", - "type": "string" - } - ] - } - - key: - name: SubscriptionType - version: 0.0.1 - value: - key: - name: SubscriptionType - version: 0.0.1 - schemaFlavour: Avro - schemaDefinition: "{\n\t\"name\": \"subscription\",\n\t\"type\": \"record\",\n\t\"fields\": [{\n\t\t\ - \t\"name\": \"subscriptionName\",\n\t\t\t\"type\": \"string\"\n\t\t},\n\t\t{\n\t\t\t\"name\": \"administrativeState\"\ - ,\n\t\t\t\"type\": \"string\"\n\t\t},\n\t\t{\n\t\t\t\"name\": \"fileBasedGP\",\n\t\t\t\"type\": \"\ - int\"\n\t\t},\n\t\t{\n\t\t\t\"name\": \"fileLocation\",\n\t\t\t\"type\": \"string\"\n\t\t},\n\t\t\ - {\n\t\t\t\"name\": \"measurementGroups\",\n\t\t\t\"type\": {\n\t\t\t\t\"type\": \"array\",\n\t\t\t\ - \t\"items\": {\n\t\t\t\t\t\"name\": \"Measurement_Groups_Type\",\n\t\t\t\t\t\"type\": \"record\",\n\ - \t\t\t\t\t\"fields\": [{\n\t\t\t\t\t\t\"name\": \"measurementGroup\",\n\t\t\t\t\t\t\"type\": {\n\t\ - \t\t\t\t\t\t\"name\": \"Measurement_Group_Type\",\n\t\t\t\t\t\t\t\"type\": \"record\",\n\t\t\t\t\t\ - \t\t\"fields\": [{\n\t\t\t\t\t\t\t\t\t\"name\": \"measurementTypes\",\n\t\t\t\t\t\t\t\t\t\"type\"\ - : {\n\t\t\t\t\t\t\t\t\t\t\"type\": \"array\",\n\t\t\t\t\t\t\t\t\t\t\"items\": {\n\t\t\t\t\t\t\t\t\t\ - \t\t\"name\": \"Measurement_Types_Type\",\n\t\t\t\t\t\t\t\t\t\t\t\"type\": \"record\",\n\t\t\t\t\t\ - \t\t\t\t\t\t\"fields\": [{\n\t\t\t\t\t\t\t\t\t\t\t\t\"name\": \"measurementType\",\n\t\t\t\t\t\t\t\ - \t\t\t\t\t\"type\": \"string\"\n\t\t\t\t\t\t\t\t\t\t\t}]\n\t\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\t\ - }\n\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\t\"name\": \"managedObjectDNsBasic\",\n\ - \t\t\t\t\t\t\t\t\t\"type\": {\n\t\t\t\t\t\t\t\t\t\t\"type\": \"array\",\n\t\t\t\t\t\t\t\t\t\t\"items\"\ - : {\n\t\t\t\t\t\t\t\t\t\t\t\"name\": \"Managed_Object_Dns_Basic_Type\",\n\t\t\t\t\t\t\t\t\t\t\t\"\ - type\": \"record\",\n\t\t\t\t\t\t\t\t\t\t\t\"fields\": [{\n\t\t\t\t\t\t\t\t\t\t\t\t\"name\": \"DN\"\ - ,\n\t\t\t\t\t\t\t\t\t\t\t\t\"type\": \"string\"\n\t\t\t\t\t\t\t\t\t\t\t}]\n\t\t\t\t\t\t\t\t\t\t}\n\ - \t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t]\n\t\t\t\t\t\t}\n\t\t\t\t\t}]\n\t\t\t\t}\n\t\ - \t\t}\n\t\t}\n\t]\n}" - - key: - name: UUIDType - version: 0.0.1 - value: - key: - name: UUIDType - version: 0.0.1 - schemaFlavour: Java - schemaDefinition: java.util.UUID - engineParameters: - executorParameters: - JAVASCRIPT: - parameterClassName: org.onap.policy.apex.plugins.executor.javascript.JavascriptExecutorParameters - contextParameters: - parameterClassName: org.onap.policy.apex.context.parameters.ContextParameters - schemaParameters: - Avro: - parameterClassName: org.onap.policy.apex.plugins.context.schema.avro.AvroSchemaHelperParameters - Java: - parameterClassName: org.onap.policy.apex.context.impl.schema.java.JavaSchemaHelperParameters - jsonAdapters: - Instant: - adaptedClass: java.time.Instant - adaptorClass: org.onap.policy.controlloop.util.Serialization$GsonInstantAdapter - eventInputParameters: - DCAEConsumer: - carrierTechnologyParameters: - carrierTechnology: RESTCLIENT - parameterClassName: org.onap.policy.apex.plugins.event.carrier.restclient.RestClientCarrierTechnologyParameters - parameters: - consumerPollTime: '50' - url: https://message-router:3905/events/unauthenticated.DCAE_CL_OUTPUT/cg1/sg1 - eventProtocolParameters: - eventProtocol: JSON - parameters: - nameAlias: policyName - eventName: pmsh-operational-policy - eventNameFilter: pmsh-operational-policy - CDSRequestConsumer: - carrierTechnologyParameters: - carrierTechnology: RESTREQUESTOR - parameterClassName: org.onap.policy.apex.plugins.event.carrier.restrequestor.RestRequestorCarrierTechnologyParameters - parameters: - url: http://10.10.10.184:30254/api/v1/execution-service/process - httpMethod: POST - restRequestTimeout: 2000 - httpHeaders: - - - Authorization - - Basic Y2NzZGthcHBzOmNjc2RrYXBwcw== - eventProtocolParameters: - eventProtocol: JSON - eventName: CDSCreateResponseEvent - eventNameFilter: CDSCreateResponseEvent - requestorMode: true - requestorPeer: CDSRequestProducer - requestorTimeout: 500 - CDSDeleteRequestConsumer: - carrierTechnologyParameters: - carrierTechnology: RESTREQUESTOR - parameterClassName: org.onap.policy.apex.plugins.event.carrier.restrequestor.RestRequestorCarrierTechnologyParameters - parameters: - url: http://10.10.10.184:30254/api/v1/execution-service/process - httpMethod: POST - restRequestTimeout: 2000 - httpHeaders: - - - Authorization - - Basic Y2NzZGthcHBzOmNjc2RrYXBwcw== - eventProtocolParameters: - eventProtocol: JSON - eventName: CDSDeleteResponseEvent - eventNameFilter: CDSDeleteResponseEvent - requestorMode: true - requestorPeer: CDSDeleteRequestProducer - requestorTimeout: 500 - CDSReplyConsumer: - carrierTechnologyParameters: - carrierTechnology: RESTREQUESTOR - parameterClassName: org.onap.policy.apex.plugins.event.carrier.restrequestor.RestRequestorCarrierTechnologyParameters - parameters: - url: https://message-router:3905/events/unauthenticated.PMSH_CL_INPUT - httpMethod: POST - restRequestTimeout: 2000 - eventProtocolParameters: - eventProtocol: JSON - eventName: MRResponseEvent - eventNameFilter: MRResponseEvent - requestorMode: true - requestorPeer: CDSReplyProducer - requestorTimeout: 500 - eventOutputParameters: - logOutputter: - carrierTechnologyParameters: - carrierTechnology: FILE - parameters: - fileName: /tmp/outputevents.log - eventProtocolParameters: - eventProtocol: JSON - StdOutOutputter: - carrierTechnologyParameters: - carrierTechnology: FILE - parameters: - standardIo: true - eventProtocolParameters: - eventProtocol: JSON - CDSRequestProducer: - carrierTechnologyParameters: - carrierTechnology: RESTREQUESTOR - parameterClassName: org.onap.policy.apex.plugins.event.carrier.restrequestor.RestRequestorCarrierTechnologyParameters - eventProtocolParameters: - eventProtocol: JSON - eventNameFilter: CDSCreateSubscriptionRequestEvent - requestorMode: true - requestorPeer: CDSRequestConsumer - requestorTimeout: 500 - CDSDeleteRequestProducer: - carrierTechnologyParameters: - carrierTechnology: RESTREQUESTOR - parameterClassName: org.onap.policy.apex.plugins.event.carrier.restrequestor.RestRequestorCarrierTechnologyParameters - eventProtocolParameters: - eventProtocol: JSON - eventNameFilter: CDSDeleteSubscriptionRequestEvent - requestorMode: true - requestorPeer: CDSDeleteRequestConsumer - requestorTimeout: 500 - CDSReplyProducer: - carrierTechnologyParameters: - carrierTechnology: RESTREQUESTOR - parameterClassName: org.onap.policy.apex.plugins.event.carrier.restrequestor.RestRequestorCarrierTechnologyParameters - eventProtocolParameters: - eventProtocol: JSON - eventNameFilter: CDSResponseStatusEvent - requestorMode: true - requestorPeer: CDSReplyConsumer - requestorTimeout: 500 diff --git a/runtime-controlloop/src/test/resources/rest/servicetemplates/pm_control_loop_tosca.yaml b/runtime-controlloop/src/test/resources/rest/servicetemplates/pm_control_loop_tosca.yaml deleted file mode 100644 index 01f825fc9..000000000 --- a/runtime-controlloop/src/test/resources/rest/servicetemplates/pm_control_loop_tosca.yaml +++ /dev/null @@ -1,452 +0,0 @@ -tosca_definitions_version: tosca_simple_yaml_1_3 -capability_types: - org.onap.EventProducer: - properties: - carrier_protocol_type: - type: string - required: true - constraints: - - valid_values: - - DMAAP_message_router - - SOMETHING_ELSE - - REST - data_format: - type: string - required: true - constraints: - - valid_values: - - JSON - - YAML - - JMS - event_format: - type: string - required: true - event_format_version: - type: string - required: false - config_keys: - type: list - required: false - entry_schema: - type: string - constraints: - - valid_values: - - all valid values should be added here - - if not specified, events of any config key may be generated - - 'examples for config_key: ves-measurement, ves-syslog, tca_handle_out, - etc.' - version: 0.0.1 - derived_from: tosca.capabilities.Root - org.onap.EventConsumer: - properties: - responding_capability: - type: string - required: false - carrier_protocol_type: - type: string - required: true - constraints: - - valid_values: - - DMAAP_message_router - - SOMETHING_ELSE - - REST - data_format: - type: string - required: true - constraints: - - valid_values: - - JSON - - YAML - - JMS - - all valid values should be added here - event_format: - type: string - description: 'examples for event_format: Ves_specification, LinkUp, VnfConfigured, - etc.' - required: true - event_format_version: - type: string - description: 'examples for event_format_version: 5.28.4, 7.30.1, etc.' - required: false - config_keys: - type: list - required: false - entry_schema: - type: string - constraints: - - valid_values: - - all valid values should be added here - - if not specified, events of any config key may be generated - - 'examples for config_key: ves-measurement, ves-syslog, tca_handle_out, - etc.' - version: 0.0.1 - derived_from: tosca.capabilities.Root -node_types: - org.onap.DynamicConfig: - properties: - application_name: - type: string - description: Value used to tie the config to an application ? should we be - using a relationship here instead? - required: true - application_version: - type: string - required: true - application_provider: - type: string - required: false - data_types: - type: object - required: false - schema: - type: object - required: false - version: 0.0.1 - derived_from: tosca.nodes.Root - org.onap.APP: - properties: - application_name: - type: string - description: Human readable name for the application Product - required: false - provider: - type: string - description: Provider of the application and of the descriptor - required: true - application_version: - type: string - description: Software version of the application - required: true - blueprint_id: - type: string - description: A reference to the app blueprint - required: false - monitoring_policy: - type: string - description: A reference to the monitoring policy - required: false - requirements: - - receive: - capability: org.onap.EventProducer - relationship: org.onap.PropagateEvent - occurrences: - - 0.0 - - UNBOUNDED - version: 0.0.0 - - send: - capability: org.onap.EventConsumer - relationship: org.onap.PropagateEvent - occurrences: - - 0.0 - - UNBOUNDED - version: 0.0.0 - version: 0.0.1 - derived_from: tosca.nodes.Root - org.onap.EventRelay: - properties: - event_format: - type: string - description: 'examples for event_format: Ves_specification, etc.' - required: true - event_format_version: - type: string - description: 'examples for event_format_version: 5.28.4, 7.30.1, etc.' - required: true - config_keys: - type: list - required: false - entry_schema: - type: string - constraints: - - valid_values: - - all valid values should be added here - - if not specified, events of any config key is relayed - - 'examples for config_key: ves-measurement, ves-syslog, tca_handle_out, - etc.' - supported_carrier_protocols: - type: map - description: 'A map describing supported carrier protocols and translations. - The tuples define what protocol combinations are supported on the producer - and consumer side: e.g. { REST: REST, DMAAP: REST, DMAAP: DMAAP}' - required: true - key_schema: - type: string - constraints: - - valid_values: - - DMAAP_message_router - - SOMETHING_ELSE - - REST - - all valid values should be added here - entry_schema: - type: string - constraints: - - valid_values: - - DMAAP_message_router - - SOMETHING_ELSE - - REST - - all valid values should be added here - supported_data_formats: - type: map - description: 'Is a map describing supported data formats and translation. - The tuples define what protocol combinations are supported on the producer - and consumer side: e.g. { JSON: JSON, JMS: JSON, YAML:YAML }' - required: true - key_schema: - type: string - constraints: - - valid_values: - - JSON - - JMS - - YAML - - etc - - all valid values should be added here - entry_schema: - type: string - constraints: - - valid_values: - - JSON - - JMS - - YAML - - etc - - all valid values should be added here - requirements: - - receive: - capability: org.onap.EventProducer - relationship: org.onap.PropagateEvent - occurrences: - - 0.0 - - UNBOUNDED - version: 0.0.0 - - send: - capability: org.onap.EventConsumer - relationship: org.onap.PropagateEvent - occurrences: - - 0.0 - - UNBOUNDED - version: 0.0.0 - version: 0.0.1 - derived_from: tosca.nodes.Root -relationship_types: - org.onap.PropagateEvent: - properties: - config_keys: - type: list - description: The relationship type used on requirements to org.onap.EventProducer - and org.onap.EventConsumer capabilities. Filters events by specific config_keys - to be transferred by this relationship. That is, any event with a specific - config_key found in the list is transferred. If list is not defined or is - empty, events with all config_keys are transferred. - required: false - entry_schema: - type: string - version: 0.0.1 - derived_from: tosca.relationships.Root -topology_template: - inputs: - pm_subscription_topic: - type: string - pm_subscription_response_topic: - type: string - pm_subscription_handler_blueprint_id: - type: string - pm_subscription_operational_policy_id: - type: string - pm_subscription_cds_blueprint_id: - type: string - enable_tls: - type: string - node_templates: - org.onap.PM_Subscription_Handler: - type: org.onap.APP - properties: - application_name: PM Subscription Handler - provider: Ericsson - application_version: 1.0.0 - artifact_id: - get_input: pm_subscription_handler_blueprint_id - description: Is this a reference to the DCAE Cloudify Blueprint that is - already stored(or will be stored before CL configuration & instatiation) - in DCAE Inventory? - artifact_config: - enable_tls: - get_input: enable_tls - pmsh_publish_topic_name: - get_input: pm_subscription_topic - capabilities: - pm-subscription-event-publisher: - properties: - carrier_protocol_type: DMAAP_message_router - data_format: JSON - event_format: pm-subscription-event-format - event_format_version: 1.0.0 - attributes: - type: org.onap.EventProducer - occurrences: - - 0.0 - - UNBOUNDED - version: 0.0.0 - pm-subscription-event-receiver: - properties: - carrier_protocol_type: DMAAP_message_router - data_format: JSON - event_format: pm-subscription-event-response-format - event_format_version: 1.0.0 - relationships: - - type: tosca.relationships.DependsOn - - description: any ideas on a better realtionship ? or is it better to - just use the root realtionship ? - - target: org.onap.PM_Monitoring_Policy - attributes: - type: org.onap.EventConsumer - occurrences: - - 0.0 - - UNBOUNDED - version: 0.0.0 - version: 0.0.0 - org.onap.PM_Monitoring_Policy: - type: org.onap.DynamicConfig - properties: - application_name: PM Subscription Handler - application_version: 1.0.0 - provider: Ericsson - data_types: - measurementType: - type: string - DN: - type: string - nfFilter: - properties: - nfNames: - type: list - entry_schema: string - modelInvariantIDs: - type: list - entry_schema: - type: string - modelVersionIDs: - type: list - entry_schema: - type: string - measurementGroup: - properties: - masurementTypes: - type: list - entry_schema: - type: measurementType - managedObjectDNsBasic: - type: list - entry_schema: - type: DN - schema: - subscription: - subscriptionName: - type: string - required: true - administrativeState: - type: string - required: true - filebasedGP: - type: integer - required: true - fileLocation: - type: string - required: true - nfFilter: - type: nfFilter - measurementGroups: - type: list - entry_schema: - type: measurementGroup - version: 0.0.0 - description: Should I be showing a dependency between PM Subscription Handler - and the PM Monitoring Policy - org.onap.PM_Policy: - type: org.onap.APP - properties: - application_name: PM Subscription Operational Policy - provider: Ericsson - application_version: 1.0.0 - artifact_id: - get_input: pm_subscription_operational_policy_id - artifact_config: NOT_DEFINED - requirements: - - receive_0: - capability: pm-subscription-event-publisher - node: org.onap.PM_Subscription_Handler - relationship: NOT_DEFINED - properties: - config_keys: - - topic_name: - get_input: pm_subscription_topic - version: 0.0.0 - - send_0: - capability: cds-rest-receive - node: org.onap.CDS - version: 0.0.0 - - receive_1: - capability: cds-rest-response - node: org.onap.CDS - version: 0.0.0 - - send_1: - capability: pm-subscription-event-receiver - node: org.onap.PM_Subscription_Handler - relationship: NOT_DEFINED - properties: - config_keys: - - topic_name: - get_input: pm_subscription_response_topic - version: 0.0.0 - capabilities: - pm-subscription-response-event-publisher: - properties: - type: org.onap.EventProducer - carrier_protocol_type: DMAAP_message_router - data_format: JSON - event_format: pm-subscription-event-response-format - event_format_version: 1.0.0 - occurrences: - - 0.0 - - UNBOUNDED - version: 0.0.0 - version: 0.0.0 - org.onap.PM_CDS_Blueprint: - type: org.onap.APP - properties: - application_name: PM Subscription CDS Blueprint - provider: Ericsson - application_version: 1.0.0 - artifact_id: - get_input: pm_subscription_cds_blueprint_id - capabilities: - cds-rest-receive: - properties: - type: org.onap.EventConsumer - protocol_type: REST - data_format: JSON - event_format: cds_action_format - event_format_version: 1.0.0 - responding_capability: cds-rest-response - occurrences: - - 0.0 - - UNBOUNDED - version: 0.0.0 - cds-rest-response: - properties: - type: org.onap.EventProducer - protocol_type: REST - data_format: JSON - event_format: cds_action_response_format - event_format_version: 1.0.0 - occurrences: - - 0.0 - version: 0.0.0 - version: 0.0.0 - org.onap.controlloop0: - type: org.onap.APP - properties: - application_name: Test Control Loop - provider: Ericsson - application_version: 1.0.0 - status: NOT_DEPLOYED - version: 0.0.0 -version: 0.0.0 diff --git a/runtime-controlloop/src/test/resources/rest/servicetemplates/pmsh_multiple_cl_tosca.yaml b/runtime-controlloop/src/test/resources/rest/servicetemplates/pmsh_multiple_cl_tosca.yaml deleted file mode 100644 index 9c440b42b..000000000 --- a/runtime-controlloop/src/test/resources/rest/servicetemplates/pmsh_multiple_cl_tosca.yaml +++ /dev/null @@ -1,238 +0,0 @@ -tosca_definitions_version: tosca_simple_yaml_1_3 -data_types: - onap.datatypes.ToscaConceptIdentifier: - derived_from: tosca.datatypes.Root - properties: - name: - type: string - required: true - version: - type: string - required: true -node_types: - org.onap.policy.clamp.controlloop.Participant: - version: 1.0.1 - derived_from: tosca.nodetypes.Root - properties: - provider: - type: string - requred: false - org.onap.policy.clamp.controlloop.ControlLoopElement: - version: 1.0.1 - derived_from: tosca.nodetypes.Root - properties: - provider: - type: string - requred: false - participantType: - type: onap.datatypes.ToscaConceptIdentifier - requred: true - startPhase: - type: integer - required: false - constraints: - - greater-or-equal: 0 - metadata: - common: true - description: A value indicating the start phase in which this control loop element will be started, the - first start phase is zero. Control Loop Elements are started in their start_phase order and stopped - in reverse start phase order. Control Loop Elements with the same start phase are started and - stopped simultaneously - org.onap.policy.clamp.controlloop.ControlLoop: - version: 1.0.1 - derived_from: tosca.nodetypes.Root - properties: - provider: - type: string - requred: false - elements: - type: list - required: true - entry_schema: - type: onap.datatypes.ToscaConceptIdentifier - org.onap.policy.clamp.controlloop.DCAEMicroserviceControlLoopElement: - version: 1.0.1 - derived_from: org.onap.policy.clamp.controlloop.ControlLoopElement - properties: - dcae_blueprint_id: - type: onap.datatypes.ToscaConceptIdentifier - requred: true - org.onap.policy.clamp.controlloop.PolicyTypeControlLoopElement: - version: 1.0.1 - derived_from: org.onap.policy.clamp.controlloop.ControlLoopElement - properties: - policy_type_id: - type: onap.datatypes.ToscaConceptIdentifier - requred: true - org.onap.policy.clamp.controlloop.CDSControlLoopElement: - version: 1.0.1 - derived_from: org.onap.policy.clamp.controlloop.ControlLoopElement - properties: - cds_blueprint_id: - type: onap.datatypes.ToscaConceptIdentifier - requred: true -topology_template: - node_templates: - org.onap.dcae.controlloop.DCAEMicroserviceControlLoopParticipant: - version: 2.3.4 - type: org.onap.policy.clamp.controlloop.Participant - type_version: 1.0.1 - description: Participant for DCAE microservices - properties: - provider: ONAP - org.onap.policy.controlloop.PolicyControlLoopParticipant: - version: 2.2.1 - type: org.onap.policy.clamp.controlloop.Participant - type_version: 1.0.1 - description: Participant for DCAE microservices - properties: - provider: ONAP - org.onap.ccsdk.cds.controlloop.CdsControlLoopParticipant: - version: 2.2.1 - type: org.onap.policy.clamp.controlloop.Participant - type_version: 1.0.1 - description: Participant for DCAE microservices - properties: - provider: ONAP - org.onap.domain.pmsh.PMSH_DCAEMicroservice: - version: 1.2.3 - type: org.onap.policy.clamp.controlloop.DCAEMicroserviceControlLoopElement - type_version: 1.0.0 - description: Control loop element for the DCAE microservice for Performance Management Subscription Handling - properties: - provider: Ericsson - participantType: - name: org.onap.dcae.controlloop.DCAEMicroserviceControlLoopParticipant - version: 2.3.4 - dcae_blueprint_id: - name: org.onap.dcae.blueprints.PMSHBlueprint - version: 1.0.0 - org.onap.domain.pmsh.PMSH_MonitoringPolicyControlLoopElement: - version: 1.2.3 - type: org.onap.policy.clamp.controlloop.PolicyTypeControlLoopElement - type_version: 1.0.0 - description: Control loop element for the monitoring policy for Performance Management Subscription Handling - properties: - provider: Ericsson - participantType: - name: org.onap.policy.controlloop.PolicyControlLoopParticipant - version: 2.2.1 - policy_type_id: - name: onap.policies.monitoring.pm-subscription-handler - version: 1.0.0 - org.onap.domain.pmsh.PMSH_OperationalPolicyControlLoopElement: - version: 1.2.3 - type: org.onap.policy.clamp.controlloop.PolicyTypeControlLoopElement - type_version: 1.0.0 - description: Control loop element for the operational policy for Performance Management Subscription Handling - properties: - provider: Ericsson - participantType: - name: org.onap.policy.controlloop.PolicyControlLoopParticipant - version: 2.2.1 - policy_type_id: - name: onap.policies.operational.pm-subscription-handler - version: 1.0.0 - org.onap.domain.pmsh.PMSH_CDS_ControlLoopElement: - version: 1.2.3 - type: org.onap.policy.clamp.controlloop.ControlLoopElement - type_version: 1.0.0 - description: Control loop element for CDS for Performance Management Subscription Handling - properties: - provider: Ericsson - participantType: - name: org.onap.ccsdk.cds.controlloop.CdsControlLoopParticipant - version: 3.2.1 - cds_blueprint_id: - name: org.onap.ccsdk.cds.PMSHCdsBlueprint - version: 1.0.0 - org.onap.domain.pmsh.PMSHControlLoopDefinition: - version: 1.2.3 - type: org.onap.policy.clamp.controlloop.ControlLoop - type_version: 1.0.0 - description: Control loop for Performance Management Subscription Handling - properties: - provider: Ericsson - elements: - - name: org.onap.domain.pmsh.PMSH_DCAEMicroservice - version: 1.2.3 - - name: org.onap.domain.pmsh.PMSH_MonitoringPolicyControlLoopElement - version: 1.2.3 - - name: org.onap.domain.pmsh.PMSH_OperationalPolicyControlLoopElement - version: 1.2.3 - - name: org.onap.domain.pmsh.PMSH_CDS_ControlLoopElement - version: 1.2.3 - org.onap.domain.pmsh.PMSD_DCAEMicroservice: - version: 1.2.3 - type: org.onap.policy.clamp.controlloop.DCAEMicroserviceControlLoopElement - type_version: 1.0.0 - description: Control loop element for the DCAE microservice for Performance Management Subscription Handling - properties: - provider: Ericsson - participantType: - name: org.onap.dcae.controlloop.DCAEMicroserviceControlLoopParticipant - version: 2.3.4 - dcae_blueprint_id: - name: org.onap.dcae.blueprints.PMSDBlueprint - version: 1.0.0 - org.onap.domain.pmsh.PMSD_MonitoringPolicyControlLoopElement: - version: 1.2.3 - type: org.onap.policy.clamp.controlloop.PolicyTypeControlLoopElement - type_version: 1.0.0 - description: Control loop element for the monitoring policy for Performance Management Subscription Handling - properties: - provider: Ericsson - participantType: - name: org.onap.policy.controlloop.PolicyControlLoopParticipant - version: 2.2.1 - policy_type_id: - name: onap.policies.monitoring.pm-subscription-handler - version: 1.0.0 - policy_id: - name: onap.policies.monitoring.pm-subscription-handler - version: 1.0.0 - org.onap.domain.pmsh.PMSD_OperationalPolicyControlLoopElement: - version: 1.2.3 - type: org.onap.policy.clamp.controlloop.PolicyTypeControlLoopElement - type_version: 1.0.0 - description: Control loop element for the operational policy for Performance Management Subscription Handling - properties: - provider: Ericsson - participantType: - name: org.onap.policy.controlloop.PolicyControlLoopParticipant - version: 2.2.1 - policy_type_id: - name: onap.policies.operational.pm-subscription-handler - version: 1.0.0 - policy_id: - name: onap.policies.monitoring.pm-subscription-handler - version: 1.0.0 - org.onap.domain.pmsh.PMSD_CDS_ControlLoopElement: - version: 1.2.3 - type: org.onap.policy.clamp.controlloop.ControlLoopElement - type_version: 1.0.0 - description: Control loop element for CDS for Performance Management Subscription Handling - properties: - provider: Ericsson - participantType: - name: org.onap.ccsdk.cds.controlloop.CdsControlLoopParticipant - version: 3.2.1 - cds_blueprint_id: - name: org.onap.ccsdk.cds.PMSDCdsBlueprint - version: 1.0.0 - org.onap.domain.pmsh.PMSDControlLoopDefinition: - version: 1.2.3 - type: org.onap.policy.clamp.controlloop.ControlLoop - type_version: 1.0.0 - description: Control loop for Performance Management Subscription Handling - properties: - provider: Ericsson - elements: - - name: org.onap.domain.pmsh.PMSD_DCAEMicroservice - version: 1.2.3 - - name: org.onap.domain.pmsh.PMSD_MonitoringPolicyControlLoopElement - version: 1.2.3 - - name: org.onap.domain.pmsh.PMSD_OperationalPolicyControlLoopElement - version: 1.2.3 - - name: org.onap.domain.pmsh.PMSD_CDS_ControlLoopElement - version: 1.2.3 diff --git a/runtime-controlloop/src/test/resources/rest/servicetemplates/tosca-for-smoke-testing.yaml b/runtime-controlloop/src/test/resources/rest/servicetemplates/tosca-for-smoke-testing.yaml deleted file mode 100644 index 9d1b7be64..000000000 --- a/runtime-controlloop/src/test/resources/rest/servicetemplates/tosca-for-smoke-testing.yaml +++ /dev/null @@ -1,3488 +0,0 @@ -tosca_definitions_version: tosca_simple_yaml_1_3 -data_types: - onap.datatypes.ToscaConceptIdentifier: - derived_from: tosca.datatypes.Root - properties: - name: - type: string - required: true - version: - type: string - required: true - onap.datatype.controlloop.Target: - derived_from: tosca.datatypes.Root - description: Definition for a entity in A&AI to perform a control loop operation on - properties: - targetType: - type: string - description: Category for the target type - required: true - constraints: - - valid_values: - - VNF - - VM - - VFMODULE - - PNF - entityIds: - type: map - description: | - Map of values that identify the resource. If none are provided, it is assumed that the - entity that generated the ONSET event will be the target. - required: false - metadata: - clamp_possible_values: ClampExecution:CSAR_RESOURCES - entry_schema: - type: string - onap.datatype.controlloop.Actor: - derived_from: tosca.datatypes.Root - description: An actor/operation/target definition - properties: - actor: - type: string - description: The actor performing the operation. - required: true - metadata: - clamp_possible_values: Dictionary:DefaultActors,ClampExecution:CDS/actor - operation: - type: string - description: The operation the actor is performing. - metadata: - clamp_possible_values: Dictionary:DefaultOperations,ClampExecution:CDS/operation - required: true - target: - type: onap.datatype.controlloop.Target - description: The resource the operation should be performed on. - required: true - payload: - type: map - description: Name/value pairs of payload information passed by Policy to the actor - required: false - metadata: - clamp_possible_values: ClampExecution:CDS/payload - entry_schema: - type: string - onap.datatype.controlloop.Operation: - derived_from: tosca.datatypes.Root - description: An operation supported by an actor - properties: - id: - type: string - description: Unique identifier for the operation - required: true - description: - type: string - description: A user-friendly description of the intent for the operation - required: false - operation: - type: onap.datatype.controlloop.Actor - description: The definition of the operation to be performed. - required: true - timeout: - type: integer - description: The amount of time for the actor to perform the operation. - required: true - retries: - type: integer - description: The number of retries the actor should attempt to perform the operation. - required: true - default: 0 - success: - type: string - description: Points to the operation to invoke on success. A value of "final_success" indicates and end to the operation. - required: false - default: final_success - failure: - type: string - description: Points to the operation to invoke on Actor operation failure. - required: false - default: final_failure - failure_timeout: - type: string - description: Points to the operation to invoke when the time out for the operation occurs. - required: false - default: final_failure_timeout - failure_retries: - type: string - description: Points to the operation to invoke when the current operation has exceeded its max retries. - required: false - default: final_failure_retries - failure_exception: - type: string - description: Points to the operation to invoke when the current operation causes an exception. - required: false - default: final_failure_exception - failure_guard: - type: string - description: Points to the operation to invoke when the current operation is blocked due to guard policy enforcement. - required: false - default: final_failure_guard - onap.datatypes.monitoring.managedObjectDNsBasic: - constraints: [] - properties: - DN: - name: DN - type: string - typeVersion: 0.0.0 - description: Managed object distinguished name - required: true - constraints: [] - metadata: {} - name: onap.datatypes.monitoring.managedObjectDNsBasic - version: 0.0.0 - derived_from: tosca.datatypes.Root - metadata: {} - onap.datatypes.monitoring.managedObjectDNsBasics: - constraints: [] - properties: - managedObjectDNsBasic: - name: managedObjectDNsBasic - type: map - typeVersion: 0.0.0 - description: Managed object distinguished name object - required: true - constraints: [] - entry_schema: - type: onap.datatypes.monitoring.managedObjectDNsBasic - typeVersion: 0.0.0 - constraints: [] - metadata: {} - name: onap.datatypes.monitoring.managedObjectDNsBasics - version: 0.0.0 - derived_from: tosca.datatypes.Root - metadata: {} - onap.datatypes.monitoring.measurementGroup: - constraints: [] - properties: - measurementTypes: - name: measurementTypes - type: list - typeVersion: 0.0.0 - description: List of measurement types - required: true - constraints: [] - entry_schema: - type: onap.datatypes.monitoring.measurementTypes - typeVersion: 0.0.0 - constraints: [] - metadata: {} - managedObjectDNsBasic: - name: managedObjectDNsBasic - type: list - typeVersion: 0.0.0 - description: List of managed object distinguished names - required: true - constraints: [] - entry_schema: - type: onap.datatypes.monitoring.managedObjectDNsBasics - typeVersion: 0.0.0 - constraints: [] - metadata: {} - name: onap.datatypes.monitoring.measurementGroup - version: 0.0.0 - derived_from: tosca.datatypes.Root - metadata: {} - onap.datatypes.monitoring.measurementGroups: - constraints: [] - properties: - measurementGroup: - name: measurementGroup - type: map - typeVersion: 0.0.0 - description: Measurement Group - required: true - constraints: [] - entry_schema: - type: onap.datatypes.monitoring.measurementGroup - typeVersion: 0.0.0 - constraints: [] - metadata: {} - name: onap.datatypes.monitoring.measurementGroups - version: 0.0.0 - derived_from: tosca.datatypes.Root - metadata: {} - onap.datatypes.monitoring.measurementType: - constraints: [] - properties: - measurementType: - name: measurementType - type: string - typeVersion: 0.0.0 - description: Measurement type - required: true - constraints: [] - metadata: {} - name: onap.datatypes.monitoring.measurementType - version: 0.0.0 - derived_from: tosca.datatypes.Root - metadata: {} - onap.datatypes.monitoring.measurementTypes: - constraints: [] - properties: - measurementType: - name: measurementType - type: map - typeVersion: 0.0.0 - description: Measurement type object - required: true - constraints: [] - entry_schema: - type: onap.datatypes.monitoring.measurementType - typeVersion: 0.0.0 - constraints: [] - metadata: {} - name: onap.datatypes.monitoring.measurementTypes - version: 0.0.0 - derived_from: tosca.datatypes.Root - metadata: {} - onap.datatypes.monitoring.nfFilter: - constraints: [] - properties: - modelNames: - name: modelNames - type: list - typeVersion: 0.0.0 - description: List of model names - required: true - constraints: [] - entry_schema: - type: string - typeVersion: 0.0.0 - constraints: [] - metadata: {} - modelInvariantIDs: - name: modelInvariantIDs - type: list - typeVersion: 0.0.0 - description: List of model invariant IDs - required: true - constraints: [] - entry_schema: - type: string - typeVersion: 0.0.0 - constraints: [] - metadata: {} - modelVersionIDs: - name: modelVersionIDs - type: list - typeVersion: 0.0.0 - description: List of model version IDs - required: true - constraints: [] - entry_schema: - type: string - typeVersion: 0.0.0 - constraints: [] - metadata: {} - nfNames: - name: nfNames - type: list - typeVersion: 0.0.0 - description: List of network functions - required: true - constraints: [] - entry_schema: - type: string - typeVersion: 0.0.0 - constraints: [] - metadata: {} - name: onap.datatypes.monitoring.nfFilter - version: 0.0.0 - derived_from: tosca.datatypes.Root - metadata: {} - onap.datatypes.monitoring.subscription: - constraints: [] - properties: - measurementGroups: - name: measurementGroups - type: list - typeVersion: 0.0.0 - description: Measurement Groups - required: true - constraints: [] - entry_schema: - type: onap.datatypes.monitoring.measurementGroups - typeVersion: 0.0.0 - constraints: [] - metadata: {} - fileBasedGP: - name: fileBasedGP - type: integer - typeVersion: 0.0.0 - description: File based granularity period - required: true - constraints: [] - metadata: {} - fileLocation: - name: fileLocation - type: string - typeVersion: 0.0.0 - description: ROP file location - required: true - constraints: [] - metadata: {} - subscriptionName: - name: subscriptionName - type: string - typeVersion: 0.0.0 - description: Name of the subscription - required: true - constraints: [] - metadata: {} - administrativeState: - name: administrativeState - type: string - typeVersion: 0.0.0 - description: State of the subscription - required: true - constraints: - - valid_values: - - LOCKED - - UNLOCKED - metadata: {} - nfFilter: - name: nfFilter - type: map - typeVersion: 0.0.0 - description: Network function filter - required: true - constraints: [] - entry_schema: - type: onap.datatypes.monitoring.nfFilter - typeVersion: 0.0.0 - constraints: [] - metadata: {} - name: onap.datatypes.monitoring.subscription - version: 0.0.0 - derived_from: tosca.datatypes.Root - metadata: {} - org.onap.datatypes.policy.clamp.controlloop.httpControlLoopElement.RestRequest: - version: 1.0.0 - derived_from: tosca.datatypes.Root - properties: - restRequestId: - type: onap.datatypes.ToscaConceptIdentifier - typeVersion: 1.0.0 - required: true - description: The name and version of a REST request to be sent to a REST endpoint - httpMethod: - type: string - required: true - constraints: - - valid_values: [POST, PUT, GET, DELETE] - description: The REST method to use - path: - type: string - required: true - description: The path of the REST request relative to the base URL - body: - type: string - required: false - description: The body of the REST request for PUT and POST requests - expectedResponse: - type: integer - required: true - constraints: [] - description: THe expected HTTP status code for the REST request - org.onap.datatypes.policy.clamp.controlloop.httpControlLoopElement.ConfigurationEntity: - version: 1.0.0 - derived_from: tosca.datatypes.Root - properties: - configurationEntityId: - type: onap.datatypes.ToscaConceptIdentifier - typeVersion: 1.0.0 - required: true - description: The name and version of a Configuration Entity to be handled by the HTTP Control Loop Element - restSequence: - type: list - entry_schema: - type: org.onap.datatypes.policy.clamp.controlloop.httpControlLoopElement.RestRequest - typeVersion: 1.0.0 - description: A sequence of REST commands to send to the REST endpoint -policy_types: - onap.policies.Monitoring: - derived_from: tosca.policies.Root - description: a base policy type for all policies that govern monitoring provisioning - version: 1.0.0 - name: onap.policies.Monitoring - onap.policies.Sirisha: - derived_from: tosca.policies.Root - description: a base policy type for all policies that govern monitoring provisioning - version: 1.0.0 - name: onap.policies.Sirisha - onap.policies.monitoring.dcae-pm-subscription-handler: - properties: - pmsh_policy: - name: pmsh_policy - type: onap.datatypes.monitoring.subscription - typeVersion: 0.0.0 - description: PMSH Policy JSON - required: false - constraints: [] - metadata: {} - name: onap.policies.monitoring.dcae-pm-subscription-handler - version: 1.0.0 - derived_from: onap.policies.Monitoring - metadata: {} - onap.policies.controlloop.operational.Common: - derived_from: tosca.policies.Root - version: 1.0.0 - name: onap.policies.controlloop.operational.Common - description: | - Operational Policy for Control Loop execution. Originated in Frankfurt to support TOSCA Compliant - Policy Types. This does NOT support the legacy Policy YAML policy type. - properties: - id: - type: string - description: The unique control loop id. - required: true - timeout: - type: integer - description: | - Overall timeout for executing all the operations. This timeout should equal or exceed the total - timeout for each operation listed. - required: true - abatement: - type: boolean - description: Whether an abatement event message will be expected for the control loop from DCAE. - required: true - default: false - trigger: - type: string - description: Initial operation to execute upon receiving an Onset event message for the Control Loop. - required: true - operations: - type: list - description: List of operations to be performed when Control Loop is triggered. - required: true - entry_schema: - type: onap.datatype.controlloop.Operation - onap.policies.controlloop.operational.common.Apex: - derived_from: onap.policies.controlloop.operational.Common - type_version: 1.0.0 - version: 1.0.0 - name: onap.policies.controlloop.operational.common.Apex - description: Operational policies for Apex PDP - properties: - engineServiceParameters: - type: string - description: The engine parameters like name, instanceCount, policy implementation, parameters etc. - required: true - eventInputParameters: - type: string - description: The event input parameters. - required: true - eventOutputParameters: - type: string - description: The event output parameters. - required: true - javaProperties: - type: string - description: Name/value pairs of properties to be set for APEX if needed. - required: false -node_types: - org.onap.policy.clamp.controlloop.Participant: - version: 1.0.1 - derived_from: tosca.nodetypes.Root - properties: - provider: - type: string - requred: false - org.onap.policy.clamp.controlloop.ControlLoopElement: - version: 1.0.1 - derived_from: tosca.nodetypes.Root - properties: - provider: - type: string - required: false - metadata: - common: true - description: Specifies the organization that provides the control loop element - participant_id: - type: onap.datatypes.ToscaConceptIdentifier - requred: true - metadata: - common: true - participantType: - type: onap.datatypes.ToscaConceptIdentifier - required: true - metadata: - common: true - description: The identity of the participant type that hosts this type of Control Loop Element - startPhase: - type: integer - required: false - constraints: - - greater_or_equal: 0 - metadata: - common: true - description: A value indicating the start phase in which this control loop element will be started, the - first start phase is zero. Control Loop Elements are started in their start_phase order and stopped - in reverse start phase order. Control Loop Elements with the same start phase are started and - stopped simultaneously - uninitializedToPassiveTimeout: - type: integer - required: false - constraints: - - greater_or_equal: 0 - default: 60 - metadata: - common: true - description: The maximum time in seconds to wait for a state chage from uninitialized to passive - passiveToRunningTimeout: - type: integer - required: false - constraints: - - greater_or_equal: 0 - default: 60 - metadata: - common: true - description: The maximum time in seconds to wait for a state chage from passive to running - runningToPassiveTimeout: - type: integer - required: false - constraints: - - greater_or_equal: 0 - default: 60 - metadata: - common: true - description: The maximum time in seconds to wait for a state chage from running to passive - passiveToUninitializedTimeout: - type: integer - required: false - constraints: - - greater_or_equal: 0 - default: 60 - metadata: - common: true - description: The maximum time in seconds to wait for a state chage from passive to uninitialized - org.onap.policy.clamp.controlloop.ControlLoop: - version: 1.0.1 - derived_from: tosca.nodetypes.Root - properties: - provider: - type: string - required: false - metadata: - common: true - description: Specifies the organization that provides the control loop element - elements: - type: list - required: true - metadata: - common: true - entry_schema: - type: onap.datatypes.ToscaConceptIdentifier - description: Specifies a list of control loop element definitions that make up this control loop definition - org.onap.policy.clamp.controlloop.PolicyControlLoopElement: - version: 1.0.1 - derived_from: org.onap.policy.clamp.controlloop.ControlLoopElement - properties: - policy_type_id: - type: onap.datatypes.ToscaConceptIdentifier - requred: true - policy_id: - type: onap.datatypes.ToscaConceptIdentifier - requred: false - org.onap.policy.clamp.controlloop.CDSControlLoopElement: - version: 1.0.1 - derived_from: org.onap.policy.clamp.controlloop.ControlLoopElement - properties: - cds_blueprint_id: - type: onap.datatypes.ToscaConceptIdentifier - requred: true - org.onap.policy.clamp.controlloop.K8SMicroserviceControlLoopElement: - version: 1.0.1 - derived_from: org.onap.policy.clamp.controlloop.ControlLoopElement - properties: - chart: - type: string - required: true - configs: - type: list - required: false - requirements: - type: string - requred: false - templates: - type: list - required: false - entry_schema: - values: - type: string - requred: true - org.onap.policy.clamp.controlloop.HttpControlLoopElement: - version: 1.0.1 - derived_from: org.onap.policy.clamp.controlloop.ControlLoopElement - properties: - baseUrl: - type: string - required: true - description: The base URL to be prepended to each path, identifies the host for the REST endpoints. - httpHeaders: - type: map - required: false - entry_schema: - type: string - description: HTTP headers to send on REST requests - configurationEntities: - type: map - required: true - entry_schema: - type: org.onap.datatypes.policy.clamp.controlloop.httpControlLoopElement.ConfigurationEntity - typeVersion: 1.0.0 - description: The connfiguration entities the Control Loop Element is managing and their associated REST requests - -topology_template: - inputs: - pmsh_monitoring_policy: - type: onap.datatypes.ToscaConceptIdentifier - description: The ID of the PMSH monitoring policy to use - default: - name: MICROSERVICE_vLoadBalancerMS_v1_0_dcae-pm-subscription-handler_1_0_0test - version: 1.0.0 - pmsh_operational_policy: - type: onap.datatypes.ToscaConceptIdentifier - description: The ID of the PMSH operational policy to use - default: - name: operational.apex.pmcontrol - version: 1.0.0 - node_templates: - org.onap.policy.controlloop.PolicyControlLoopParticipant: - version: 2.3.1 - type: org.onap.policy.clamp.controlloop.Participant - type_version: 1.0.1 - description: Participant for DCAE microservices - properties: - provider: ONAP - org.onap.domain.pmsh.PMSH_MonitoringPolicyControlLoopElement: - version: 1.2.3 - type: org.onap.policy.clamp.controlloop.PolicyControlLoopElement - type_version: 1.0.0 - description: Control loop element for the monitoring policy for Performance Management Subscription Handling - properties: - provider: Ericsson - participant_id: - name: org.onap.PM_Policy - version: 1.0.0 - participantType: - name: org.onap.policy.controlloop.PolicyControlLoopParticipant - version: 2.3.1 - policy_type_id: - name: onap.policies.monitoring.pm-subscription-handler - version: 1.0.0 - policy_id: - get_input: pmsh_monitoring_policy - org.onap.domain.pmsh.PMSH_OperationalPolicyControlLoopElement: - version: 1.2.3 - type: org.onap.policy.clamp.controlloop.PolicyControlLoopElement - type_version: 1.0.0 - description: Control loop element for the operational policy for Performance Management Subscription Handling - properties: - provider: Ericsson - participant_id: - name: org.onap.PM_Policy - version: 1.0.0 - participantType: - name: org.onap.policy.controlloop.PolicyControlLoopParticipant - version: 2.3.1 - policy_type_id: - name: onap.policies.operational.pm-subscription-handler - version: 1.0.0 - policy_id: - get_input: pmsh_operational_policy - org.onap.k8s.controlloop.K8SControlLoopParticipant: - version: 2.3.4 - type: org.onap.policy.clamp.controlloop.Participant - type_version: 1.0.1 - description: Participant for K8S - properties: - provider: ONAP - org.onap.domain.database.PMSH_K8SMicroserviceControlLoopElement: - # Chart from new repository - version: 1.2.3 - type: org.onap.policy.clamp.controlloop.K8SMicroserviceControlLoopElement - type_version: 1.0.0 - description: Control loop element for the K8S microservice for PMSH - properties: - provider: ONAP - participant_id: - name: K8sParticipant0 - version: 1.0.0 - participantType: - name: org.onap.k8s.controlloop.K8SControlLoopParticipant - version: 2.3.4 - chart: - chartId: - name: dcae-pmsh - version: 8.0.0 - namespace: onap - releaseName: pmshms - repository: - repoName: chartmuseum - protocol: http - address: 10.152.183.120 - port: 80 - userName: onapinitializer - password: demo123456! - overrideParams: - global.masterPassword: test - - org.onap.domain.database.Local_K8SMicroserviceControlLoopElement: - # Chart installation without passing repository info - version: 1.2.3 - type: org.onap.policy.clamp.controlloop.K8SMicroserviceControlLoopElement - type_version: 1.0.0 - description: Control loop element for the K8S microservice for local chart - properties: - provider: ONAP - participant_id: - name: K8sParticipant0 - version: 1.0.0 - participantType: - name: org.onap.k8s.controlloop.K8SControlLoopParticipant - version: 2.3.4 - chart: - chartId: - name: nginx-ingress - version: 0.9.1 - releaseName: nginxms - namespace: test - org.onap.controlloop.HttpControlLoopParticipant: - version: 2.3.4 - type: org.onap.policy.clamp.controlloop.Participant - type_version: 1.0.1 - description: Participant for Http requests - properties: - provider: ONAP - org.onap.domain.database.Http_PMSHMicroserviceControlLoopElement: - # Consul http config for PMSH. - version: 1.2.3 - type: org.onap.policy.clamp.controlloop.HttpControlLoopElement - type_version: 1.0.1 - description: Control loop element for the http requests of PMSH microservice - properties: - provider: ONAP - participant_id: - name: HttpParticipant0 - version: 1.0.0 - participantType: - name: org.onap.k8s.controlloop.HttpControlLoopParticipant - version: 2.3.4 - uninitializedToPassiveTimeout: 180 - startPhase: 1 - baseUrl: http://10.152.183.51:8500 - httpHeaders: - Content-Type: application/json - configurationEntities: - - configurationEntityId: - name: entity1 - version: 1.0.1 - restSequence: - - restRequestId: - name: request1 - version: 1.0.1 - httpMethod: PUT - path: v1/kv/dcae-pmsh2 - body: '{ - "control_loop_name":"pmsh-control-loop", - "operational_policy_name":"pmsh-operational-policy", - "aaf_password":"demo123456!", - "aaf_identity":"dcae@dcae.onap.org", - "cert_path":"/opt/app/pmsh/etc/certs/cert.pem", - "key_path":"/opt/app/pmsh/etc/certs/key.pem", - "ca_cert_path":"/opt/app/pmsh/etc/certs/cacert.pem", - "enable_tls":"true", - "pmsh_policy":{ - "subscription":{ - "subscriptionName":"ExtraPM-All-gNB-R2B", - "administrativeState":"UNLOCKED", - "fileBasedGP":15, - "fileLocation":"\/pm\/pm.xml", - "nfFilter":{ - "nfNames":[ - "^pnf.*", - "^vnf.*" - ], - "modelInvariantIDs":[ - ], - "modelVersionIDs":[ - ], - "modelNames":[ - ] - }, - "measurementGroups":[ - { - "measurementGroup":{ - "measurementTypes":[ - { - "measurementType":"countera" - }, - { - "measurementType":"counterb" - } - ], - "managedObjectDNsBasic":[ - { - "DN":"dna" - }, - { - "DN":"dnb" - } - ] - } - }, - { - "measurementGroup":{ - "measurementTypes":[ - { - "measurementType":"counterc" - }, - { - "measurementType":"counterd" - } - ], - "managedObjectDNsBasic":[ - { - "DN":"dnc" - }, - { - "DN":"dnd" - } - ] - } - } - ] - } - }, - "streams_subscribes":{ - "aai_subscriber":{ - "type":"message_router", - "dmaap_info":{ - "topic_url":"https://10.152.183.151:3905/events/AAI_EVENT", - "client_role":"org.onap.dcae.aaiSub", - "location":"san-francisco", - "client_id":"1575976809466" - } - }, - "policy_pm_subscriber":{ - "type":"message_router", - "dmaap_info":{ - "topic_url":"https://10.152.183.151:3905/events/org.onap.dmaap.mr.PM_SUBSCRIPTIONS", - "client_role":"org.onap.dcae.pmSubscriber", - "location":"san-francisco", - "client_id":"1575876809456" - } - } - }, - "streams_publishes":{ - "policy_pm_publisher":{ - "type":"message_router", - "dmaap_info":{ - "topic_url":"https://10.152.183.151:3905/events/org.onap.dmaap.mr.PM_SUBSCRIPTIONS", - "client_role":"org.onap.dcae.pmPublisher", - "location":"san-francisco", - "client_id":"1475976809466" - } - }, - "other_publisher":{ - "type":"message_router", - "dmaap_info":{ - "topic_url":"https://10.152.183.151:3905/events/org.onap.dmaap.mr.SOME_OTHER_TOPIC", - "client_role":"org.onap.dcae.pmControlPub", - "location":"san-francisco", - "client_id":"1875976809466" - } - } - } - }' - expectedResponse: 200 - org.onap.domain.sample.GenericK8s_ControlLoopDefinition: - version: 1.2.3 - type: org.onap.policy.clamp.controlloop.ControlLoop - type_version: 1.0.0 - description: Control loop for Hello World - properties: - provider: ONAP - elements: - - name: org.onap.domain.database.PMSH_K8SMicroserviceControlLoopElement - version: 1.2.3 - - name: org.onap.domain.database.Local_K8SMicroserviceControlLoopElement - version: 1.2.3 - - name: org.onap.domain.database.Http_PMSHMicroserviceControlLoopElement - version: 1.2.3 - - name: org.onap.domain.pmsh.PMSH_MonitoringPolicyControlLoopElement - version: 1.2.3 - - name: org.onap.domain.pmsh.PMSH_OperationalPolicyControlLoopElement - version: 1.2.3 - policies: - - operational.apex.pmcontrol: - type: onap.policies.controlloop.operational.common.Apex - type_version: 1.0.0 - version: 1.0.0 - metadata: - policy-id: operational.apex.pmcontrol - policy-version: 1 - properties: - engineServiceParameters: - name: MyApexEngine - version: 0.0.1 - id: 45 - instanceCount: 2 - deploymentPort: 12561 - policy_type_impl: - apexPolicyModel: - key: - name: PMControlPolicy - version: 0.0.1 - keyInformation: - key: - name: PMControlPolicy_KeyInfo - version: 0.0.1 - keyInfoMap: - entry: - - key: - name: CDSActionIdentifiersType - version: 0.0.1 - value: - key: - name: CDSActionIdentifiersType - version: 0.0.1 - UUID: 6e5fa19b-14df-37e3-a4ae-8c537e861a82 - description: Generated description for concept referred to by key "CDSActionIdentifiersType:0.0.1" - - key: - name: CDSCreateResponseEvent - version: 0.0.1 - value: - key: - name: CDSCreateResponseEvent - version: 0.0.1 - UUID: 14b29e38-ac75-3273-aa4e-8583c0aa7dad - description: Generated description for concept referred to by key "CDSCreateResponseEvent:0.0.1" - - key: - name: CDSCreateResponsePayloadType - version: 0.0.1 - value: - key: - name: CDSCreateResponsePayloadType - version: 0.0.1 - UUID: 04573f8f-e772-30a5-b1d9-d7318d4a1e13 - description: Generated description for concept referred to by key "CDSCreateResponsePayloadType:0.0.1" - - key: - name: CDSCreateResponsePolicy - version: 0.0.1 - value: - key: - name: CDSCreateResponsePolicy - version: 0.0.1 - UUID: e126c965-fc09-3bfe-8f55-70f380a4a49c - description: Generated description for concept referred to by key "CDSCreateResponsePolicy:0.0.1" - - key: - name: CDSCreateResponseTask - version: 0.0.1 - value: - key: - name: CDSCreateResponseTask - version: 0.0.1 - UUID: 6165ee82-afd2-3aab-a517-f00b3f2461d2 - description: Generated description for concept referred to by key "CDSCreateResponseTask:0.0.1" - - key: - name: CDSCreateSubscriptionPayloadType - version: 0.0.1 - value: - key: - name: CDSCreateSubscriptionPayloadType - version: 0.0.1 - UUID: 8350ac5e-c157-38b9-9614-a0f93a830e60 - description: Generated description for concept referred to by key "CDSCreateSubscriptionPayloadType:0.0.1" - - key: - name: CDSCreateSubscriptionRequestEvent - version: 0.0.1 - value: - key: - name: CDSCreateSubscriptionRequestEvent - version: 0.0.1 - UUID: cfa325ba-226b-3a31-9183-ec43e2b6e9a2 - description: Generated description for concept referred to by key "CDSCreateSubscriptionRequestEvent:0.0.1" - - key: - name: CDSDeleteResponseEvent - version: 0.0.1 - value: - key: - name: CDSDeleteResponseEvent - version: 0.0.1 - UUID: 8be9c0fa-7437-3841-aff2-b3cec6ae3bd8 - description: Generated description for concept referred to by key "CDSDeleteResponseEvent:0.0.1" - - key: - name: CDSDeleteResponsePayloadType - version: 0.0.1 - value: - key: - name: CDSDeleteResponsePayloadType - version: 0.0.1 - UUID: 3fbfe0c9-152e-34d3-a504-09cd13c058d0 - description: Generated description for concept referred to by key "CDSDeleteResponsePayloadType:0.0.1" - - key: - name: CDSDeleteResponsePolicy - version: 0.0.1 - value: - key: - name: CDSDeleteResponsePolicy - version: 0.0.1 - UUID: a780251c-edd5-3132-b865-04313246b43c - description: Generated description for concept referred to by key "CDSDeleteResponsePolicy:0.0.1" - - key: - name: CDSDeleteResponseTask - version: 0.0.1 - value: - key: - name: CDSDeleteResponseTask - version: 0.0.1 - UUID: afce4555-3aa3-3521-a7d8-ee8cdf0d3efc - description: Generated description for concept referred to by key "CDSDeleteResponseTask:0.0.1" - - key: - name: CDSDeleteSubscriptionPayloadType - version: 0.0.1 - value: - key: - name: CDSDeleteSubscriptionPayloadType - version: 0.0.1 - UUID: 12658406-9147-3c9d-a38c-5ad5e30b092b - description: Generated description for concept referred to by key "CDSDeleteSubscriptionPayloadType:0.0.1" - - key: - name: CDSDeleteSubscriptionRequestEvent - version: 0.0.1 - value: - key: - name: CDSDeleteSubscriptionRequestEvent - version: 0.0.1 - UUID: 24380c95-9289-36e6-8cbf-0edefa15ccd9 - description: Generated description for concept referred to by key "CDSDeleteSubscriptionRequestEvent:0.0.1" - - key: - name: CDSRequestCommonHeaderType - version: 0.0.1 - value: - key: - name: CDSRequestCommonHeaderType - version: 0.0.1 - UUID: 35590ac0-062c-39f1-8786-b4ff716e30b1 - description: Generated description for concept referred to by key "CDSRequestCommonHeaderType:0.0.1" - - key: - name: CDSResponseCommonHeaderType - version: 0.0.1 - value: - key: - name: CDSResponseCommonHeaderType - version: 0.0.1 - UUID: dd7e1805-885a-350b-aaf9-ed541321ae3c - description: Generated description for concept referred to by key "CDSResponseCommonHeaderType:0.0.1" - - key: - name: CDSResponseStatusEvent - version: 0.0.1 - value: - key: - name: CDSResponseStatusEvent - version: 0.0.1 - UUID: 7986e21b-32f7-302e-9554-31f21b673493 - description: Generated description for concept referred to by key "CDSResponseStatusEvent:0.0.1" - - key: - name: CDSResponseStatusType - version: 0.0.1 - value: - key: - name: CDSResponseStatusType - version: 0.0.1 - UUID: 92b8a2cf-344e-3ce1-8cc0-2b7d3cb695fa - description: Generated description for concept referred to by key "CDSResponseStatusType:0.0.1" - - key: - name: CreateSubscriptionPayloadEvent - version: 0.0.1 - value: - key: - name: CreateSubscriptionPayloadEvent - version: 0.0.1 - UUID: 92162397-1a8e-3a3f-a469-d2af7700af4a - description: Generated description for concept referred to by key "CreateSubscriptionPayloadEvent:0.0.1" - - key: - name: CreateSubscriptionPayloadTask - version: 0.0.1 - value: - key: - name: CreateSubscriptionPayloadTask - version: 0.0.1 - UUID: bc0c69f0-52ed-38ea-b468-ae4a6fd1730d - description: Generated description for concept referred to by key "CreateSubscriptionPayloadTask:0.0.1" - - key: - name: CreateSubscriptionRequestTask - version: 0.0.1 - value: - key: - name: CreateSubscriptionRequestTask - version: 0.0.1 - UUID: 89cb75e9-f06c-30d3-b4ff-698d45f63869 - description: Generated description for concept referred to by key "CreateSubscriptionRequestTask:0.0.1" - - key: - name: DeleteSubscriptionPayloadEvent - version: 0.0.1 - value: - key: - name: DeleteSubscriptionPayloadEvent - version: 0.0.1 - UUID: 994fa441-04ab-33bb-832d-1cd12ab5d074 - description: Generated description for concept referred to by key "DeleteSubscriptionPayloadEvent:0.0.1" - - key: - name: DeleteSubscriptionPayloadTask - version: 0.0.1 - value: - key: - name: DeleteSubscriptionPayloadTask - version: 0.0.1 - UUID: 0f519117-5fea-3e4b-941f-8f778100465f - description: Generated description for concept referred to by key "DeleteSubscriptionPayloadTask:0.0.1" - - key: - name: DeleteSubscriptionRequestTask - version: 0.0.1 - value: - key: - name: DeleteSubscriptionRequestTask - version: 0.0.1 - UUID: acb772fe-d442-39e3-98f9-b1080caf4150 - description: Generated description for concept referred to by key "DeleteSubscriptionRequestTask:0.0.1" - - key: - name: MRResponseEvent - version: 0.0.1 - value: - key: - name: MRResponseEvent - version: 0.0.1 - UUID: 13c747a3-6bae-3bcf-9c80-b152e01dc194 - description: Generated description for concept referred to by key "MRResponseEvent:0.0.1" - - key: - name: PMControlPolicy - version: 0.0.1 - value: - key: - name: PMControlPolicy - version: 0.0.1 - UUID: acf1e55c-7bc5-3bd5-975a-0ca54afcd8a4 - description: Generated description for concept referred to by key "PMControlPolicy:0.0.1" - - key: - name: PMControlPolicy_Albums - version: 0.0.1 - value: - key: - name: PMControlPolicy_Albums - version: 0.0.1 - UUID: b38ad204-c2c8-32f4-9b5a-dda0aeb0145b - description: Generated description for concept referred to by key "PMControlPolicy_Albums:0.0.1" - - key: - name: PMControlPolicy_Events - version: 0.0.1 - value: - key: - name: PMControlPolicy_Events - version: 0.0.1 - UUID: be3871a0-c42a-3113-a066-82d192840eca - description: Generated description for concept referred to by key "PMControlPolicy_Events:0.0.1" - - key: - name: PMControlPolicy_KeyInfo - version: 0.0.1 - value: - key: - name: PMControlPolicy_KeyInfo - version: 0.0.1 - UUID: ced37634-28a4-3178-b7f6-2980794927b0 - description: Generated description for concept referred to by key "PMControlPolicy_KeyInfo:0.0.1" - - key: - name: PMControlPolicy_Policies - version: 0.0.1 - value: - key: - name: PMControlPolicy_Policies - version: 0.0.1 - UUID: be3d180d-ef9c-3a75-8e9c-84271a038bed - description: Generated description for concept referred to by key "PMControlPolicy_Policies:0.0.1" - - key: - name: PMControlPolicy_Schemas - version: 0.0.1 - value: - key: - name: PMControlPolicy_Schemas - version: 0.0.1 - UUID: e61973f1-189c-39e5-82f6-0d3afe298a20 - description: Generated description for concept referred to by key "PMControlPolicy_Schemas:0.0.1" - - key: - name: PMControlPolicy_Tasks - version: 0.0.1 - value: - key: - name: PMControlPolicy_Tasks - version: 0.0.1 - UUID: 5658adb3-2962-30a3-a241-fae75bb8eb4a - description: Generated description for concept referred to by key "PMControlPolicy_Tasks:0.0.1" - - key: - name: PMSubscriptionAlbum - version: 0.0.1 - value: - key: - name: PMSubscriptionAlbum - version: 0.0.1 - UUID: c2bd6f0d-6854-317a-9be2-97c08338428c - description: Generated description for concept referred to by key "PMSubscriptionAlbum:0.0.1" - - key: - name: PMSubscriptionOutputEvent - version: 0.0.1 - value: - key: - name: PMSubscriptionOutputEvent - version: 0.0.1 - UUID: 992b7819-9f69-3aa0-bb0f-6e45ea15ce05 - description: Generated description for concept referred to by key "PMSubscriptionOutputEvent:0.0.1" - - key: - name: PMSubscriptionType - version: 0.0.1 - value: - key: - name: PMSubscriptionType - version: 0.0.1 - UUID: 73c1c397-4fc3-357f-93b6-a8ad707fbaae - description: Generated description for concept referred to by key "PMSubscriptionType:0.0.1" - - key: - name: ReceiveEventPolicy - version: 0.0.1 - value: - key: - name: ReceiveEventPolicy - version: 0.0.1 - UUID: 568b7345-9de1-36d3-b6a3-9b857e6809a1 - description: Generated description for concept referred to by key "ReceiveEventPolicy:0.0.1" - - key: - name: ReceiveSubscriptionTask - version: 0.0.1 - value: - key: - name: ReceiveSubscriptionTask - version: 0.0.1 - UUID: f596afc8-100c-35eb-92c8-352355ea457d - description: Generated description for concept referred to by key "ReceiveSubscriptionTask:0.0.1" - - key: - name: SimpleIntType - version: 0.0.1 - value: - key: - name: SimpleIntType - version: 0.0.1 - UUID: 153791fd-ae0a-36a7-88a5-309a7936415d - description: Generated description for concept referred to by key "SimpleIntType:0.0.1" - - key: - name: SimpleStringType - version: 0.0.1 - value: - key: - name: SimpleStringType - version: 0.0.1 - UUID: 8a4957cf-9493-3a76-8c22-a208e23259af - description: Generated description for concept referred to by key "SimpleStringType:0.0.1" - - key: - name: SubscriptionStatusType - version: 0.0.1 - value: - key: - name: SubscriptionStatusType - version: 0.0.1 - UUID: 597643b1-9db1-31ce-85d0-e1c63c43b30b - description: Generated description for concept referred to by key "SubscriptionStatusType:0.0.1" - - key: - name: SubscriptionType - version: 0.0.1 - value: - key: - name: SubscriptionType - version: 0.0.1 - UUID: 184547bb-7d64-3cb2-a273-d7185102c5ce - description: Generated description for concept referred to by key "SubscriptionType:0.0.1" - - key: - name: UUIDType - version: 0.0.1 - value: - key: - name: UUIDType - version: 0.0.1 - UUID: 6a8cc68e-dfc8-3403-9c6d-071c886b319c - description: Generated description for concept referred to by key "UUIDType:0.0.1" - - key: - name: pmsh-operational-policy - version: 0.0.1 - value: - key: - name: pmsh-operational-policy - version: 0.0.1 - UUID: fdf2c9ff-6422-3ea6-b6b6-49b12116265d - description: Generated description for concept referred to by key "pmsh-operational-policy:0.0.1" - policies: - key: - name: PMControlPolicy_Policies - version: 0.0.1 - policyMap: - entry: - - key: - name: CDSCreateResponsePolicy - version: 0.0.1 - value: - policyKey: - name: CDSCreateResponsePolicy - version: 0.0.1 - template: Freestyle - state: - entry: - - key: CDSCreateResponseState - value: - stateKey: - parentKeyName: CDSCreateResponsePolicy - parentKeyVersion: 0.0.1 - parentLocalName: 'NULL' - localName: CDSCreateResponseState - trigger: - name: CDSCreateResponseEvent - version: 0.0.1 - stateOutputs: - entry: - - key: ResponseOutput - value: - key: - parentKeyName: CDSCreateResponsePolicy - parentKeyVersion: 0.0.1 - parentLocalName: CDSCreateResponseState - localName: ResponseOutput - outgoingEvent: - name: CDSResponseStatusEvent - version: 0.0.1 - nextState: - parentKeyName: 'NULL' - parentKeyVersion: 0.0.0 - parentLocalName: 'NULL' - localName: 'NULL' - contextAlbumReference: [ ] - taskSelectionLogic: - key: 'NULL' - logicFlavour: UNDEFINED - logic: '' - stateFinalizerLogicMap: - entry: [ ] - defaultTask: - name: CDSCreateResponseTask - version: 0.0.1 - taskReferences: - entry: - - key: - name: CDSCreateResponseTask - version: 0.0.1 - value: - key: - parentKeyName: CDSCreateResponsePolicy - parentKeyVersion: 0.0.1 - parentLocalName: CDSCreateResponseState - localName: CDSCreateResponsePolicy - outputType: DIRECT - output: - parentKeyName: CDSCreateResponsePolicy - parentKeyVersion: 0.0.1 - parentLocalName: CDSCreateResponseState - localName: ResponseOutput - firstState: CDSCreateResponseState - - key: - name: CDSDeleteResponsePolicy - version: 0.0.1 - value: - policyKey: - name: CDSDeleteResponsePolicy - version: 0.0.1 - template: Freestyle - state: - entry: - - key: CDSDeleteResponseState - value: - stateKey: - parentKeyName: CDSDeleteResponsePolicy - parentKeyVersion: 0.0.1 - parentLocalName: 'NULL' - localName: CDSDeleteResponseState - trigger: - name: CDSDeleteResponseEvent - version: 0.0.1 - stateOutputs: - entry: - - key: ResponseOutput - value: - key: - parentKeyName: CDSDeleteResponsePolicy - parentKeyVersion: 0.0.1 - parentLocalName: CDSDeleteResponseState - localName: ResponseOutput - outgoingEvent: - name: CDSResponseStatusEvent - version: 0.0.1 - nextState: - parentKeyName: 'NULL' - parentKeyVersion: 0.0.0 - parentLocalName: 'NULL' - localName: 'NULL' - contextAlbumReference: [ ] - taskSelectionLogic: - key: 'NULL' - logicFlavour: UNDEFINED - logic: '' - stateFinalizerLogicMap: - entry: [ ] - defaultTask: - name: CDSDeleteResponseTask - version: 0.0.1 - taskReferences: - entry: - - key: - name: CDSDeleteResponseTask - version: 0.0.1 - value: - key: - parentKeyName: CDSDeleteResponsePolicy - parentKeyVersion: 0.0.1 - parentLocalName: CDSDeleteResponseState - localName: CDSDeleteResponsePolicy - outputType: DIRECT - output: - parentKeyName: CDSDeleteResponsePolicy - parentKeyVersion: 0.0.1 - parentLocalName: CDSDeleteResponseState - localName: ResponseOutput - firstState: CDSDeleteResponseState - - key: - name: ReceiveEventPolicy - version: 0.0.1 - value: - policyKey: - name: ReceiveEventPolicy - version: 0.0.1 - template: Freestyle - state: - entry: - - key: CreateOrDeleteState - value: - stateKey: - parentKeyName: ReceiveEventPolicy - parentKeyVersion: 0.0.1 - parentLocalName: 'NULL' - localName: CreateOrDeleteState - trigger: - name: PMSubscriptionOutputEvent - version: 0.0.1 - stateOutputs: - entry: - - key: CreateSubscriptionPayload - value: - key: - parentKeyName: ReceiveEventPolicy - parentKeyVersion: 0.0.1 - parentLocalName: CreateOrDeleteState - localName: CreateSubscriptionPayload - outgoingEvent: - name: CreateSubscriptionPayloadEvent - version: 0.0.1 - nextState: - parentKeyName: ReceiveEventPolicy - parentKeyVersion: 0.0.1 - parentLocalName: 'NULL' - localName: CreateSubscription - - key: DeleteSubscriptionPayload - value: - key: - parentKeyName: ReceiveEventPolicy - parentKeyVersion: 0.0.1 - parentLocalName: CreateOrDeleteState - localName: DeleteSubscriptionPayload - outgoingEvent: - name: DeleteSubscriptionPayloadEvent - version: 0.0.1 - nextState: - parentKeyName: ReceiveEventPolicy - parentKeyVersion: 0.0.1 - parentLocalName: 'NULL' - localName: DeleteSubscription - contextAlbumReference: - - name: PMSubscriptionAlbum - version: 0.0.1 - taskSelectionLogic: - key: TaskSelectionLogic - logicFlavour: JAVASCRIPT - logic: |- - /* - * ============LICENSE_START======================================================= - * Copyright (C) 2020 Nordix. 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); - - var pmSubscriptionInfo = executor.getContextAlbum("PMSubscriptionAlbum").get(executor.inFields.get("albumID").toString()) - var changeType = pmSubscriptionInfo.get("changeType").toString() - - executor.logger.info("Change Type is " + changeType) - - if ("CREATE".equals(changeType)) { - executor.logger.info("Choosing to create a subscription") - executor.subject.getTaskKey("CreateSubscriptionPayloadTask").copyTo(executor.selectedTask); - } - else if ("DELETE".equals(changeType)) { - executor.logger.info("Choosing to delete a subscription") - executor.subject.getTaskKey("DeleteSubscriptionPayloadTask").copyTo(executor.selectedTask); - } - - //var returnValue = executor.isTrue; - true; - stateFinalizerLogicMap: - entry: [ ] - defaultTask: - name: CreateSubscriptionPayloadTask - version: 0.0.1 - taskReferences: - entry: - - key: - name: CreateSubscriptionPayloadTask - version: 0.0.1 - value: - key: - parentKeyName: ReceiveEventPolicy - parentKeyVersion: 0.0.1 - parentLocalName: CreateOrDeleteState - localName: ReceiveEventPolicy - outputType: DIRECT - output: - parentKeyName: ReceiveEventPolicy - parentKeyVersion: 0.0.1 - parentLocalName: CreateOrDeleteState - localName: CreateSubscriptionPayload - - key: - name: DeleteSubscriptionPayloadTask - version: 0.0.1 - value: - key: - parentKeyName: ReceiveEventPolicy - parentKeyVersion: 0.0.1 - parentLocalName: CreateOrDeleteState - localName: ReceiveEventPolicy - outputType: DIRECT - output: - parentKeyName: ReceiveEventPolicy - parentKeyVersion: 0.0.1 - parentLocalName: CreateOrDeleteState - localName: DeleteSubscriptionPayload - - key: CreateSubscription - value: - stateKey: - parentKeyName: ReceiveEventPolicy - parentKeyVersion: 0.0.1 - parentLocalName: 'NULL' - localName: CreateSubscription - trigger: - name: CreateSubscriptionPayloadEvent - version: 0.0.1 - stateOutputs: - entry: - - key: IssueCreateSubscriptionRequestOutput - value: - key: - parentKeyName: ReceiveEventPolicy - parentKeyVersion: 0.0.1 - parentLocalName: CreateSubscription - localName: IssueCreateSubscriptionRequestOutput - outgoingEvent: - name: CDSCreateSubscriptionRequestEvent - version: 0.0.1 - nextState: - parentKeyName: 'NULL' - parentKeyVersion: 0.0.0 - parentLocalName: 'NULL' - localName: 'NULL' - contextAlbumReference: - - name: PMSubscriptionAlbum - version: 0.0.1 - taskSelectionLogic: - key: 'NULL' - logicFlavour: UNDEFINED - logic: '' - stateFinalizerLogicMap: - entry: [ ] - defaultTask: - name: CreateSubscriptionRequestTask - version: 0.0.1 - taskReferences: - entry: - - key: - name: CreateSubscriptionRequestTask - version: 0.0.1 - value: - key: - parentKeyName: ReceiveEventPolicy - parentKeyVersion: 0.0.1 - parentLocalName: CreateSubscription - localName: ReceiveEventPolicy - outputType: DIRECT - output: - parentKeyName: ReceiveEventPolicy - parentKeyVersion: 0.0.1 - parentLocalName: CreateSubscription - localName: IssueCreateSubscriptionRequestOutput - - key: DeleteSubscription - value: - stateKey: - parentKeyName: ReceiveEventPolicy - parentKeyVersion: 0.0.1 - parentLocalName: 'NULL' - localName: DeleteSubscription - trigger: - name: DeleteSubscriptionPayloadEvent - version: 0.0.1 - stateOutputs: - entry: - - key: IssueDeleteSubscriptionRequestOutput - value: - key: - parentKeyName: ReceiveEventPolicy - parentKeyVersion: 0.0.1 - parentLocalName: DeleteSubscription - localName: IssueDeleteSubscriptionRequestOutput - outgoingEvent: - name: CDSDeleteSubscriptionRequestEvent - version: 0.0.1 - nextState: - parentKeyName: 'NULL' - parentKeyVersion: 0.0.0 - parentLocalName: 'NULL' - localName: 'NULL' - contextAlbumReference: - - name: PMSubscriptionAlbum - version: 0.0.1 - taskSelectionLogic: - key: 'NULL' - logicFlavour: UNDEFINED - logic: '' - stateFinalizerLogicMap: - entry: [ ] - defaultTask: - name: DeleteSubscriptionRequestTask - version: 0.0.1 - taskReferences: - entry: - - key: - name: DeleteSubscriptionRequestTask - version: 0.0.1 - value: - key: - parentKeyName: ReceiveEventPolicy - parentKeyVersion: 0.0.1 - parentLocalName: DeleteSubscription - localName: ReceiveEventPolicy - outputType: DIRECT - output: - parentKeyName: ReceiveEventPolicy - parentKeyVersion: 0.0.1 - parentLocalName: DeleteSubscription - localName: IssueDeleteSubscriptionRequestOutput - - key: ReceiveSubscriptionState - value: - stateKey: - parentKeyName: ReceiveEventPolicy - parentKeyVersion: 0.0.1 - parentLocalName: 'NULL' - localName: ReceiveSubscriptionState - trigger: - name: pmsh-operational-policy - version: 0.0.1 - stateOutputs: - entry: - - key: ReceivePMSubscriptionOutput - value: - key: - parentKeyName: ReceiveEventPolicy - parentKeyVersion: 0.0.1 - parentLocalName: ReceiveSubscriptionState - localName: ReceivePMSubscriptionOutput - outgoingEvent: - name: PMSubscriptionOutputEvent - version: 0.0.1 - nextState: - parentKeyName: ReceiveEventPolicy - parentKeyVersion: 0.0.1 - parentLocalName: 'NULL' - localName: CreateOrDeleteState - contextAlbumReference: - - name: PMSubscriptionAlbum - version: 0.0.1 - taskSelectionLogic: - key: 'NULL' - logicFlavour: UNDEFINED - logic: '' - stateFinalizerLogicMap: - entry: [ ] - defaultTask: - name: ReceiveSubscriptionTask - version: 0.0.1 - taskReferences: - entry: - - key: - name: ReceiveSubscriptionTask - version: 0.0.1 - value: - key: - parentKeyName: ReceiveEventPolicy - parentKeyVersion: 0.0.1 - parentLocalName: ReceiveSubscriptionState - localName: ReceiveEventPolicy - outputType: DIRECT - output: - parentKeyName: ReceiveEventPolicy - parentKeyVersion: 0.0.1 - parentLocalName: ReceiveSubscriptionState - localName: ReceivePMSubscriptionOutput - firstState: ReceiveSubscriptionState - tasks: - key: - name: PMControlPolicy_Tasks - version: 0.0.1 - taskMap: - entry: - - key: - name: CDSCreateResponseTask - version: 0.0.1 - value: - key: - name: CDSCreateResponseTask - version: 0.0.1 - inputFields: - entry: - - key: actionIdentifiers - value: - key: actionIdentifiers - fieldSchemaKey: - name: CDSActionIdentifiersType - version: 0.0.1 - optional: false - - key: commonHeader - value: - key: commonHeader - fieldSchemaKey: - name: CDSResponseCommonHeaderType - version: 0.0.1 - optional: false - - key: payload - value: - key: payload - fieldSchemaKey: - name: CDSCreateResponsePayloadType - version: 0.0.1 - optional: false - - key: status - value: - key: status - fieldSchemaKey: - name: CDSResponseStatusType - version: 0.0.1 - optional: false - outputFields: - entry: - - key: status - value: - key: status - fieldSchemaKey: - name: SubscriptionStatusType - version: 0.0.1 - optional: false - taskParameters: - entry: [ ] - contextAlbumReference: - - name: PMSubscriptionAlbum - version: 0.0.1 - taskLogic: - key: TaskLogic - logicFlavour: JAVASCRIPT - logic: |- - /* - * ============LICENSE_START======================================================= - * Copyright (C) 2020 Nordix. 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); - - var commonHeader = executor.inFields.get("commonHeader") - var response = executor.inFields.get("payload") - var albumID = commonHeader.get("requestId") - - var pmSubscriptionInfo = executor.getContextAlbum("PMSubscriptionAlbum").get(albumID.toString()); - var responseStatus = executor.subject.getOutFieldSchemaHelper("status").createNewInstance(); - - responseStatus.put("subscriptionName", pmSubscriptionInfo.get("subscription").get("subscriptionName")) - responseStatus.put("nfName", pmSubscriptionInfo.get("nfName")) - responseStatus.put("changeType", pmSubscriptionInfo.get("changeType")) - - var status = response.get(pmSubscriptionInfo.get("changeType").toLowerCase() + "_DasH_subscription_DasH_response").get("odl_DasH_response").get("status") - - executor.logger.info("RESPONSE STATUS = " + status) - - if(status == "success") { - responseStatus.put("message", "success") - } else { - responseStatus.put("message", "failed") - } - - executor.outFields.put("status", responseStatus) - - //var returnValue = executor.isTrue; - true; - - key: - name: CDSDeleteResponseTask - version: 0.0.1 - value: - key: - name: CDSDeleteResponseTask - version: 0.0.1 - inputFields: - entry: - - key: actionIdentifiers - value: - key: actionIdentifiers - fieldSchemaKey: - name: CDSActionIdentifiersType - version: 0.0.1 - optional: false - - key: commonHeader - value: - key: commonHeader - fieldSchemaKey: - name: CDSResponseCommonHeaderType - version: 0.0.1 - optional: false - - key: payload - value: - key: payload - fieldSchemaKey: - name: CDSDeleteResponsePayloadType - version: 0.0.1 - optional: false - - key: status - value: - key: status - fieldSchemaKey: - name: CDSResponseStatusType - version: 0.0.1 - optional: false - outputFields: - entry: - - key: status - value: - key: status - fieldSchemaKey: - name: SubscriptionStatusType - version: 0.0.1 - optional: false - taskParameters: - entry: [ ] - contextAlbumReference: - - name: PMSubscriptionAlbum - version: 0.0.1 - taskLogic: - key: TaskLogic - logicFlavour: JAVASCRIPT - logic: |- - /* - * ============LICENSE_START======================================================= - * Copyright (C) 2020 Nordix. 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); - - var commonHeader = executor.inFields.get("commonHeader") - var response = executor.inFields.get("payload") - var albumID = commonHeader.get("requestId") - - var pmSubscriptionInfo = executor.getContextAlbum("PMSubscriptionAlbum").get(albumID.toString()); - var responseStatus = executor.subject.getOutFieldSchemaHelper("status").createNewInstance(); - - responseStatus.put("subscriptionName", pmSubscriptionInfo.get("subscription").get("subscriptionName")) - responseStatus.put("nfName", pmSubscriptionInfo.get("nfName")) - responseStatus.put("changeType", pmSubscriptionInfo.get("changeType")) - - var status = response.get(pmSubscriptionInfo.get("changeType").toLowerCase() + "_DasH_subscription_DasH_response").get("odl_DasH_response").get("status") - - executor.logger.info("RESPONSE STATUS = " + status) - - if(status == "success") { - responseStatus.put("message", "success") - } else { - responseStatus.put("message", "failed") - } - - executor.outFields.put("status", responseStatus) - - //var returnValue = executor.isTrue; - true; - - key: - name: CreateSubscriptionPayloadTask - version: 0.0.1 - value: - key: - name: CreateSubscriptionPayloadTask - version: 0.0.1 - inputFields: - entry: - - key: albumID - value: - key: albumID - fieldSchemaKey: - name: UUIDType - version: 0.0.1 - optional: false - outputFields: - entry: - - key: albumID - value: - key: albumID - fieldSchemaKey: - name: UUIDType - version: 0.0.1 - optional: false - - key: payload - value: - key: payload - fieldSchemaKey: - name: CDSCreateSubscriptionPayloadType - version: 0.0.1 - optional: false - taskParameters: - entry: [ ] - contextAlbumReference: - - name: PMSubscriptionAlbum - version: 0.0.1 - taskLogic: - key: TaskLogic - logicFlavour: JAVASCRIPT - logic: |- - /* - * ============LICENSE_START======================================================= - * Copyright (C) 2020 Nordix. 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); - - var pmSubscriptionInfo = executor.getContextAlbum("PMSubscriptionAlbum").get(executor.inFields.get("albumID").toString()) - - var changeType = pmSubscriptionInfo.get("changeType").toLowerCase() - - var payloadProperties = executor.subject.getOutFieldSchemaHelper("payload").createNewSubInstance(changeType + "_DasH_subscription_DasH_properties_record"); - - payloadProperties.put("nfName", pmSubscriptionInfo.get("nfName")) - payloadProperties.put("subscriptionName", pmSubscriptionInfo.get("subscription").get("subscriptionName")) - payloadProperties.put("administrativeState", pmSubscriptionInfo.get("subscription").get("administrativeState")) - payloadProperties.put("fileBasedGP", pmSubscriptionInfo.get("subscription").get("fileBasedGP").toString()) - payloadProperties.put("fileLocation", pmSubscriptionInfo.get("subscription").get("fileLocation")) - payloadProperties.put("measurementGroups", pmSubscriptionInfo.get("subscription").get("measurementGroups")) - - var payloadEntry = executor.subject.getOutFieldSchemaHelper("payload").createNewSubInstance("CDSRequestPayloadEntry"); - payloadEntry.put(changeType + "_DasH_subscription_DasH_properties", payloadProperties) - - var payload = executor.subject.getOutFieldSchemaHelper("payload").createNewInstance(); - payload.put(changeType + "_DasH_subscription_DasH_request", payloadEntry); - - executor.outFields.put("albumID", executor.inFields.get("albumID")) - executor.outFields.put("payload", payload); - - //var returnValue = executor.isTrue; - true; - - key: - name: CreateSubscriptionRequestTask - version: 0.0.1 - value: - key: - name: CreateSubscriptionRequestTask - version: 0.0.1 - inputFields: - entry: - - key: albumID - value: - key: albumID - fieldSchemaKey: - name: UUIDType - version: 0.0.1 - optional: false - - key: payload - value: - key: payload - fieldSchemaKey: - name: CDSCreateSubscriptionPayloadType - version: 0.0.1 - optional: false - outputFields: - entry: - - key: actionIdentifiers - value: - key: actionIdentifiers - fieldSchemaKey: - name: CDSActionIdentifiersType - version: 0.0.1 - optional: false - - key: commonHeader - value: - key: commonHeader - fieldSchemaKey: - name: CDSRequestCommonHeaderType - version: 0.0.1 - optional: false - - key: payload - value: - key: payload - fieldSchemaKey: - name: CDSCreateSubscriptionPayloadType - version: 0.0.1 - optional: false - taskParameters: - entry: [ ] - contextAlbumReference: - - name: PMSubscriptionAlbum - version: 0.0.1 - taskLogic: - key: TaskLogic - logicFlavour: JAVASCRIPT - logic: |- - /* - * ============LICENSE_START======================================================= - * Copyright (C) 2020 Nordix. 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); - - var pmSubscriptionInfo = executor.getContextAlbum("PMSubscriptionAlbum").get(executor.inFields.get("albumID").toString()) - - var changeType = pmSubscriptionInfo.get("changeType").toLowerCase() - var blueprintName = pmSubscriptionInfo.get("blueprintName").toLowerCase() - var blueprintVersion = pmSubscriptionInfo.get("blueprintVersion").toLowerCase() - var payload = executor.inFields.get("payload") - var actionName = changeType + "-subscription" - - var commonHeader = executor.subject.getOutFieldSchemaHelper("commonHeader").createNewInstance(); - commonHeader.put("originatorId", "sdnc"); - commonHeader.put("requestId", executor.inFields.get("albumID").toString()); - commonHeader.put("subRequestId", "sub-123456-1000"); - - var actionIdentifiers = executor.subject.getOutFieldSchemaHelper("actionIdentifiers").createNewInstance(); - actionIdentifiers.put("actionName", actionName); - actionIdentifiers.put("blueprintName", blueprintName); - actionIdentifiers.put("blueprintVersion", blueprintVersion); - actionIdentifiers.put("mode", "sync"); - - executor.outFields.put("commonHeader", commonHeader); - executor.outFields.put("actionIdentifiers", actionIdentifiers); - executor.outFields.put("payload", payload); - - //var returnValue = executor.isTrue; - true; - - key: - name: DeleteSubscriptionPayloadTask - version: 0.0.1 - value: - key: - name: DeleteSubscriptionPayloadTask - version: 0.0.1 - inputFields: - entry: - - key: albumID - value: - key: albumID - fieldSchemaKey: - name: UUIDType - version: 0.0.1 - optional: false - outputFields: - entry: - - key: albumID - value: - key: albumID - fieldSchemaKey: - name: UUIDType - version: 0.0.1 - optional: false - - key: payload - value: - key: payload - fieldSchemaKey: - name: CDSDeleteSubscriptionPayloadType - version: 0.0.1 - optional: false - taskParameters: - entry: [ ] - contextAlbumReference: - - name: PMSubscriptionAlbum - version: 0.0.1 - taskLogic: - key: TaskLogic - logicFlavour: JAVASCRIPT - logic: |- - /* - * ============LICENSE_START======================================================= - * Copyright (C) 2020 Nordix. 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); - - var pmSubscriptionInfo = executor.getContextAlbum("PMSubscriptionAlbum").get(executor.inFields.get("albumID").toString()) - - var changeType = pmSubscriptionInfo.get("changeType").toLowerCase() - - var payloadProperties = executor.subject.getOutFieldSchemaHelper("payload").createNewSubInstance(changeType + "_DasH_subscription_DasH_properties_record"); - - payloadProperties.put("nfName", pmSubscriptionInfo.get("nfName")) - payloadProperties.put("subscriptionName", pmSubscriptionInfo.get("subscription").get("subscriptionName")) - payloadProperties.put("administrativeState", pmSubscriptionInfo.get("subscription").get("administrativeState")) - payloadProperties.put("fileBasedGP", pmSubscriptionInfo.get("subscription").get("fileBasedGP").toString()) - payloadProperties.put("fileLocation", pmSubscriptionInfo.get("subscription").get("fileLocation")) - payloadProperties.put("measurementGroups", pmSubscriptionInfo.get("subscription").get("measurementGroups")) - - var payloadEntry = executor.subject.getOutFieldSchemaHelper("payload").createNewSubInstance("CDSRequestPayloadEntry"); - payloadEntry.put(changeType + "_DasH_subscription_DasH_properties", payloadProperties) - - var payload = executor.subject.getOutFieldSchemaHelper("payload").createNewInstance(); - payload.put(changeType + "_DasH_subscription_DasH_request", payloadEntry); - - executor.outFields.put("albumID", executor.inFields.get("albumID")) - executor.outFields.put("payload", payload); - - //var returnValue = executor.isTrue; - true; - - key: - name: DeleteSubscriptionRequestTask - version: 0.0.1 - value: - key: - name: DeleteSubscriptionRequestTask - version: 0.0.1 - inputFields: - entry: - - key: albumID - value: - key: albumID - fieldSchemaKey: - name: UUIDType - version: 0.0.1 - optional: false - - key: payload - value: - key: payload - fieldSchemaKey: - name: CDSDeleteSubscriptionPayloadType - version: 0.0.1 - optional: false - outputFields: - entry: - - key: actionIdentifiers - value: - key: actionIdentifiers - fieldSchemaKey: - name: CDSActionIdentifiersType - version: 0.0.1 - optional: false - - key: commonHeader - value: - key: commonHeader - fieldSchemaKey: - name: CDSRequestCommonHeaderType - version: 0.0.1 - optional: false - - key: payload - value: - key: payload - fieldSchemaKey: - name: CDSDeleteSubscriptionPayloadType - version: 0.0.1 - optional: false - taskParameters: - entry: [ ] - contextAlbumReference: - - name: PMSubscriptionAlbum - version: 0.0.1 - taskLogic: - key: TaskLogic - logicFlavour: JAVASCRIPT - logic: |- - /* - * ============LICENSE_START======================================================= - * Copyright (C) 2020 Nordix. 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); - - var pmSubscriptionInfo = executor.getContextAlbum("PMSubscriptionAlbum").get(executor.inFields.get("albumID").toString()) - - var changeType = pmSubscriptionInfo.get("changeType").toLowerCase() - var blueprintName = pmSubscriptionInfo.get("blueprintName").toLowerCase() - var blueprintVersion = pmSubscriptionInfo.get("blueprintVersion").toLowerCase() - var payload = executor.inFields.get("payload") - var actionName = changeType + "-subscription" - - var commonHeader = executor.subject.getOutFieldSchemaHelper("commonHeader").createNewInstance(); - commonHeader.put("originatorId", "sdnc"); - commonHeader.put("requestId", executor.inFields.get("albumID").toString()); - commonHeader.put("subRequestId", "sub-123456-1000"); - - var actionIdentifiers = executor.subject.getOutFieldSchemaHelper("actionIdentifiers").createNewInstance(); - actionIdentifiers.put("actionName", actionName); - actionIdentifiers.put("blueprintName", blueprintName); - actionIdentifiers.put("blueprintVersion", blueprintVersion); - actionIdentifiers.put("mode", "sync"); - - executor.outFields.put("commonHeader", commonHeader); - executor.outFields.put("actionIdentifiers", actionIdentifiers); - executor.outFields.put("payload", payload); - - //var returnValue = executor.isTrue; - true; - - key: - name: ReceiveSubscriptionTask - version: 0.0.1 - value: - key: - name: ReceiveSubscriptionTask - version: 0.0.1 - inputFields: - entry: - - key: blueprintName - value: - key: blueprintName - fieldSchemaKey: - name: SimpleStringType - version: 0.0.1 - optional: false - - key: blueprintVersion - value: - key: blueprintVersion - fieldSchemaKey: - name: SimpleStringType - version: 0.0.1 - optional: false - - key: changeType - value: - key: changeType - fieldSchemaKey: - name: SimpleStringType - version: 0.0.1 - optional: false - - key: closedLoopControlName - value: - key: closedLoopControlName - fieldSchemaKey: - name: SimpleStringType - version: 0.0.1 - optional: false - - key: nfName - value: - key: nfName - fieldSchemaKey: - name: SimpleStringType - version: 0.0.1 - optional: false - - key: policyName - value: - key: policyName - fieldSchemaKey: - name: SimpleStringType - version: 0.0.1 - optional: false - - key: subscription - value: - key: subscription - fieldSchemaKey: - name: SubscriptionType - version: 0.0.1 - optional: false - outputFields: - entry: - - key: albumID - value: - key: albumID - fieldSchemaKey: - name: UUIDType - version: 0.0.1 - optional: false - taskParameters: - entry: [ ] - contextAlbumReference: - - name: PMSubscriptionAlbum - version: 0.0.1 - taskLogic: - key: TaskLogic - logicFlavour: JAVASCRIPT - logic: |- - /* - * ============LICENSE_START======================================================= - * Copyright (C) 2020 Nordix. 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========================================================= - */ - var uuidType = java.util.UUID; - - executor.logger.info(executor.subject.id); - - //albumID will be used to fetch info from our album later - var albumID = uuidType.randomUUID(); - var pmSubscriptionInfo = executor.getContextAlbum("PMSubscriptionAlbum").getSchemaHelper().createNewInstance(); - var returnValue = true; - - if(executor.inFields.get("policyName") != null) { - executor.logger.info("nfName in receive sub event " + executor.inFields.get("nfName")); - - var changeType = executor.inFields.get("changeType") - var nfName = executor.inFields.get("nfName") - var policyName = executor.inFields.get("policyName") - var closedLoopControlName = executor.inFields.get("closedLoopControlName") - var subscription = executor.inFields.get("subscription") - var blueprintName = executor.inFields.get("blueprintName") - var blueprintVersion = executor.inFields.get("blueprintVersion") - - pmSubscriptionInfo.put("nfName", executor.inFields.get("nfName")); - pmSubscriptionInfo.put("changeType", executor.inFields.get("changeType")) - pmSubscriptionInfo.put("policyName", executor.inFields.get("policyName")) - pmSubscriptionInfo.put("closedLoopControlName", executor.inFields.get("closedLoopControlName")) - pmSubscriptionInfo.put("subscription", subscription) - pmSubscriptionInfo.put("blueprintName", blueprintName) - pmSubscriptionInfo.put("blueprintVersion", blueprintVersion) - - - executor.getContextAlbum("PMSubscriptionAlbum").put(albumID.toString(), pmSubscriptionInfo); - - executor.outFields.put("albumID", albumID) - } else { - executor.message = "Received invalid event" - returnValue = false; - } - - returnValue; - events: - key: - name: PMControlPolicy_Events - version: 0.0.1 - eventMap: - entry: - - key: - name: CDSCreateResponseEvent - version: 0.0.1 - value: - key: - name: CDSCreateResponseEvent - version: 0.0.1 - nameSpace: org.onap.policy.apex.onap.pmcontrol - source: CDS - target: APEX - parameter: - entry: - - key: actionIdentifiers - value: - key: actionIdentifiers - fieldSchemaKey: - name: CDSActionIdentifiersType - version: 0.0.1 - optional: false - - key: commonHeader - value: - key: commonHeader - fieldSchemaKey: - name: CDSResponseCommonHeaderType - version: 0.0.1 - optional: false - - key: payload - value: - key: payload - fieldSchemaKey: - name: CDSCreateResponsePayloadType - version: 0.0.1 - optional: false - - key: status - value: - key: status - fieldSchemaKey: - name: CDSResponseStatusType - version: 0.0.1 - optional: false - - key: - name: CDSCreateSubscriptionRequestEvent - version: 0.0.1 - value: - key: - name: CDSCreateSubscriptionRequestEvent - version: 0.0.1 - nameSpace: org.onap.policy.apex.onap.pmcontrol - source: APEX - target: APEX - parameter: - entry: - - key: actionIdentifiers - value: - key: actionIdentifiers - fieldSchemaKey: - name: CDSActionIdentifiersType - version: 0.0.1 - optional: false - - key: commonHeader - value: - key: commonHeader - fieldSchemaKey: - name: CDSRequestCommonHeaderType - version: 0.0.1 - optional: false - - key: payload - value: - key: payload - fieldSchemaKey: - name: CDSCreateSubscriptionPayloadType - version: 0.0.1 - optional: false - - key: - name: CDSDeleteResponseEvent - version: 0.0.1 - value: - key: - name: CDSDeleteResponseEvent - version: 0.0.1 - nameSpace: org.onap.policy.apex.onap.pmcontrol - source: CDS - target: APEX - parameter: - entry: - - key: actionIdentifiers - value: - key: actionIdentifiers - fieldSchemaKey: - name: CDSActionIdentifiersType - version: 0.0.1 - optional: false - - key: commonHeader - value: - key: commonHeader - fieldSchemaKey: - name: CDSResponseCommonHeaderType - version: 0.0.1 - optional: false - - key: payload - value: - key: payload - fieldSchemaKey: - name: CDSDeleteResponsePayloadType - version: 0.0.1 - optional: false - - key: status - value: - key: status - fieldSchemaKey: - name: CDSResponseStatusType - version: 0.0.1 - optional: false - - key: - name: CDSDeleteSubscriptionRequestEvent - version: 0.0.1 - value: - key: - name: CDSDeleteSubscriptionRequestEvent - version: 0.0.1 - nameSpace: org.onap.policy.apex.onap.pmcontrol - source: APEX - target: APEX - parameter: - entry: - - key: actionIdentifiers - value: - key: actionIdentifiers - fieldSchemaKey: - name: CDSActionIdentifiersType - version: 0.0.1 - optional: false - - key: commonHeader - value: - key: commonHeader - fieldSchemaKey: - name: CDSRequestCommonHeaderType - version: 0.0.1 - optional: false - - key: payload - value: - key: payload - fieldSchemaKey: - name: CDSDeleteSubscriptionPayloadType - version: 0.0.1 - optional: false - - key: - name: CDSResponseStatusEvent - version: 0.0.1 - value: - key: - name: CDSResponseStatusEvent - version: 0.0.1 - nameSpace: org.onap.policy.apex.onap.pmcontrol - source: APEX - target: DCAE - parameter: - entry: - - key: status - value: - key: status - fieldSchemaKey: - name: SubscriptionStatusType - version: 0.0.1 - optional: false - - key: - name: CreateSubscriptionPayloadEvent - version: 0.0.1 - value: - key: - name: CreateSubscriptionPayloadEvent - version: 0.0.1 - nameSpace: org.onap.policy.apex.onap.pmcontrol - source: APEX - target: APEX - parameter: - entry: - - key: albumID - value: - key: albumID - fieldSchemaKey: - name: UUIDType - version: 0.0.1 - optional: false - - key: payload - value: - key: payload - fieldSchemaKey: - name: CDSCreateSubscriptionPayloadType - version: 0.0.1 - optional: false - - key: - name: DeleteSubscriptionPayloadEvent - version: 0.0.1 - value: - key: - name: DeleteSubscriptionPayloadEvent - version: 0.0.1 - nameSpace: org.onap.policy.apex.onap.pmcontrol - source: APEX - target: APEX - parameter: - entry: - - key: albumID - value: - key: albumID - fieldSchemaKey: - name: UUIDType - version: 0.0.1 - optional: false - - key: payload - value: - key: payload - fieldSchemaKey: - name: CDSDeleteSubscriptionPayloadType - version: 0.0.1 - optional: false - - key: - name: MRResponseEvent - version: 0.0.1 - value: - key: - name: MRResponseEvent - version: 0.0.1 - nameSpace: org.onap.policy.apex.onap.pmcontrol - source: DCAE - target: APEX - parameter: - entry: - - key: count - value: - key: count - fieldSchemaKey: - name: SimpleIntType - version: 0.0.1 - optional: false - - key: serverTimeMs - value: - key: serverTimeMs - fieldSchemaKey: - name: SimpleIntType - version: 0.0.1 - optional: false - - key: - name: PMSubscriptionOutputEvent - version: 0.0.1 - value: - key: - name: PMSubscriptionOutputEvent - version: 0.0.1 - nameSpace: org.onap.policy.apex.onap.pmcontrol - source: APEX - target: APEX - parameter: - entry: - - key: albumID - value: - key: albumID - fieldSchemaKey: - name: UUIDType - version: 0.0.1 - optional: false - - key: - name: pmsh-operational-policy - version: 0.0.1 - value: - key: - name: pmsh-operational-policy - version: 0.0.1 - nameSpace: org.onap.policy.apex.onap.pmcontrol - source: DCAE - target: APEX - parameter: - entry: - - key: blueprintName - value: - key: blueprintName - fieldSchemaKey: - name: SimpleStringType - version: 0.0.1 - optional: false - - key: blueprintVersion - value: - key: blueprintVersion - fieldSchemaKey: - name: SimpleStringType - version: 0.0.1 - optional: false - - key: changeType - value: - key: changeType - fieldSchemaKey: - name: SimpleStringType - version: 0.0.1 - optional: false - - key: closedLoopControlName - value: - key: closedLoopControlName - fieldSchemaKey: - name: SimpleStringType - version: 0.0.1 - optional: false - - key: nfName - value: - key: nfName - fieldSchemaKey: - name: SimpleStringType - version: 0.0.1 - optional: false - - key: policyName - value: - key: policyName - fieldSchemaKey: - name: SimpleStringType - version: 0.0.1 - optional: false - - key: subscription - value: - key: subscription - fieldSchemaKey: - name: SubscriptionType - version: 0.0.1 - optional: false - albums: - key: - name: PMControlPolicy_Albums - version: 0.0.1 - albums: - entry: - - key: - name: PMSubscriptionAlbum - version: 0.0.1 - value: - key: - name: PMSubscriptionAlbum - version: 0.0.1 - scope: policy - isWritable: true - itemSchema: - name: PMSubscriptionType - version: 0.0.1 - schemas: - key: - name: PMControlPolicy_Schemas - version: 0.0.1 - schemas: - entry: - - key: - name: CDSActionIdentifiersType - version: 0.0.1 - value: - key: - name: CDSActionIdentifiersType - version: 0.0.1 - schemaFlavour: Avro - schemaDefinition: |- - { - "type": "record", - "name": "ActionIdentifiers_Type", - "namespace": "org.onap.policy.apex.onap.helloworld", - "fields": [ - { - "name": "actionName", - "type": "string" - }, - { - "name": "blueprintName", - "type": "string" - }, - { - "name": "blueprintVersion", - "type": "string" - }, - { - "name": "mode", - "type": "string" - } - ] - } - - key: - name: CDSCreateResponsePayloadType - version: 0.0.1 - value: - key: - name: CDSCreateResponsePayloadType - version: 0.0.1 - schemaFlavour: Avro - schemaDefinition: |- - { - "name": "CreateResponsePayloadEntry", - "type": "record", - "namespace": "org.onap.policy.apex.onap.helloworld", - "fields": [ - { - "name": "create_DasH_subscription_DasH_response", - "type": { - "name": "create_DasH_subscription_DasH_response", - "type": "record", - "fields": [ - { - "name": "odl_DasH_response", - "type": { - "name": "odl_DasH_response", - "type": "record", - "fields": [ - { - "name": "status", - "type": "string" - } - ] - } - } - ] - } - } - ] - } - - key: - name: CDSCreateSubscriptionPayloadType - version: 0.0.1 - value: - key: - name: CDSCreateSubscriptionPayloadType - version: 0.0.1 - schemaFlavour: Avro - schemaDefinition: |- - { - "type": "map", - "values": { - "type": "record", - "name": "CDSRequestPayloadEntry", - "fields": [ - { - "name": "create_DasH_subscription_DasH_properties", - "type": { - "name": "create_DasH_subscription_DasH_properties_record", - "type": "record", - "fields": [ - { - "name": "nfName", - "type": "string" - }, - { - "name": "subscriptionName", - "type": "string" - }, - { - "name": "administrativeState", - "type": "string" - }, - { - "name": "fileBasedGP", - "type": "string" - }, - { - "name": "fileLocation", - "type": "string" - }, - { - "name": "measurementGroups", - "type": { - "type": "array", - "items": { - "name": "measurementGroups_record", - "type": "record", - "fields": [ - { - "name": "measurementGroup", - "type": { - "name": "measurementGroup", - "type": "record", - "fields": [ - { - "name": "measurementTypes", - "type": { - "type": "array", - "items": { - "name": "measurementTypes_record", - "type": "record", - "fields": [ - { - "name": "measurementType", - "type": "string" - } - ] - } - } - }, - { - "name": "managedObjectDNsBasic", - "type": { - "type": "array", - "items": { - "name": "managedObjectDNsBasic_record", - "type": "record", - "fields": [ - { - "name": "DN", - "type": "string" - } - ] - } - } - } - ] - } - } - ] - } - } - } - ] - } - } - ] - } - } - - key: - name: CDSDeleteResponsePayloadType - version: 0.0.1 - value: - key: - name: CDSDeleteResponsePayloadType - version: 0.0.1 - schemaFlavour: Avro - schemaDefinition: |- - { - "name": "DeleteResponsePayloadEntry", - "type": "record", - "namespace": "com.acme.avro", - "fields": [ - { - "name": "delete_DasH_subscription_DasH_response", - "type": { - "name": "delete_DasH_subscription_DasH_response", - "type": "record", - "fields": [ - { - "name": "odl_DasH_response", - "type": { - "name": "odl_DasH_response", - "type": "record", - "fields": [ - { - "name": "status", - "type": "string" - } - ] - } - } - ] - } - } - ] - } - - key: - name: CDSDeleteSubscriptionPayloadType - version: 0.0.1 - value: - key: - name: CDSDeleteSubscriptionPayloadType - version: 0.0.1 - schemaFlavour: Avro - schemaDefinition: |- - { - "type": "map", - "values": { - "type": "record", - "name": "CDSRequestPayloadEntry", - "fields": [ - { - "name": "delete_DasH_subscription_DasH_properties", - "type": { - "name": "delete_DasH_subscription_DasH_properties_record", - "type": "record", - "fields": [ - { - "name": "nfName", - "type": "string" - }, - { - "name": "subscriptionName", - "type": "string" - }, - { - "name": "administrativeState", - "type": "string" - }, - { - "name": "fileBasedGP", - "type": "string" - }, - { - "name": "fileLocation", - "type": "string" - }, - { - "name": "measurementGroups", - "type": { - "type": "array", - "items": { - "name": "measurementGroups_record", - "type": "record", - "fields": [ - { - "name": "measurementGroup", - "type": { - "name": "measurementGroup", - "type": "record", - "fields": [ - { - "name": "measurementTypes", - "type": { - "type": "array", - "items": { - "name": "measurementTypes_record", - "type": "record", - "fields": [ - { - "name": "measurementType", - "type": "string" - } - ] - } - } - }, - { - "name": "managedObjectDNsBasic", - "type": { - "type": "array", - "items": { - "name": "managedObjectDNsBasic_record", - "type": "record", - "fields": [ - { - "name": "DN", - "type": "string" - } - ] - } - } - } - ] - } - } - ] - } - } - } - ] - } - } - ] - } - } - - key: - name: CDSRequestCommonHeaderType - version: 0.0.1 - value: - key: - name: CDSRequestCommonHeaderType - version: 0.0.1 - schemaFlavour: Avro - schemaDefinition: |- - { - "type": "record", - "name": "RequestCommonHeader_Type", - "namespace": "org.onap.policy.apex.onap.helloworld", - "fields": [ - { - "name": "originatorId", - "type": "string" - }, - { - "name": "requestId", - "type": "string" - }, - { - "name": "subRequestId", - "type": "string" - } - ] - } - - key: - name: CDSResponseCommonHeaderType - version: 0.0.1 - value: - key: - name: CDSResponseCommonHeaderType - version: 0.0.1 - schemaFlavour: Avro - schemaDefinition: |- - { - "type": "record", - "name": "ResponseCommonHeader_Type", - "namespace": "org.onap.policy.apex.onap.helloworld", - "fields": [ - { - "name": "originatorId", - "type": "string" - }, - { - "name": "requestId", - "type": "string" - }, - { - "name": "subRequestId", - "type": "string" - }, - { - "name": "timestamp", - "type": "string" - }, - { - "name": "flags", - "type": ["null", "string"] - } - ] - } - - key: - name: CDSResponseStatusType - version: 0.0.1 - value: - key: - name: CDSResponseStatusType - version: 0.0.1 - schemaFlavour: Avro - schemaDefinition: |- - { - "type": "record", - "name": "ResponseStatus_Type", - "namespace": "org.onap.policy.apex.onap.helloworld", - "fields": [ - { - "name": "code", - "type": "int" - }, - { - "name": "eventType", - "type": "string" - }, - { - "name": "timestamp", - "type": "string" - }, - { - "name": "message", - "type": "string" - } - ] - } - - key: - name: PMSubscriptionType - version: 0.0.1 - value: - key: - name: PMSubscriptionType - version: 0.0.1 - schemaFlavour: Avro - schemaDefinition: "{\n\t\"name\": \"PMSubscription\",\n\t\"type\": \"record\",\n\t\"namespace\": \"\ - org.onap.policy.apex.onap.pmcontrol\",\n\t\"fields\": [\n {\n \"name\": \"nfName\"\ - ,\n \"type\": \"string\"\n },\n\t {\n\t\t\t\"name\": \"changeType\",\n\t\t\t\"\ - type\": \"string\"\n\t\t},\n\t\t{\n\t\t\t\"name\": \"closedLoopControlName\",\n\t\t\t\"type\": \"\ - string\"\n\t\t},\n\t\t{\n\t\t\t\"name\": \"policyName\",\n\t\t\t\"type\": \"string\"\n\t\t},\n\t\t\ - {\n\t\t \"name\": \"blueprintName\",\n\t\t \"type\": \"string\"\n\t\t},\n\t\t{\n\t\t \"name\"\ - : \"blueprintVersion\",\n\t\t \"type\": \"string\"\n\t\t},\n\t\t{\n\t\t\t\"name\": \"subscription\"\ - ,\n\t\t\t\"type\": {\n\t\t\t\t\"name\": \"subscription\",\n\t\t\t\t\"type\": \"record\",\n\t\t\t\t\ - \"fields\": [{\n\t\t\t\t\t\t\"name\": \"subscriptionName\",\n\t\t\t\t\t\t\"type\": \"string\"\n\t\t\ - \t\t\t},\n\t\t\t\t\t{\n\t\t\t\t\t\t\"name\": \"administrativeState\",\n\t\t\t\t\t\t\"type\": \"string\"\ - \n\t\t\t\t\t},\n\t\t\t\t\t{\n\t\t\t\t\t\t\"name\": \"fileBasedGP\",\n\t\t\t\t\t\t\"type\": \"int\"\ - \n\t\t\t\t\t},\n\t\t\t\t\t{\n\t\t\t\t\t\t\"name\": \"fileLocation\",\n\t\t\t\t\t\t\"type\": \"string\"\ - \n\t\t\t\t\t},\n\t\t\t\t\t{\n\t\t\t\t\t\t\"name\": \"measurementGroups\",\n\t\t\t\t\t\t\"type\": {\n\ - \t\t\t\t\t\t\t\"type\": \"array\",\n\t\t\t\t\t\t\t\"items\": {\n\t\t\t\t\t\t\t\t\"name\": \"Measurement_Groups_Type\"\ - ,\n\t\t\t\t\t\t\t\t\"type\": \"record\",\n\t\t\t\t\t\t\t\t\"fields\": [{\n\t\t\t\t\t\t\t\t\t\"name\"\ - : \"measurementGroup\",\n\t\t\t\t\t\t\t\t\t\"type\": {\n\t\t\t\t\t\t\t\t\t\t\"name\": \"Measurement_Group_Type\"\ - ,\n\t\t\t\t\t\t\t\t\t\t\"type\": \"record\",\n\t\t\t\t\t\t\t\t\t\t\"fields\": [{\n\t\t\t\t\t\t\t\t\ - \t\t\t\t\"name\": \"measurementTypes\",\n\t\t\t\t\t\t\t\t\t\t\t\t\"type\": {\n\t\t\t\t\t\t\t\t\t\t\ - \t\t\t\"type\": \"array\",\n\t\t\t\t\t\t\t\t\t\t\t\t\t\"items\": {\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\"\ - name\": \"Measurement_Types_Type\",\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\"type\": \"record\",\n\t\t\t\t\t\ - \t\t\t\t\t\t\t\t\t\"fields\": [{\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\"name\": \"measurementType\",\n\t\ - \t\t\t\t\t\t\t\t\t\t\t\t\t\t\"type\": \"string\"\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t}]\n\t\t\t\t\t\t\t\t\ - \t\t\t\t\t}\n\t\t\t\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\t\t\t\t{\n\t\t\t\t\ - \t\t\t\t\t\t\t\t\"name\": \"managedObjectDNsBasic\",\n\t\t\t\t\t\t\t\t\t\t\t\t\"type\": {\n\t\t\t\t\ - \t\t\t\t\t\t\t\t\t\"type\": \"array\",\n\t\t\t\t\t\t\t\t\t\t\t\t\t\"items\": {\n\t\t\t\t\t\t\t\t\t\ - \t\t\t\t\t\"name\": \"Managed_Object_Dns_Basic_Type\",\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\"type\": \"record\"\ - ,\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\"fields\": [{\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\"name\": \"DN\",\n\t\ - \t\t\t\t\t\t\t\t\t\t\t\t\t\t\"type\": \"string\"\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t}]\n\t\t\t\t\t\t\t\t\ - \t\t\t\t\t}\n\t\t\t\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\t\t]\n\t\t\t\t\t\ - \t\t\t\t}\n\t\t\t\t\t\t\t\t}]\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t]\n\t\t\t}\n\t\ - \t}\n\t]\n}" - - key: - name: SimpleIntType - version: 0.0.1 - value: - key: - name: SimpleIntType - version: 0.0.1 - schemaFlavour: Java - schemaDefinition: java.lang.Integer - - key: - name: SimpleStringType - version: 0.0.1 - value: - key: - name: SimpleStringType - version: 0.0.1 - schemaFlavour: Java - schemaDefinition: java.lang.String - - key: - name: SubscriptionStatusType - version: 0.0.1 - value: - key: - name: SubscriptionStatusType - version: 0.0.1 - schemaFlavour: Avro - schemaDefinition: |- - { - "type": "record", - "name": "ActivateSubscriptionStatus_Type", - "namespace": "org.onap.policy.apex.onap.helloworld", - "fields": [ - { - "name": "subscriptionName", - "type": "string" - }, - { - "name": "nfName", - "type": "string" - }, - { - "name": "changeType", - "type": "string" - }, - { - "name": "message", - "type": "string" - } - ] - } - - key: - name: SubscriptionType - version: 0.0.1 - value: - key: - name: SubscriptionType - version: 0.0.1 - schemaFlavour: Avro - schemaDefinition: "{\n\t\"name\": \"subscription\",\n\t\"type\": \"record\",\n\t\"fields\": [{\n\t\t\ - \t\"name\": \"subscriptionName\",\n\t\t\t\"type\": \"string\"\n\t\t},\n\t\t{\n\t\t\t\"name\": \"administrativeState\"\ - ,\n\t\t\t\"type\": \"string\"\n\t\t},\n\t\t{\n\t\t\t\"name\": \"fileBasedGP\",\n\t\t\t\"type\": \"\ - int\"\n\t\t},\n\t\t{\n\t\t\t\"name\": \"fileLocation\",\n\t\t\t\"type\": \"string\"\n\t\t},\n\t\t\ - {\n\t\t\t\"name\": \"measurementGroups\",\n\t\t\t\"type\": {\n\t\t\t\t\"type\": \"array\",\n\t\t\t\ - \t\"items\": {\n\t\t\t\t\t\"name\": \"Measurement_Groups_Type\",\n\t\t\t\t\t\"type\": \"record\",\n\ - \t\t\t\t\t\"fields\": [{\n\t\t\t\t\t\t\"name\": \"measurementGroup\",\n\t\t\t\t\t\t\"type\": {\n\t\ - \t\t\t\t\t\t\"name\": \"Measurement_Group_Type\",\n\t\t\t\t\t\t\t\"type\": \"record\",\n\t\t\t\t\t\ - \t\t\"fields\": [{\n\t\t\t\t\t\t\t\t\t\"name\": \"measurementTypes\",\n\t\t\t\t\t\t\t\t\t\"type\"\ - : {\n\t\t\t\t\t\t\t\t\t\t\"type\": \"array\",\n\t\t\t\t\t\t\t\t\t\t\"items\": {\n\t\t\t\t\t\t\t\t\t\ - \t\t\"name\": \"Measurement_Types_Type\",\n\t\t\t\t\t\t\t\t\t\t\t\"type\": \"record\",\n\t\t\t\t\t\ - \t\t\t\t\t\t\"fields\": [{\n\t\t\t\t\t\t\t\t\t\t\t\t\"name\": \"measurementType\",\n\t\t\t\t\t\t\t\ - \t\t\t\t\t\"type\": \"string\"\n\t\t\t\t\t\t\t\t\t\t\t}]\n\t\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\t\ - }\n\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\t\"name\": \"managedObjectDNsBasic\",\n\ - \t\t\t\t\t\t\t\t\t\"type\": {\n\t\t\t\t\t\t\t\t\t\t\"type\": \"array\",\n\t\t\t\t\t\t\t\t\t\t\"items\"\ - : {\n\t\t\t\t\t\t\t\t\t\t\t\"name\": \"Managed_Object_Dns_Basic_Type\",\n\t\t\t\t\t\t\t\t\t\t\t\"\ - type\": \"record\",\n\t\t\t\t\t\t\t\t\t\t\t\"fields\": [{\n\t\t\t\t\t\t\t\t\t\t\t\t\"name\": \"DN\"\ - ,\n\t\t\t\t\t\t\t\t\t\t\t\t\"type\": \"string\"\n\t\t\t\t\t\t\t\t\t\t\t}]\n\t\t\t\t\t\t\t\t\t\t}\n\ - \t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t]\n\t\t\t\t\t\t}\n\t\t\t\t\t}]\n\t\t\t\t}\n\t\ - \t\t}\n\t\t}\n\t]\n}" - - key: - name: UUIDType - version: 0.0.1 - value: - key: - name: UUIDType - version: 0.0.1 - schemaFlavour: Java - schemaDefinition: java.util.UUID - engineParameters: - executorParameters: - JAVASCRIPT: - parameterClassName: org.onap.policy.apex.plugins.executor.javascript.JavascriptExecutorParameters - contextParameters: - parameterClassName: org.onap.policy.apex.context.parameters.ContextParameters - schemaParameters: - Avro: - parameterClassName: org.onap.policy.apex.plugins.context.schema.avro.AvroSchemaHelperParameters - Java: - parameterClassName: org.onap.policy.apex.context.impl.schema.java.JavaSchemaHelperParameters - jsonAdapters: - Instant: - adaptedClass: java.time.Instant - adaptorClass: org.onap.policy.controlloop.util.Serialization$GsonInstantAdapter - eventInputParameters: - DCAEConsumer: - carrierTechnologyParameters: - carrierTechnology: RESTCLIENT - parameterClassName: org.onap.policy.apex.plugins.event.carrier.restclient.RestClientCarrierTechnologyParameters - parameters: - consumerPollTime: '50' - url: https://message-router:3905/events/unauthenticated.DCAE_CL_OUTPUT/cg1/sg1 - eventProtocolParameters: - eventProtocol: JSON - parameters: - nameAlias: policyName - eventName: pmsh-operational-policy - eventNameFilter: pmsh-operational-policy - CDSRequestConsumer: - carrierTechnologyParameters: - carrierTechnology: RESTREQUESTOR - parameterClassName: org.onap.policy.apex.plugins.event.carrier.restrequestor.RestRequestorCarrierTechnologyParameters - parameters: - url: http://10.10.10.184:30254/api/v1/execution-service/process - httpMethod: POST - restRequestTimeout: 2000 - httpHeaders: - - - Authorization - - Basic Y2NzZGthcHBzOmNjc2RrYXBwcw== - eventProtocolParameters: - eventProtocol: JSON - eventName: CDSCreateResponseEvent - eventNameFilter: CDSCreateResponseEvent - requestorMode: true - requestorPeer: CDSRequestProducer - requestorTimeout: 500 - CDSDeleteRequestConsumer: - carrierTechnologyParameters: - carrierTechnology: RESTREQUESTOR - parameterClassName: org.onap.policy.apex.plugins.event.carrier.restrequestor.RestRequestorCarrierTechnologyParameters - parameters: - url: http://10.10.10.184:30254/api/v1/execution-service/process - httpMethod: POST - restRequestTimeout: 2000 - httpHeaders: - - - Authorization - - Basic Y2NzZGthcHBzOmNjc2RrYXBwcw== - eventProtocolParameters: - eventProtocol: JSON - eventName: CDSDeleteResponseEvent - eventNameFilter: CDSDeleteResponseEvent - requestorMode: true - requestorPeer: CDSDeleteRequestProducer - requestorTimeout: 500 - CDSReplyConsumer: - carrierTechnologyParameters: - carrierTechnology: RESTREQUESTOR - parameterClassName: org.onap.policy.apex.plugins.event.carrier.restrequestor.RestRequestorCarrierTechnologyParameters - parameters: - url: https://message-router:3905/events/unauthenticated.PMSH_CL_INPUT - httpMethod: POST - restRequestTimeout: 2000 - eventProtocolParameters: - eventProtocol: JSON - eventName: MRResponseEvent - eventNameFilter: MRResponseEvent - requestorMode: true - requestorPeer: CDSReplyProducer - requestorTimeout: 500 - eventOutputParameters: - logOutputter: - carrierTechnologyParameters: - carrierTechnology: FILE - parameters: - fileName: /tmp/outputevents.log - eventProtocolParameters: - eventProtocol: JSON - StdOutOutputter: - carrierTechnologyParameters: - carrierTechnology: FILE - parameters: - standardIo: true - eventProtocolParameters: - eventProtocol: JSON - CDSRequestProducer: - carrierTechnologyParameters: - carrierTechnology: RESTREQUESTOR - parameterClassName: org.onap.policy.apex.plugins.event.carrier.restrequestor.RestRequestorCarrierTechnologyParameters - eventProtocolParameters: - eventProtocol: JSON - eventNameFilter: CDSCreateSubscriptionRequestEvent - requestorMode: true - requestorPeer: CDSRequestConsumer - requestorTimeout: 500 - CDSDeleteRequestProducer: - carrierTechnologyParameters: - carrierTechnology: RESTREQUESTOR - parameterClassName: org.onap.policy.apex.plugins.event.carrier.restrequestor.RestRequestorCarrierTechnologyParameters - eventProtocolParameters: - eventProtocol: JSON - eventNameFilter: CDSDeleteSubscriptionRequestEvent - requestorMode: true - requestorPeer: CDSDeleteRequestConsumer - requestorTimeout: 500 - CDSReplyProducer: - carrierTechnologyParameters: - carrierTechnology: RESTREQUESTOR - parameterClassName: org.onap.policy.apex.plugins.event.carrier.restrequestor.RestRequestorCarrierTechnologyParameters - eventProtocolParameters: - eventProtocol: JSON - eventNameFilter: CDSResponseStatusEvent - requestorMode: true - requestorPeer: CDSReplyConsumer - requestorTimeout: 500 diff --git a/runtime-controlloop/src/test/resources/testscripts/listenOnTopic.sh b/runtime-controlloop/src/test/resources/testscripts/listenOnTopic.sh deleted file mode 100755 index 5e661777b..000000000 --- a/runtime-controlloop/src/test/resources/testscripts/listenOnTopic.sh +++ /dev/null @@ -1,31 +0,0 @@ -#! /bin/bash -# ============LICENSE_START======================================================= -# Copyright (C) 2021 Nordix Foundation. -# ================================================================================ -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# -# SPDX-License-Identifier: Apache-2.0 -# ============LICENSE_END========================================================= - -if [ $# -ne 1 ] -then - echo invalid parameters $*, specify a single parameter as the topic to listen on - exit 1 -fi - -while true -do - curl "http://localhost:3904/events/$1/TEST/1?timeout=60000" - echo "" -done - diff --git a/runtime/src/main/java/org/onap/policy/clamp/clds/config/AafConfiguration.java b/runtime/src/main/java/org/onap/policy/clamp/clds/config/AafConfiguration.java index e8502b72a..bdefdfe6d 100644 --- a/runtime/src/main/java/org/onap/policy/clamp/clds/config/AafConfiguration.java +++ b/runtime/src/main/java/org/onap/policy/clamp/clds/config/AafConfiguration.java @@ -61,7 +61,7 @@ public class AafConfiguration { registration.addUrlPatterns("/restservices/clds/v2/policyToscaModels/*"); registration.addUrlPatterns("/restservices/clds/v2/policies/*"); registration.addUrlPatterns("/restservices/clds/v2/loop/*"); - registration.addUrlPatterns("/restservices/clds/v2/toscaControlLoop/*"); + registration.addUrlPatterns("/restservices/clds/v2/acm/*"); registration.setName("cadiFilter"); registration.setOrder(0); return registration; diff --git a/runtime/src/main/resources/application-noaaf.properties b/runtime/src/main/resources/application-noaaf.properties index 9f13a314c..22f9774e1 100644 --- a/runtime/src/main/resources/application-noaaf.properties +++ b/runtime/src/main/resources/application-noaaf.properties @@ -193,6 +193,6 @@ clamp.config.cds.userName=ccsdkapps clamp.config.cds.password=ccsdkapps # Configuration settings for ControlLoop Runtime Rest API -clamp.config.controlloop.runtime.url=http://localhost:6969 -clamp.config.controlloop.runtime.userName=runtimeUser -clamp.config.controlloop.runtime.password=zb!XztG34 +clamp.config.acm.runtime.url=http://localhost:6969 +clamp.config.acm.runtime.userName=runtimeUser +clamp.config.acm.runtime.password=zb!XztG34 diff --git a/runtime/src/main/resources/application.properties b/runtime/src/main/resources/application.properties index 21b37c69f..054b88972 100644 --- a/runtime/src/main/resources/application.properties +++ b/runtime/src/main/resources/application.properties @@ -203,6 +203,6 @@ clamp.config.cds.userName=ccsdkapps clamp.config.cds.password=ccsdkapps # Configuration settings for ControlLoop Runtime Rest API -clamp.config.controlloop.runtime.url=http://localhost:6969 -clamp.config.controlloop.runtime.userName=runtimeUser -clamp.config.controlloop.runtime.password=zb!XztG34 +clamp.config.acm.runtime.url=http://localhost:6969 +clamp.config.acm.runtime.userName=runtimeUser +clamp.config.acm.runtime.password=zb!XztG34 diff --git a/runtime/src/main/resources/clds/camel/rest/clamp-api-v2.xml b/runtime/src/main/resources/clds/camel/rest/clamp-api-v2.xml index 8c9824ef7..8ad20a844 100644 --- a/runtime/src/main/resources/clds/camel/rest/clamp-api-v2.xml +++ b/runtime/src/main/resources/clds/camel/rest/clamp-api-v2.xml @@ -1476,7 +1476,7 @@ - - - - - + @@ -1679,7 +1679,7 @@ - + @@ -1713,7 +1713,7 @@ - + @@ -1748,7 +1748,7 @@ - + @@ -1783,7 +1783,7 @@ - + @@ -1796,7 +1796,7 @@ true - + java.lang.Exception @@ -1806,19 +1806,19 @@ + message="GET Automation Composition Definitions request failed: ${exception.stacktrace}"/> 500 - GET Control Loop Definitions FAILED + GET Automation Composition Definitions FAILED - - - + @@ -1939,7 +1939,7 @@ - - + + + + + + + GET + + + application/json + + + ${header.name} + + + ${header.version} + + + + + + + + + + + + + + + + + POST + + + application/json + + + + + + + + + + + + + + + + + DELETE + + + application/json + + + ${header.name} + + + ${header.version} + + + + + + + + + + + + + + + + + GET + + + application/json + + + + + + + + + + + + + + + + + DELETE + + + application/json + + + ${header.name} + + + ${header.version} + + + + + + + + + + + + + + + + + POST + + + application/json + + + + + + + + + + + + + + + + + DELETE + + + application/json + + + ${header.name} + + + ${header.version} + + + + + + + + + + + + + + + + + POST + + + application/json + + + + + + + + + + + + + + + + + PUT + + + application/json + + + + + + + + + + + + + + + + + GET + + + application/json + + + ${header.name} + + + ${header.version} + + + + + + + + + + + + + + + + + GET + + + application/json + + + ${header.section} + + + + + + + + + + + + + + + + + GET + + + application/json + + + + + + + + + + + + + + + + + GET + + + application/json + + + + + + + + + + + + + + + + + GET + + + application/json + + + ${header.common} + + + + + + + + + + + diff --git a/runtime/src/main/resources/clds/camel/routes/controlloop-flows.xml b/runtime/src/main/resources/clds/camel/routes/controlloop-flows.xml deleted file mode 100644 index 146ab14d5..000000000 --- a/runtime/src/main/resources/clds/camel/routes/controlloop-flows.xml +++ /dev/null @@ -1,387 +0,0 @@ - - - - - - - - GET - - - application/json - - - ${header.name} - - - ${header.version} - - - - - - - - - - - - - - - - - POST - - - application/json - - - - - - - - - - - - - - - - - DELETE - - - application/json - - - ${header.name} - - - ${header.version} - - - - - - - - - - - - - - - - - GET - - - application/json - - - - - - - - - - - - - - - - - DELETE - - - application/json - - - ${header.name} - - - ${header.version} - - - - - - - - - - - - - - - - - POST - - - application/json - - - - - - - - - - - - - - - - - DELETE - - - application/json - - - ${header.name} - - - ${header.version} - - - - - - - - - - - - - - - - - POST - - - application/json - - - - - - - - - - - - - - - - - PUT - - - application/json - - - - - - - - - - - - - - - - - GET - - - application/json - - - ${header.name} - - - ${header.version} - - - - - - - - - - - - - - - - - GET - - - application/json - - - ${header.section} - - - - - - - - - - - - - - - - - GET - - - application/json - - - - - - - - - - - - - - - - - GET - - - application/json - - - - - - - - - - - - - - - - - GET - - - application/json - - - ${header.common} - - - - - - - - - - - diff --git a/runtime/src/test/java/org/onap/policy/clamp/runtime/RuntimeCommissioningResponseItTestCase.java b/runtime/src/test/java/org/onap/policy/clamp/runtime/RuntimeCommissioningResponseItTestCase.java index 7824be460..8c9c5b3e4 100644 --- a/runtime/src/test/java/org/onap/policy/clamp/runtime/RuntimeCommissioningResponseItTestCase.java +++ b/runtime/src/test/java/org/onap/policy/clamp/runtime/RuntimeCommissioningResponseItTestCase.java @@ -125,7 +125,7 @@ public class RuntimeCommissioningResponseItTestCase { ProducerTemplate prodTemplate = camelContext.createProducerTemplate(); Exchange exchangeResponse = - prodTemplate.send("direct:get-control-loop-definitions", ExchangeBuilder.anExchange(camelContext) + prodTemplate.send("direct:get-acm-definitions", ExchangeBuilder.anExchange(camelContext) .withProperty("name", "ToscaServiceTemplate") .withProperty("version", "1.0.0") .withProperty("raiseHttpExceptionFlag", "true") diff --git a/runtime/src/test/java/org/onap/policy/clamp/runtime/RuntimeInstantiationResponseItTestCase.java b/runtime/src/test/java/org/onap/policy/clamp/runtime/RuntimeInstantiationResponseItTestCase.java index cc08ea0a6..d655257c6 100644 --- a/runtime/src/test/java/org/onap/policy/clamp/runtime/RuntimeInstantiationResponseItTestCase.java +++ b/runtime/src/test/java/org/onap/policy/clamp/runtime/RuntimeInstantiationResponseItTestCase.java @@ -53,9 +53,10 @@ public class RuntimeInstantiationResponseItTestCase { private static final String RAISE_HTTP_EXCEPTION_FLAG = "raiseHttpExceptionFlag"; - private static final String SAMPLE_CONTROL_LOOP_LIST = "{\"controlLoopList\": [{\"name\": \"PMSHInstance0\"," + private static final String SAMPLE_CONTROL_LOOP_LIST = + "{\"automationCompositionList\": [{\"name\": \"PMSHInstance0\"," + "\"version\": \"1.0.1\",\"definition\": {},\"state\": \"UNINITIALISED\",\"orderedState\": \"UNINITIALISED\"," - + "\"description\": \"PMSH control loop instance 0\",\"elements\": {}}]}"; + + "\"description\": \"PMSH Automation Composition instance 0\",\"elements\": {}}]}"; private static final String SAMPLE_TOSCA_TEMPLATE = "{\"tosca_definitions_version\": \"tosca_simple_yaml_1_1_0\"," diff --git a/runtime/src/test/resources/application.properties b/runtime/src/test/resources/application.properties index f2cf0dd33..d09b3ce49 100644 --- a/runtime/src/test/resources/application.properties +++ b/runtime/src/test/resources/application.properties @@ -182,6 +182,6 @@ clamp.config.tosca.converter.default.datatypes=classpath:/clds/tosca-converter/d clamp.config.tosca.converter.dictionary.support.enabled=true # Configuration settings for ControlLoop Runtime Rest API -clamp.config.controlloop.runtime.url=http://localhost:${docker.http-cache.port.host} -clamp.config.controlloop.runtime.userName=runtimeUser -clamp.config.controlloop.runtime.password=zb!XztG34 +clamp.config.acm.runtime.url=http://localhost:${docker.http-cache.port.host} +clamp.config.acm.runtime.userName=runtimeUser +clamp.config.acm.runtime.password=zb!XztG34 diff --git a/runtime/src/test/resources/http-cache/third_party_proxy.py b/runtime/src/test/resources/http-cache/third_party_proxy.py index 786c366e0..9c22f3ff5 100644 --- a/runtime/src/test/resources/http-cache/third_party_proxy.py +++ b/runtime/src/test/resources/http-cache/third_party_proxy.py @@ -276,44 +276,44 @@ class Proxy(SimpleHTTPServer.SimpleHTTPRequestHandler): with open(cached_file_content, 'w') as f: f.write(response) return True - elif (self.path.startswith("/onap/controlloop/v2/commission/toscaservicetemplate")) and http_type == "GET": + elif (self.path.startswith("/onap/policy/clamp/acm/v2/commission/toscaservicetemplate")) and http_type == "GET": if not _file_available: cached_file_folder = cached_file_folder.split('bridgeEndpoint')[0] print(("cached file folder for onap is %s: ", cached_file_folder)) - print("self.path start with /onap/controlloop/v2/commission/, generating response json...") + print("self.path start with /onap/policy/clamp/acm/v2/commission/, generating response json...") jsonGenerated = "{\"tosca_definitions_version\": \"tosca_simple_yaml_1_1_0\",\"data_types\": {},\"node_types\": {}, \"policy_types\": {}, \"topology_template\": {}, \"name\": \"ToscaServiceTemplateSimple\", \"version\": \"1.0.0\", \"metadata\": {}}" self._create_cache(jsonGenerated, cached_file_folder, cached_file_header, cached_file_content) return True - elif (self.path.startswith("/onap/controlloop/v2/commission/toscaServiceTemplateSchema")) and http_type == "GET": + elif (self.path.startswith("/onap/policy/clamp/acm/v2/commission/toscaServiceTemplateSchema")) and http_type == "GET": if not _file_available: cached_file_folder = cached_file_folder.split('bridgeEndpoint')[0] print(("cached file folder for onap is %s: ", cached_file_folder)) - print("self.path start with /onap/controlloop/v2/commission/, generating response json...") + print("self.path start with /onap/policy/clamp/acm/v2/commission/, generating response json...") jsonGenerated = "{\"tosca_definitions_version\": \"tosca_simple_yaml_1_1_0\",\"data_types\": {},\"node_types\": {}, \"policy_types\": {}, \"topology_template\": {}, \"name\": \"ToscaServiceTemplateSimple\", \"version\": \"1.0.0\", \"metadata\": {}}" self._create_cache(jsonGenerated, cached_file_folder, cached_file_header, cached_file_content) return True - elif (self.path.startswith("/onap/controlloop/v2/commission/elements")) and http_type == "GET": + elif (self.path.startswith("/onap/policy/clamp/acm/v2/commission/elements")) and http_type == "GET": if not _file_available: - print("self.path start with /commission/elements Control Loop Elements, generating response json...") + print("self.path start with /commission/elements Automation Composition Elements, generating response json...") jsonGenerated = "[{\"name\": ,\"org.onap.domain.pmsh.PMSH_DCAEMicroservice\": [{ \"version\": \"1.2.3\", \"derived_from\": null }]}]" self._create_cache(jsonGenerated, cached_file_folder, cached_file_header, cached_file_content) return True - elif (self.path.startswith("/onap/controlloop/v2/commission")) and http_type == "GET": + elif (self.path.startswith("/onap/policy/clamp/acm/v2/commission")) and http_type == "GET": if not _file_available: - print("self.path start with /commission control loop definition, generating response json...") + print("self.path start with /commission Automation Composition definition, generating response json...") #jsondata = json.loads(self.data_string) jsonGenerated = "[{\"name\": ,\"org.onap.domain.pmsh.PMSHControlLoopDefinition\": [{ \"version\": \"1.2.3\", \"derived_from\": null }]}]" self._create_cache(jsonGenerated, cached_file_folder, cached_file_header, cached_file_content) return True - elif (self.path.startswith("/onap/controlloop/v2/commission/getCommonOrInstanceProperties")) and http_type == "GET": + elif (self.path.startswith("/onap/policy/clamp/acm/v2/commission/getCommonOrInstanceProperties")) and http_type == "GET": if not _file_available: print("self.path start with /commission getting common properties, generating response json...") with open("example/node_template.json", "r") as f: jsonGenerated = f.read() self._create_cache(jsonGenerated, cached_file_folder, cached_file_header, cached_file_content) return True - elif (self.path.startswith("/onap/controlloop/v2/commission")) and http_type == "POST": - print("self.path start with POST /onap/controlloop/v2/commission, copying body to response ...") + elif (self.path.startswith("/onap/policy/clamp/acm/v2/commission")) and http_type == "POST": + print("self.path start with POST /onap/policy/clamp/acm/v2/commission, copying body to response ...") if not os.path.exists(cached_file_folder): os.makedirs(cached_file_folder, 0o777) with open(cached_file_header, 'w+') as f: @@ -321,18 +321,18 @@ class Proxy(SimpleHTTPServer.SimpleHTTPRequestHandler): with open(cached_file_content, 'w+') as f: f.write(self.data_string) return True - elif (self.path.startswith("/onap/controlloop/v2/commission")) and http_type == "DELETE": + elif (self.path.startswith("/onap/policy/clamp/acm/v2/commission")) and http_type == "DELETE": print("self.path start with /commission Decommissioning, generating response json...") jsonGenerated = "{\"errorDetails\": null,\"affectedControlLoopDefinitions\": [{ \"name\": \"ToscaServiceTemplateSimple\", \"version\": \"1.0.0\" }]}" self._create_cache(jsonGenerated, cached_file_folder, cached_file_header, cached_file_content) return True - elif (self.path.startswith("/onap/controlloop/v2/instantiation")) and http_type == "GET": + elif (self.path.startswith("/onap/policy/clamp/acm/v2/instantiation")) and http_type == "GET": print("self.path start with /instantiation Retrieving Instantiation, generating response json...") - jsonGenerated = "{\"controlLoopList\": [{\"name\": \"PMSHInstance0\",\"version\": \"1.0.1\",\"definition\": {},\"state\": \"UNINITIALISED\",\"orderedState\": \"UNINITIALISED\",\"description\": \"PMSH control loop instance 0\",\"elements\": {}}]}"; + jsonGenerated = "{\"automationCompositionList\": [{\"name\": \"PMSHInstance0\",\"version\": \"1.0.1\",\"definition\": {},\"state\": \"UNINITIALISED\",\"orderedState\": \"UNINITIALISED\",\"description\": \"PMSH Automation Composition instance 0\",\"elements\": {}}]}"; self._create_cache(jsonGenerated, cached_file_folder, cached_file_header, cached_file_content) return True - elif (self.path.startswith("/onap/controlloop/v2/instanceProperties")) and http_type == "POST": - print("self.path start with POST /onap/controlloop/v2/instanceProperties, copying body to response ...") + elif (self.path.startswith("/onap/policy/clamp/acm/v2/instanceProperties")) and http_type == "POST": + print("self.path start with POST /onap/policy/clamp/acm/v2/instanceProperties, copying body to response ...") if not os.path.exists(cached_file_folder): os.makedirs(cached_file_folder, 0o777) with open(cached_file_header, 'w+') as f: @@ -340,12 +340,12 @@ class Proxy(SimpleHTTPServer.SimpleHTTPRequestHandler): with open(cached_file_content, 'w+') as f: f.write(self.data_string) return True - elif (self.path.startswith("/onap/controlloop/v2/instanceProperties")) and http_type == "DELETE": + elif (self.path.startswith("/onap/policy/clamp/acm/v2/instanceProperties")) and http_type == "DELETE": print("self.path start with /instanceProperties Deleting instance properties, generating response json...") jsonGenerated = "{\"errorDetails\": null,\"affectedControlLoopDefinitions\": [{ \"name\": \"PMSH_Instance1\", \"version\": \"2.3.1\" }]}" self._create_cache(jsonGenerated, cached_file_folder, cached_file_header, cached_file_content) return True - elif (self.path.startswith("/onap/controlloop/v2/instantiation/command")) and http_type == "PUT": + elif (self.path.startswith("/onap/policy/clamp/acm/v2/instantiation/command")) and http_type == "PUT": print("self.path start with /instantiation/command Changing order state, generating response json...") jsonGenerated = "{\"orderedState\":\"PASSIVE\",\"controlLoopIdentifierList\":[{\"name\":\"PMSH_Instance1\",\"version\":\"2.3.1\"}]}" self._create_cache(jsonGenerated, cached_file_folder, cached_file_header, cached_file_content) -- cgit 1.2.3-korg