aboutsummaryrefslogtreecommitdiffstats
path: root/runtime-acm/src/main
diff options
context:
space:
mode:
Diffstat (limited to 'runtime-acm/src/main')
-rw-r--r--runtime-acm/src/main/java/org/onap/policy/clamp/acm/runtime/instantiation/AutomationCompositionInstantiationProvider.java4
-rw-r--r--runtime-acm/src/main/java/org/onap/policy/clamp/acm/runtime/supervision/SupervisionAcHandler.java61
-rw-r--r--runtime-acm/src/main/java/org/onap/policy/clamp/acm/runtime/supervision/SupervisionScanner.java24
3 files changed, 59 insertions, 30 deletions
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
index 02e5b1ac6..4665fec37 100644
--- 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
@@ -196,8 +196,8 @@ public class AutomationCompositionInstantiationProvider {
"Automation composition state is still " + automationComposition.getDeployState());
}
var response = new InstantiationResponse();
- automationComposition =
- automationCompositionProvider.deleteAutomationComposition(automationComposition.getInstanceId());
+ var acDefinition = acDefinitionProvider.getAcDefinition(automationComposition.getCompositionId());
+ supervisionAcHandler.delete(automationComposition, acDefinition);
response.setInstanceId(automationComposition.getInstanceId());
response.setAffectedAutomationComposition(automationComposition.getKey().asIdentifier());
return response;
diff --git a/runtime-acm/src/main/java/org/onap/policy/clamp/acm/runtime/supervision/SupervisionAcHandler.java b/runtime-acm/src/main/java/org/onap/policy/clamp/acm/runtime/supervision/SupervisionAcHandler.java
index 0eb4ecbd9..8032b4d5d 100644
--- a/runtime-acm/src/main/java/org/onap/policy/clamp/acm/runtime/supervision/SupervisionAcHandler.java
+++ b/runtime-acm/src/main/java/org/onap/policy/clamp/acm/runtime/supervision/SupervisionAcHandler.java
@@ -109,6 +109,19 @@ public class SupervisionAcHandler {
}
/**
+ * Handle Delete an AutomationComposition instance.
+ *
+ * @param automationComposition the AutomationComposition
+ * @param acDefinition the AutomationCompositionDefinition
+ */
+ public void delete(AutomationComposition automationComposition, AutomationCompositionDefinition acDefinition) {
+ AcmUtils.setCascadedState(automationComposition, DeployState.DELETING, LockState.NONE);
+ automationCompositionProvider.updateAutomationComposition(automationComposition);
+ var startPhase = ParticipantUtils.getFirstStartPhase(automationComposition, acDefinition.getServiceTemplate());
+ automationCompositionStateChangePublisher.send(automationComposition, startPhase, true);
+ }
+
+ /**
* Handle a AutomationComposition deploy acknowledge message from a participant.
*
* @param automationCompositionAckMessage the AutomationCompositionAck message received from a participant
@@ -139,19 +152,33 @@ public class SupervisionAcHandler {
}
private void setAcElementStateInDb(AutomationCompositionDeployAck automationCompositionAckMessage) {
- if (automationCompositionAckMessage.getAutomationCompositionResultMap() != null) {
- var automationComposition = automationCompositionProvider
- .findAutomationComposition(automationCompositionAckMessage.getAutomationCompositionId());
- if (automationComposition.isPresent()) {
- var updated = updateState(automationComposition.get(),
- automationCompositionAckMessage.getAutomationCompositionResultMap().entrySet());
- if (updated) {
- automationCompositionProvider.updateAutomationComposition(automationComposition.get());
- }
+ var automationComposition = automationCompositionProvider
+ .findAutomationComposition(automationCompositionAckMessage.getAutomationCompositionId());
+ if (automationComposition.isEmpty()) {
+ LOGGER.warn("AutomationComposition not found in database {}",
+ automationCompositionAckMessage.getAutomationCompositionId());
+ return;
+ }
+
+ if (automationCompositionAckMessage.getAutomationCompositionResultMap() == null
+ || automationCompositionAckMessage.getAutomationCompositionResultMap().isEmpty()) {
+ if (DeployState.DELETING.equals(automationComposition.get().getDeployState())) {
+ // scenario when Automation Composition instance has never been deployed
+ automationComposition.get().getElements().values()
+ .forEach(element -> element.setDeployState(DeployState.DELETED));
+ automationCompositionProvider.updateAutomationComposition(automationComposition.get());
} else {
- LOGGER.warn("AutomationComposition not found in database {}",
- automationCompositionAckMessage.getAutomationCompositionId());
+ LOGGER.warn("Empty AutomationCompositionResultMap {} {}",
+ automationCompositionAckMessage.getAutomationCompositionId(),
+ automationCompositionAckMessage.getMessage());
}
+ return;
+ }
+
+ var updated = updateState(automationComposition.get(),
+ automationCompositionAckMessage.getAutomationCompositionResultMap().entrySet());
+ if (updated) {
+ automationCompositionProvider.updateAutomationComposition(automationComposition.get());
}
}
@@ -163,15 +190,9 @@ public class SupervisionAcHandler {
if (element != null) {
element.setDeployState(acElementAck.getValue().getDeployState());
element.setLockState(acElementAck.getValue().getLockState());
- if (DeployState.DEPLOYED.equals(element.getDeployState())) {
- element.setOperationalState(acElementAck.getValue().getOperationalState());
- element.setUseState(acElementAck.getValue().getUseState());
- element.setStatusProperties(acElementAck.getValue().getStatusProperties());
- } else {
- element.setOperationalState(null);
- element.setUseState(null);
- element.setStatusProperties(Map.of());
- }
+ element.setOperationalState(acElementAck.getValue().getOperationalState());
+ element.setUseState(acElementAck.getValue().getUseState());
+ element.setStatusProperties(acElementAck.getValue().getStatusProperties());
updated = true;
}
}
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
index 7ee7267e2..e23d79d57 100644
--- 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
@@ -133,14 +133,7 @@ public class SupervisionScanner {
LOGGER.debug("automation composition scan: transition state {} {} ", automationComposition.getDeployState(),
automationComposition.getLockState());
- var deployState = automationComposition.getDeployState();
- automationComposition.setDeployState(AcmUtils.deployCompleted(deployState));
- automationComposition
- .setLockState(AcmUtils.lockCompleted(deployState, automationComposition.getLockState()));
- automationCompositionProvider.updateAutomationComposition(automationComposition);
-
- // Clear missed report counter on automation composition
- clearFaultAndCounter(automationComposition);
+ complete(automationComposition);
} else {
LOGGER.debug("automation composition scan: transition from state {} to {} not completed",
automationComposition.getDeployState(), automationComposition.getLockState());
@@ -163,6 +156,21 @@ public class SupervisionScanner {
}
}
+ private void complete(final AutomationComposition automationComposition) {
+ var deployState = automationComposition.getDeployState();
+ automationComposition.setDeployState(AcmUtils.deployCompleted(deployState));
+ automationComposition
+ .setLockState(AcmUtils.lockCompleted(deployState, automationComposition.getLockState()));
+ if (DeployState.DELETED.equals(automationComposition.getDeployState())) {
+ automationCompositionProvider.deleteAutomationComposition(automationComposition.getInstanceId());
+ } else {
+ automationCompositionProvider.updateAutomationComposition(automationComposition);
+ }
+
+ // Clear missed report counter on automation composition
+ clearFaultAndCounter(automationComposition);
+ }
+
private void clearFaultAndCounter(AutomationComposition automationComposition) {
automationCompositionCounter.clear(automationComposition.getInstanceId());
phaseMap.remove(automationComposition.getInstanceId());