From da3ffabb02a1b1823557dcf179fbef613706dfc4 Mon Sep 17 00:00:00 2001 From: "pramod.jamkhedkar" Date: Wed, 28 Aug 2019 15:11:22 -0400 Subject: 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 --- .../main/resources/__closedLoopControlName__.drl | 35 +++++++++++++++++----- 1 file changed, 27 insertions(+), 8 deletions(-) (limited to 'controlloop/templates/archetype-cl-amsterdam') 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(); } -- cgit 1.2.3-korg