diff options
author | Saravanan A <saravanan.a75@wipro.com> | 2018-09-10 17:31:33 +0530 |
---|---|---|
committer | Saravanan A <saravanan.a75@wipro.com> | 2018-09-12 21:51:11 +0530 |
commit | dbecba3a4baffacf9f2da82592b3e3a9e2929f21 (patch) | |
tree | 71b93f111551115b8d0f8d634a23b825a9cd4b0e /controlloop/common/eventmanager/src/main/java | |
parent | 2e2f7f988509b273912664ac2ffc07f583988b59 (diff) |
Add implementation for OOF PCI use case
Receive DMaaP message from PCI-Handler MS with PCI Config
change recommendations through DCAE_CL_OUTPUT topic.
Trigger SDN-R (if allowed by policy) by sending
DMaaP request through SDNR-CL topic.
When the response is received from SDNR through
SDNR-CL-RSP topic, just parse and print.
Code review comments addressed
Change-Id: If340a23ae18367b7f98e31fe79c09a09e645b2ad
Issue-ID: POLICY-1089
Signed-off-by: Saravanan A<saravanan.a75@wipro.com>
Diffstat (limited to 'controlloop/common/eventmanager/src/main/java')
-rw-r--r-- | controlloop/common/eventmanager/src/main/java/org/onap/policy/controlloop/eventmanager/ControlLoopOperationManager.java | 59 |
1 files changed, 58 insertions, 1 deletions
diff --git a/controlloop/common/eventmanager/src/main/java/org/onap/policy/controlloop/eventmanager/ControlLoopOperationManager.java b/controlloop/common/eventmanager/src/main/java/org/onap/policy/controlloop/eventmanager/ControlLoopOperationManager.java index f1d912ef5..1ad1e5af7 100644 --- a/controlloop/common/eventmanager/src/main/java/org/onap/policy/controlloop/eventmanager/ControlLoopOperationManager.java +++ b/controlloop/common/eventmanager/src/main/java/org/onap/policy/controlloop/eventmanager/ControlLoopOperationManager.java @@ -26,8 +26,8 @@ import java.time.Instant; import java.util.AbstractMap; import java.util.LinkedList; import java.util.List; -import java.util.Properties; import java.util.NoSuchElementException; +import java.util.Properties; import javax.persistence.EntityManager; import javax.persistence.Persistence; @@ -43,12 +43,14 @@ import org.onap.policy.controlloop.ControlLoopOperation; import org.onap.policy.controlloop.VirtualControlLoopEvent; import org.onap.policy.controlloop.actor.appc.APPCActorServiceProvider; import org.onap.policy.controlloop.actor.appclcm.AppcLcmActorServiceProvider; +import org.onap.policy.controlloop.actor.sdnr.SdnrActorServiceProvider; import org.onap.policy.controlloop.actor.so.SOActorServiceProvider; import org.onap.policy.controlloop.actor.vfc.VFCActorServiceProvider; import org.onap.policy.controlloop.policy.Policy; import org.onap.policy.controlloop.policy.PolicyResult; import org.onap.policy.drools.system.PolicyEngine; import org.onap.policy.guard.Util; +import org.onap.policy.sdnr.PciResponseWrapper; import org.onap.policy.so.SOResponseWrapper; import org.onap.policy.vfc.VFCResponse; import org.slf4j.Logger; @@ -214,6 +216,8 @@ public class ControlLoopOperationManager implements Serializable { break; case "SO": break; + case "SDNR": + break; case "VFC": break; default: @@ -284,6 +288,21 @@ public class ControlLoopOperationManager implements Serializable { this.policyResult = PolicyResult.FAILURE; } return operationRequest; + case "SDNR": + /* + * If the recipe is ModifyConfig, a SDNR request is constructed. + */ + this.currentOperation = operation; + this.operationRequest = SdnrActorServiceProvider.constructRequest((VirtualControlLoopEvent) onset, + operation.clOperation, this.policy); + // + // Save the operation + // + if (this.operationRequest == null) { + this.policyResult = PolicyResult.FAILURE; + } + + return operationRequest; default: throw new ControlLoopException("invalid actor " + policy.getActor() + " on policy"); } @@ -309,6 +328,11 @@ public class ControlLoopOperationManager implements Serializable { // Cast LCM response and handle it // return onResponse((LcmResponseWrapper) response); + } else if (response instanceof PciResponseWrapper) { + // + // Cast SDNR response and handle it + // + return onResponse((PciResponseWrapper) response); } else if (response instanceof SOResponseWrapper) { // // Cast SO response and handle it @@ -451,6 +475,39 @@ public class ControlLoopOperationManager implements Serializable { } /** + * This method handles operation responses from SDNR. + * + * @param dmaapResponse the SDNR response + * @return the result of the response handling + */ + private PolicyResult onResponse(PciResponseWrapper dmaapResponse) { + /* + * Parse out the operation attempt using the subrequestid + */ + Integer operationAttempt = SdnrActorServiceProvider + .parseOperationAttempt(dmaapResponse.getBody().getCommonHeader().getSubRequestId()); + if (operationAttempt == null) { + this.completeOperation(operationAttempt, "Policy was unable to parse SDNR SubRequestID.", + PolicyResult.FAILURE_EXCEPTION); + } + + /* + * Process the SDNR response to see what PolicyResult should be returned + */ + SdnrActorServiceProvider.Pair<PolicyResult, String> result = + SdnrActorServiceProvider.processResponse(dmaapResponse); + + if (result.getResult() != null) { + this.completeOperation(operationAttempt, result.getMessage(), result.getResult()); + if (PolicyResult.FAILURE_TIMEOUT.equals(this.policyResult)) { + return null; + } + return result.getResult(); + } + return null; + } + + /** * This method handles operation responses from SO. * * @param msoResponse the SO response |