update to the latest drl 41/16541/2
authorJorge Hernandez <jh1730@att.com>
Fri, 29 Sep 2017 00:43:03 +0000 (19:43 -0500)
committerJorge Hernandez <jh1730@att.com>
Fri, 29 Sep 2017 03:37:51 +0000 (22:37 -0500)
Change-Id: I80b53b794832f9f440d60b33ff3958553ef5591f
Issue-ID: POLICY-264
Signed-off-by: Jorge Hernandez <jh1730@att.com>
config/pe/ClosedLoopControlName.drl

index c1af5cb..3273dc6 100644 (file)
@@ -114,7 +114,6 @@ rule "${policyName}.SETUP"
     logger.info("{}: {} : YAML=[{}]", params.getClosedLoopControlName(), drools.getRule().getName(), params.getControlLoopYaml());
     
     String sqlDbUsername = PolicyEngine.manager.getEnvironmentProperty("sql.db.username");
-    String sqlDbPassword = PolicyEngine.manager.getEnvironmentProperty("sql.db.password");
     
     String aaiUrl = PolicyEngine.manager.getEnvironmentProperty("aai.url");
     String aaiUsername = PolicyEngine.manager.getEnvironmentProperty("aai.username");
@@ -129,15 +128,16 @@ rule "${policyName}.SETUP"
     String vfcPassword = PolicyEngine.manager.getEnvironmentProperty("vfc.password");
     
     String guardUrl = PolicyEngine.manager.getEnvironmentProperty("guard.url");
-    String guardUsername = PolicyEngine.manager.getEnvironmentProperty("guard.username");
-    String guardPassword = PolicyEngine.manager.getEnvironmentProperty("guard.password");
+    String guardUsername = PolicyEngine.manager.getEnvironmentProperty("pdpx.username");
+    String guardPassword = PolicyEngine.manager.getEnvironmentProperty("pdpx.password");
     String guardJdbcUrl = PolicyEngine.manager.getEnvironmentProperty("guard.jdbc.url");
+    String guardDisabled = PolicyEngine.manager.getEnvironmentProperty("guard.disabled");
     
     logger.info("{}: {} : AAI=[{}:{}]", params.getClosedLoopControlName(), drools.getRule().getName(), aaiUrl, aaiUsername);
     logger.info("{}: {} : SO=[{}:{}]", params.getClosedLoopControlName(), drools.getRule().getName(), soUrl, soUsername);
     logger.info("{}: {} : VFC=[{}:{}]", params.getClosedLoopControlName(), drools.getRule().getName(), vfcUrl, vfcUsername);
