diff options
author | Rashmi Pujar <rashmi.pujar@bell.ca> | 2019-09-30 12:12:07 -0400 |
---|---|---|
committer | Rashmi Pujar <rashmi.pujar@bell.ca> | 2019-10-01 12:01:14 +0000 |
commit | 5af913104ec412086deab4d599359751246e4ba3 (patch) | |
tree | 436e10c0bb6e02aa354ffaf93714069309e2e611 /models-interactions/model-actors/actor.cds/src/main | |
parent | f70ddacbd97e34ad0d1373466367115982a251db (diff) |
Update CDS grpc request generation in CDS Actor service provider
- CDS payload requires resolution-key (random UUID)
- Update the CDS request object to rename the payload child node key name from config-deploy-properties to policy-payload.
- Generate dynamic childnode key name from the policy recipe-name aka CDS action-name. action-name itself is never included in serialization as is.
Below is a sample:
{
"commonHeader": {
"subRequestId": "$subReqId",
"requestId": "$reqId",
"originatorId": "POLICY"
},
"actionIdentifiers": {
"mode": "sync",
"blueprintName": "$bpName",
"blueprintVersion": "$bpVer",
"actionName": "$recipeName"
},
"payload": {
"$recipeName-request": {
"resolution-key": "{{$guid}}",
"aai-properties": {
"$key": "$value",
...
},
"policy-payload": {
"$clamp-payload"
}
}
}
}
Issue-ID: POLICY-2120
Signed-off-by: Rashmi Pujar <rashmi.pujar@bell.ca>
Change-Id: Ia7f0551f94755bbe73b48ae387b4c53842729a81
Diffstat (limited to 'models-interactions/model-actors/actor.cds/src/main')
-rw-r--r-- | models-interactions/model-actors/actor.cds/src/main/java/org/onap/policy/controlloop/actor/cds/CdsActorServiceProvider.java | 7 | ||||
-rw-r--r-- | models-interactions/model-actors/actor.cds/src/main/java/org/onap/policy/controlloop/actor/cds/beans/CdsActionRequest.java (renamed from models-interactions/model-actors/actor.cds/src/main/java/org/onap/policy/controlloop/actor/cds/beans/ConfigDeployRequest.java) | 25 |
2 files changed, 25 insertions, 7 deletions
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 aaf07ac21..1ad184e49 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 @@ -29,6 +29,7 @@ import java.util.ArrayList; import java.util.List; import java.util.Map; import java.util.Optional; +import java.util.UUID; import java.util.concurrent.CountDownLatch; import java.util.concurrent.TimeUnit; import java.util.concurrent.atomic.AtomicReference; @@ -42,7 +43,7 @@ import org.onap.policy.cds.client.CdsProcessorGrpcClient; import org.onap.policy.cds.properties.CdsServerProperties; import org.onap.policy.controlloop.ControlLoopOperation; import org.onap.policy.controlloop.VirtualControlLoopEvent; -import org.onap.policy.controlloop.actor.cds.beans.ConfigDeployRequest; +import org.onap.policy.controlloop.actor.cds.beans.CdsActionRequest; import org.onap.policy.controlloop.actor.cds.constants.CdsActorConstants; import org.onap.policy.controlloop.actorserviceprovider.spi.Actor; import org.onap.policy.controlloop.policy.Policy; @@ -112,8 +113,10 @@ public class CdsActorServiceProvider implements Actor { String cbaActionName = policy.getRecipe(); // Embed payload from policy to ConfigDeployRequest object, serialize and inject into grpc request. - ConfigDeployRequest request = new ConfigDeployRequest(); + CdsActionRequest request = new CdsActionRequest(); request.setConfigDeployProperties(payload); + request.setActionName(cbaActionName); + request.setResolutionKey(UUID.randomUUID().toString()); // Inject AAI properties into payload map. Offer flexibility to the usecase // implementation to inject whatever AAI parameters are of interest to them. diff --git a/models-interactions/model-actors/actor.cds/src/main/java/org/onap/policy/controlloop/actor/cds/beans/ConfigDeployRequest.java b/models-interactions/model-actors/actor.cds/src/main/java/org/onap/policy/controlloop/actor/cds/beans/CdsActionRequest.java index f33f226f9..8aac67bb0 100644 --- a/models-interactions/model-actors/actor.cds/src/main/java/org/onap/policy/controlloop/actor/cds/beans/ConfigDeployRequest.java +++ b/models-interactions/model-actors/actor.cds/src/main/java/org/onap/policy/controlloop/actor/cds/beans/CdsActionRequest.java @@ -18,26 +18,41 @@ package org.onap.policy.controlloop.actor.cds.beans; -import com.google.gson.Gson; import com.google.gson.annotations.SerializedName; import java.util.Map; import lombok.Getter; import lombok.Setter; +import org.onap.policy.common.utils.coder.Coder; +import org.onap.policy.common.utils.coder.CoderException; +import org.onap.policy.common.utils.coder.StandardCoder; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; @Getter @Setter -public class ConfigDeployRequest { +public class CdsActionRequest { - private static final Gson GSON = new Gson(); + private static final Logger LOGGER = LoggerFactory.getLogger(CdsActionRequest.class); + private static final Coder CODER = new StandardCoder(); - @SerializedName("config-deploy-properties") + @SerializedName("policy-payload") private Map<String, String> configDeployProperties; @SerializedName("aai-properties") private Map<String, String> aaiProperties; + @SerializedName("resolution-key") + private String resolutionKey; + + private transient String actionName; + @Override public String toString() { - return "{\"config-deploy-request\":" + GSON.toJson(this) + '}'; + try { + return "{" + "\"" + actionName + "-request\":" + CODER.encode(this) + '}'; + } catch (CoderException e) { + LOGGER.error("Failure serializing CdsActionRequest object: ", e); + return ""; + } } } |