From d0a1bcee60c43a736a0526d49c07c564632c4f02 Mon Sep 17 00:00:00 2001 From: Sirisha_Manchikanti Date: Tue, 10 Aug 2021 21:51:48 +0100 Subject: Updated ControlLoop component messages Updated controlloop messages (ParticipantUpdate, ControlLoopUpdate, ParticipantStatus) according to the following Wiki and added implementation for the corresponding updates in runtime-controlloop and participant components https://wiki.onap.org/display/DW/The+CLAMP+Control+Loop+Participant+Protocol Issue-ID: POLICY-3417 Signed-off-by: Sirisha_Manchikanti Change-Id: I80d96a7553a89ca47de2aa35e09df5a5c792acfa --- .../main/handler/ControlLoopElementHandler.java | 38 ++++++++++++---------- 1 file changed, 21 insertions(+), 17 deletions(-) (limited to 'participant/participant-impl/participant-impl-policy/src/main/java') diff --git a/participant/participant-impl/participant-impl-policy/src/main/java/org/onap/policy/clamp/controlloop/participant/policy/main/handler/ControlLoopElementHandler.java b/participant/participant-impl/participant-impl-policy/src/main/java/org/onap/policy/clamp/controlloop/participant/policy/main/handler/ControlLoopElementHandler.java index 1b176f076..60515048e 100644 --- a/participant/participant-impl/participant-impl-policy/src/main/java/org/onap/policy/clamp/controlloop/participant/policy/main/handler/ControlLoopElementHandler.java +++ b/participant/participant-impl/participant-impl-policy/src/main/java/org/onap/policy/clamp/controlloop/participant/policy/main/handler/ControlLoopElementHandler.java @@ -35,6 +35,7 @@ import org.onap.policy.clamp.controlloop.participant.intermediary.api.Participan import org.onap.policy.clamp.controlloop.participant.policy.client.PolicyApiHttpClient; import org.onap.policy.models.base.PfModelException; import org.onap.policy.models.base.PfModelRuntimeException; +import org.onap.policy.models.tosca.authorative.concepts.ToscaNodeTemplate; import org.onap.policy.models.tosca.authorative.concepts.ToscaPolicy; import org.onap.policy.models.tosca.authorative.concepts.ToscaPolicyType; import org.onap.policy.models.tosca.authorative.concepts.ToscaServiceTemplate; @@ -115,32 +116,35 @@ public class ControlLoopElementHandler implements ControlLoopElementListener { * Callback method to handle an update on a control loop element. * * @param element the information on the control loop element - * @param controlLoopDefinition toscaServiceTemplate + * @param clElementDefinition toscaNodeTemplate * @throws PfModelException in case of an exception */ @Override - public void controlLoopElementUpdate(ControlLoopElement element, ToscaServiceTemplate controlLoopDefinition) + public void controlLoopElementUpdate(ControlLoopElement element, ToscaNodeTemplate clElementDefinition) throws PfModelException { intermediaryApi.updateControlLoopElementState(element.getId(), element.getOrderedState(), ControlLoopState.PASSIVE); - if (controlLoopDefinition.getPolicyTypes() != null) { - for (ToscaPolicyType policyType : controlLoopDefinition.getPolicyTypes().values()) { - policyTypeMap.put(policyType.getName(), policyType.getVersion()); + ToscaServiceTemplate controlLoopDefinition = intermediaryApi.getToscaServiceTemplate(); + if (controlLoopDefinition.getToscaTopologyTemplate() != null) { + if (controlLoopDefinition.getPolicyTypes() != null) { + for (ToscaPolicyType policyType : controlLoopDefinition.getPolicyTypes().values()) { + policyTypeMap.put(policyType.getName(), policyType.getVersion()); + } + LOGGER.debug("Found Policy Types in control loop definition: {} , Creating Policy Types", + controlLoopDefinition.getName()); + apiHttpClient.createPolicyType(controlLoopDefinition); } - LOGGER.debug("Found Policy Types in control loop definition: {} , Creating Policy Types", - controlLoopDefinition.getName()); - apiHttpClient.createPolicyType(controlLoopDefinition); - } - if (controlLoopDefinition.getToscaTopologyTemplate().getPolicies() != null) { - for (Map foundPolicyMap : controlLoopDefinition.getToscaTopologyTemplate() - .getPolicies()) { - for (ToscaPolicy policy : foundPolicyMap.values()) { - policyMap.put(policy.getName(), policy.getVersion()); + if (controlLoopDefinition.getToscaTopologyTemplate().getPolicies() != null) { + for (Map foundPolicyMap : controlLoopDefinition.getToscaTopologyTemplate() + .getPolicies()) { + for (ToscaPolicy policy : foundPolicyMap.values()) { + policyMap.put(policy.getName(), policy.getVersion()); + } } + LOGGER.debug("Found Policies in control loop definition: {} , Creating Policies", + controlLoopDefinition.getName()); + apiHttpClient.createPolicy(controlLoopDefinition); } - LOGGER.debug("Found Policies in control loop definition: {} , Creating Policies", - controlLoopDefinition.getName()); - apiHttpClient.createPolicy(controlLoopDefinition); } } -- cgit 1.2.3-korg