summaryrefslogtreecommitdiffstats
path: root/runtime-controlloop
diff options
context:
space:
mode:
Diffstat (limited to 'runtime-controlloop')
-rw-r--r--runtime-controlloop/src/main/java/org/onap/policy/clamp/controlloop/runtime/supervision/comm/ControlLoopUpdatePublisher.java36
-rw-r--r--runtime-controlloop/src/main/java/org/onap/policy/clamp/controlloop/runtime/supervision/comm/ParticipantUpdatePublisher.java2
-rw-r--r--runtime-controlloop/src/test/java/org/onap/policy/clamp/controlloop/runtime/supervision/comm/SupervisionMessagesTest.java1
-rw-r--r--runtime-controlloop/src/test/resources/rest/servicetemplates/pmsh_multiple_cl_tosca.yaml6
4 files changed, 42 insertions, 3 deletions
diff --git a/runtime-controlloop/src/main/java/org/onap/policy/clamp/controlloop/runtime/supervision/comm/ControlLoopUpdatePublisher.java b/runtime-controlloop/src/main/java/org/onap/policy/clamp/controlloop/runtime/supervision/comm/ControlLoopUpdatePublisher.java
index 6df030d32..d68a643d2 100644
--- a/runtime-controlloop/src/main/java/org/onap/policy/clamp/controlloop/runtime/supervision/comm/ControlLoopUpdatePublisher.java
+++ b/runtime-controlloop/src/main/java/org/onap/policy/clamp/controlloop/runtime/supervision/comm/ControlLoopUpdatePublisher.java
@@ -31,6 +31,11 @@ import org.onap.policy.clamp.controlloop.models.controlloop.concepts.ControlLoop
import org.onap.policy.clamp.controlloop.models.controlloop.concepts.ControlLoopElement;
import org.onap.policy.clamp.controlloop.models.controlloop.concepts.ParticipantUpdates;
import org.onap.policy.clamp.controlloop.models.messages.dmaap.participant.ControlLoopUpdate;
+import org.onap.policy.models.base.PfModelException;
+import org.onap.policy.models.provider.PolicyModelsProvider;
+import org.onap.policy.models.tosca.authorative.concepts.ToscaNodeTemplate;
+import org.onap.policy.models.tosca.authorative.concepts.ToscaServiceTemplate;
+import org.onap.policy.models.tosca.authorative.concepts.ToscaTopologyTemplate;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Component;
@@ -43,6 +48,9 @@ import org.springframework.stereotype.Component;
public class ControlLoopUpdatePublisher extends AbstractParticipantPublisher<ControlLoopUpdate> {
private static final Logger LOGGER = LoggerFactory.getLogger(ControlLoopUpdatePublisher.class);
+ private static final String POLICY_TYPE_ID = "policy_type_id";
+ private static final String POLICY_ID = "policy_id";
+ private final PolicyModelsProvider modelsProvider;
/**
* Send ControlLoopUpdate to Participant.
@@ -54,9 +62,37 @@ public class ControlLoopUpdatePublisher extends AbstractParticipantPublisher<Con
controlLoopUpdateMsg.setControlLoopId(controlLoop.getKey().asIdentifier());
controlLoopUpdateMsg.setMessageId(UUID.randomUUID());
controlLoopUpdateMsg.setTimestamp(Instant.now());
+ ToscaServiceTemplate toscaServiceTemplate;
+ try {
+ toscaServiceTemplate = modelsProvider.getServiceTemplateList(null, null).get(0);
+ } catch (PfModelException pfme) {
+ LOGGER.warn("Get of tosca service template failed, cannot send participantupdate", pfme);
+ return;
+ }
List<ParticipantUpdates> participantUpdates = new ArrayList<>();
for (ControlLoopElement element : controlLoop.getElements().values()) {
+ ToscaNodeTemplate toscaNodeTemplate = toscaServiceTemplate
+ .getToscaTopologyTemplate().getNodeTemplates().get(element.getDefinition().getName());
+ // If the ControlLoopElement has policy_type_id or policy_id, identify it as a PolicyControlLoopElement
+ // and pass respective PolicyTypes or Policies as part of toscaServiceTemplateFragment
+ if ((toscaNodeTemplate.getProperties().get(POLICY_TYPE_ID) != null)
+ || (toscaNodeTemplate.getProperties().get(POLICY_ID) != null)) {
+ // ControlLoopElement for policy framework, send policies and policyTypes to participants
+ if ((toscaServiceTemplate.getPolicyTypes() != null)
+ || (toscaServiceTemplate.getToscaTopologyTemplate().getPolicies() != null)) {
+ ToscaServiceTemplate toscaServiceTemplateFragment = new ToscaServiceTemplate();
+ toscaServiceTemplateFragment.setPolicyTypes(toscaServiceTemplate.getPolicyTypes());
+
+ ToscaTopologyTemplate toscaTopologyTemplate = new ToscaTopologyTemplate();
+ toscaTopologyTemplate.setPolicies(toscaServiceTemplate.getToscaTopologyTemplate().getPolicies());
+ toscaServiceTemplateFragment.setToscaTopologyTemplate(toscaTopologyTemplate);
+
+ toscaServiceTemplateFragment.setDataTypes(toscaServiceTemplate.getDataTypes());
+
+ element.setToscaServiceTemplateFragment(toscaServiceTemplateFragment);
+ }
+ }
prepareParticipantUpdate(element, participantUpdates);
}
controlLoopUpdateMsg.setParticipantUpdatesList(participantUpdates);
diff --git a/runtime-controlloop/src/main/java/org/onap/policy/clamp/controlloop/runtime/supervision/comm/ParticipantUpdatePublisher.java b/runtime-controlloop/src/main/java/org/onap/policy/clamp/controlloop/runtime/supervision/comm/ParticipantUpdatePublisher.java
index 41ed4e291..c820bf3f1 100644
--- a/runtime-controlloop/src/main/java/org/onap/policy/clamp/controlloop/runtime/supervision/comm/ParticipantUpdatePublisher.java
+++ b/runtime-controlloop/src/main/java/org/onap/policy/clamp/controlloop/runtime/supervision/comm/ParticipantUpdatePublisher.java
@@ -95,11 +95,9 @@ public class ParticipantUpdatePublisher extends AbstractParticipantPublisher<Par
if (commissionFlag) {
// Commission the controlloop but sending participantdefinitions to participants
message.setParticipantDefinitionUpdates(participantDefinitionUpdates);
- message.setToscaServiceTemplate(toscaServiceTemplate);
} else {
// DeCommission the controlloop but deleting participantdefinitions on participants
message.setParticipantDefinitionUpdates(null);
- message.setToscaServiceTemplate(null);
}
LOGGER.debug("Participant Update sent {}", message);
super.send(message);
diff --git a/runtime-controlloop/src/test/java/org/onap/policy/clamp/controlloop/runtime/supervision/comm/SupervisionMessagesTest.java b/runtime-controlloop/src/test/java/org/onap/policy/clamp/controlloop/runtime/supervision/comm/SupervisionMessagesTest.java
index 4cfcf1508..64bf6b009 100644
--- a/runtime-controlloop/src/test/java/org/onap/policy/clamp/controlloop/runtime/supervision/comm/SupervisionMessagesTest.java
+++ b/runtime-controlloop/src/test/java/org/onap/policy/clamp/controlloop/runtime/supervision/comm/SupervisionMessagesTest.java
@@ -206,7 +206,6 @@ class SupervisionMessagesTest extends CommonRestController {
}
participantUpdateMsg.setParticipantDefinitionUpdates(participantDefinitionUpdates);
- participantUpdateMsg.setToscaServiceTemplate(toscaServiceTemplate);
synchronized (lockit) {
ParticipantUpdatePublisher participantUpdatePublisher =
new ParticipantUpdatePublisher(modelsProvider);
diff --git a/runtime-controlloop/src/test/resources/rest/servicetemplates/pmsh_multiple_cl_tosca.yaml b/runtime-controlloop/src/test/resources/rest/servicetemplates/pmsh_multiple_cl_tosca.yaml
index 9acff1356..9c440b42b 100644
--- a/runtime-controlloop/src/test/resources/rest/servicetemplates/pmsh_multiple_cl_tosca.yaml
+++ b/runtime-controlloop/src/test/resources/rest/servicetemplates/pmsh_multiple_cl_tosca.yaml
@@ -188,6 +188,9 @@ topology_template:
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_OperationalPolicyControlLoopElement:
version: 1.2.3
type: org.onap.policy.clamp.controlloop.PolicyTypeControlLoopElement
@@ -201,6 +204,9 @@ topology_template:
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_ControlLoopElement:
version: 1.2.3
type: org.onap.policy.clamp.controlloop.ControlLoopElement