summaryrefslogtreecommitdiffstats
path: root/participant/participant-impl/participant-impl-kubernetes/src/main
diff options
context:
space:
mode:
authorFrancescoFioraEst <francesco.fiora@est.tech>2023-07-04 09:26:41 +0100
committerFrancesco Fiora <francesco.fiora@est.tech>2023-07-13 13:20:31 +0000
commitef0a60deb046c5bf5ed1a6209493dfde6a6457a9 (patch)
tree3e92ffecd8579cfb0ddabef80dee5586c695eda1 /participant/participant-impl/participant-impl-kubernetes/src/main
parent51ef04415186a0de3e50339b7fca04fb5ef079c9 (diff)
Add restart support inside participants
Issue-ID: POLICY-4747 Change-Id: I09ca3e373f8271fbfe612c031920058b744cf413 Signed-off-by: FrancescoFioraEst <francesco.fiora@est.tech>
Diffstat (limited to 'participant/participant-impl/participant-impl-kubernetes/src/main')
-rw-r--r--participant/participant-impl/participant-impl-kubernetes/src/main/java/org/onap/policy/clamp/acm/participant/kubernetes/handler/AutomationCompositionElementHandler.java37
1 files changed, 37 insertions, 0 deletions
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 7385a1f3b..a0ea31673 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
@@ -44,6 +44,7 @@ import org.onap.policy.clamp.models.acm.concepts.AutomationCompositionElementDef
import org.onap.policy.clamp.models.acm.concepts.DeployState;
import org.onap.policy.clamp.models.acm.concepts.LockState;
import org.onap.policy.clamp.models.acm.concepts.StateChangeResult;
+import org.onap.policy.clamp.models.acm.utils.AcmUtils;
import org.onap.policy.common.utils.coder.Coder;
import org.onap.policy.common.utils.coder.CoderException;
import org.onap.policy.common.utils.coder.StandardCoder;
@@ -212,4 +213,40 @@ public class AutomationCompositionElementHandler implements AutomationCompositio
intermediaryApi.updateCompositionState(compositionId, AcTypeState.COMMISSIONED, StateChangeResult.NO_ERROR,
"Deprimed");
}
+
+ @Override
+ public void handleRestartComposition(UUID compositionId,
+ List<AutomationCompositionElementDefinition> elementDefinitionList, AcTypeState state)
+ throws PfModelException {
+ var finalState = AcTypeState.PRIMED.equals(state) || AcTypeState.PRIMING.equals(state) ? AcTypeState.PRIMED
+ : AcTypeState.COMMISSIONED;
+ intermediaryApi.updateCompositionState(compositionId, finalState, StateChangeResult.NO_ERROR, "Restarted");
+ }
+
+ @Override
+ public void handleRestartInstance(UUID automationCompositionId, AcElementDeploy element,
+ Map<String, Object> properties, DeployState deployState, LockState lockState) throws PfModelException {
+ if (DeployState.DEPLOYING.equals(deployState)) {
+ deploy(automationCompositionId, element, properties);
+ return;
+ }
+ if (DeployState.UNDEPLOYING.equals(deployState) || DeployState.DEPLOYED.equals(deployState)
+ || DeployState.UPDATING.equals(deployState)) {
+ try {
+ var chartInfo = getChartInfo(properties);
+ chartMap.put(element.getId(), chartInfo);
+ } catch (AutomationCompositionException e) {
+ intermediaryApi.updateAutomationCompositionElementState(automationCompositionId, element.getId(),
+ DeployState.UNDEPLOYED, null, StateChangeResult.FAILED, e.getMessage());
+ }
+ }
+ if (DeployState.UNDEPLOYING.equals(deployState)) {
+ undeploy(automationCompositionId, element.getId());
+ return;
+ }
+ deployState = AcmUtils.deployCompleted(deployState);
+ lockState = AcmUtils.lockCompleted(deployState, lockState);
+ intermediaryApi.updateAutomationCompositionElementState(automationCompositionId, element.getId(), deployState,
+ lockState, StateChangeResult.NO_ERROR, "Restarted");
+ }
}