aboutsummaryrefslogtreecommitdiffstats
path: root/participant/participant-impl
diff options
context:
space:
mode:
authorFrancescoFioraEst <francesco.fiora@est.tech>2023-02-10 15:28:50 +0000
committerFrancescoFioraEst <francesco.fiora@est.tech>2023-02-13 16:28:28 +0000
commite45da39db2625accf9ba3a77dc936a87d560fb5e (patch)
tree626de1ca14703df7dd1a81526966481cd57cc456 /participant/participant-impl
parent1191f992ddf1f6bcc94e7fa246ee3efbc71a3a8f (diff)
Deployment and undeployment on Participant Intermediary
Handle AC Element Instance Deployment and undeployment on Participant Intermediary. Issue-ID: POLICY-4507 Change-Id: I6a6976a8893450467ee609a1a476dbfa473a0e82 Signed-off-by: FrancescoFioraEst <francesco.fiora@est.tech>
Diffstat (limited to 'participant/participant-impl')
-rwxr-xr-xparticipant/participant-impl/participant-impl-a1pms/src/main/java/org/onap/policy/clamp/acm/participant/a1pms/handler/AutomationCompositionElementHandler.java65
-rwxr-xr-xparticipant/participant-impl/participant-impl-a1pms/src/test/java/org/onap/policy/clamp/acm/participant/a1pms/handler/AcElementHandlerTest.java42
-rwxr-xr-xparticipant/participant-impl/participant-impl-a1pms/src/test/java/org/onap/policy/clamp/acm/participant/a1pms/utils/CommonTestData.java12
-rw-r--r--participant/participant-impl/participant-impl-http/src/main/java/org/onap/policy/clamp/acm/participant/http/main/handler/AutomationCompositionElementHandler.java45
-rw-r--r--participant/participant-impl/participant-impl-http/src/test/java/org/onap/policy/clamp/acm/participant/http/handler/AcElementHandlerTest.java25
-rw-r--r--participant/participant-impl/participant-impl-http/src/test/java/org/onap/policy/clamp/acm/participant/http/utils/CommonTestData.java12
-rw-r--r--participant/participant-impl/participant-impl-kubernetes/src/main/java/org/onap/policy/clamp/acm/participant/kubernetes/handler/AutomationCompositionElementHandler.java72
-rw-r--r--participant/participant-impl/participant-impl-kubernetes/src/test/java/org/onap/policy/clamp/acm/participant/kubernetes/handler/AutomationCompositionElementHandlerTest.java33
-rw-r--r--participant/participant-impl/participant-impl-policy/src/main/java/org/onap/policy/clamp/acm/participant/policy/main/handler/AutomationCompositionElementHandler.java79
-rw-r--r--participant/participant-impl/participant-impl-policy/src/test/java/org/onap/policy/clamp/acm/participant/policy/main/handler/AutomationCompositionElementHandlerTest.java35
10 files changed, 134 insertions, 286 deletions
diff --git a/participant/participant-impl/participant-impl-a1pms/src/main/java/org/onap/policy/clamp/acm/participant/a1pms/handler/AutomationCompositionElementHandler.java b/participant/participant-impl/participant-impl-a1pms/src/main/java/org/onap/policy/clamp/acm/participant/a1pms/handler/AutomationCompositionElementHandler.java
index bcc3fd498..a60e7b4bb 100755
--- a/participant/participant-impl/participant-impl-a1pms/src/main/java/org/onap/policy/clamp/acm/participant/a1pms/handler/AutomationCompositionElementHandler.java
+++ b/participant/participant-impl/participant-impl-a1pms/src/main/java/org/onap/policy/clamp/acm/participant/a1pms/handler/AutomationCompositionElementHandler.java
@@ -1,6 +1,6 @@
/*-
* ============LICENSE_START=======================================================
- * Copyright (C) 2022 Nordix Foundation.
+ * Copyright (C) 2022-2023 Nordix Foundation.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -36,10 +36,9 @@ import org.onap.policy.clamp.acm.participant.a1pms.models.ConfigurationEntity;
import org.onap.policy.clamp.acm.participant.a1pms.webclient.AcA1PmsClient;
import org.onap.policy.clamp.acm.participant.intermediary.api.AutomationCompositionElementListener;
import org.onap.policy.clamp.acm.participant.intermediary.api.ParticipantIntermediaryApi;
-import org.onap.policy.clamp.models.acm.concepts.AutomationCompositionElement;
-import org.onap.policy.clamp.models.acm.concepts.AutomationCompositionOrderedState;
-import org.onap.policy.clamp.models.acm.concepts.AutomationCompositionState;
-import org.onap.policy.clamp.models.acm.messages.dmaap.participant.ParticipantMessageType;
+import org.onap.policy.clamp.models.acm.concepts.AcElementDeploy;
+import org.onap.policy.clamp.models.acm.concepts.DeployState;
+import org.onap.policy.clamp.models.acm.concepts.LockState;
import org.onap.policy.common.utils.coder.Coder;
import org.onap.policy.common.utils.coder.CoderException;
import org.onap.policy.common.utils.coder.StandardCoder;
@@ -73,42 +72,20 @@ public class AutomationCompositionElementHandler implements AutomationCompositio
*
* @param automationCompositionId the ID of the automation composition
* @param automationCompositionElementId the ID of the automation composition element
- * @param currentState the current state of the automation composition element
- * @param newState the state to which the automation composition element is changing to
* @throws PfModelException in case of a model exception
*/
@Override
- public void automationCompositionElementStateChange(UUID automationCompositionId,
- UUID automationCompositionElementId, AutomationCompositionState currentState,
- AutomationCompositionOrderedState newState) throws A1PolicyServiceException {
- switch (newState) {
- case UNINITIALISED:
- var configurationEntity = configRequestMap.get(automationCompositionElementId);
- if (configurationEntity != null && acA1PmsClient.isPmsHealthy()) {
- acA1PmsClient.deleteService(configurationEntity.getPolicyServiceEntities());
- configRequestMap.remove(automationCompositionElementId);
- intermediaryApi.updateAutomationCompositionElementState(automationCompositionId,
- automationCompositionElementId, newState, AutomationCompositionState.UNINITIALISED,
- ParticipantMessageType.AUTOMATION_COMPOSITION_STATE_CHANGE);
- } else {
- LOGGER.warn("Failed to connect with A1PMS. Service configuration is: {}", configurationEntity);
- throw new A1PolicyServiceException(HttpStatus.SC_SERVICE_UNAVAILABLE,
- "Unable to connect with A1PMS");
- }
- break;
- case PASSIVE:
- intermediaryApi.updateAutomationCompositionElementState(automationCompositionId,
- automationCompositionElementId, newState, AutomationCompositionState.PASSIVE,
- ParticipantMessageType.AUTOMATION_COMPOSITION_STATE_CHANGE);
- break;
- case RUNNING:
- intermediaryApi.updateAutomationCompositionElementState(automationCompositionId,
- automationCompositionElementId, newState, AutomationCompositionState.RUNNING,
- ParticipantMessageType.AUTOMATION_COMPOSITION_STATE_CHANGE);
- break;
- default:
- LOGGER.warn("Cannot transition from state {} to state {}", currentState, newState);
- break;
+ public void undeploy(UUID automationCompositionId, UUID automationCompositionElementId)
+ throws A1PolicyServiceException {
+ var configurationEntity = configRequestMap.get(automationCompositionElementId);
+ if (configurationEntity != null && acA1PmsClient.isPmsHealthy()) {
+ acA1PmsClient.deleteService(configurationEntity.getPolicyServiceEntities());
+ configRequestMap.remove(automationCompositionElementId);
+ intermediaryApi.updateAutomationCompositionElementState(automationCompositionId,
+ automationCompositionElementId, DeployState.UNDEPLOYED, LockState.NONE);
+ } else {
+ LOGGER.warn("Failed to connect with A1PMS. Service configuration is: {}", configurationEntity);
+ throw new A1PolicyServiceException(HttpStatus.SC_SERVICE_UNAVAILABLE, "Unable to connect with A1PMS");
}
}
@@ -116,24 +93,22 @@ public class AutomationCompositionElementHandler implements AutomationCompositio
* Callback method to handle an update on an automation composition element.
*
* @param automationCompositionId the ID of the automation composition
- * @param element the information on the automation composition element
+ * @param element the information on the automation composition element
* @param properties properties Map
*/
@Override
- public void automationCompositionElementUpdate(UUID automationCompositionId,
- AutomationCompositionElement element, Map<String, Object> properties) throws A1PolicyServiceException {
+ public void deploy(UUID automationCompositionId, AcElementDeploy element, Map<String, Object> properties)
+ throws A1PolicyServiceException {
try {
var configurationEntity = CODER.convert(properties, ConfigurationEntity.class);
- var violations =
- Validation.buildDefaultValidatorFactory().getValidator().validate(configurationEntity);
+ var violations = Validation.buildDefaultValidatorFactory().getValidator().validate(configurationEntity);
if (violations.isEmpty()) {
if (acA1PmsClient.isPmsHealthy()) {
acA1PmsClient.createService(configurationEntity.getPolicyServiceEntities());
configRequestMap.put(element.getId(), configurationEntity);
intermediaryApi.updateAutomationCompositionElementState(automationCompositionId, element.getId(),
- AutomationCompositionOrderedState.PASSIVE, AutomationCompositionState.PASSIVE,
- ParticipantMessageType.AUTOMATION_COMPOSITION_STATE_CHANGE);
+ DeployState.DEPLOYED, LockState.LOCKED);
} else {
LOGGER.error("Failed to connect with A1PMS");
throw new A1PolicyServiceException(HttpStatus.SC_SERVICE_UNAVAILABLE,
diff --git a/participant/participant-impl/participant-impl-a1pms/src/test/java/org/onap/policy/clamp/acm/participant/a1pms/handler/AcElementHandlerTest.java b/participant/participant-impl/participant-impl-a1pms/src/test/java/org/onap/policy/clamp/acm/participant/a1pms/handler/AcElementHandlerTest.java
index ce775b616..a39076697 100755
--- a/participant/participant-impl/participant-impl-a1pms/src/test/java/org/onap/policy/clamp/acm/participant/a1pms/handler/AcElementHandlerTest.java
+++ b/participant/participant-impl/participant-impl-a1pms/src/test/java/org/onap/policy/clamp/acm/participant/a1pms/handler/AcElementHandlerTest.java
@@ -1,6 +1,6 @@
/*-
* ============LICENSE_START=======================================================
- * Copyright (C) 2022 Nordix Foundation.
+ * Copyright (C) 2022-2023 Nordix Foundation.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -39,8 +39,6 @@ import org.onap.policy.clamp.acm.participant.a1pms.utils.CommonTestData;
import org.onap.policy.clamp.acm.participant.a1pms.utils.ToscaUtils;
import org.onap.policy.clamp.acm.participant.a1pms.webclient.AcA1PmsClient;
import org.onap.policy.clamp.acm.participant.intermediary.api.ParticipantIntermediaryApi;
-import org.onap.policy.clamp.models.acm.concepts.AutomationCompositionOrderedState;
-import org.onap.policy.clamp.models.acm.concepts.AutomationCompositionState;
import org.onap.policy.models.tosca.authorative.concepts.ToscaServiceTemplate;
import org.springframework.test.context.junit.jupiter.SpringExtension;
@@ -79,27 +77,17 @@ class AcElementHandlerTest {
var automationCompositionElementId = element.getId();
var nodeTemplatesMap = serviceTemplate.getToscaTopologyTemplate().getNodeTemplates();
- automationCompositionElementHandler
- .automationCompositionElementUpdate(commonTestData.getAutomationCompositionId(), element,
- nodeTemplatesMap.get(A1_AUTOMATION_COMPOSITION_ELEMENT).getProperties());
+ automationCompositionElementHandler.deploy(
+ commonTestData.getAutomationCompositionId(), element,
+ nodeTemplatesMap.get(A1_AUTOMATION_COMPOSITION_ELEMENT).getProperties());
- assertDoesNotThrow(() -> automationCompositionElementHandler.automationCompositionElementStateChange(
- automationCompositionId, automationCompositionElementId, AutomationCompositionState.PASSIVE,
- AutomationCompositionOrderedState.PASSIVE));
-
- assertDoesNotThrow(() -> automationCompositionElementHandler.automationCompositionElementStateChange(
- automationCompositionId, automationCompositionElementId, AutomationCompositionState.PASSIVE,
- AutomationCompositionOrderedState.UNINITIALISED));
-
- assertDoesNotThrow(() -> automationCompositionElementHandler.automationCompositionElementStateChange(
- automationCompositionId, automationCompositionElementId, AutomationCompositionState.PASSIVE,
- AutomationCompositionOrderedState.RUNNING));
+ assertDoesNotThrow(() -> automationCompositionElementHandler.undeploy(
+ automationCompositionId, automationCompositionElementId));
when(acA1PmsClient.isPmsHealthy()).thenReturn(Boolean.FALSE);
assertThrows(A1PolicyServiceException.class,
- () -> automationCompositionElementHandler.automationCompositionElementStateChange(
- automationCompositionId, automationCompositionElementId, AutomationCompositionState.PASSIVE,
- AutomationCompositionOrderedState.UNINITIALISED));
+ () -> automationCompositionElementHandler.undeploy(
+ automationCompositionId, automationCompositionElementId));
}
@Test
@@ -107,9 +95,9 @@ class AcElementHandlerTest {
var element = commonTestData.getAutomationCompositionElement();
var nodeTemplatesMap = serviceTemplate.getToscaTopologyTemplate().getNodeTemplates();
- assertDoesNotThrow(() -> automationCompositionElementHandler
- .automationCompositionElementUpdate(commonTestData.getAutomationCompositionId(), element,
- nodeTemplatesMap.get(A1_AUTOMATION_COMPOSITION_ELEMENT).getProperties()));
+ assertDoesNotThrow(() -> automationCompositionElementHandler.deploy(
+ commonTestData.getAutomationCompositionId(), element,
+ nodeTemplatesMap.get(A1_AUTOMATION_COMPOSITION_ELEMENT).getProperties()));
}
@Test
@@ -118,8 +106,9 @@ class AcElementHandlerTest {
when(acA1PmsClient.isPmsHealthy()).thenReturn(Boolean.FALSE);
var nodeTemplatesMap = serviceTemplate.getToscaTopologyTemplate().getNodeTemplates();
- assertThrows(A1PolicyServiceException.class, () -> automationCompositionElementHandler
- .automationCompositionElementUpdate(commonTestData.getAutomationCompositionId(), element,
+ assertThrows(A1PolicyServiceException.class,
+ () -> automationCompositionElementHandler.deploy(
+ commonTestData.getAutomationCompositionId(), element,
nodeTemplatesMap.get(A1_AUTOMATION_COMPOSITION_ELEMENT).getProperties()));
}
@@ -127,7 +116,6 @@ class AcElementHandlerTest {
void test_AutomationCompositionElementUpdateWithInvalidConfiguration() {
var element = commonTestData.getAutomationCompositionElement();
assertThrows(A1PolicyServiceException.class, () -> automationCompositionElementHandler
- .automationCompositionElementUpdate(commonTestData.getAutomationCompositionId(), element,
- Map.of()));
+ .deploy(commonTestData.getAutomationCompositionId(), element, Map.of()));
}
}
diff --git a/participant/participant-impl/participant-impl-a1pms/src/test/java/org/onap/policy/clamp/acm/participant/a1pms/utils/CommonTestData.java b/participant/participant-impl/participant-impl-a1pms/src/test/java/org/onap/policy/clamp/acm/participant/a1pms/utils/CommonTestData.java
index b68faa692..d31e81fe8 100755
--- a/participant/participant-impl/participant-impl-a1pms/src/test/java/org/onap/policy/clamp/acm/participant/a1pms/utils/CommonTestData.java
+++ b/participant/participant-impl/participant-impl-a1pms/src/test/java/org/onap/policy/clamp/acm/participant/a1pms/utils/CommonTestData.java
@@ -1,6 +1,6 @@
/*-
* ============LICENSE_START=======================================================
- * Copyright (C) 2022 Nordix Foundation.
+ * Copyright (C) 2022-2023 Nordix Foundation.
* Modifications Copyright (C) 2022 AT&T Intellectual Property. All rights reserved.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
@@ -24,8 +24,8 @@ package org.onap.policy.clamp.acm.participant.a1pms.utils;
import java.util.List;
import java.util.UUID;
import org.onap.policy.clamp.acm.participant.a1pms.models.A1PolicyServiceEntity;
-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.AcElementDeploy;
+import org.onap.policy.clamp.models.acm.messages.rest.instantiation.DeployOrder;
import org.onap.policy.models.tosca.authorative.concepts.ToscaConceptIdentifier;
public class CommonTestData {
@@ -38,11 +38,11 @@ public class CommonTestData {
*
* @return automationCompositionElement object
*/
- public AutomationCompositionElement getAutomationCompositionElement() {
- var element = new AutomationCompositionElement();
+ public AcElementDeploy getAutomationCompositionElement() {
+ var element = new AcElementDeploy();
element.setId(UUID.randomUUID());
element.setDefinition(new ToscaConceptIdentifier(TEST_KEY_NAME, "1.0.1"));
- element.setOrderedState(AutomationCompositionOrderedState.PASSIVE);
+ element.setOrderedState(DeployOrder.DEPLOY);
return element;
}
diff --git a/participant/participant-impl/participant-impl-http/src/main/java/org/onap/policy/clamp/acm/participant/http/main/handler/AutomationCompositionElementHandler.java b/participant/participant-impl/participant-impl-http/src/main/java/org/onap/policy/clamp/acm/participant/http/main/handler/AutomationCompositionElementHandler.java
index 42b26c6a4..c62216dfc 100644
--- a/participant/participant-impl/participant-impl-http/src/main/java/org/onap/policy/clamp/acm/participant/http/main/handler/AutomationCompositionElementHandler.java
+++ b/participant/participant-impl/participant-impl-http/src/main/java/org/onap/policy/clamp/acm/participant/http/main/handler/AutomationCompositionElementHandler.java
@@ -1,6 +1,6 @@
/*-
* ============LICENSE_START=======================================================
- * Copyright (C) 2021-2022 Nordix Foundation.
+ * Copyright (C) 2021-2023 Nordix Foundation.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -38,10 +38,9 @@ import org.onap.policy.clamp.acm.participant.http.main.models.ConfigRequest;
import org.onap.policy.clamp.acm.participant.http.main.webclient.AcHttpClient;
import org.onap.policy.clamp.acm.participant.intermediary.api.AutomationCompositionElementListener;
import org.onap.policy.clamp.acm.participant.intermediary.api.ParticipantIntermediaryApi;
-import org.onap.policy.clamp.models.acm.concepts.AutomationCompositionElement;
-import org.onap.policy.clamp.models.acm.concepts.AutomationCompositionOrderedState;
-import org.onap.policy.clamp.models.acm.concepts.AutomationCompositionState;
-import org.onap.policy.clamp.models.acm.messages.dmaap.participant.ParticipantMessageType;
+import org.onap.policy.clamp.models.acm.concepts.AcElementDeploy;
+import org.onap.policy.clamp.models.acm.concepts.DeployState;
+import org.onap.policy.clamp.models.acm.concepts.LockState;
import org.onap.policy.common.utils.coder.Coder;
import org.onap.policy.common.utils.coder.CoderException;
import org.onap.policy.common.utils.coder.StandardCoder;
@@ -73,34 +72,13 @@ public class AutomationCompositionElementHandler implements AutomationCompositio
* Handle a automation composition element state change.
*
* @param automationCompositionElementId the ID of the automation composition element
- * @param currentState the current state of the automation composition element
- * @param newState the state to which the automation composition element is changing to
* @throws PfModelException in case of a model exception
*/
@Override
- public void automationCompositionElementStateChange(UUID automationCompositionId,
- UUID automationCompositionElementId, AutomationCompositionState currentState,
- AutomationCompositionOrderedState newState) {
- switch (newState) {
- case UNINITIALISED:
- intermediaryApi.updateAutomationCompositionElementState(automationCompositionId,
- automationCompositionElementId, newState, AutomationCompositionState.UNINITIALISED,
- ParticipantMessageType.AUTOMATION_COMPOSITION_STATE_CHANGE);
- break;
- case PASSIVE:
- intermediaryApi.updateAutomationCompositionElementState(automationCompositionId,
- automationCompositionElementId, newState, AutomationCompositionState.PASSIVE,
- ParticipantMessageType.AUTOMATION_COMPOSITION_STATE_CHANGE);
- break;
- case RUNNING:
- intermediaryApi.updateAutomationCompositionElementState(automationCompositionId,
- automationCompositionElementId, newState, AutomationCompositionState.RUNNING,
- ParticipantMessageType.AUTOMATION_COMPOSITION_STATE_CHANGE);
- break;
- default:
- LOGGER.warn("Cannot transition from state {} to state {}", currentState, newState);
- break;
- }
+ public void undeploy(UUID automationCompositionId,
+ UUID automationCompositionElementId) {
+ intermediaryApi.updateAutomationCompositionElementState(automationCompositionId,
+ automationCompositionElementId, DeployState.UNDEPLOYED, LockState.NONE);
}
/**
@@ -111,8 +89,8 @@ public class AutomationCompositionElementHandler implements AutomationCompositio
* @param properties properties Map
*/
@Override
- public void automationCompositionElementUpdate(UUID automationCompositionId,
- AutomationCompositionElement element, Map<String, Object> properties) {
+ public void deploy(UUID automationCompositionId,
+ AcElementDeploy element, Map<String, Object> properties) {
try {
var configRequest = CODER.convert(properties, ConfigRequest.class);
var violations =
@@ -124,8 +102,7 @@ public class AutomationCompositionElementHandler implements AutomationCompositio
.is2xxSuccessful()).collect(Collectors.toList());
if (failedResponseStatus.isEmpty()) {
intermediaryApi.updateAutomationCompositionElementState(automationCompositionId, element.getId(),
- AutomationCompositionOrderedState.PASSIVE, AutomationCompositionState.PASSIVE,
- ParticipantMessageType.AUTOMATION_COMPOSITION_STATE_CHANGE);
+ DeployState.DEPLOYED, LockState.LOCKED);
} else {
LOGGER.error("Error on Invoking the http request: {}", failedResponseStatus);
}
diff --git a/participant/participant-impl/participant-impl-http/src/test/java/org/onap/policy/clamp/acm/participant/http/handler/AcElementHandlerTest.java b/participant/participant-impl/participant-impl-http/src/test/java/org/onap/policy/clamp/acm/participant/http/handler/AcElementHandlerTest.java
index 8e77b2acc..857490ef5 100644
--- a/participant/participant-impl/participant-impl-http/src/test/java/org/onap/policy/clamp/acm/participant/http/handler/AcElementHandlerTest.java
+++ b/participant/participant-impl/participant-impl-http/src/test/java/org/onap/policy/clamp/acm/participant/http/handler/AcElementHandlerTest.java
@@ -1,6 +1,6 @@
/*-
* ============LICENSE_START=======================================================
- * Copyright (C) 2021-2022 Nordix Foundation.
+ * Copyright (C) 2021-2023 Nordix Foundation.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -38,8 +38,6 @@ import org.onap.policy.clamp.acm.participant.http.main.models.ConfigRequest;
import org.onap.policy.clamp.acm.participant.http.utils.CommonTestData;
import org.onap.policy.clamp.acm.participant.http.utils.ToscaUtils;
import org.onap.policy.clamp.acm.participant.intermediary.api.ParticipantIntermediaryApi;
-import org.onap.policy.clamp.models.acm.concepts.AutomationCompositionOrderedState;
-import org.onap.policy.clamp.models.acm.concepts.AutomationCompositionState;
import org.onap.policy.models.tosca.authorative.concepts.ToscaServiceTemplate;
import org.springframework.test.context.junit.jupiter.SpringExtension;
@@ -49,13 +47,13 @@ class AcElementHandlerTest {
@InjectMocks
@Spy
private AutomationCompositionElementHandler automationCompositionElementHandler =
- new AutomationCompositionElementHandler();
+ new AutomationCompositionElementHandler();
private final CommonTestData commonTestData = new CommonTestData();
private static ToscaServiceTemplate serviceTemplate;
private static final String HTTP_AUTOMATION_COMPOSITION_ELEMENT =
- "org.onap.domain.database.Http_PMSHMicroserviceAutomationCompositionElement";
+ "org.onap.domain.database.Http_PMSHMicroserviceAutomationCompositionElement";
@BeforeAll
static void init() {
@@ -76,17 +74,8 @@ class AcElementHandlerTest {
var config = Mockito.mock(ConfigRequest.class);
assertDoesNotThrow(() -> automationCompositionElementHandler.invokeHttpClient(config));
- assertDoesNotThrow(() -> automationCompositionElementHandler.automationCompositionElementStateChange(
- automationCompositionId, automationCompositionElementId, AutomationCompositionState.PASSIVE,
- AutomationCompositionOrderedState.PASSIVE));
-
- assertDoesNotThrow(() -> automationCompositionElementHandler.automationCompositionElementStateChange(
- automationCompositionId, automationCompositionElementId, AutomationCompositionState.PASSIVE,
- AutomationCompositionOrderedState.UNINITIALISED));
-
- assertDoesNotThrow(() -> automationCompositionElementHandler.automationCompositionElementStateChange(
- automationCompositionId, automationCompositionElementId, AutomationCompositionState.PASSIVE,
- AutomationCompositionOrderedState.RUNNING));
+ assertDoesNotThrow(() -> automationCompositionElementHandler.undeploy(
+ automationCompositionId, automationCompositionElementId));
automationCompositionElementHandler.close();
}
@@ -100,7 +89,7 @@ class AcElementHandlerTest {
var map = new HashMap<>(nodeTemplatesMap.get(HTTP_AUTOMATION_COMPOSITION_ELEMENT).getProperties());
map.putAll(element.getProperties());
- assertDoesNotThrow(() -> automationCompositionElementHandler.automationCompositionElementUpdate(
- commonTestData.getAutomationCompositionId(), element, map));
+ assertDoesNotThrow(() -> automationCompositionElementHandler
+ .deploy(commonTestData.getAutomationCompositionId(), element, map));
}
}
diff --git a/participant/participant-impl/participant-impl-http/src/test/java/org/onap/policy/clamp/acm/participant/http/utils/CommonTestData.java b/participant/participant-impl/participant-impl-http/src/test/java/org/onap/policy/clamp/acm/participant/http/utils/CommonTestData.java
index 48b7bdcd7..7ae9b3359 100644
--- a/participant/participant-impl/participant-impl-http/src/test/java/org/onap/policy/clamp/acm/participant/http/utils/CommonTestData.java
+++ b/participant/participant-impl/participant-impl-http/src/test/java/org/onap/policy/clamp/acm/participant/http/utils/CommonTestData.java
@@ -1,6 +1,6 @@
/*-
* ============LICENSE_START=======================================================
- * Copyright (C) 2021-2022 Nordix Foundation.
+ * Copyright (C) 2021-2023 Nordix Foundation.
* Modifications Copyright (C) 2021 AT&T Intellectual Property. All rights reserved.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
@@ -26,8 +26,8 @@ import java.util.Map;
import java.util.UUID;
import org.onap.policy.clamp.acm.participant.http.main.models.ConfigurationEntity;
import org.onap.policy.clamp.acm.participant.http.main.models.RestParams;
-import org.onap.policy.clamp.models.acm.concepts.AutomationCompositionElement;
-import org.onap.policy.clamp.models.acm.concepts.AutomationCompositionOrderedState;
+import org.onap.policy.clamp.models.acm.concepts.AcElementDeploy;
+import org.onap.policy.clamp.models.acm.messages.rest.instantiation.DeployOrder;
import org.onap.policy.models.tosca.authorative.concepts.ToscaConceptIdentifier;
public class CommonTestData {
@@ -41,11 +41,11 @@ public class CommonTestData {
*
* @return automationCompositionElement object
*/
- public AutomationCompositionElement getAutomationCompositionElement() {
- AutomationCompositionElement element = new AutomationCompositionElement();
+ public AcElementDeploy getAutomationCompositionElement() {
+ var element = new AcElementDeploy();
element.setId(UUID.randomUUID());
element.setDefinition(new ToscaConceptIdentifier(TEST_KEY_NAME, "1.0.1"));
- element.setOrderedState(AutomationCompositionOrderedState.PASSIVE);
+ element.setOrderedState(DeployOrder.DEPLOY);
return element;
}
diff --git a/participant/participant-impl/participant-impl-kubernetes/src/main/java/org/onap/policy/clamp/acm/participant/kubernetes/handler/AutomationCompositionElementHandler.java b/participant/participant-impl/participant-impl-kubernetes/src/main/java/org/onap/policy/clamp/acm/participant/kubernetes/handler/AutomationCompositionElementHandler.java
index c64bc4906..3233cdc06 100644
--- a/participant/participant-impl/participant-impl-kubernetes/src/main/java/org/onap/policy/clamp/acm/participant/kubernetes/handler/AutomationCompositionElementHandler.java
+++ b/participant/participant-impl/participant-impl-kubernetes/src/main/java/org/onap/policy/clamp/acm/participant/kubernetes/handler/AutomationCompositionElementHandler.java
@@ -1,6 +1,6 @@
/*-
* ============LICENSE_START=======================================================
- * Copyright (C) 2021-2022 Nordix Foundation.
+ * Copyright (C) 2021-2023 Nordix Foundation.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -38,10 +38,9 @@ import org.onap.policy.clamp.acm.participant.kubernetes.exception.ServiceExcepti
import org.onap.policy.clamp.acm.participant.kubernetes.helm.PodStatusValidator;
import org.onap.policy.clamp.acm.participant.kubernetes.models.ChartInfo;
import org.onap.policy.clamp.acm.participant.kubernetes.service.ChartService;
-import org.onap.policy.clamp.models.acm.concepts.AutomationCompositionElement;
-import org.onap.policy.clamp.models.acm.concepts.AutomationCompositionOrderedState;
-import org.onap.policy.clamp.models.acm.concepts.AutomationCompositionState;
-import org.onap.policy.clamp.models.acm.messages.dmaap.participant.ParticipantMessageType;
+import org.onap.policy.clamp.models.acm.concepts.AcElementDeploy;
+import org.onap.policy.clamp.models.acm.concepts.DeployState;
+import org.onap.policy.clamp.models.acm.concepts.LockState;
import org.onap.policy.common.utils.coder.Coder;
import org.onap.policy.common.utils.coder.CoderException;
import org.onap.policy.common.utils.coder.StandardCoder;
@@ -85,43 +84,21 @@ public class AutomationCompositionElementHandler implements AutomationCompositio
* Callback method to handle a automation composition element state change.
*
* @param automationCompositionElementId the ID of the automation composition element
- * @param currentState the current state of the automation composition element
- * @param newState the state to which the automation composition element is changing to
*/
@Override
- public synchronized void automationCompositionElementStateChange(UUID automationCompositionId,
- UUID automationCompositionElementId, AutomationCompositionState currentState,
- AutomationCompositionOrderedState newState) {
- switch (newState) {
- case UNINITIALISED:
- var chart = chartMap.get(automationCompositionElementId);
- if (chart != null) {
- LOGGER.info("Helm deployment to be deleted {} ", chart.getReleaseName());
- try {
- chartService.uninstallChart(chart);
- intermediaryApi.updateAutomationCompositionElementState(automationCompositionId,
- automationCompositionElementId, newState, AutomationCompositionState.UNINITIALISED,
- ParticipantMessageType.AUTOMATION_COMPOSITION_STATE_CHANGE);
- chartMap.remove(automationCompositionElementId);
- podStatusMap.remove(chart.getReleaseName());
- } catch (ServiceException se) {
- LOGGER.warn("Deletion of Helm deployment failed", se);
- }
- }
- break;
- case PASSIVE:
+ public synchronized void undeploy(UUID automationCompositionId, UUID automationCompositionElementId) {
+ var chart = chartMap.get(automationCompositionElementId);
+ if (chart != null) {
+ LOGGER.info("Helm deployment to be deleted {} ", chart.getReleaseName());
+ try {
+ chartService.uninstallChart(chart);
intermediaryApi.updateAutomationCompositionElementState(automationCompositionId,
- automationCompositionElementId, newState, AutomationCompositionState.PASSIVE,
- ParticipantMessageType.AUTOMATION_COMPOSITION_STATE_CHANGE);
- break;
- case RUNNING:
- intermediaryApi.updateAutomationCompositionElementState(automationCompositionId,
- automationCompositionElementId, newState, AutomationCompositionState.RUNNING,
- ParticipantMessageType.AUTOMATION_COMPOSITION_STATE_CHANGE);
- break;
- default:
- LOGGER.warn("Cannot transition from state {} to state {}", currentState, newState);
- break;
+ automationCompositionElementId, DeployState.UNDEPLOYED, LockState.NONE);
+ chartMap.remove(automationCompositionElementId);
+ podStatusMap.remove(chart.getReleaseName());
+ } catch (ServiceException se) {
+ LOGGER.warn("Deletion of Helm deployment failed", se);
+ }
}
}
@@ -134,8 +111,8 @@ public class AutomationCompositionElementHandler implements AutomationCompositio
* @throws PfModelException in case of an exception
*/
@Override
- public synchronized void automationCompositionElementUpdate(UUID automationCompositionId,
- AutomationCompositionElement element, Map<String, Object> properties) throws PfModelException {
+ public synchronized void deploy(UUID automationCompositionId, AcElementDeploy element,
+ Map<String, Object> properties) throws PfModelException {
@SuppressWarnings("unchecked")
var chartData = (Map<String, Object>) properties.get("chart");
@@ -149,8 +126,7 @@ public class AutomationCompositionElementHandler implements AutomationCompositio
checkPodStatus(automationCompositionId, element.getId(), chartInfo,
config.uninitializedToPassiveTimeout, config.podStatusCheckInterval);
}
- } catch (ServiceException | CoderException | IOException | ExecutionException
- | InterruptedException e) {
+ } catch (ServiceException | CoderException | IOException | ExecutionException | InterruptedException e) {
LOGGER.warn("Installation of Helm chart failed", e);
}
}
@@ -160,16 +136,14 @@ public class AutomationCompositionElementHandler implements AutomationCompositio
*
* @param chart ChartInfo
*/
- public void checkPodStatus(UUID automationCompositionId, UUID elementId,
- ChartInfo chart, int timeout, int podStatusCheckInterval) throws ExecutionException, InterruptedException {
+ public void checkPodStatus(UUID automationCompositionId, UUID elementId, ChartInfo chart, int timeout,
+ int podStatusCheckInterval) throws ExecutionException, InterruptedException {
// Invoke runnable thread to check pod status
- var result = executor.submit(new PodStatusValidator(chart, timeout,
- podStatusCheckInterval), "Done");
+ var result = executor.submit(new PodStatusValidator(chart, timeout, podStatusCheckInterval), "Done");
if (!result.get().isEmpty()) {
LOGGER.info("Pod Status Validator Completed: {}", result.isDone());
intermediaryApi.updateAutomationCompositionElementState(automationCompositionId, elementId,
- AutomationCompositionOrderedState.PASSIVE, AutomationCompositionState.PASSIVE,
- ParticipantMessageType.AUTOMATION_COMPOSITION_STATE_CHANGE);
+ DeployState.DEPLOYED, LockState.LOCKED);
}
}
}
diff --git a/participant/participant-impl/participant-impl-kubernetes/src/test/java/org/onap/policy/clamp/acm/participant/kubernetes/handler/AutomationCompositionElementHandlerTest.java b/participant/participant-impl/participant-impl-kubernetes/src/test/java/org/onap/policy/clamp/acm/participant/kubernetes/handler/AutomationCompositionElementHandlerTest.java
index f1357e435..ee0039c3f 100644
--- a/participant/participant-impl/participant-impl-kubernetes/src/test/java/org/onap/policy/clamp/acm/participant/kubernetes/handler/AutomationCompositionElementHandlerTest.java
+++ b/participant/participant-impl/participant-impl-kubernetes/src/test/java/org/onap/policy/clamp/acm/participant/kubernetes/handler/AutomationCompositionElementHandlerTest.java
@@ -1,6 +1,6 @@
/*-
* ============LICENSE_START=======================================================
- * Copyright (C) 2021-2022 Nordix Foundation.
+ * Copyright (C) 2021-2023 Nordix Foundation.
* Modifications Copyright (C) 2021 AT&T Intellectual Property. All rights reserved.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
@@ -50,9 +50,9 @@ import org.onap.policy.clamp.acm.participant.kubernetes.models.ChartList;
import org.onap.policy.clamp.acm.participant.kubernetes.parameters.CommonTestData;
import org.onap.policy.clamp.acm.participant.kubernetes.service.ChartService;
import org.onap.policy.clamp.acm.participant.kubernetes.utils.TestUtils;
+import org.onap.policy.clamp.models.acm.concepts.AcElementDeploy;
import org.onap.policy.clamp.models.acm.concepts.AutomationCompositionElement;
-import org.onap.policy.clamp.models.acm.concepts.AutomationCompositionOrderedState;
-import org.onap.policy.clamp.models.acm.concepts.AutomationCompositionState;
+import org.onap.policy.clamp.models.acm.messages.rest.instantiation.DeployOrder;
import org.onap.policy.common.utils.coder.Coder;
import org.onap.policy.common.utils.coder.CoderException;
import org.onap.policy.common.utils.coder.StandardCoder;
@@ -106,24 +106,13 @@ class AutomationCompositionElementHandlerTest {
doNothing().when(chartService).uninstallChart(charts.get(0));
- automationCompositionElementHandler.automationCompositionElementStateChange(
- commonTestData.getAutomationCompositionId(), automationCompositionElementId1,
- AutomationCompositionState.PASSIVE, AutomationCompositionOrderedState.UNINITIALISED);
+ automationCompositionElementHandler.undeploy(
+ commonTestData.getAutomationCompositionId(), automationCompositionElementId1);
doThrow(new ServiceException("Error uninstalling the chart")).when(chartService).uninstallChart(charts.get(0));
- assertDoesNotThrow(() -> automationCompositionElementHandler.automationCompositionElementStateChange(
- commonTestData.getAutomationCompositionId(), automationCompositionElementId1,
- AutomationCompositionState.PASSIVE, AutomationCompositionOrderedState.PASSIVE));
-
- assertDoesNotThrow(() -> automationCompositionElementHandler.automationCompositionElementStateChange(
- commonTestData.getAutomationCompositionId(), automationCompositionElementId1,
- AutomationCompositionState.PASSIVE, AutomationCompositionOrderedState.UNINITIALISED));
-
- assertDoesNotThrow(() -> automationCompositionElementHandler.automationCompositionElementStateChange(
- commonTestData.getAutomationCompositionId(), automationCompositionElementId1,
- AutomationCompositionState.PASSIVE, AutomationCompositionOrderedState.RUNNING));
-
+ assertDoesNotThrow(() -> automationCompositionElementHandler.undeploy(
+ commonTestData.getAutomationCompositionId(), automationCompositionElementId1));
}
@Test
@@ -132,14 +121,14 @@ class AutomationCompositionElementHandlerTest {
doReturn(true).when(chartService).installChart(any());
doNothing().when(automationCompositionElementHandler).checkPodStatus(any(), any(), any(), anyInt(), anyInt());
var elementId1 = UUID.randomUUID();
- var element = new AutomationCompositionElement();
+ var element = new AcElementDeploy();
element.setId(elementId1);
element.setDefinition(new ToscaConceptIdentifier(KEY_NAME, "1.0.1"));
- element.setOrderedState(AutomationCompositionOrderedState.PASSIVE);
+ element.setOrderedState(DeployOrder.DEPLOY);
var nodeTemplatesMap =
toscaServiceTemplate.getToscaTopologyTemplate().getNodeTemplates();
- automationCompositionElementHandler.automationCompositionElementUpdate(
+ automationCompositionElementHandler.deploy(
commonTestData.getAutomationCompositionId(), element,
nodeTemplatesMap.get(K8S_AUTOMATION_COMPOSITION_ELEMENT).getProperties());
@@ -149,7 +138,7 @@ class AutomationCompositionElementHandlerTest {
var elementId2 = UUID.randomUUID();
element.setId(elementId2);
- automationCompositionElementHandler.automationCompositionElementUpdate(
+ automationCompositionElementHandler.deploy(
commonTestData.getAutomationCompositionId(), element,
nodeTemplatesMap.get(K8S_AUTOMATION_COMPOSITION_ELEMENT).getProperties());
diff --git a/participant/participant-impl/participant-impl-policy/src/main/java/org/onap/policy/clamp/acm/participant/policy/main/handler/AutomationCompositionElementHandler.java b/participant/participant-impl/participant-impl-policy/src/main/java/org/onap/policy/clamp/acm/participant/policy/main/handler/AutomationCompositionElementHandler.java
index ca27c8214..0b03e236f 100644
--- a/participant/participant-impl/participant-impl-policy/src/main/java/org/onap/policy/clamp/acm/participant/policy/main/handler/AutomationCompositionElementHandler.java
+++ b/participant/participant-impl/participant-impl-policy/src/main/java/org/onap/policy/clamp/acm/participant/policy/main/handler/AutomationCompositionElementHandler.java
@@ -1,6 +1,6 @@
/*-
* ============LICENSE_START=======================================================
- * Copyright (C) 2021,2022 Nordix Foundation.
+ * Copyright (C) 2021-2023 Nordix Foundation.
* ================================================================================
* Modifications Copyright (C) 2021 AT&T Intellectual Property. All rights reserved.
* ================================================================================
@@ -31,10 +31,9 @@ import org.onap.policy.clamp.acm.participant.intermediary.api.AutomationComposit
import org.onap.policy.clamp.acm.participant.intermediary.api.ParticipantIntermediaryApi;
import org.onap.policy.clamp.acm.participant.policy.client.PolicyApiHttpClient;
import org.onap.policy.clamp.acm.participant.policy.client.PolicyPapHttpClient;
-import org.onap.policy.clamp.models.acm.concepts.AutomationCompositionElement;
-import org.onap.policy.clamp.models.acm.concepts.AutomationCompositionOrderedState;
-import org.onap.policy.clamp.models.acm.concepts.AutomationCompositionState;
-import org.onap.policy.clamp.models.acm.messages.dmaap.participant.ParticipantMessageType;
+import org.onap.policy.clamp.models.acm.concepts.AcElementDeploy;
+import org.onap.policy.clamp.models.acm.concepts.DeployState;
+import org.onap.policy.clamp.models.acm.concepts.LockState;
import org.onap.policy.models.base.PfModelException;
import org.onap.policy.models.base.PfModelRuntimeException;
import org.onap.policy.models.pdp.concepts.DeploymentSubGroup;
@@ -73,50 +72,22 @@ public class AutomationCompositionElementHandler implements AutomationCompositio
/**
* Callback method to handle a automation composition element state change.
*
- * @param automationCompositionId the ID of the automation composition
+ * @param automationCompositionId the ID of the automation composition
* @param automationCompositionElementId the ID of the automation composition element
- * @param currentState the current state of the automation composition element
- * @param orderedState the state to which the automation composition element is changing to
*/
@Override
- public void automationCompositionElementStateChange(UUID automationCompositionId,
- UUID automationCompositionElementId,
- AutomationCompositionState currentState,
- AutomationCompositionOrderedState orderedState) {
- switch (orderedState) {
- case UNINITIALISED:
- try {
- undeployPolicies(automationCompositionElementId);
- deletePolicyData(automationCompositionId, automationCompositionElementId, orderedState);
- intermediaryApi.updateAutomationCompositionElementState(automationCompositionId,
- automationCompositionElementId, orderedState, AutomationCompositionState.UNINITIALISED,
- ParticipantMessageType.AUTOMATION_COMPOSITION_STATE_CHANGE);
- } catch (PfModelRuntimeException e) {
- LOGGER.error("Undeploying/Deleting policy failed {}", automationCompositionElementId, e);
- }
- break;
- case PASSIVE:
- try {
- undeployPolicies(automationCompositionElementId);
- } catch (PfModelRuntimeException e) {
- LOGGER.error("Undeploying policies failed - no policies to undeploy {}",
- automationCompositionElementId);
- }
- intermediaryApi.updateAutomationCompositionElementState(automationCompositionId,
- automationCompositionElementId, orderedState, AutomationCompositionState.PASSIVE,
- ParticipantMessageType.AUTOMATION_COMPOSITION_STATE_CHANGE);
- break;
- case RUNNING:
- LOGGER.info("Running state is not supported");
- break;
- default:
- LOGGER.debug("Unknown orderedstate {}", orderedState);
- break;
+ public void undeploy(UUID automationCompositionId, UUID automationCompositionElementId) {
+ try {
+ undeployPolicies(automationCompositionElementId);
+ deletePolicyData(automationCompositionId, automationCompositionElementId);
+ intermediaryApi.updateAutomationCompositionElementState(automationCompositionId,
+ automationCompositionElementId, DeployState.UNDEPLOYED, LockState.NONE);
+ } catch (PfModelRuntimeException e) {
+ LOGGER.error("Undeploying/Deleting policy failed {}", automationCompositionElementId, e);
}
}
- private void deletePolicyData(UUID automationCompositionId,
- UUID automationCompositionElementId, AutomationCompositionOrderedState newState) {
+ private void deletePolicyData(UUID automationCompositionId, UUID automationCompositionElementId) {
// Delete all policies of this automationComposition from policy framework
for (var policy : policyMap.entrySet()) {
apiHttpClient.deletePolicy(policy.getKey(), policy.getValue());
@@ -129,8 +100,7 @@ public class AutomationCompositionElementHandler implements AutomationCompositio
policyTypeMap.clear();
}
- private void deployPolicies(UUID automationCompositionId, UUID automationCompositionElementId,
- AutomationCompositionOrderedState newState) {
+ private void deployPolicies(UUID automationCompositionId, UUID automationCompositionElementId) {
var deployFailure = false;
// Deploy all policies of this automationComposition from Policy Framework
if (!policyMap.entrySet().isEmpty()) {
@@ -145,11 +115,10 @@ public class AutomationCompositionElementHandler implements AutomationCompositio
} else {
LOGGER.debug("No policies to deploy to {}", automationCompositionElementId);
}
- if (! deployFailure) {
+ if (!deployFailure) {
// Update the AC element state
intermediaryApi.updateAutomationCompositionElementState(automationCompositionId,
- automationCompositionElementId, newState, AutomationCompositionState.PASSIVE,
- ParticipantMessageType.AUTOMATION_COMPOSITION_STATE_CHANGE);
+ automationCompositionElementId, DeployState.DEPLOYED, LockState.LOCKED);
}
}
@@ -158,7 +127,7 @@ public class AutomationCompositionElementHandler implements AutomationCompositio
if (!policyMap.entrySet().isEmpty()) {
for (var policy : policyMap.entrySet()) {
papHttpClient.handlePolicyDeployOrUndeploy(policy.getKey(), policy.getValue(),
- DeploymentSubGroup.Action.DELETE);
+ DeploymentSubGroup.Action.DELETE);
}
LOGGER.debug("Undeployed policies from {} successfully", automationCompositionElementId);
} else {
@@ -175,8 +144,8 @@ public class AutomationCompositionElementHandler implements AutomationCompositio
* @throws PfModelException in case of an exception
*/
@Override
- public void automationCompositionElementUpdate(UUID automationCompositionId,
- AutomationCompositionElement element, Map<String, Object> properties) throws PfModelException {
+ public void deploy(UUID automationCompositionId, AcElementDeploy element, Map<String, Object> properties)
+ throws PfModelException {
var createPolicyTypeResp = HttpStatus.SC_OK;
var createPolicyResp = HttpStatus.SC_OK;
@@ -187,7 +156,7 @@ public class AutomationCompositionElementHandler implements AutomationCompositio
policyTypeMap.put(policyType.getName(), policyType.getVersion());
}
LOGGER.info("Found Policy Types in automation composition definition: {} , Creating Policy Types",
- automationCompositionDefinition.getName());
+ automationCompositionDefinition.getName());
createPolicyTypeResp = apiHttpClient.createPolicyType(automationCompositionDefinition).getStatus();
}
if (automationCompositionDefinition.getToscaTopologyTemplate().getPolicies() != null) {
@@ -197,16 +166,16 @@ public class AutomationCompositionElementHandler implements AutomationCompositio
}
}
LOGGER.info("Found Policies in automation composition definition: {} , Creating Policies",
- automationCompositionDefinition.getName());
+ automationCompositionDefinition.getName());
createPolicyResp = apiHttpClient.createPolicy(automationCompositionDefinition).getStatus();
}
if (createPolicyTypeResp == HttpStatus.SC_OK && createPolicyResp == HttpStatus.SC_OK) {
LOGGER.info("PolicyTypes/Policies for the automation composition element : {} are created "
+ "successfully", element.getId());
- deployPolicies(automationCompositionId, element.getId(), element.getOrderedState());
+ deployPolicies(automationCompositionId, element.getId());
} else {
LOGGER.error("Creation of PolicyTypes/Policies failed. Policies will not be deployed.");
}
}
}
-} \ No newline at end of file
+}
diff --git a/participant/participant-impl/participant-impl-policy/src/test/java/org/onap/policy/clamp/acm/participant/policy/main/handler/AutomationCompositionElementHandlerTest.java b/participant/participant-impl/participant-impl-policy/src/test/java/org/onap/policy/clamp/acm/participant/policy/main/handler/AutomationCompositionElementHandlerTest.java
index 4fc10b828..e0b4a69c2 100644
--- a/participant/participant-impl/participant-impl-policy/src/test/java/org/onap/policy/clamp/acm/participant/policy/main/handler/AutomationCompositionElementHandlerTest.java
+++ b/participant/participant-impl/participant-impl-policy/src/test/java/org/onap/policy/clamp/acm/participant/policy/main/handler/AutomationCompositionElementHandlerTest.java
@@ -1,6 +1,6 @@
/*-
* ============LICENSE_START=======================================================
- * Copyright (C) 2021-2022 Nordix Foundation.
+ * Copyright (C) 2021-2023 Nordix Foundation.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -33,10 +33,8 @@ import org.mockito.Mockito;
import org.onap.policy.clamp.acm.participant.intermediary.api.ParticipantIntermediaryApi;
import org.onap.policy.clamp.acm.participant.policy.client.PolicyApiHttpClient;
import org.onap.policy.clamp.acm.participant.policy.client.PolicyPapHttpClient;
-import org.onap.policy.clamp.acm.participant.policy.main.parameters.CommonTestData;
-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.AcElementDeploy;
+import org.onap.policy.clamp.models.acm.messages.rest.instantiation.DeployOrder;
import org.onap.policy.models.base.PfModelException;
import org.onap.policy.models.tosca.authorative.concepts.ToscaConceptIdentifier;
import org.onap.policy.models.tosca.authorative.concepts.ToscaPolicy;
@@ -59,14 +57,7 @@ class AutomationCompositionElementHandlerTest {
void testHandlerDoesNotThrowExceptions() {
var handler = getTestingHandler();
- assertDoesNotThrow(() -> handler.automationCompositionElementStateChange(AC_ID, automationCompositionElementId,
- AutomationCompositionState.UNINITIALISED, AutomationCompositionOrderedState.PASSIVE));
-
- assertDoesNotThrow(() -> handler.automationCompositionElementStateChange(AC_ID, automationCompositionElementId,
- AutomationCompositionState.RUNNING, AutomationCompositionOrderedState.UNINITIALISED));
-
- assertDoesNotThrow(() -> handler.automationCompositionElementStateChange(AC_ID, automationCompositionElementId,
- AutomationCompositionState.PASSIVE, AutomationCompositionOrderedState.RUNNING));
+ assertDoesNotThrow(() -> handler.undeploy(AC_ID, automationCompositionElementId));
}
private AutomationCompositionElementHandler getTestingHandler() {
@@ -76,14 +67,11 @@ class AutomationCompositionElementHandlerTest {
return handler;
}
- private AutomationCompositionElement getTestingAcElement() {
- var element = new AutomationCompositionElement();
+ private AcElementDeploy getTestingAcElement() {
+ var element = new AcElementDeploy();
element.setDefinition(DEFINITION);
- element.setDescription("Description");
element.setId(automationCompositionElementId);
- element.setOrderedState(AutomationCompositionOrderedState.UNINITIALISED);
- element.setParticipantId(CommonTestData.getParticipantId());
- element.setState(AutomationCompositionState.UNINITIALISED);
+ element.setOrderedState(DeployOrder.DEPLOY);
var template = new ToscaServiceTemplate();
template.setToscaTopologyTemplate(new ToscaTopologyTemplate());
template.getToscaTopologyTemplate().setPolicies(List.of(Map.of("DummyPolicy", new ToscaPolicy())));
@@ -102,17 +90,16 @@ class AutomationCompositionElementHandlerTest {
var handler = getTestingHandler();
var element = getTestingAcElement();
- assertDoesNotThrow(() -> handler.automationCompositionElementUpdate(AC_ID, element, Map.of()));
+ assertDoesNotThrow(() -> handler.deploy(AC_ID, element, Map.of()));
- assertDoesNotThrow(() -> handler.automationCompositionElementStateChange(AC_ID, automationCompositionElementId,
- AutomationCompositionState.PASSIVE, AutomationCompositionOrderedState.UNINITIALISED));
+ assertDoesNotThrow(() -> handler.undeploy(AC_ID, automationCompositionElementId));
// Mock failure in policy deployment
doReturn(Response.serverError().build()).when(pap).handlePolicyDeployOrUndeploy(any(), any(), any());
- assertDoesNotThrow(() -> handler.automationCompositionElementUpdate(AC_ID, element, Map.of()));
+ assertDoesNotThrow(() -> handler.deploy(AC_ID, element, Map.of()));
// Mock failure in policy type creation
doReturn(Response.serverError().build()).when(api).createPolicyType(any());
- assertDoesNotThrow(() -> handler.automationCompositionElementUpdate(AC_ID, element, Map.of()));
+ assertDoesNotThrow(() -> handler.deploy(AC_ID, element, Map.of()));
}
}