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
* 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,
/* 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());
return null;
} else if (response instanceof SOResponse) {
SOResponse msoResponse = (SOResponse) response;
-
- Integer operationAttempt = this.attempts;
switch (msoResponse.httpResponseCode) {
case 200:
//
// 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;
}
//
// 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;
}
//
// 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;
}
$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 ..",
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();
//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";
}
//
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();
$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());
Logger.metrics($lock);
- Object request = $operation.getOperationRequest();
+ Object request = $operation.startOperation($event);
if (request != null) {
Logger.info("Starting operation");
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();
//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";
}
//
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();
@BeforeClass
public static void setPUProp(){
System.setProperty(OPSHISTPUPROP, "TestOperationsHistoryPU");
- Util.setTestGuardProps();
+ Util.setGuardProps();
}
@AfterClass
public static void restorePUProp(){
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");
}
-
+
}
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;
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
* 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
/* Set environment properties */
Util.setAAIProps();
Util.setSOProps();
+ Util.setGuardProps();
}
@BeforeClass
try {
Util.buildAaiSim();
Util.buildSoSim();
+ Util.buildGuardSim();
} catch (Exception e) {
fail(e.getMessage());
}
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
static {
/* Set environment properties */
Util.setAAIProps();
+ Util.setGuardProps();
}
@BeforeClass
public static void setUpSimulator() {
try {
Util.buildAaiSim();
+ Util.buildGuardSim();
} catch (Exception e) {
fail(e.getMessage());
}
* 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