summaryrefslogtreecommitdiffstats
path: root/controlloop/common/controller-usecases/src/main/java
diff options
context:
space:
mode:
Diffstat (limited to 'controlloop/common/controller-usecases/src/main/java')
-rw-r--r--controlloop/common/controller-usecases/src/main/java/org/onap/policy/drools/apps/controller/usecases/GetTargetEntityOperation2.java16
-rw-r--r--controlloop/common/controller-usecases/src/main/java/org/onap/policy/drools/apps/controller/usecases/UsecasesEventManager.java46
-rw-r--r--controlloop/common/controller-usecases/src/main/java/org/onap/policy/drools/apps/controller/usecases/step/Step2.java24
3 files changed, 50 insertions, 36 deletions
diff --git a/controlloop/common/controller-usecases/src/main/java/org/onap/policy/drools/apps/controller/usecases/GetTargetEntityOperation2.java b/controlloop/common/controller-usecases/src/main/java/org/onap/policy/drools/apps/controller/usecases/GetTargetEntityOperation2.java
index e1259e48d..f9d90af4d 100644
--- a/controlloop/common/controller-usecases/src/main/java/org/onap/policy/drools/apps/controller/usecases/GetTargetEntityOperation2.java
+++ b/controlloop/common/controller-usecases/src/main/java/org/onap/policy/drools/apps/controller/usecases/GetTargetEntityOperation2.java
@@ -33,10 +33,10 @@ import org.onap.aai.domain.yang.GenericVnf;
import org.onap.policy.controlloop.VirtualControlLoopEvent;
import org.onap.policy.controlloop.actorserviceprovider.OperationOutcome;
import org.onap.policy.controlloop.actorserviceprovider.OperationProperties;
+import org.onap.policy.controlloop.actorserviceprovider.TargetType;
import org.onap.policy.controlloop.actorserviceprovider.impl.OperationPartial;
import org.onap.policy.controlloop.actorserviceprovider.parameters.ControlLoopOperationParams;
import org.onap.policy.controlloop.eventmanager.StepContext;
-import org.onap.policy.controlloop.policy.Target;
/**
* An operation to get the target entity. This is a "pseudo" operation; it is not found
@@ -65,7 +65,7 @@ public class GetTargetEntityOperation2 extends OperationPartial {
@Override
public List<String> getPropertyNames() {
- String propName = detmTarget(params.getTarget());
+ String propName = detmTarget(params.getTargetType());
return (propName == null ? Collections.emptyList() : List.of(propName));
}
@@ -77,26 +77,22 @@ public class GetTargetEntityOperation2 extends OperationPartial {
/**
* Determines the target entity.
*
- * @param target policy target
+ * @param targetType policy target type
*
* @return the property containing the target entity, or {@code null} if the target
* entity is already known
*/
- private String detmTarget(Target target) {
+ private String detmTarget(TargetType targetType) {
if (stepContext.contains(OperationProperties.AAI_TARGET_ENTITY)) {
// the target entity has already been determined
return null;
}
- if (target == null) {
- throw new IllegalArgumentException("The target is null");
- }
-
- if (target.getType() == null) {
+ if (targetType == null) {
throw new IllegalArgumentException("The target type is null");
}
- switch (target.getType()) {
+ switch (targetType) {
case PNF:
return detmPnfTarget();
case VM:
diff --git a/controlloop/common/controller-usecases/src/main/java/org/onap/policy/drools/apps/controller/usecases/UsecasesEventManager.java b/controlloop/common/controller-usecases/src/main/java/org/onap/policy/drools/apps/controller/usecases/UsecasesEventManager.java
index cf8cc8ee3..d92fbcfad 100644
--- a/controlloop/common/controller-usecases/src/main/java/org/onap/policy/drools/apps/controller/usecases/UsecasesEventManager.java
+++ b/controlloop/common/controller-usecases/src/main/java/org/onap/policy/drools/apps/controller/usecases/UsecasesEventManager.java
@@ -58,16 +58,16 @@ import org.onap.policy.controlloop.ControlLoopOperation;
import org.onap.policy.controlloop.ControlLoopResponse;
import org.onap.policy.controlloop.VirtualControlLoopEvent;
import org.onap.policy.controlloop.VirtualControlLoopNotification;
+import org.onap.policy.controlloop.actorserviceprovider.OperationFinalResult;
import org.onap.policy.controlloop.actorserviceprovider.OperationOutcome;
import org.onap.policy.controlloop.actorserviceprovider.OperationProperties;
+import org.onap.policy.controlloop.actorserviceprovider.OperationResult;
+import org.onap.policy.controlloop.actorserviceprovider.TargetType;
import org.onap.policy.controlloop.actorserviceprovider.parameters.ControlLoopOperationParams;
import org.onap.policy.controlloop.drl.legacy.ControlLoopParams;
import org.onap.policy.controlloop.eventmanager.ActorConstants;
import org.onap.policy.controlloop.eventmanager.ControlLoopEventManager;
import org.onap.policy.controlloop.eventmanager.StepContext;
-import org.onap.policy.controlloop.policy.FinalResult;
-import org.onap.policy.controlloop.policy.Policy;
-import org.onap.policy.controlloop.policy.PolicyResult;
import org.onap.policy.drools.apps.controller.usecases.step.AaiCqStep2;
import org.onap.policy.drools.apps.controller.usecases.step.AaiGetPnfStep2;
import org.onap.policy.drools.apps.controller.usecases.step.AaiGetTenantStep2;
@@ -75,6 +75,9 @@ import org.onap.policy.drools.apps.controller.usecases.step.GetTargetEntityStep2
import org.onap.policy.drools.apps.controller.usecases.step.GuardStep2;
import org.onap.policy.drools.apps.controller.usecases.step.LockStep2;
import org.onap.policy.drools.apps.controller.usecases.step.Step2;
+import org.onap.policy.drools.domain.models.operational.ActorOperation;
+import org.onap.policy.drools.domain.models.operational.Operation;
+import org.onap.policy.drools.domain.models.operational.OperationalTarget;
import org.onap.policy.drools.system.PolicyEngine;
import org.onap.policy.drools.system.PolicyEngineConstants;
import org.onap.policy.sdnr.PciMessage;
@@ -172,7 +175,7 @@ public class UsecasesEventManager extends ControlLoopEventManager implements Ste
/**
* Policy currently being processed.
*/
- private Policy policy;
+ private Operation policy;
/**
* Result of the last policy operation. This is just a place where the rules can store
@@ -180,7 +183,7 @@ public class UsecasesEventManager extends ControlLoopEventManager implements Ste
*/
@Getter
@Setter
- private PolicyResult result = PolicyResult.SUCCESS;
+ private OperationResult result = OperationResult.SUCCESS;
@ToString.Include
private int numOnsets = 1;
@@ -205,7 +208,7 @@ public class UsecasesEventManager extends ControlLoopEventManager implements Ste
private final transient Deque<OperationOutcome2> partialHistory = new LinkedList<>();
@Getter
- private FinalResult finalResult = null;
+ private OperationFinalResult finalResult = null;
/**
* Message to be placed into the final notification. Typically used when something
@@ -284,7 +287,7 @@ public class UsecasesEventManager extends ControlLoopEventManager implements Ste
* @param finalResult final result
* @param finalMessage final message
*/
- public void abort(@NonNull State finalState, FinalResult finalResult, String finalMessage) {
+ public void abort(@NonNull State finalState, OperationFinalResult finalResult, String finalMessage) {
this.state = finalState;
this.finalResult = finalResult;
this.finalMessage = finalMessage;
@@ -297,7 +300,7 @@ public class UsecasesEventManager extends ControlLoopEventManager implements Ste
*
* @throws ControlLoopException if the processor cannot get a policy
*/
- public void loadNextPolicy(@NonNull PolicyResult lastResult) throws ControlLoopException {
+ public void loadNextPolicy(@NonNull OperationResult lastResult) throws ControlLoopException {
getProcessor().nextPolicyForResult(lastResult);
loadPolicy();
}
@@ -317,23 +320,30 @@ public class UsecasesEventManager extends ControlLoopEventManager implements Ste
policy = getProcessor().getCurrentPolicy();
+ ActorOperation actor = policy.getActorOperation();
+
+ OperationalTarget target = actor.getTarget();
+ String targetType = (target != null ? target.getTargetType() : null);
+ Map<String, String> entityIds = (target != null ? target.getEntityIds() : null);
+
// convert policy payload from Map<String,String> to Map<String,Object>
Map<String, Object> payload = new LinkedHashMap<>();
- if (policy.getPayload() != null) {
- payload.putAll(policy.getPayload());
+ if (actor.getPayload() != null) {
+ payload.putAll(actor.getPayload());
}
// @formatter:off
ControlLoopOperationParams params = ControlLoopOperationParams.builder()
.actorService(getActorService())
- .actor(policy.getActor())
- .operation(policy.getRecipe())
+ .actor(actor.getActor())
+ .operation(actor.getOperation())
.requestId(event.getRequestId())
.preprocessed(true)
.executor(getExecutor())
- .target(policy.getTarget())
- .retry(policy.getRetry())
+ .retry(policy.getRetries())
.timeoutSec(policy.getTimeout())
+ .targetType(TargetType.toTargetType(targetType))
+ .targetEntityIds(entityIds)
.payload(payload)
.startCallback(this::onStart)
.completeCallback(this::onComplete)
@@ -450,7 +460,7 @@ public class UsecasesEventManager extends ControlLoopEventManager implements Ste
* @return {@code true} if the TOSCA should be aborted, {@code false} otherwise
*/
public boolean isAbort(OperationOutcome outcome) {
- return (outcome.getResult() != PolicyResult.SUCCESS && ABORT_ACTORS.contains(outcome.getActor()));
+ return (outcome.getResult() != OperationResult.SUCCESS && ABORT_ACTORS.contains(outcome.getActor()));
}
/**
@@ -741,7 +751,11 @@ public class UsecasesEventManager extends ControlLoopEventManager implements Ste
this.attempt = attempts;
clOperation = outcome.toControlLoopOperation();
- clOperation.setTarget(policy.getTarget().toString());
+
+ // TODO encode()?
+ OperationalTarget target = policy.getActorOperation().getTarget();
+ String targetStr = (target != null ? target.toString() : null);
+ clOperation.setTarget(targetStr);
if (outcome.getEnd() == null) {
clOperation.setOutcome("Started");
diff --git a/controlloop/common/controller-usecases/src/main/java/org/onap/policy/drools/apps/controller/usecases/step/Step2.java b/controlloop/common/controller-usecases/src/main/java/org/onap/policy/drools/apps/controller/usecases/step/Step2.java
index 9275f791d..5d80ea5f4 100644
--- a/controlloop/common/controller-usecases/src/main/java/org/onap/policy/drools/apps/controller/usecases/step/Step2.java
+++ b/controlloop/common/controller-usecases/src/main/java/org/onap/policy/drools/apps/controller/usecases/step/Step2.java
@@ -59,7 +59,11 @@ import org.onap.policy.drools.apps.controller.usecases.UsecasesConstants;
* steps.
*/
public class Step2 extends Step {
- public static final String TARGET_INFO_MSG = "Target information";
+ public static final String TARGET_MODEL_VERSION_ID = "modelVersionId";
+ public static final String TARGET_MODEL_CUSTOMIZATION_ID = "modelCustomizationId";
+ public static final String TARGET_MODEL_INVARIANT_ID = "modelInvariantId";
+ public static final String TARGET_RESOURCE_ID = "resourceID";
+ public static final String TARGET_INFO_MSG = "Target Entity IDs";
public static final String ENRICHMENT_PREFIX = "enrichment/";
public static final String VSERVER_VSERVER_NAME = "vserver.vserver-name";
public static final String RESOURCE_LINK = "resource-link";
@@ -293,9 +297,9 @@ public class Step2 extends Step {
}
protected GenericVnf getResourceVnf() {
- verifyNotNull(TARGET_INFO_MSG, params.getTarget());
+ verifyNotNull(TARGET_INFO_MSG, params.getTargetEntityIds());
- String resourceId = params.getTarget().getResourceID();
+ String resourceId = params.getTargetEntityIds().get(TARGET_RESOURCE_ID);
verifyNotNull("Target resource ID", resourceId);
@@ -323,11 +327,11 @@ public class Step2 extends Step {
}
protected GenericVnf getVnf() {
- verifyNotNull(TARGET_INFO_MSG, params.getTarget());
+ verifyNotNull(TARGET_INFO_MSG, params.getTargetEntityIds());
- String modelInvariantId = params.getTarget().getModelInvariantId();
+ String modelInvariantId = params.getTargetEntityIds().get(TARGET_MODEL_INVARIANT_ID);
- verifyNotNull("modelInvariantId", modelInvariantId);
+ verifyNotNull(TARGET_MODEL_INVARIANT_ID, modelInvariantId);
AaiCqResponse aaicq = getCustomQueryData();
return aaicq.getGenericVnfByVfModuleModelInvariantId(modelInvariantId);
@@ -359,11 +363,11 @@ public class Step2 extends Step {
return stepContext.getProperty(OperationProperties.DATA_VF_COUNT);
}
- verifyNotNull(TARGET_INFO_MSG, params.getTarget());
+ verifyNotNull(TARGET_INFO_MSG, params.getTargetEntityIds());
- String modelCustomizationId = params.getTarget().getModelCustomizationId();
- String modelInvariantId = params.getTarget().getModelInvariantId();
- String modelVersionId = params.getTarget().getModelVersionId();
+ String modelCustomizationId = params.getTargetEntityIds().get(TARGET_MODEL_CUSTOMIZATION_ID);
+ String modelInvariantId = params.getTargetEntityIds().get(TARGET_MODEL_INVARIANT_ID);
+ String modelVersionId = params.getTargetEntityIds().get(TARGET_MODEL_VERSION_ID);
verifyNotNull("target modelCustomizationId", modelCustomizationId);
verifyNotNull("target modelInvariantId", modelInvariantId);