diff options
author | 2018-10-01 18:09:24 -0500 | |
---|---|---|
committer | 2018-10-05 11:32:44 -0400 | |
commit | 4498fc2617e0003b7d2f53a6b09051fd216c840e (patch) | |
tree | 70238cb07b5bde82625e63f2aa3b337a05438f29 /controlloop/templates/archetype-cl-casablanca/src/main/resources | |
parent | 8c87163466a4eb5a010a9977adf8a365faec8631 (diff) |
Add new actor SDNC to support CCVPN Closed Loop
Issue-ID: POLICY-1183
Change-Id: I1b77b5b9cefca104382d9d84dd00bbd63b20e0f2
Signed-off-by: Xin Miao <xin.miao@huawei.com>
Signed-off-by: Pamela Dragosh <pdragosh@research.att.com>
Diffstat (limited to 'controlloop/templates/archetype-cl-casablanca/src/main/resources')
2 files changed, 94 insertions, 0 deletions
diff --git a/controlloop/templates/archetype-cl-casablanca/src/main/resources/archetype-resources/pom.xml b/controlloop/templates/archetype-cl-casablanca/src/main/resources/archetype-resources/pom.xml index aa56082bd..e44ebb20e 100644 --- a/controlloop/templates/archetype-cl-casablanca/src/main/resources/archetype-resources/pom.xml +++ b/controlloop/templates/archetype-cl-casablanca/src/main/resources/archetype-resources/pom.xml @@ -90,6 +90,11 @@ </dependency> <dependency> <groupId>org.onap.policy.drools-applications.controlloop.common.model-impl</groupId> + <artifactId>sdnc</artifactId> + <version>${dependenciesVersion}</version> + </dependency> + <dependency> + <groupId>org.onap.policy.drools-applications.controlloop.common.model-impl</groupId> <artifactId>trafficgenerator</artifactId> <version>${dependenciesVersion}</version> </dependency> @@ -134,6 +139,11 @@ <version>${dependenciesVersion}</version> </dependency> <dependency> + <groupId>org.onap.policy.drools-applications.controlloop.common.actors</groupId> + <artifactId>actor.sdnc</artifactId> + <version>${dependenciesVersion}</version> + </dependency> + <dependency> <groupId>org.onap.policy.drools-applications.controlloop.common</groupId> <artifactId>policy-yaml</artifactId> <version>${dependenciesVersion}</version> diff --git a/controlloop/templates/archetype-cl-casablanca/src/main/resources/archetype-resources/src/main/resources/__closedLoopControlName__.drl b/controlloop/templates/archetype-cl-casablanca/src/main/resources/archetype-resources/src/main/resources/__closedLoopControlName__.drl index f2fe23162..11855d47d 100644 --- a/controlloop/templates/archetype-cl-casablanca/src/main/resources/archetype-resources/src/main/resources/__closedLoopControlName__.drl +++ b/controlloop/templates/archetype-cl-casablanca/src/main/resources/archetype-resources/src/main/resources/__closedLoopControlName__.drl @@ -61,6 +61,9 @@ import org.onap.policy.so.SORelatedInstanceListElement; import org.onap.policy.so.SORelatedInstance; import org.onap.policy.so.SOResponse; import org.onap.policy.so.SOResponseWrapper; +import org.onap.policy.sdnc.SdncRequest; +import org.onap.policy.sdnc.SdncManager; +import org.onap.policy.sdnc.SdncResponse; import org.onap.policy.guard.PolicyGuard; import org.onap.policy.guard.PolicyGuard.LockResult; import org.onap.policy.guard.TargetLock; @@ -550,6 +553,14 @@ rule "EVENT.MANAGER.OPERATION.LOCKED.GUARD_PERMITTED" PolicyEngine.manager.deliver("SDNR-CL", request); } break; + + case "SDNC": + if (request instanceof SdncRequest) { + // Start SDNC thread + Thread t = new Thread(new SdncManager(drools.getWorkingMemory(), (SdncRequest)request)); + t.start(); + } + break; } } else { // @@ -1137,6 +1148,79 @@ end /* * +* This rule responds to SDNC Response Events +* +*/ +rule "SDNC.RESPONSE" + when + $params : ControlLoopParams( $clName : getClosedLoopControlName() ) + $event : VirtualControlLoopEvent( closedLoopControlName == $clName, closedLoopEventStatus == ControlLoopEventStatus.ONSET ) + $manager : ControlLoopEventManager( closedLoopControlName == $event.getClosedLoopControlName(), requestID == $event.getRequestId() ) + $operation : ControlLoopOperationManager( onset.closedLoopControlName == $event.getClosedLoopControlName(), onset.getRequestId() == $event.getRequestId() ) + $opTimer : ControlLoopTimer( closedLoopControlName == $event.getClosedLoopControlName(), + requestID == $event.getRequestId().toString(), timerType == "Operation", !expired ) + $lock : TargetLock (requestID == $event.getRequestId()) + $response : SdncResponse( requestId.toString() == $event.getRequestId().toString() ) + then + Logger logger = LoggerFactory.getLogger(drools.getRule().getPackage()); + logger.info("{}: {}", $clName, $params.getPolicyName() + "." + drools.getRule().getName()); + logger.debug("{}: {}: event={} manager={} operation={} lock={} opTimer={} response={}", + $clName, $params.getPolicyName() + "." + drools.getRule().getName(), + $event, $manager, $operation, $lock, $operation, $opTimer, $response); + + // Get the result of the operation + // + PolicyResult policyResult = $operation.onResponse($response); + if (policyResult != null) { + // + // This Operation has completed, construct a notification showing our results + // + VirtualControlLoopNotification notification = new VirtualControlLoopNotification($event); + notification.setFrom("policy"); + notification.setPolicyName($params.getPolicyName() + "." + drools.getRule().getName()); + notification.setPolicyScope($params.getPolicyScope()); + notification.setPolicyVersion($params.getPolicyVersion()); + notification.setMessage($operation.getOperationHistory()); + notification.setHistory($operation.getHistory()); + // + // Ensure the operation is complete + // + if ($operation.isOperationComplete()) { + // + // It is complete, remove it from memory + // + retract($operation); + // + // We must also retract the timer object + // NOTE: We could write a Rule to do this + // + retract($opTimer); + // + // Complete the operation + // + modify($manager) {finishOperation($operation)}; + } else { + // + // Just doing this will kick off the LOCKED rule again + // + modify($operation) {}; + } + } else { + // + // Its not finished yet (i.e. expecting more Response objects) + // + // Or possibly it is a leftover response that we timed the request out previously + // + } + // + // We are going to retract these objects from memory + // + retract($response); + +end + +/* +* * This manages a single timer. * Due to a bug in the drools code, the drools timer needed to be split from most of the objects in the when clause * |