diff options
author | 2019-08-28 15:11:22 -0400 | |
---|---|---|
committer | 2019-09-04 09:06:54 -0400 | |
commit | da3ffabb02a1b1823557dcf179fbef613706dfc4 (patch) | |
tree | 5d5f220fff8d0b35bd392d325654e5b4b56e36ab /controlloop/templates/archetype-cl-amsterdam/src/main/resources/archetype-resources | |
parent | c08643d82c6f615da747a8b4dedaac77277d4433 (diff) |
Changes drl files
Changes to the DRL file to change the rules to support custom query.
Added new VdnsControlLoop test for custom query, and supporting yaml
request
Issue-ID: POLICY-1858
Change-Id: Ic1b9e771bd36fe0642e9a3439189076a4906a4b8
Signed-off-by: pramod.jamkhedkar <pramod@research.att.com>
Diffstat (limited to 'controlloop/templates/archetype-cl-amsterdam/src/main/resources/archetype-resources')
-rw-r--r-- | controlloop/templates/archetype-cl-amsterdam/src/main/resources/archetype-resources/src/main/resources/__closedLoopControlName__.drl | 35 |
1 files changed, 27 insertions, 8 deletions
diff --git a/controlloop/templates/archetype-cl-amsterdam/src/main/resources/archetype-resources/src/main/resources/__closedLoopControlName__.drl b/controlloop/templates/archetype-cl-amsterdam/src/main/resources/archetype-resources/src/main/resources/__closedLoopControlName__.drl index 049bd9a23..57ebd7089 100644 --- a/controlloop/templates/archetype-cl-amsterdam/src/main/resources/archetype-resources/src/main/resources/__closedLoopControlName__.drl +++ b/controlloop/templates/archetype-cl-amsterdam/src/main/resources/archetype-resources/src/main/resources/__closedLoopControlName__.drl @@ -33,6 +33,7 @@ import org.onap.policy.controlloop.eventmanager.ControlLoopEventManager.NewEvent import org.onap.policy.controlloop.eventmanager.ControlLoopOperationManager; import org.onap.policy.controlloop.actor.so.SoActorServiceProvider; import org.onap.policy.aai.AaiNqResponseWrapper; +import org.onap.policy.aai.AaiCqResponse; import org.onap.policy.appc.Request; import org.onap.policy.appc.Response; import org.onap.policy.appc.CommonHeader; @@ -729,23 +730,24 @@ rule "${policyName}.EVENT.MANAGER.OPERATION.LOCKED.GUARD_NOT_YET_QUERIED" notification.setPolicyName(drools.getRule().getName()); notification.setPolicyScope("${policyScope}"); notification.setPolicyVersion("${policyVersion}"); - + PolicyEngineConstants.getManager().deliver("POLICY-CL-MGT", notification); - + // // Now send Guard Request to XACML Guard. In order to bypass the call to Guard, // just change guardEnabled to false. - // + // // In order to use REST XACML, provide a URL instead of "" as a second argument // to the CallGuardTask() and set the first argument to null // (instead of XacmlPdpEngine). // - + // NOTE: The environment properties uses "guard.disabled" but the boolean is guardEnabled boolean guardEnabled = "false".equalsIgnoreCase(PolicyEngineConstants.getManager().getEnvironmentProperty("guard.disabled")); - + boolean cqEnabled = "true".equalsIgnoreCase(PolicyEngineConstants.getManager().getEnvironmentProperty("aai.customQuery")); + if(guardEnabled){ - + Thread t = new Thread(new org.onap.policy.guard.CallGuardTask( drools.getWorkingMemory(), $event.getClosedLoopControlName(), @@ -754,8 +756,25 @@ rule "${policyName}.EVENT.MANAGER.OPERATION.LOCKED.GUARD_NOT_YET_QUERIED" $operation.getTargetEntity(), $event.getRequestId().toString(), () -> { - AaiNqResponseWrapper resp = $manager.getNqVserverFromAai(); - return(resp == null ? null : resp.countVfModules()); + if (!cqEnabled) { + AaiNqResponseWrapper resp = $manager.getNqVserverFromAai(); + return(resp == null ? null : resp.countVfModules()); + } else { + try { + AaiCqResponse resp_cq = $manager.getCqResponse($event); + if (resp_cq == null){ + return null; + } else { + String custId = $operation.policy.getTarget().getModelCustomizationId(); + String invId = $operation.policy.getTarget().getModelInvariantId(); + String verId = $operation.policy.getTarget().getModelVersionId(); + return resp_cq.getVfModuleCount(custId, invId, verId); + } + } catch (Exception e){ + logger.warn("{}: {}", $params.getClosedLoopControlName(), drools.getRule().getName(), e); + } + return null; + } })); t.start(); } |