diff options
author | daniel <dc443y@att.com> | 2017-08-11 11:36:09 -0500 |
---|---|---|
committer | daniel <dc443y@att.com> | 2017-09-06 17:14:59 -0500 |
commit | 7576237fd14304e987eb3c907d481f503dab8232 (patch) | |
tree | ddc75f000cb86e3a426cf34d6031efbc14c8735e /controlloop/common/eventmanager/src/main | |
parent | b2bdc20c1ce3a390dd7928144c2ccb17a98b1363 (diff) |
Add APPC LCM Interface
The LCM model code and service provider code is implemented.
This model code is now used for the vCPE use case scenario.
The vFW use case is still using the legacy APPC API as
request by APPC for Policy to use in R1. The APPC
service provider now generates a demo legacy APPC
request with pg-streams.
An A&AI named query is implemented for the vFW use case.
The code for obtaining the generic-vnf.vnf-id is not
in use until we set up the A&AI simulator to work
without having cyclical depenncies inside the POMs.
JUnits for the vFW and vCPE use cases are now supported.
These JUnits test the complete flow of each scenario.
A&AI testing is not supported in the JUnit test yet.
These JUnits use a target type of VM as VNF is not
supported yet. This will be changed when the Target
Lock supports VNF.
Amended to fix Sonar blockers.
Issue-ID: POLICY-104
Change-Id: I46869c5fd5094919da55ad563d608fe6d4b6fea7
Signed-off-by: Daniel Cruz <dc443y@att.com>
Diffstat (limited to 'controlloop/common/eventmanager/src/main')
2 files changed, 50 insertions, 10 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 09f69fb0b..94b6e1618 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 @@ -23,6 +23,7 @@ package org.onap.policy.controlloop.eventmanager; import java.io.Serializable; import java.sql.Timestamp; import java.time.Instant; +import java.util.AbstractMap; import java.util.LinkedList; import javax.persistence.EntityManager; @@ -30,6 +31,7 @@ import javax.persistence.Persistence; import org.onap.policy.appc.Response; import org.onap.policy.appc.ResponseCode; +import org.onap.policy.appclcm.LCMResponseWrapper; import org.onap.policy.controlloop.ControlLoopEvent; import org.onap.policy.controlloop.ControlLoopOperation; import org.onap.policy.controlloop.VirtualControlLoopEvent; @@ -40,7 +42,7 @@ import org.onap.policy.controlloop.actor.appc.APPCActorServiceProvider; import org.onap.policy.controlloop.actor.vfc.VFCActorServiceProvider; import org.slf4j.Logger; import org.slf4j.LoggerFactory; - +import org.onap.policy.controlloop.actor.appclcm.AppcLcmActorServiceProvider; public class ControlLoopOperationManager implements Serializable { @@ -196,16 +198,22 @@ public class ControlLoopOperationManager implements Serializable { // switch (policy.getActor()) { case "APPC": - //Request request = APPCActorServiceProvider.constructRequest(onset, operation.operation, this.policy); - this.operationRequest = APPCActorServiceProvider.constructRequest((VirtualControlLoopEvent)onset, operation.operation, this.policy); + /* + * If the recipe is ModifyConfig, a legacy APPC + * request is constructed. Otherwise an LCMRequest + * is constructed. + */ + if ("ModifyConfig".equalsIgnoreCase(policy.getRecipe())) { + + this.operationRequest = APPCActorServiceProvider.constructRequest((VirtualControlLoopEvent)onset, operation.operation, this.policy); + } + else { + this.operationRequest = AppcLcmActorServiceProvider.constructRequest((VirtualControlLoopEvent) onset, operation.operation, this.policy); + } // // Save the operation // this.currentOperation = operation; - //System.out.print("************* BEFORE STORING....."); - //this.storeOperationInDataBase("startOperation"); - //System.out.print("************* AFTER STORING....."); - // return operationRequest; case "MSO": // @@ -306,7 +314,34 @@ public class ControlLoopOperationManager implements Serializable { } return PolicyResult.FAILURE; } - } + } + else if (response instanceof LCMResponseWrapper) { + + LCMResponseWrapper dmaapResponse = (LCMResponseWrapper) response; + + /* + * Parse out the operation attempt using the subrequestid + */ + Integer operationAttempt = AppcLcmActorServiceProvider.parseOperationAttempt(dmaapResponse.getBody().getCommonHeader().getSubRequestId()); + if (operationAttempt == null) { + this.completeOperation(operationAttempt, "Policy was unable to parse APP-C SubRequestID (it was null).", PolicyResult.FAILURE_EXCEPTION); + } + + /* + * Process the APPCLCM response to see what PolicyResult + * should be returned + */ + AbstractMap.SimpleEntry<PolicyResult, String> result = AppcLcmActorServiceProvider.processResponse(dmaapResponse); + + if (result.getKey() != null) { + this.completeOperation(operationAttempt, result.getValue(), result.getKey()); + if (PolicyResult.FAILURE_TIMEOUT.equals(this.policyResult)) { + return null; + } + return result.getKey(); + } + return null; + } return null; } diff --git a/controlloop/common/eventmanager/src/main/java/org/onap/policy/drools/impl/PolicyEngineJUnitImpl.java b/controlloop/common/eventmanager/src/main/java/org/onap/policy/drools/impl/PolicyEngineJUnitImpl.java index bb5cec8da..aed72815c 100644 --- a/controlloop/common/eventmanager/src/main/java/org/onap/policy/drools/impl/PolicyEngineJUnitImpl.java +++ b/controlloop/common/eventmanager/src/main/java/org/onap/policy/drools/impl/PolicyEngineJUnitImpl.java @@ -26,6 +26,7 @@ import java.util.Map; import java.util.Queue; import org.onap.policy.appc.Request; +import org.onap.policy.appclcm.LCMRequestWrapper; import org.onap.policy.controlloop.ControlLoopNotification; import org.onap.policy.controlloop.util.Serialization; import org.slf4j.Logger; @@ -49,6 +50,10 @@ public class PolicyEngineJUnitImpl implements PolicyEngine { Request request = (Request) obj; logger.debug("Request: {} subrequst {}", request.Action, request.CommonHeader.SubRequestID); } + else if (obj instanceof LCMRequestWrapper) { + LCMRequestWrapper dmaapRequest = (LCMRequestWrapper) obj; + logger.debug("Request: {} subrequest {}", dmaapRequest.getBody().getAction(), dmaapRequest.getBody().getCommonHeader().getSubRequestId()); + } // // Does the bus exist? // @@ -57,7 +62,7 @@ public class PolicyEngineJUnitImpl implements PolicyEngine { // // Create the bus // - busMap.put(busType, new HashMap<String, Queue<Object>>()); + busMap.put(busType, new HashMap<>()); } // // Get the bus @@ -71,7 +76,7 @@ public class PolicyEngineJUnitImpl implements PolicyEngine { // // Create the topic // - topicMap.put(topic, new LinkedList<Object>()); + topicMap.put(topic, new LinkedList<>()); } // // Get the topic queue |