-    logger.info("{}: {} : GUARD=[{}:{}:{}]", params.getClosedLoopControlName(), drools.getRule().getName(), guardUrl, guardUsername, guardJdbcUrl);
-    logger.info("{}: {} : DB=[{}:{}]", params.getClosedLoopControlName(), drools.getRule().getName(), sqlDbUsername, sqlDbPassword);
+    logger.info("{}: {} : GUARD=[{}:{}:{}:{}]", params.getClosedLoopControlName(), drools.getRule().getName(), guardUrl, guardUsername, guardJdbcUrl, guardDisabled);
+    logger.info("{}: {} : DB=[{}]", params.getClosedLoopControlName(), drools.getRule().getName(), sqlDbUsername);
 end
 
 /*
@@ -506,7 +506,7 @@ rule "${policyName}.EVENT.MANAGER.OPERATION.LOCKED.GUARD_PERMITTED"
         $params : Params( getClosedLoopControlName() == "${closedLoopControlName}" )
         $event : VirtualControlLoopEvent( closedLoopControlName == $params.getClosedLoopControlName() )
         $manager : ControlLoopEventManager( closedLoopControlName == $event.closedLoopControlName, requestID == $event.requestID )
-        $operation : ControlLoopOperationManager( onset.closedLoopControlName == $event.closedLoopControlName, onset.requestID == $event.requestID, getGuardApprovalStatus() == "Permit" )
+        $operation : ControlLoopOperationManager( onset.closedLoopControlName == $event.closedLoopControlName, onset.requestID == $event.requestID, "Permit".equalsIgnoreCase(getGuardApprovalStatus()) )
         $lock : TargetLock (requestID == $event.requestID)
     then
 
@@ -515,7 +515,7 @@ rule "${policyName}.EVENT.MANAGER.OPERATION.LOCKED.GUARD_PERMITTED"
                 $params.getClosedLoopControlName(), drools.getRule().getName(),
                 $event, $manager, $operation, $lock);    
 
-    Object request = $operation.getOperationRequest();
+    Object request = $operation.startOperation($event);
     
     if (request != null) {
       logger.debug("{}: {}: starting operation ..", 
@@ -592,18 +592,13 @@ rule "${policyName}.EVENT.MANAGER.OPERATION.LOCKED.GUARD_NOT_YET_QUERIED"
     logger.info("{}: {}: event={} manager={} operation={} lock={}", 
                 $params.getClosedLoopControlName(), drools.getRule().getName(),
                 $event, $manager, $operation, $lock);
-
-    //
-    // We are starting the operation but the actor won't be contacted until Guard is queried and permitted.
-    //
-    $operation.startOperation($event);
     
     //
     // Sending notification that we are about to query Guard ("DB write - start operation")
     //
     VirtualControlLoopNotification notification = new VirtualControlLoopNotification($event);
     notification.notification = ControlLoopNotificationType.OPERATION;
-    notification.message = $operation.getOperationMessage();
+    notification.message = "Sending guard query for " + $operation.policy.getActor() + " " + $operation.policy.getRecipe();
     notification.history = $operation.getHistory();
     notification.from = "policy";
     notification.policyName = drools.getRule().getName();
@@ -620,12 +615,13 @@ rule "${policyName}.EVENT.MANAGER.OPERATION.LOCKED.GUARD_NOT_YET_QUERIED"
     // to the CallGuardTask() and set the first argument to null 
     // (instead of XacmlPdpEngine).
     //
-    boolean guardEnabled = false;
+    
+    // NOTE: The environment properties uses "guard.disabled" but the boolean is guardEnabled
+    boolean guardEnabled = "false".equalsIgnoreCase(PolicyEngine.manager.getEnvironmentProperty("guard.disabled"));
     
     if(guardEnabled){
     
         Thread t = new Thread(new org.onap.policy.guard.CallGuardTask(
-                                                        PolicyEngine.manager.getEnvironmentProperty("guard.url"), 
                                                         drools.getWorkingMemory(),
                                                         $event.closedLoopControlName,
                                                         $operation.policy.getActor().toString(),
@@ -664,7 +660,7 @@ rule "${policyName}.GUARD.RESPONSE"
         
         
     //we will permit the operation if there was no Guard for it
-    if("Indeterminate".equals($guardResponse.result)){
+    if("Indeterminate".equalsIgnoreCase($guardResponse.result)){
         $guardResponse.result = "Permit";
     }
     
@@ -673,7 +669,7 @@ rule "${policyName}.GUARD.RESPONSE"
     //
     VirtualControlLoopNotification notification = new VirtualControlLoopNotification($event);
     notification.notification = ControlLoopNotificationType.OPERATION;
-    notification.message = $operation.getOperationMessage($guardResponse.result);
+    notification.message = "Guard result for " + $operation.policy.getActor() + " " + $operation.policy.getRecipe() + " is " + $guardResponse.result;
     notification.history = $operation.getHistory();
     notification.from = "policy";
     notification.policyName = drools.getRule().getName();
@@ -682,7 +678,7 @@ rule "${policyName}.GUARD.RESPONSE"
     
     PolicyEngine.manager.deliver("POLICY-CL-MGT", notification);
     
-    if("Permit".equals($guardResponse.result)){
+    if("Permit".equalsIgnoreCase($guardResponse.result)){
     
         modify($operation){setGuardApprovalStatus($guardResponse.result)};
     }
@@ -936,7 +932,7 @@ rule "${policyName}.SO.RESPONSE"
         $operation : ControlLoopOperationManager( onset.closedLoopControlName == $event.closedLoopControlName, onset.requestID == $event.requestID )
         $opTimer : OperationTimer( closedLoopControlName == $event.closedLoopControlName, requestID == $event.requestID.toString() )
         $lock : TargetLock (requestID == $event.requestID)
-        $response : SOResponse( request.requestId == $event.requestID.toString() )  
+        $response : SOResponse( requestReferences.requestId.toString() == $event.requestID.toString() )  
     then
         
     Logger logger = LoggerFactory.getLogger(drools.getRule().getPackage());
@@ -1224,4 +1220,4 @@ rule "${policyName}.EVENT.MANAGER.TIMEOUT"
             retract(lock);
         }
     }
-end
\ No newline at end of file
+end