diff options
12 files changed, 40 insertions, 49 deletions
diff --git a/controlloop/common/actors/actor.appc/src/main/java/org/onap/policy/controlloop/actor/appc/APPCActorServiceProvider.java b/controlloop/common/actors/actor.appc/src/main/java/org/onap/policy/controlloop/actor/appc/APPCActorServiceProvider.java index 9e63e467b..75810c01e 100644 --- a/controlloop/common/actors/actor.appc/src/main/java/org/onap/policy/controlloop/actor/appc/APPCActorServiceProvider.java +++ b/controlloop/common/actors/actor.appc/src/main/java/org/onap/policy/controlloop/actor/appc/APPCActorServiceProvider.java @@ -94,7 +94,8 @@ public class APPCActorServiceProvider implements Actor { request.CommonHeader = new CommonHeader(); request.CommonHeader.RequestID = onset.requestID; request.CommonHeader.SubRequestID = operation.subRequestId; - request.Action = policy.getRecipe(); + request.Action = policy.getRecipe().substring(0, 1).toUpperCase() + + policy.getRecipe().substring(1); /* * The target vnf-id may not be the same as the source vnf-id diff --git a/controlloop/common/actors/actor.appclcm/src/main/java/org/onap/policy/controlloop/actor/appclcm/AppcLcmActorServiceProvider.java b/controlloop/common/actors/actor.appclcm/src/main/java/org/onap/policy/controlloop/actor/appclcm/AppcLcmActorServiceProvider.java index 9f556fa2e..4ff1c1d2c 100644 --- a/controlloop/common/actors/actor.appclcm/src/main/java/org/onap/policy/controlloop/actor/appclcm/AppcLcmActorServiceProvider.java +++ b/controlloop/common/actors/actor.appclcm/src/main/java/org/onap/policy/controlloop/actor/appclcm/AppcLcmActorServiceProvider.java @@ -232,7 +232,8 @@ public class AppcLcmActorServiceProvider implements Actor { * An action is required for all APPC requests, this will * be the recipe specified in the policy. */ - appcRequest.setAction(policy.getRecipe().toLowerCase()); + appcRequest.setAction(policy.getRecipe().substring(0, 1).toUpperCase() + + policy.getRecipe().substring(1).toLowerCase()); /* * For R1, the payloads will not be required for the Restart, diff --git a/controlloop/common/actors/actor.appclcm/src/test/java/org/onap/policy/controlloop/actor/appclcm/AppcLcmServiceProviderTest.java b/controlloop/common/actors/actor.appclcm/src/test/java/org/onap/policy/controlloop/actor/appclcm/AppcLcmServiceProviderTest.java index f1df440a8..63ecd2ec9 100644 --- a/controlloop/common/actors/actor.appclcm/src/test/java/org/onap/policy/controlloop/actor/appclcm/AppcLcmServiceProviderTest.java +++ b/controlloop/common/actors/actor.appclcm/src/test/java/org/onap/policy/controlloop/actor/appclcm/AppcLcmServiceProviderTest.java @@ -157,7 +157,7 @@ public class AppcLcmServiceProviderTest { /* An action is required and cannot be null */ assertNotNull(appcRequest.getAction()); - assertEquals(appcRequest.getAction(), "restart"); + assertEquals(appcRequest.getAction(), "Restart"); /* Action Identifiers are required and cannot be null */ assertNotNull(appcRequest.getActionIdentifiers()); 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 262c4c6de..6e57b5ef0 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 @@ -346,8 +346,6 @@ public class ControlLoopOperationManager implements Serializable { return null; } else if (response instanceof SOResponse) { SOResponse msoResponse = (SOResponse) response; - - Integer operationAttempt = this.attempts; switch (msoResponse.httpResponseCode) { case 200: @@ -355,7 +353,7 @@ public class ControlLoopOperationManager implements Serializable { // // Consider it as success // - this.completeOperation(operationAttempt, msoResponse.httpResponseCode + " Success", PolicyResult.SUCCESS); + this.completeOperation(this.attempts, msoResponse.httpResponseCode + " Success", PolicyResult.SUCCESS); if (this.policyResult != null && this.policyResult.equals(PolicyResult.FAILURE_TIMEOUT)) { return null; } @@ -364,23 +362,21 @@ public class ControlLoopOperationManager implements Serializable { // // Consider it as failure // - this.completeOperation(operationAttempt, msoResponse.httpResponseCode + " Failed", PolicyResult.FAILURE); + this.completeOperation(this.attempts, msoResponse.httpResponseCode + " Failed", PolicyResult.FAILURE); if (this.policyResult != null && this.policyResult.equals(PolicyResult.FAILURE_TIMEOUT)) { return null; } - // increment operation attempts for retries - this.attempts += 1; return PolicyResult.FAILURE; } } else if (response instanceof VFCResponse) { VFCResponse vfcResponse = (VFCResponse) response; - Integer operationAttempt = this.attempts; + if (vfcResponse.responseDescriptor.getStatus().equalsIgnoreCase("finished")) { // // Consider it as success // - this.completeOperation(operationAttempt, " Success", PolicyResult.SUCCESS); + this.completeOperation(this.attempts, " Success", PolicyResult.SUCCESS); if (this.policyResult != null && this.policyResult.equals(PolicyResult.FAILURE_TIMEOUT)) { return null; } @@ -389,7 +385,7 @@ public class ControlLoopOperationManager implements Serializable { // // Consider it as failure // - this.completeOperation(operationAttempt, " Failed", PolicyResult.FAILURE); + this.completeOperation(this.attempts, " Failed", PolicyResult.FAILURE); if (this.policyResult != null && this.policyResult.equals(PolicyResult.FAILURE_TIMEOUT)) { return null; } 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 3dc984dd2..c3bd446c7 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 @@ -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(); @@ -663,7 +658,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"; } @@ -672,7 +667,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(); @@ -935,7 +930,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()); diff --git a/controlloop/templates/template.demo/src/main/resources/ControlLoop_Template_xacml_guard.drl b/controlloop/templates/template.demo/src/main/resources/ControlLoop_Template_xacml_guard.drl index 03a38e5dc..6916524b5 100644 --- a/controlloop/templates/template.demo/src/main/resources/ControlLoop_Template_xacml_guard.drl +++ b/controlloop/templates/template.demo/src/main/resources/ControlLoop_Template_xacml_guard.drl @@ -487,7 +487,7 @@ rule "${policyName}.EVENT.MANAGER.OPERATION.LOCKED.GUARD_PERMITTED" Logger.metrics($lock); - Object request = $operation.getOperationRequest(); + Object request = $operation.startOperation($event); if (request != null) { Logger.info("Starting operation"); @@ -561,19 +561,13 @@ rule "${policyName}.EVENT.MANAGER.OPERATION.LOCKED.GUARD_NOT_YET_QUERIED" Logger.metrics($manager); Logger.metrics($operation); Logger.metrics($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(); @@ -637,7 +631,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"; } @@ -646,7 +640,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(); diff --git a/controlloop/templates/template.demo/src/test/java/org/onap/policy/template/demo/ControlLoopXacmlGuardTest.java b/controlloop/templates/template.demo/src/test/java/org/onap/policy/template/demo/ControlLoopXacmlGuardTest.java index a6a4d3fc6..77a1ac063 100644 --- a/controlloop/templates/template.demo/src/test/java/org/onap/policy/template/demo/ControlLoopXacmlGuardTest.java +++ b/controlloop/templates/template.demo/src/test/java/org/onap/policy/template/demo/ControlLoopXacmlGuardTest.java @@ -76,7 +76,7 @@ public class ControlLoopXacmlGuardTest { @BeforeClass public static void setPUProp(){ System.setProperty(OPSHISTPUPROP, "TestOperationsHistoryPU"); - Util.setTestGuardProps(); + Util.setGuardProps(); } @AfterClass public static void restorePUProp(){ diff --git a/controlloop/templates/template.demo/src/test/java/org/onap/policy/template/demo/Util.java b/controlloop/templates/template.demo/src/test/java/org/onap/policy/template/demo/Util.java index df10714b9..66a72bc2b 100644 --- a/controlloop/templates/template.demo/src/test/java/org/onap/policy/template/demo/Util.java +++ b/controlloop/templates/template.demo/src/test/java/org/onap/policy/template/demo/Util.java @@ -275,18 +275,26 @@ public final class Util { PolicyEngine.manager.setEnvironmentProperty("aai.username", "AAI"); PolicyEngine.manager.setEnvironmentProperty("aai.password", "AAI"); } + public static void setSOProps(){ PolicyEngine.manager.setEnvironmentProperty("so.url", "http://localhost:6667"); PolicyEngine.manager.setEnvironmentProperty("so.username", "SO"); PolicyEngine.manager.setEnvironmentProperty("so.password", "SO"); } - public static void setTestGuardProps(){ + + public static void setGuardProps(){ PolicyEngine.manager.setEnvironmentProperty(org.onap.policy.guard.Util.PROP_GUARD_URL, "http://localhost:6669/pdp/api/getDecision"); PolicyEngine.manager.setEnvironmentProperty(org.onap.policy.guard.Util.PROP_GUARD_USER, "python"); PolicyEngine.manager.setEnvironmentProperty(org.onap.policy.guard.Util.PROP_GUARD_PASS, "test"); PolicyEngine.manager.setEnvironmentProperty(org.onap.policy.guard.Util.PROP_GUARD_CLIENT_USER, "python"); PolicyEngine.manager.setEnvironmentProperty(org.onap.policy.guard.Util.PROP_GUARD_CLIENT_PASS, "test"); PolicyEngine.manager.setEnvironmentProperty(org.onap.policy.guard.Util.PROP_GUARD_ENV, "TEST"); + } + + public static void setVFCProps() { + PolicyEngine.manager.setEnvironmentProperty("vfc.url", "http://localhost:6668"); + PolicyEngine.manager.setEnvironmentProperty("vfc.username", "VFC"); + PolicyEngine.manager.setEnvironmentProperty("vfc.password", "VFC"); } - + } diff --git a/controlloop/templates/template.demo/src/test/java/org/onap/policy/template/demo/VCPEControlLoopTest.java b/controlloop/templates/template.demo/src/test/java/org/onap/policy/template/demo/VCPEControlLoopTest.java index 9743f8808..d43537b80 100644 --- a/controlloop/templates/template.demo/src/test/java/org/onap/policy/template/demo/VCPEControlLoopTest.java +++ b/controlloop/templates/template.demo/src/test/java/org/onap/policy/template/demo/VCPEControlLoopTest.java @@ -45,7 +45,6 @@ import org.onap.policy.controlloop.policy.ControlLoopPolicy; import org.onap.policy.controlloop.policy.TargetType; import org.onap.policy.drools.http.server.HttpServletServer; import org.onap.policy.drools.impl.PolicyEngineJUnitImpl; -import org.onap.policy.drools.system.PolicyEngine; import org.onap.policy.guard.PolicyGuard; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -60,13 +59,8 @@ public class VCPEControlLoopTest { static { /* Set environment properties */ - PolicyEngine.manager.setEnvironmentProperty("aai.url", "http://localhost:6666"); - PolicyEngine.manager.setEnvironmentProperty("aai.username", "AAI"); - PolicyEngine.manager.setEnvironmentProperty("aai.password", "AAI"); - - PolicyEngine.manager.setEnvironmentProperty("guard.url", "http://localhost:6669/pdp/api/getDecision"); - PolicyEngine.manager.setEnvironmentProperty("guard.username", "GUARD"); - PolicyEngine.manager.setEnvironmentProperty("guard.password", "GUARD"); + Util.setAAIProps(); + Util.setGuardProps(); } @BeforeClass @@ -198,7 +192,7 @@ public class VCPEControlLoopTest { * See if Guard permits this action, if it does * not then the test should fail */ - if (((VirtualControlLoopNotification)obj).message.contains("Guard result: PERMIT")) { + if (((VirtualControlLoopNotification)obj).message.contains("PERMIT")) { /* * A notification should be sent out of the Policy diff --git a/controlloop/templates/template.demo/src/test/java/org/onap/policy/template/demo/VDNSControlLoopTest.java b/controlloop/templates/template.demo/src/test/java/org/onap/policy/template/demo/VDNSControlLoopTest.java index a8a4bf398..0b0cb6d1f 100644 --- a/controlloop/templates/template.demo/src/test/java/org/onap/policy/template/demo/VDNSControlLoopTest.java +++ b/controlloop/templates/template.demo/src/test/java/org/onap/policy/template/demo/VDNSControlLoopTest.java @@ -61,6 +61,7 @@ public class VDNSControlLoopTest { /* Set environment properties */ Util.setAAIProps(); Util.setSOProps(); + Util.setGuardProps(); } @BeforeClass @@ -68,6 +69,7 @@ public class VDNSControlLoopTest { try { Util.buildAaiSim(); Util.buildSoSim(); + Util.buildGuardSim(); } catch (Exception e) { fail(e.getMessage()); } diff --git a/controlloop/templates/template.demo/src/test/java/org/onap/policy/template/demo/VFCControlLoopTest.java b/controlloop/templates/template.demo/src/test/java/org/onap/policy/template/demo/VFCControlLoopTest.java index a4845693c..fbe9129bd 100644 --- a/controlloop/templates/template.demo/src/test/java/org/onap/policy/template/demo/VFCControlLoopTest.java +++ b/controlloop/templates/template.demo/src/test/java/org/onap/policy/template/demo/VFCControlLoopTest.java @@ -59,10 +59,8 @@ public class VFCControlLoopTest { static { /* Set environment properties */ Util.setAAIProps(); - - PolicyEngine.manager.setEnvironmentProperty("vfc.url", "http://localhost:6668"); - PolicyEngine.manager.setEnvironmentProperty("vfc.username", "VFC"); - PolicyEngine.manager.setEnvironmentProperty("vfc.password", "VFC"); + Util.setVFCProps(); + Util.setGuardProps(); } @BeforeClass diff --git a/controlloop/templates/template.demo/src/test/java/org/onap/policy/template/demo/VFWControlLoopTest.java b/controlloop/templates/template.demo/src/test/java/org/onap/policy/template/demo/VFWControlLoopTest.java index a63344d35..2569768f9 100644 --- a/controlloop/templates/template.demo/src/test/java/org/onap/policy/template/demo/VFWControlLoopTest.java +++ b/controlloop/templates/template.demo/src/test/java/org/onap/policy/template/demo/VFWControlLoopTest.java @@ -62,12 +62,14 @@ public class VFWControlLoopTest { static { /* Set environment properties */ Util.setAAIProps(); + Util.setGuardProps(); } @BeforeClass public static void setUpSimulator() { try { Util.buildAaiSim(); + Util.buildGuardSim(); } catch (Exception e) { fail(e.getMessage()); } @@ -192,7 +194,7 @@ public class VFWControlLoopTest { * See if Guard permits this action, if it does * not then the test should fail */ - if (((VirtualControlLoopNotification)obj).message.contains("Guard result: Permit")) { + if (((VirtualControlLoopNotification)obj).message.contains("PERMIT")) { /* * Obtain the ControlLoopNoticiation, it should be of type operation |