Make Actors event-agnostic
[policy/models.git] / models-interactions / model-actors / actor.so / src / main / java / org / onap / policy / controlloop / actor / so / VfModuleCreate.java
index af06c91..f5c860e 100644 (file)
@@ -33,8 +33,6 @@ import org.onap.aai.domain.yang.GenericVnf;
 import org.onap.aai.domain.yang.ModelVer;
 import org.onap.aai.domain.yang.ServiceInstance;
 import org.onap.aai.domain.yang.Tenant;
-import org.onap.policy.aai.AaiConstants;
-import org.onap.policy.aai.AaiCqResponse;
 import org.onap.policy.common.endpoints.event.comm.Topic.CommInfrastructure;
 import org.onap.policy.common.endpoints.utils.NetLoggerUtil.EventType;
 import org.onap.policy.controlloop.actorserviceprovider.OperationOutcome;
@@ -51,10 +49,8 @@ import org.onap.policy.so.SoRequestParameters;
 import org.onap.policy.so.SoResponse;
 
 /**
- * Operation to create a VF Module. This gets the VF count from the A&AI Custom Query
- * response and stores it in the context. It also passes the count+1 to the guard. Once
- * the "create" completes successfully, it bumps the VF count that's stored in the
- * context.
+ * Operation to create a VF Module. When this completes successfully, it increments its VF
+ * Count property.
  */
 public class VfModuleCreate extends SoOperation {
     public static final String NAME = "VF Module Create";
@@ -86,38 +82,6 @@ public class VfModuleCreate extends SoOperation {
         validateTarget();
     }
 
-    /**
-     * Ensures that A&AI custom query has been performed, and then runs the guard.
-     */
-    @Override
-    @SuppressWarnings("unchecked")
-    protected CompletableFuture<OperationOutcome> startPreprocessorAsync() {
-        if (params.isPreprocessed()) {
-            return null;
-        }
-
-        // need the VF count
-        ControlLoopOperationParams cqParams = params.toBuilder().actor(AaiConstants.ACTOR_NAME)
-                        .operation(AaiCqResponse.OPERATION).payload(null).retry(null).timeoutSec(null).build();
-
-        // run Custom Query, extract the VF count, and then run the Guard
-
-        // @formatter:off
-        return sequence(() -> params.getContext().obtain(AaiCqResponse.CONTEXT_KEY, cqParams),
-                        this::obtainVfCount, this::startGuardAsync);
-        // @formatter:on
-    }
-
-    @Override
-    protected Map<String, Object> makeGuardPayload() {
-        Map<String, Object> payload = super.makeGuardPayload();
-
-        // run guard with the proposed vf count
-        payload.put(PAYLOAD_KEY_VF_COUNT, getVfCount() + 1);
-
-        return payload;
-    }
-
     @Override
     protected CompletableFuture<OperationOutcome> startOperationAsync(int attempt, OperationOutcome outcome) {
 
@@ -166,8 +130,8 @@ public class VfModuleCreate extends SoOperation {
         final ServiceInstance vnfServiceItem = getServiceInstance();
         final Tenant tenantItem = getDefaultTenant();
         final CloudRegion cloudRegionItem = getDefaultCloudRegion();
-        final ModelVer vnfModel = getVnfModel(vnfItem);
-        final ModelVer vnfServiceModel = getServiceModel(vnfServiceItem);
+        final ModelVer vnfModel = getVnfModel();
+        final ModelVer vnfServiceModel = getServiceModel();
 
         SoRequest request = new SoRequest();
         request.setOperationType(SoOperationType.SCALE_OUT);
@@ -181,7 +145,7 @@ public class VfModuleCreate extends SoOperation {
         request.getRequestDetails().getRequestParameters().setUserParams(null);
 
         // cloudConfiguration
-        request.getRequestDetails().setCloudConfiguration(constructCloudConfigurationCq(tenantItem, cloudRegionItem));
+        request.getRequestDetails().setCloudConfiguration(constructCloudConfiguration(tenantItem, cloudRegionItem));
 
         // modelInfo
         request.getRequestDetails().setModelInfo(soModelInfo);