From 73e3ea2f9183fc7ed6ba8c0f221e41a804fbe2c7 Mon Sep 17 00:00:00 2001 From: Rashmi Pujar Date: Tue, 29 Oct 2019 16:13:05 -0400 Subject: PNF support changes in policy/models AAI Enrichment method for PNF target-type and unit tests. Addition of a hashmap field to ControlLoopEvent class to hold event specific parameters. Update CDS actor to include additional event parameters Issue-ID: POLICY-1187 Signed-off-by: Rashmi Pujar Change-Id: Ie0ceb320943531de6e6bc8675844b29a358dfb7e --- .../policy/controlloop/actor/cds/CdsActorServiceProvider.java | 5 +++++ .../controlloop/actor/cds/request/CdsActionRequest.java | 11 ++++++++--- .../controlloop/actor/cds/request/CdsActionRequestTest.java | 4 ++++ 3 files changed, 17 insertions(+), 3 deletions(-) (limited to 'models-interactions/model-actors') diff --git a/models-interactions/model-actors/actor.cds/src/main/java/org/onap/policy/controlloop/actor/cds/CdsActorServiceProvider.java b/models-interactions/model-actors/actor.cds/src/main/java/org/onap/policy/controlloop/actor/cds/CdsActorServiceProvider.java index 65cc03931..df13ba306 100644 --- a/models-interactions/model-actors/actor.cds/src/main/java/org/onap/policy/controlloop/actor/cds/CdsActorServiceProvider.java +++ b/models-interactions/model-actors/actor.cds/src/main/java/org/onap/policy/controlloop/actor/cds/CdsActorServiceProvider.java @@ -130,6 +130,11 @@ public class CdsActorServiceProvider implements Actor { // E.g. For vFW usecase El-Alto inject service-instance-id, generic-vnf-id as needed by CDS. request.setAaiProperties(aaiParams); + // Inject any additional event parameters that may be present in the onset event + if (onset.getAdditionalEventParams() != null) { + request.setAdditionalEventParams(onset.getAdditionalEventParams()); + } + Builder struct = Struct.newBuilder(); try { String requestStr = request.generateCdsPayload(); diff --git a/models-interactions/model-actors/actor.cds/src/main/java/org/onap/policy/controlloop/actor/cds/request/CdsActionRequest.java b/models-interactions/model-actors/actor.cds/src/main/java/org/onap/policy/controlloop/actor/cds/request/CdsActionRequest.java index 38ab2bdc7..4193db59f 100644 --- a/models-interactions/model-actors/actor.cds/src/main/java/org/onap/policy/controlloop/actor/cds/request/CdsActionRequest.java +++ b/models-interactions/model-actors/actor.cds/src/main/java/org/onap/policy/controlloop/actor/cds/request/CdsActionRequest.java @@ -38,16 +38,18 @@ public class CdsActionRequest implements Serializable { private String resolutionKey; private Map aaiProperties; private Map policyPayload; + private Map additionalEventParams; /** * Generate the CDS gRPC request payload from the action-name (aka operational policy recipe). * The CDS gRPC request payload generation follows the below pattern: * { * "{@link CdsActionRequest#getActionName()}-request": { - * "resolution-key": "{@link CdsActionRequest#getResolutionKey()} ()}", + * "resolution-key": "{@link CdsActionRequest#getResolutionKey()}", * "{@link CdsActionRequest#getActionName()}-properties": { - * "{@link CdsActionRequest#getAaiProperties()} ()}", - * "{@link CdsActionRequest#getPolicyPayload()} ()}" + * "{@link CdsActionRequest#getAaiProperties()}", + * "{@link CdsActionRequest#getPolicyPayload()}", + * "{@link CdsActionRequest#getAdditionalEventParams()}" * } * } * } @@ -59,6 +61,9 @@ public class CdsActionRequest implements Serializable { Map cdsActionPropsMap = new LinkedHashMap<>(); cdsActionPropsMap.putAll(aaiProperties); cdsActionPropsMap.putAll(policyPayload); + if (additionalEventParams != null) { + cdsActionPropsMap.putAll(additionalEventParams); + } // 2. Build the enclosing CDS action request properties object to contain (1) and the resolution-key Map cdsActionRequestMap = new LinkedHashMap<>(); diff --git a/models-interactions/model-actors/actor.cds/src/test/java/org/onap/policy/controlloop/actor/cds/request/CdsActionRequestTest.java b/models-interactions/model-actors/actor.cds/src/test/java/org/onap/policy/controlloop/actor/cds/request/CdsActionRequestTest.java index 3f28bada4..e34fa33ab 100644 --- a/models-interactions/model-actors/actor.cds/src/test/java/org/onap/policy/controlloop/actor/cds/request/CdsActionRequestTest.java +++ b/models-interactions/model-actors/actor.cds/src/test/java/org/onap/policy/controlloop/actor/cds/request/CdsActionRequestTest.java @@ -43,6 +43,10 @@ public class CdsActionRequestTest { ImmutableMap.of("service-instance.service-instance-id", "1234", "generic-vnf.vnf-id", "5678"); req.setAaiProperties(aaiParams); + Map eventParams = + ImmutableMap.of("event-param-1", "1234", "event-param-2", "5678"); + req.setAdditionalEventParams(eventParams); + // Act String result = req.generateCdsPayload(); -- cgit 1.2.3-korg