aboutsummaryrefslogtreecommitdiffstats
path: root/runtime-acm/src
diff options
context:
space:
mode:
authorliamfallon <liam.fallon@est.tech>2022-01-25 19:55:43 +0000
committerliamfallon <liam.fallon@est.tech>2022-02-18 15:54:40 +0000
commit43098043c4ef31d9d5dead66568d7d9482a6b165 (patch)
tree6f6ea4812ff93d65e7c64e12a3ec6ab4462a64e2 /runtime-acm/src
parentf401b5099bcb64f3e21de608d0207dd69d8043cd (diff)
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 <liam.fallon@est.tech>
Diffstat (limited to 'runtime-acm/src')
-rw-r--r--runtime-acm/src/main/java/org/onap/policy/clamp/acm/runtime/Application.java53
-rw-r--r--runtime-acm/src/main/java/org/onap/policy/clamp/acm/runtime/commissioning/CommissioningProvider.java383
-rw-r--r--runtime-acm/src/main/java/org/onap/policy/clamp/acm/runtime/config/AafConfiguration.java43
-rw-r--r--runtime-acm/src/main/java/org/onap/policy/clamp/acm/runtime/config/ConverterConfiguration.java44
-rw-r--r--runtime-acm/src/main/java/org/onap/policy/clamp/acm/runtime/config/FilterConfig.java45
-rw-r--r--runtime-acm/src/main/java/org/onap/policy/clamp/acm/runtime/config/SecurityConfig.java47
-rw-r--r--runtime-acm/src/main/java/org/onap/policy/clamp/acm/runtime/config/SpringFoxConfig.java45
-rw-r--r--runtime-acm/src/main/java/org/onap/policy/clamp/acm/runtime/config/messaging/Listener.java41
-rw-r--r--runtime-acm/src/main/java/org/onap/policy/clamp/acm/runtime/config/messaging/MessageDispatcherActivator.java137
-rw-r--r--runtime-acm/src/main/java/org/onap/policy/clamp/acm/runtime/config/messaging/Publisher.java34
-rw-r--r--runtime-acm/src/main/java/org/onap/policy/clamp/acm/runtime/instantiation/AutomationCompositionInstantiationProvider.java637
-rw-r--r--runtime-acm/src/main/java/org/onap/policy/clamp/acm/runtime/main/parameters/AcRuntimeParameterGroup.java49
-rw-r--r--runtime-acm/src/main/java/org/onap/policy/clamp/acm/runtime/main/parameters/ParticipantParameters.java45
-rw-r--r--runtime-acm/src/main/java/org/onap/policy/clamp/acm/runtime/main/parameters/ParticipantUpdateParameters.java46
-rw-r--r--runtime-acm/src/main/java/org/onap/policy/clamp/acm/runtime/main/rest/CommissioningController.java501
-rw-r--r--runtime-acm/src/main/java/org/onap/policy/clamp/acm/runtime/main/rest/InstantiationController.java623
-rw-r--r--runtime-acm/src/main/java/org/onap/policy/clamp/acm/runtime/main/rest/MonitoringQueryController.java334
-rw-r--r--runtime-acm/src/main/java/org/onap/policy/clamp/acm/runtime/main/web/AbstractRestController.java91
-rw-r--r--runtime-acm/src/main/java/org/onap/policy/clamp/acm/runtime/main/web/AutomationConfiguraitonAafFilter.java38
-rw-r--r--runtime-acm/src/main/java/org/onap/policy/clamp/acm/runtime/main/web/GlobalControllerExceptionHandler.java67
-rw-r--r--runtime-acm/src/main/java/org/onap/policy/clamp/acm/runtime/main/web/RuntimeErrorController.java104
-rw-r--r--runtime-acm/src/main/java/org/onap/policy/clamp/acm/runtime/monitoring/MonitoringProvider.java247
-rw-r--r--runtime-acm/src/main/java/org/onap/policy/clamp/acm/runtime/supervision/HandleCounter.java106
-rw-r--r--runtime-acm/src/main/java/org/onap/policy/clamp/acm/runtime/supervision/MessageIntercept.java32
-rw-r--r--runtime-acm/src/main/java/org/onap/policy/clamp/acm/runtime/supervision/SupervisionAspect.java105
-rw-r--r--runtime-acm/src/main/java/org/onap/policy/clamp/acm/runtime/supervision/SupervisionHandler.java518
-rw-r--r--runtime-acm/src/main/java/org/onap/policy/clamp/acm/runtime/supervision/SupervisionScanner.java307
-rw-r--r--runtime-acm/src/main/java/org/onap/policy/clamp/acm/runtime/supervision/comm/AbstractParticipantAckPublisher.java62
-rw-r--r--runtime-acm/src/main/java/org/onap/policy/clamp/acm/runtime/supervision/comm/AbstractParticipantPublisher.java62
-rw-r--r--runtime-acm/src/main/java/org/onap/policy/clamp/acm/runtime/supervision/comm/AutomationCompositionStateChangeAckListener.java70
-rw-r--r--runtime-acm/src/main/java/org/onap/policy/clamp/acm/runtime/supervision/comm/AutomationCompositionStateChangePublisher.java50
-rw-r--r--runtime-acm/src/main/java/org/onap/policy/clamp/acm/runtime/supervision/comm/AutomationCompositionUpdateAckListener.java70
-rw-r--r--runtime-acm/src/main/java/org/onap/policy/clamp/acm/runtime/supervision/comm/AutomationCompositionUpdatePublisher.java91
-rw-r--r--runtime-acm/src/main/java/org/onap/policy/clamp/acm/runtime/supervision/comm/ParticipantDeregisterAckPublisher.java45
-rw-r--r--runtime-acm/src/main/java/org/onap/policy/clamp/acm/runtime/supervision/comm/ParticipantDeregisterListener.java69
-rw-r--r--runtime-acm/src/main/java/org/onap/policy/clamp/acm/runtime/supervision/comm/ParticipantRegisterAckPublisher.java50
-rw-r--r--runtime-acm/src/main/java/org/onap/policy/clamp/acm/runtime/supervision/comm/ParticipantRegisterListener.java69
-rw-r--r--runtime-acm/src/main/java/org/onap/policy/clamp/acm/runtime/supervision/comm/ParticipantStatusListener.java68
-rw-r--r--runtime-acm/src/main/java/org/onap/policy/clamp/acm/runtime/supervision/comm/ParticipantStatusReqPublisher.java48
-rw-r--r--runtime-acm/src/main/java/org/onap/policy/clamp/acm/runtime/supervision/comm/ParticipantUpdateAckListener.java69
-rw-r--r--runtime-acm/src/main/java/org/onap/policy/clamp/acm/runtime/supervision/comm/ParticipantUpdatePublisher.java127
-rw-r--r--runtime-acm/src/main/resources/application.yaml66
-rw-r--r--runtime-acm/src/main/resources/version.txt4
-rw-r--r--runtime-acm/src/test/java/org/onap/policy/clamp/acm/runtime/commissioning/CommissioningProviderTest.java221
-rw-r--r--runtime-acm/src/test/java/org/onap/policy/clamp/acm/runtime/commissioning/rest/CommissioningControllerTest.java303
-rw-r--r--runtime-acm/src/test/java/org/onap/policy/clamp/acm/runtime/config/messaging/MessageDispatcherActivatorTest.java102
-rw-r--r--runtime-acm/src/test/java/org/onap/policy/clamp/acm/runtime/instantiation/AutomationCompositionInstantiationProviderTest.java394
-rw-r--r--runtime-acm/src/test/java/org/onap/policy/clamp/acm/runtime/instantiation/InstantiationUtils.java147
-rw-r--r--runtime-acm/src/test/java/org/onap/policy/clamp/acm/runtime/instantiation/rest/InstantiationControllerTest.java543
-rw-r--r--runtime-acm/src/test/java/org/onap/policy/clamp/acm/runtime/main/rest/ActuatorControllerTest.java91
-rw-r--r--runtime-acm/src/test/java/org/onap/policy/clamp/acm/runtime/monitoring/TestMonitoringProvider.java321
-rw-r--r--runtime-acm/src/test/java/org/onap/policy/clamp/acm/runtime/monitoring/rest/MonitoringQueryControllerTest.java242
-rw-r--r--runtime-acm/src/test/java/org/onap/policy/clamp/acm/runtime/supervision/HandleCounterTest.java84
-rw-r--r--runtime-acm/src/test/java/org/onap/policy/clamp/acm/runtime/supervision/SupervisionAspectTest.java66
-rw-r--r--runtime-acm/src/test/java/org/onap/policy/clamp/acm/runtime/supervision/SupervisionHandlerTest.java319
-rw-r--r--runtime-acm/src/test/java/org/onap/policy/clamp/acm/runtime/supervision/SupervisionScannerTest.java214
-rw-r--r--runtime-acm/src/test/java/org/onap/policy/clamp/acm/runtime/supervision/comm/SupervisionMessagesTest.java225
-rw-r--r--runtime-acm/src/test/java/org/onap/policy/clamp/acm/runtime/util/CommonTestData.java125
-rw-r--r--runtime-acm/src/test/java/org/onap/policy/clamp/acm/runtime/util/rest/CommonRestController.java201
-rw-r--r--runtime-acm/src/test/resources/application_test.properties37
-rw-r--r--runtime-acm/src/test/resources/parameters/TestParameters.json44
-rw-r--r--runtime-acm/src/test/resources/parameters/logback-test.xml42
-rw-r--r--runtime-acm/src/test/resources/rest/acm/AutomationCompositionElementsNotFound.json142
-rw-r--r--runtime-acm/src/test/resources/rest/acm/AutomationCompositionVersionNotMatches.json142
-rw-r--r--runtime-acm/src/test/resources/rest/acm/AutomationCompositions.json174
-rw-r--r--runtime-acm/src/test/resources/rest/acm/AutomationCompositionsNotFound.json142
-rw-r--r--runtime-acm/src/test/resources/rest/acm/AutomationCompositionsSmoke.json174
-rw-r--r--runtime-acm/src/test/resources/rest/acm/AutomationCompositionsUpdate.json174
-rw-r--r--runtime-acm/src/test/resources/rest/acm/PassiveCommand.json13
-rw-r--r--runtime-acm/src/test/resources/rest/monitoring/TestAcElementStatistics.json44
-rw-r--r--runtime-acm/src/test/resources/rest/monitoring/TestAcElementStatistics_Invalid.json13
-rw-r--r--runtime-acm/src/test/resources/rest/monitoring/TestParticipantStatistics.json46
-rw-r--r--runtime-acm/src/test/resources/rest/monitoring/TestParticipantStatistics_Invalid.json16
-rw-r--r--runtime-acm/src/test/resources/rest/servicetemplates/PMSHMultipleACTosca.yaml232
-rw-r--r--runtime-acm/src/test/resources/rest/servicetemplates/full-tosca-with-common-properties.yaml3546
-rw-r--r--runtime-acm/src/test/resources/rest/servicetemplates/pm_automation_composition_tosca.yaml452
-rw-r--r--runtime-acm/src/test/resources/rest/servicetemplates/pmsh_multiple_ac_tosca.yaml238
-rw-r--r--runtime-acm/src/test/resources/rest/servicetemplates/tosca-for-smoke-testing.yaml3488
-rwxr-xr-xruntime-acm/src/test/resources/testscripts/listenOnTopic.sh31
79 files changed, 18530 insertions, 0 deletions
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<Participant> 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<Participant> 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<ToscaNodeTemplate> getAutomationCompositionDefinitions(String acName, String acVersion)
+ throws PfModelException {
+
+ // @formatter:off
+ ToscaTypedEntityFilter<ToscaNodeTemplate> nodeTemplateFilter = ToscaTypedEntityFilter
+ .<ToscaNodeTemplate>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<ToscaNodeTemplate> 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<Map<String, String>> automationCompositionElements =
+ (List<Map<String, String>>) automationCompositionNodeTemplate.getProperties().get("elements");
+
+ if (CollectionUtils.isEmpty(automationCompositionElements)) {
+ return Collections.emptyList();
+ }
+
+ List<ToscaNodeTemplate> 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<String, ToscaNodeTemplate> 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<ToscaServiceTemplate> 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<ToscaServiceTemplate> filteredServiceTemplateList = filterToscaNodeTemplateInstance(serviceTemplateList);
+
+ if (filteredServiceTemplateList.isEmpty()) {
+ throw new PfModelException(Status.BAD_REQUEST, "Invalid Service Template");
+ }
+
+ ToscaServiceTemplate fullTemplate = filteredServiceTemplateList.get(0);
+
+ var template = new HashMap<String, Object>();
+ 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<ToscaServiceTemplate> filterToscaNodeTemplateInstance(List<ToscaServiceTemplate> serviceTemplates) {
+
+ List<ToscaServiceTemplate> toscaServiceTemplates = new ArrayList<>();
+
+ serviceTemplates.stream().forEach(serviceTemplate -> {
+
+ Map<String, ToscaNodeTemplate> 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<HttpMessageConverter<?>> 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<RequestResponseLoggingFilter> loggingFilter() {
+ FilterRegistrationBean<RequestResponseLoggingFilter> 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<T> {
+
+ /**
+ * 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<T> 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<TopicSink> topicSinks;
+ private List<TopicSource> 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 <T> MessageDispatcherActivator(final AcRuntimeParameterGroup acRuntimeParameterGroup,
+ List<Publisher> publishers, List<Listener<T>> 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<TopicSink> 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<UUID, AutomationCompositionElement> automationCompositionElements = new HashMap<>();
+
+ ToscaServiceTemplate toscaServiceTemplate = commissioningProvider.getAllToscaServiceTemplate().get(0);
+
+ Map<String, ToscaNodeTemplate> persistedNodeTemplateMap =
+ toscaServiceTemplate.getToscaTopologyTemplate().getNodeTemplates();
+
+ Map<String, ToscaNodeTemplate> 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<String, ToscaNodeTemplate> 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<ToscaNodeTemplate> 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<ToscaNodeTemplate> 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<ToscaNodeTemplate> acElementDefinitions =
+ commissioningProvider.getAutomationCompositionElementDefinitions(toscaNodeTemplates.get(0));
+
+ // @formatter:off
+ Map<String, ToscaConceptIdentifier> 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<String, ToscaConceptIdentifier> 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<AutomationComposition> 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<AutomationComposition> automationCompositions,
+ List<Participant> participants) {
+ var result = new BeanValidationResult("AutomationCompositions", automationCompositions);
+
+ Map<ToscaConceptIdentifier, Participant> 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<AutomationComposition> 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<AutomationComposition> 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<String, ToscaNodeTemplate> toscaSavedNodeTemplate =
+ automationCompositionProvider.saveInstanceProperties(serviceTemplate);
+ automationCompositionProvider.saveAutomationCompositions(automationCompositions.getAutomationCompositionList());
+ List<ToscaConceptIdentifier> affectedAutomationCompositions = automationCompositions
+ .getAutomationCompositionList().stream().map(ac -> ac.getKey().asIdentifier()).collect(Collectors.toList());
+
+ List<ToscaConceptIdentifier> 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<UUID, AutomationCompositionElement> 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<String> 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<ToscaNodeTemplate> 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<String, Object> participantId =
+ (LinkedTreeMap<String, Object>) 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<String, Object> participantType =
+ (LinkedTreeMap<String, Object>) 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<String, ToscaNodeTemplate> deepCloneNodeTemplate(ToscaServiceTemplate serviceTemplate) {
+ String jsonString = GSON.toJson(serviceTemplate.getToscaTopologyTemplate().getNodeTemplates());
+ Type type = new TypeToken<HashMap<String, ToscaNodeTemplate>>() {}.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<CommissioningResponse> 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<CommissioningResponse> 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<List<ToscaNodeTemplate>> 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<String> 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<String> 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<Map<String, ToscaNodeTemplate>> 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<List<ToscaNodeTemplate>> 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<ToscaNodeTemplate> 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<ToscaNodeTemplate> 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<InstantiationResponse> 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<InstancePropertiesResponse> 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<InstantiationResponse> 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<AutomationCompositions> 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<InstantiationResponse> 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<InstantiationResponse> 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<InstantiationResponse> 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<AutomationCompositionOrderStateResponse> 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<AutomationCompositionPrimedResponse> 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<ParticipantStatisticsList> 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<ParticipantStatisticsList> 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<AcElementStatisticsList> 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<AcElementStatisticsList> 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<SimpleResponse> handleBadRequest(AutomationCompositionException ex) {
+ return RestUtils.toSimpleResponse(ex);
+ }
+
+ /**
+ * Handle PfModelRuntimeException.
+ *
+ * @param ex PfModelRuntimeException
+ * @return ResponseEntity
+ */
+ @ExceptionHandler(PfModelRuntimeException.class)
+ public ResponseEntity<SimpleResponse> handleBadRequest(PfModelRuntimeException ex) {
+ return RestUtils.toSimpleResponse(ex);
+ }
+
+ /**
+ * Handle PfModelException.
+ *
+ * @param ex PfModelException
+ * @return ResponseEntity
+ */
+ @ExceptionHandler(PfModelException.class)
+ public ResponseEntity<SimpleResponse> 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<TypedSimpleResponse<SimpleResponse>> handleError(HttpServletRequest request) {
+ Map<String, Object> 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<SimpleResponse> 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> 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<AcElementStatistics> 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<String, Object> 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> participantStatistics = new ArrayList<>();
+ try {
+ // Fetch all participantIds for a specific automation composition
+ List<ToscaConceptIdentifier> 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<String, Object> 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<AcElementStatistics> acElementStats = new ArrayList<>();
+ try {
+ List<AutomationCompositionElement> 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<ToscaConceptIdentifier> getAllParticipantIdsPerAutomationComposition(String name, String version)
+ throws PfModelException {
+ List<ToscaConceptIdentifier> 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<String, ToscaConceptIdentifier> getAllAcElementsIdPerAutomationComposition(String name, String version)
+ throws PfModelException {
+ Map<String, ToscaConceptIdentifier> 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<K> {
+ @Getter
+ @Setter
+ private long maxWaitMs;
+
+ @Getter
+ @Setter
+ private int maxRetryCount;
+
+ private Map<K, Integer> mapCounter = new HashMap<>();
+ private Set<K> mapFault = new HashSet<>();
+ private Map<K, Long> 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<K> 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.
+ *
+ * <p/>
+ * 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.
+ *
+ * <p/>
+ * 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<ToscaConceptIdentifier> 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<Map.Entry<UUID, AutomationCompositionElementAck>> 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<ToscaConceptIdentifier> automationCompositionCounter = new HandleCounter<>();
+ private final HandleCounter<ToscaConceptIdentifier> participantStatusCounter = new HandleCounter<>();
+ private final HandleCounter<Pair<ToscaConceptIdentifier, ToscaConceptIdentifier>> participantUpdateCounter =
+ new HandleCounter<>();
+
+ private final Map<ToscaConceptIdentifier, Integer> 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<ToscaConceptIdentifier, ToscaConceptIdentifier> id) {
+ participantUpdateCounter.clear(id);
+ }
+
+ public void handleParticipantUpdateAck(Pair<ToscaConceptIdentifier, ToscaConceptIdentifier> 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<E extends ParticipantAckMessage> 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<TopicSink> 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<E extends ParticipantMessage> 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<TopicSink> 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<AutomationCompositionAck>
+ implements Listener<AutomationCompositionAck> {
+ 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<AutomationCompositionAck> 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<AutomationCompositionStateChange> {
+
+ /**
+ * 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<AutomationCompositionAck>
+ implements Listener<AutomationCompositionAck> {
+ 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<AutomationCompositionAck> 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<AutomationCompositionUpdate> {
+
+ 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> 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<ParticipantDeregisterAck> {
+
+ /**
+ * 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<ParticipantDeregister>
+ implements Listener<ParticipantDeregister> {
+ 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<ParticipantDeregister> 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<ParticipantRegisterAck> {
+
+ /**
+ * 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<ParticipantRegister>
+ implements Listener<ParticipantRegister> {
+ 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<ParticipantRegister> 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<ParticipantStatus> implements Listener<ParticipantStatus> {
+ 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<ParticipantStatus> 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<ParticipantStatusReq> {
+
+ 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<ParticipantUpdateAck>
+ implements Listener<ParticipantUpdateAck> {
+ 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<ParticipantUpdateAck> 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<ParticipantUpdate> {
+
+ 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<String, ToscaNodeType> 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<ParticipantDefinition> 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<ToscaNodeTemplate> 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<ToscaNodeTemplate> 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<ToscaConceptIdentifier> 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<String, ToscaNodeTemplate> 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<String, Class<?>> 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<String, Class<?>> 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<String, ToscaNodeTemplate> 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<ToscaServiceTemplate> 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<Listener<ParticipantStatus>> 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<String, ToscaConceptIdentifier> 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<Integer>();
+ 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<Integer>();
+ 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<Integer>() {
+ 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<Participant> 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 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ ============LICENSE_START=======================================================
+ Copyright (C) 2021 Nordix Foundation.
+ ================================================================================
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+
+ SPDX-License-Identifier: Apache-2.0
+ ============LICENSE_END=========================================================
+-->
+
+<configuration>
+
+ <contextName>Apex</contextName>
+ <statusListener class="ch.qos.logback.core.status.OnConsoleStatusListener" />
+ <property name="LOG_DIR" value="${java.io.tmpdir}/clamp_logging/" />
+
+ <!-- USE FOR STD OUT ONLY -->
+ <appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender">
+ <encoder>
+ <Pattern>%d %contextName [%t] %level %logger{36} - %msg%n</Pattern>
+ </encoder>
+ </appender>
+
+ <root level="info">
+ <appender-ref ref="STDOUT" />
+ </root>
+
+ <logger name="org.onap.policy.clamp.acm.runtime" level="trace" additivity="false">
+ <appender-ref ref="STDOUT" />
+ </logger>
+</configuration>
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
+