summaryrefslogtreecommitdiffstats
path: root/models-interactions/model-actors
diff options
context:
space:
mode:
authorpramod.jamkhedkar <pramod@research.att.com>2019-11-13 13:21:16 -0500
committerpramod.jamkhedkar <pramod@research.att.com>2019-11-13 15:41:00 -0500
commit6de5a0c9e2acf3a799f53c9fedf8a40861b6ddbe (patch)
tree8acb76dd6de88cef955ce0914046d072c3a6d1a0 /models-interactions/model-actors
parentc34a4b6b2e111462cde7f5663b8fbbc4ad86fc7e (diff)
Removing Named Query.
Removing all the related files and necessary modifications for removing named query. The code now only supports Custom Query Issue-ID: POLICY-2125 Change-Id: Ifa5ccb74142aa424359c0dea85b90bbcf70147cb Signed-off-by: pramod.jamkhedkar <pramod@research.att.com>
Diffstat (limited to 'models-interactions/model-actors')
-rw-r--r--models-interactions/model-actors/actor.appclcm/src/main/java/org/onap/policy/controlloop/actor/appclcm/AppcLcmActorServiceProvider.java81
-rw-r--r--models-interactions/model-actors/actor.appclcm/src/test/java/org/onap/policy/controlloop/actor/appclcm/AppcLcmActorServiceProviderTest.java13
-rw-r--r--models-interactions/model-actors/actor.so/src/main/java/org/onap/policy/controlloop/actor/so/SoActorServiceProvider.java239
-rw-r--r--models-interactions/model-actors/actor.so/src/test/java/org/onap/policy/controlloop/actor/so/SoActorServiceProviderTest.java123
-rw-r--r--models-interactions/model-actors/actor.vfc/src/main/java/org/onap/policy/controlloop/actor/vfc/VfcActorServiceProvider.java74
-rw-r--r--models-interactions/model-actors/actor.vfc/src/test/java/org/onap/policy/controlloop/actor/vfc/VfcActorServiceProviderTest.java49
6 files changed, 0 insertions, 579 deletions
diff --git a/models-interactions/model-actors/actor.appclcm/src/main/java/org/onap/policy/controlloop/actor/appclcm/AppcLcmActorServiceProvider.java b/models-interactions/model-actors/actor.appclcm/src/main/java/org/onap/policy/controlloop/actor/appclcm/AppcLcmActorServiceProvider.java
index 447a2720d..fb307587d 100644
--- a/models-interactions/model-actors/actor.appclcm/src/main/java/org/onap/policy/controlloop/actor/appclcm/AppcLcmActorServiceProvider.java
+++ b/models-interactions/model-actors/actor.appclcm/src/main/java/org/onap/policy/controlloop/actor/appclcm/AppcLcmActorServiceProvider.java
@@ -30,15 +30,6 @@ import java.util.Collections;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
-import java.util.UUID;
-import org.onap.policy.aai.AaiManager;
-import org.onap.policy.aai.AaiNqInstanceFilters;
-import org.onap.policy.aai.AaiNqInventoryResponseItem;
-import org.onap.policy.aai.AaiNqNamedQuery;
-import org.onap.policy.aai.AaiNqQueryParameters;
-import org.onap.policy.aai.AaiNqRequest;
-import org.onap.policy.aai.AaiNqResponse;
-import org.onap.policy.aai.util.AaiException;
import org.onap.policy.appclcm.AppcLcmBody;
import org.onap.policy.appclcm.AppcLcmCommonHeader;
import org.onap.policy.appclcm.AppcLcmDmaapWrapper;
@@ -50,7 +41,6 @@ import org.onap.policy.controlloop.VirtualControlLoopEvent;
import org.onap.policy.controlloop.actorserviceprovider.spi.Actor;
import org.onap.policy.controlloop.policy.Policy;
import org.onap.policy.controlloop.policy.PolicyResult;
-import org.onap.policy.rest.RestManager;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -104,77 +94,6 @@ public class AppcLcmActorServiceProvider implements Actor {
return ImmutableList.copyOf(payloads.getOrDefault(recipe, Collections.emptyList()));
}
- /**
- * This method recursively traverses the A&AI named query response to find the generic-vnf
- * object that contains a model-invariant-id that matches the resourceId of the policy. Once
- * this match is found the generic-vnf object's vnf-id is returned.
- *
- * @param items the list of items related to the vnf returned by A&AI
- * @param resourceId the id of the target from the sdc catalog
- *
- * @return the vnf-id of the target vnf to act upon or null if not found
- */
- private static String parseAaiResponse(List<AaiNqInventoryResponseItem> items, String resourceId) {
- String vnfId = null;
- for (AaiNqInventoryResponseItem item : items) {
- if ((item.getGenericVnf() != null) && (item.getGenericVnf().getModelInvariantId() != null)
- && (resourceId.equals(item.getGenericVnf().getModelInvariantId()))) {
- vnfId = item.getGenericVnf().getVnfId();
- break;
- } else {
- if ((item.getItems() != null) && (item.getItems().getInventoryResponseItems() != null)) {
- vnfId = parseAaiResponse(item.getItems().getInventoryResponseItems(), resourceId);
- }
- }
- }
- return vnfId;
- }
-
- /**
- * Constructs an A&AI Named Query using a source vnf-id to determine the vnf-id of the target
- * entity specified in the policy to act upon.
- *
- * @param resourceId the id of the target from the sdc catalog
- *
- * @param sourceVnfId the vnf id of the source entity reporting the alert
- *
- * @return the target entities vnf id to act upon
- * @throws AaiException it an error occurs
- */
- public static String vnfNamedQuery(String resourceId, String sourceVnfId, String aaiUrl,
- String aaiUser, String aaiPassword) throws AaiException {
-
- // TODO: This request id should not be hard coded in future releases
- UUID requestId = UUID.fromString("a93ac487-409c-4e8c-9e5f-334ae8f99087");
-
- AaiNqRequest aaiRequest = new AaiNqRequest();
- aaiRequest.setQueryParameters(new AaiNqQueryParameters());
- aaiRequest.getQueryParameters().setNamedQuery(new AaiNqNamedQuery());
- aaiRequest.getQueryParameters().getNamedQuery().setNamedQueryUuid(requestId);
-
- Map<String, Map<String, String>> filter = new HashMap<>();
- Map<String, String> filterItem = new HashMap<>();
-
- filterItem.put("vnf-id", sourceVnfId);
- filter.put("generic-vnf", filterItem);
-
- aaiRequest.setInstanceFilters(new AaiNqInstanceFilters());
- aaiRequest.getInstanceFilters().getInstanceFilter().add(filter);
-
- AaiNqResponse aaiResponse = new AaiManager(new RestManager()).postQuery(aaiUrl,
- aaiUser, aaiPassword, aaiRequest, requestId);
-
- if (aaiResponse == null) {
- throw new AaiException("The named query response was null");
- }
-
- String targetVnfId = parseAaiResponse(aaiResponse.getInventoryResponseItems(), resourceId);
- if (targetVnfId == null) {
- throw new AaiException("Target vnf-id could not be found");
- }
-
- return targetVnfId;
- }
/**
* Constructs an APPC request conforming to the lcm API. The actual request is constructed and
diff --git a/models-interactions/model-actors/actor.appclcm/src/test/java/org/onap/policy/controlloop/actor/appclcm/AppcLcmActorServiceProviderTest.java b/models-interactions/model-actors/actor.appclcm/src/test/java/org/onap/policy/controlloop/actor/appclcm/AppcLcmActorServiceProviderTest.java
index 45057f008..88fb6e97f 100644
--- a/models-interactions/model-actors/actor.appclcm/src/test/java/org/onap/policy/controlloop/actor/appclcm/AppcLcmActorServiceProviderTest.java
+++ b/models-interactions/model-actors/actor.appclcm/src/test/java/org/onap/policy/controlloop/actor/appclcm/AppcLcmActorServiceProviderTest.java
@@ -332,19 +332,6 @@ public class AppcLcmActorServiceProviderTest {
}
/*
- * This test ensures that that if the the source entity is also the target entity, the source
- * will be used for the APPC request.
- */
- @Test
- public void sourceIsTargetTest() throws Exception {
- String resourceId = "82194af1-3c2c-485a-8f44-420e22a9eaa4";
- String targetVnfId = AppcLcmActorServiceProvider.vnfNamedQuery(resourceId, VNF01, "http://localhost:6666",
- "AAI", "AAI");
- assertNotNull(targetVnfId);
- assertEquals(VNF01, targetVnfId);
- }
-
- /*
* This test exercises getters not exercised in other tests.
*/
@Test
diff --git a/models-interactions/model-actors/actor.so/src/main/java/org/onap/policy/controlloop/actor/so/SoActorServiceProvider.java b/models-interactions/model-actors/actor.so/src/main/java/org/onap/policy/controlloop/actor/so/SoActorServiceProvider.java
index 842d0f6a5..b85307547 100644
--- a/models-interactions/model-actors/actor.so/src/main/java/org/onap/policy/controlloop/actor/so/SoActorServiceProvider.java
+++ b/models-interactions/model-actors/actor.so/src/main/java/org/onap/policy/controlloop/actor/so/SoActorServiceProvider.java
@@ -33,9 +33,6 @@ import org.onap.aai.domain.yang.GenericVnf;
import org.onap.aai.domain.yang.ServiceInstance;
import org.onap.aai.domain.yang.Tenant;
import org.onap.policy.aai.AaiCqResponse;
-import org.onap.policy.aai.AaiNqExtraProperty;
-import org.onap.policy.aai.AaiNqInventoryResponseItem;
-import org.onap.policy.aai.AaiNqResponseWrapper;
import org.onap.policy.controlloop.ControlLoopOperation;
import org.onap.policy.controlloop.VirtualControlLoopEvent;
import org.onap.policy.controlloop.actorserviceprovider.spi.Actor;
@@ -82,10 +79,6 @@ public class SoActorServiceProvider implements Actor {
// name of configuration parameters within policy payload
public static final String CONFIG_PARAM_NM = "configurationParameters";
- private static final String MODEL_NAME_PROPERTY_KEY = "model-ver.model-name";
- private static final String MODEL_VERSION_PROPERTY_KEY = "model-ver.model-version";
- private static final String MODEL_VERSION_ID_PROPERTY_KEY = "model-ver.model-version-id";
-
// used to decode configuration parameters via gson
private static final Type CONFIG_TYPE = new TypeToken<List<Map<String, String>>>() {}.getType();
@@ -116,79 +109,6 @@ public class SoActorServiceProvider implements Actor {
return Collections.emptyList();
}
- /**
- * Constructs a SO request conforming to the lcm API. The actual request is constructed and then placed in a wrapper
- * object used to send through DMAAP.
- *
- * @param onset the event that is reporting the alert for policy to perform an action
- * @param operation the control loop operation specifying the actor, operation, target, etc.
- * @param policy the policy the was specified from the yaml generated by CLAMP or through the Policy GUI/API
- * @param aaiResponseWrapper wrapper for AAI vserver named-query response
- * @return a SO request conforming to the lcm API using the DMAAP wrapper
- */
- public SoRequest constructRequest(VirtualControlLoopEvent onset, ControlLoopOperation operation, Policy policy,
- AaiNqResponseWrapper aaiResponseWrapper) {
- if (!SO_ACTOR.equals(policy.getActor()) || !recipes().contains(policy.getRecipe())) {
- return null;
- }
-
- // A&AI named query should have been performed by now. If not, return null
- if (aaiResponseWrapper == null) {
- return null;
- }
-
- AaiNqInventoryResponseItem vnfItem;
- AaiNqInventoryResponseItem vnfServiceItem;
- AaiNqInventoryResponseItem tenantItem;
-
- // Extract the items we're interested in from the response
- try {
- vnfItem = aaiResponseWrapper.getAaiNqResponse().getInventoryResponseItems().get(0).getItems()
- .getInventoryResponseItems().get(0);
- } catch (Exception e) {
- logger.error("VNF Item not found in AAI response {}", Serialization.gsonPretty.toJson(aaiResponseWrapper),
- e);
- return null;
- }
-
- try {
- vnfServiceItem = vnfItem.getItems().getInventoryResponseItems().get(0);
- } catch (Exception e) {
- logger.error("VNF Service Item not found in AAI response {}",
- Serialization.gsonPretty.toJson(aaiResponseWrapper), e);
- return null;
- }
-
- try {
- tenantItem = aaiResponseWrapper.getAaiNqResponse().getInventoryResponseItems().get(0).getItems()
- .getInventoryResponseItems().get(1);
- } catch (Exception e) {
- logger.error(TENANT_NOT_FOUND,
- Serialization.gsonPretty.toJson(aaiResponseWrapper), e);
- return null;
- }
-
- // Find the index for base vf module and non-base vf module
- AaiNqInventoryResponseItem baseItem = findVfModule(aaiResponseWrapper, true);
-
- SoModelInfo soModelInfo = prepareSoModelInfo(policy);
-
- // Report the error if either base vf module or non-base vf module is not found
- if (baseItem == null || soModelInfo == null) {
- logger.error("Either base or non-base vf module is not found from AAI response.");
- return null;
- }
-
- // Construct SO Request for a policy's recipe
- if (RECIPE_VF_MODULE_CREATE.equals(policy.getRecipe())) {
- return constructCreateRequest(aaiResponseWrapper, policy, tenantItem, vnfItem, vnfServiceItem, soModelInfo);
- } else if (RECIPE_VF_MODULE_DELETE.equals(policy.getRecipe())) {
- return constructDeleteRequest(tenantItem, vnfItem, vnfServiceItem, policy);
- } else {
- return null;
- }
- }
-
private SoModelInfo prepareSoModelInfo(Policy policy) {
if (policy.getTarget() == null || policy.getTarget().getModelCustomizationId() == null
@@ -212,139 +132,6 @@ public class SoActorServiceProvider implements Actor {
}
/**
- * Construct SO request to create vf-module.
- *
- * @param aaiResponseWrapper the AAI response containing the VF modules
- * @param policy the policy
- * @param tenantItem tenant item from A&AI named-query response
- * @param vnfItem vnf item from A&AI named-query response
- * @param vnfServiceItem vnf service item from A&AI named-query response
- * @param vfModuleItem vf module item from A&AI named-query response
- * @return SO create vf-module request
- */
- private SoRequest constructCreateRequest(AaiNqResponseWrapper aaiResponseWrapper, Policy policy,
- AaiNqInventoryResponseItem tenantItem, AaiNqInventoryResponseItem vnfItem,
- AaiNqInventoryResponseItem vnfServiceItem, SoModelInfo vfModuleItem) {
- SoRequest request = new SoRequest();
- request.setOperationType(SoOperationType.SCALE_OUT);
- //
- //
- // Do NOT send So the requestId, they do not support this field
- //
- request.setRequestDetails(new SoRequestDetails());
- request.getRequestDetails().setRequestParameters(new SoRequestParameters());
- request.getRequestDetails().getRequestParameters().setUserParams(null);
-
- // cloudConfiguration
- request.getRequestDetails().setCloudConfiguration(constructCloudConfiguration(tenantItem));
- // modelInfo
- request.getRequestDetails().setModelInfo(vfModuleItem);
-
- // requestInfo
- request.getRequestDetails().setRequestInfo(constructRequestInfo());
- String vfModuleName = aaiResponseWrapper.genVfModuleName();
- request.getRequestDetails().getRequestInfo().setInstanceName(vfModuleName);
-
- // relatedInstanceList
- SoRelatedInstanceListElement relatedInstanceListElement1 = new SoRelatedInstanceListElement();
- SoRelatedInstanceListElement relatedInstanceListElement2 = new SoRelatedInstanceListElement();
- relatedInstanceListElement1.setRelatedInstance(new SoRelatedInstance());
- relatedInstanceListElement2.setRelatedInstance(new SoRelatedInstance());
-
- // Service Item
- relatedInstanceListElement1.getRelatedInstance()
- .setInstanceId(vnfServiceItem.getServiceInstance().getServiceInstanceId());
- relatedInstanceListElement1.getRelatedInstance().setModelInfo(new SoModelInfo());
- relatedInstanceListElement1.getRelatedInstance().getModelInfo().setModelType("service");
- relatedInstanceListElement1.getRelatedInstance().getModelInfo()
- .setModelInvariantId(vnfServiceItem.getServiceInstance().getModelInvariantId());
- for (AaiNqExtraProperty prop : vnfServiceItem.getExtraProperties().getExtraProperty()) {
- if (prop.getPropertyName().equals(MODEL_NAME_PROPERTY_KEY)) {
- relatedInstanceListElement1.getRelatedInstance().getModelInfo().setModelName(prop.getPropertyValue());
- } else if (prop.getPropertyName().equals(MODEL_VERSION_PROPERTY_KEY)) {
- relatedInstanceListElement1.getRelatedInstance().getModelInfo()
- .setModelVersion(prop.getPropertyValue());
- } else if (prop.getPropertyName().equals(MODEL_VERSION_ID_PROPERTY_KEY)) {
- relatedInstanceListElement1.getRelatedInstance().getModelInfo()
- .setModelVersionId(prop.getPropertyValue());
- }
- }
-
- // VNF Item
- relatedInstanceListElement2.getRelatedInstance().setInstanceId(vnfItem.getGenericVnf().getVnfId());
- relatedInstanceListElement2.getRelatedInstance().setModelInfo(new SoModelInfo());
- relatedInstanceListElement2.getRelatedInstance().getModelInfo().setModelType("vnf");
- relatedInstanceListElement2.getRelatedInstance().getModelInfo()
- .setModelInvariantId(vnfItem.getGenericVnf().getModelInvariantId());
- for (AaiNqExtraProperty prop : vnfItem.getExtraProperties().getExtraProperty()) {
- if (prop.getPropertyName().equals(MODEL_NAME_PROPERTY_KEY)) {
- relatedInstanceListElement2.getRelatedInstance().getModelInfo().setModelName(prop.getPropertyValue());
- } else if (prop.getPropertyName().equals(MODEL_VERSION_PROPERTY_KEY)) {
- relatedInstanceListElement2.getRelatedInstance().getModelInfo()
- .setModelVersion(prop.getPropertyValue());
- } else if (prop.getPropertyName().equals(MODEL_VERSION_ID_PROPERTY_KEY)) {
- relatedInstanceListElement2.getRelatedInstance().getModelInfo()
- .setModelVersionId(prop.getPropertyValue());
- }
- }
-
- relatedInstanceListElement2.getRelatedInstance().getModelInfo().setModelCustomizationName(vnfItem
- .getGenericVnf().getVnfType().substring(vnfItem.getGenericVnf().getVnfType().lastIndexOf('/') + 1));
- relatedInstanceListElement2.getRelatedInstance().getModelInfo()
- .setModelCustomizationId(vnfItem.getGenericVnf().getModelCustomizationId());
-
- // Insert the Service Item and VNF Item
- request.getRequestDetails().getRelatedInstanceList().add(relatedInstanceListElement1);
- request.getRequestDetails().getRelatedInstanceList().add(relatedInstanceListElement2);
-
- // Request Parameters
- buildRequestParameters(policy, request.getRequestDetails());
-
- // Configuration Parameters
- buildConfigurationParameters(policy, request.getRequestDetails());
- // Save the instance IDs for the VNF and service to static fields
- // vfModuleId is not required for the create vf-module
- preserveInstanceIds(vnfItem.getGenericVnf().getVnfId(),
- vnfServiceItem.getServiceInstance().getServiceInstanceId(), null);
- if (logger.isDebugEnabled()) {
- logger.debug(CONSTRUCTED_SO_MSG, Serialization.gsonPretty.toJson(request));
- }
- return request;
- }
-
- /**
- * Construct SO request to delete vf-module.
- *
- * @param tenantItem tenant item from A&AI named-query response
- * @param vnfItem vnf item from A&AI named-query response
- * @param vnfServiceItem vnf service item from A&AI named-query response
- * @return SO delete vf-module request
- */
- private SoRequest constructDeleteRequest(AaiNqInventoryResponseItem tenantItem, AaiNqInventoryResponseItem vnfItem,
- AaiNqInventoryResponseItem vnfServiceItem, Policy policy) {
- SoRequest request = new SoRequest();
- request.setOperationType(SoOperationType.DELETE_VF_MODULE);
- request.setRequestDetails(new SoRequestDetails());
- request.getRequestDetails().setRelatedInstanceList(null);
- request.getRequestDetails().setConfigurationParameters(null);
-
- // cloudConfiguration
- request.getRequestDetails().setCloudConfiguration(constructCloudConfiguration(tenantItem));
- // modelInfo
- request.getRequestDetails().setModelInfo(prepareSoModelInfo(policy));
- // requestInfo
- request.getRequestDetails().setRequestInfo(constructRequestInfo());
- // Save the instance IDs for the VNF, service and vfModule to static fields
- preserveInstanceIds(vnfItem.getGenericVnf().getVnfId(),
- vnfServiceItem.getServiceInstance().getServiceInstanceId(), null);
-
- if (logger.isDebugEnabled()) {
- logger.debug(CONSTRUCTED_SO_MSG, Serialization.gsonPretty.toJson(request));
- }
- return request;
- }
-
- /**
* Construct requestInfo for the SO requestDetails.
*
* @return SO request information
@@ -358,20 +145,6 @@ public class SoActorServiceProvider implements Actor {
}
/**
- * Construct cloudConfiguration for the SO requestDetails.
- *
- * @param tenantItem tenant item from A&AI named-query response
- * @return SO cloud configuration
- */
- private SoCloudConfiguration constructCloudConfiguration(AaiNqInventoryResponseItem tenantItem) {
- SoCloudConfiguration cloudConfiguration = new SoCloudConfiguration();
- cloudConfiguration.setTenantId(tenantItem.getTenant().getTenantId());
- cloudConfiguration.setLcpCloudRegionId(
- tenantItem.getItems().getInventoryResponseItems().get(0).getCloudRegion().getCloudRegionId());
- return cloudConfiguration;
- }
-
- /**
* This method is needed to get the serviceInstanceId and vnfInstanceId which is used in the asyncSORestCall.
*
* @param requestId the request Id
@@ -388,18 +161,6 @@ public class SoActorServiceProvider implements Actor {
lastVfModuleItemVfModuleInstanceId, (SoRequest) request);
}
- /**
- * Find the base or non base VF module item in an AAI response. If there is more than one item, then the <i>last</i>
- * item is returned
- *
- * @param aaiResponseWrapper the AAI response containing the VF modules
- * @param baseFlag true if we are searching for the base, false if we are searching for the non base
- * @return the base or non base VF module item or null if the module was not found
- */
- private AaiNqInventoryResponseItem findVfModule(AaiNqResponseWrapper aaiResponseWrapper, boolean baseFlag) {
- List<AaiNqInventoryResponseItem> lst = aaiResponseWrapper.getVfModuleItems(baseFlag);
- return (lst.isEmpty() ? null : lst.get(lst.size() - 1));
- }
/**
* Builds the request parameters from the policy payload.
diff --git a/models-interactions/model-actors/actor.so/src/test/java/org/onap/policy/controlloop/actor/so/SoActorServiceProviderTest.java b/models-interactions/model-actors/actor.so/src/test/java/org/onap/policy/controlloop/actor/so/SoActorServiceProviderTest.java
index 175d2fe0c..b46ac52fb 100644
--- a/models-interactions/model-actors/actor.so/src/test/java/org/onap/policy/controlloop/actor/so/SoActorServiceProviderTest.java
+++ b/models-interactions/model-actors/actor.so/src/test/java/org/onap/policy/controlloop/actor/so/SoActorServiceProviderTest.java
@@ -37,8 +37,6 @@ import java.util.UUID;
import org.apache.commons.io.IOUtils;
import org.junit.Test;
import org.onap.policy.aai.AaiCqResponse;
-import org.onap.policy.aai.AaiNqResponse;
-import org.onap.policy.aai.AaiNqResponseWrapper;
import org.onap.policy.controlloop.ControlLoopOperation;
import org.onap.policy.controlloop.VirtualControlLoopEvent;
import org.onap.policy.controlloop.policy.Policy;
@@ -55,113 +53,6 @@ public class SoActorServiceProviderTest {
private static final String VF_MODULE_CREATE = "VF Module Create";
private static final String VF_MODULE_DELETE = "VF Module Delete";
- @Test
- public void testConstructRequest() throws Exception {
- VirtualControlLoopEvent onset = new VirtualControlLoopEvent();
- final ControlLoopOperation operation = new ControlLoopOperation();
- final AaiNqResponseWrapper aaiNqResp = loadAaiResponse(onset, "aai/AaiNqResponse-Full.json");
-
- final UUID requestId = UUID.randomUUID();
- onset.setRequestId(requestId);
-
- Policy policy = new Policy();
- policy.setActor("Dorothy");
- policy.setRecipe("GoToOz");
-
- instantiateTarget(policy);
-
- assertNull(new SoActorServiceProvider().constructRequest(onset, operation, policy, aaiNqResp));
-
- policy.setActor("SO");
- assertNull(new SoActorServiceProvider().constructRequest(onset, operation, policy, aaiNqResp));
-
- policy.setRecipe(VF_MODULE_CREATE);
-
- // empty policy payload
- SoRequest request = new SoActorServiceProvider().constructRequest(onset, operation, policy, aaiNqResp);
- assertNotNull(request);
-
- assertEquals("my_module_3", request.getRequestDetails().getRequestInfo().getInstanceName());
- assertEquals("policy", request.getRequestDetails().getRequestInfo().getRequestorId());
- assertEquals("RegionOne", request.getRequestDetails().getCloudConfiguration().getLcpCloudRegionId());
-
- // non-empty policy payload
- policy.setPayload(makePayload());
- request = new SoActorServiceProvider().constructRequest(onset, operation, policy, aaiNqResp);
- assertNotNull(request);
- assertEquals(true, request.getRequestDetails().getRequestParameters().isUsePreload());
- assertEquals(A_VALUE, request.getRequestDetails().getRequestParameters().getUserParams().get(0).get("akey"));
- assertEquals(1, request.getRequestDetails().getConfigurationParameters().size());
- assertEquals(C_VALUE, request.getRequestDetails().getConfigurationParameters().get(0).get("ckey"));
-
- // payload with config, but no request params
- policy.setPayload(makePayload());
- policy.getPayload().remove(SoActorServiceProvider.REQ_PARAM_NM);
- request = new SoActorServiceProvider().constructRequest(onset, operation, policy, aaiNqResp);
- assertNotNull(request);
- assertNull(request.getRequestDetails().getRequestParameters());
- assertNotNull(request.getRequestDetails().getConfigurationParameters());
-
- // payload with request, but no config params
- policy.setPayload(makePayload());
- policy.getPayload().remove(SoActorServiceProvider.CONFIG_PARAM_NM);
- request = new SoActorServiceProvider().constructRequest(onset, operation, policy, aaiNqResp);
- assertNotNull(request);
- assertNotNull(request.getRequestDetails().getRequestParameters());
- assertNull(request.getRequestDetails().getConfigurationParameters());
-
- // null response
- assertNull(new SoActorServiceProvider().constructRequest(onset, operation, policy, null));
-
- // response has no base VF module
- assertNull(new SoActorServiceProvider().constructRequest(onset, operation, policy,
- loadAaiResponse(onset, "aai/AaiNqResponse-NoBase.json")));
-
- policy.setTarget(null);
-
- // response has no non-base VF modules (other than the "dummy")
- assertNull(new SoActorServiceProvider().constructRequest(onset, operation, policy,
- loadAaiResponse(onset, "aai/AaiNqResponse-NoNonBase.json")));
-
- instantiateTarget(policy);
- policy.setRecipe(VF_MODULE_DELETE);
- SoRequest deleteRequest = new SoActorServiceProvider().constructRequest(onset, operation, policy, aaiNqResp);
- assertNotNull(deleteRequest);
- assertEquals(SoOperationType.DELETE_VF_MODULE, deleteRequest.getOperationType());
-
- /*
- * NOTE: The remaining tests must be done in order
- */
-
- policy.setRecipe(VF_MODULE_CREATE);
-
- // null tenant
- aaiNqResp.getAaiNqResponse().getInventoryResponseItems().get(0).getItems().getInventoryResponseItems()
- .remove(1);
- assertNull(new SoActorServiceProvider().constructRequest(onset, operation, policy, aaiNqResp));
-
- // null service item
- aaiNqResp.getAaiNqResponse().getInventoryResponseItems().get(0).getItems().getInventoryResponseItems().get(0)
- .setItems(null);
- assertNull(new SoActorServiceProvider().constructRequest(onset, operation, policy, aaiNqResp));
-
- // null response
- aaiNqResp.setAaiNqResponse(null);
- assertNull(new SoActorServiceProvider().constructRequest(onset, operation, policy, aaiNqResp));
- }
-
- private void instantiateTarget(Policy policy) {
-
- Target target = new Target();
- target.setModelCustomizationId("3e2d67ad-3495-4732-82f6-b0b872791fff");
- target.setModelInvariantId("90b793b5-b8ae-4c36-b10b-4b6372859d3a");
- target.setModelName("SproutScalingVf..scaling_sprout..module-1");
- target.setModelVersion("1");
- target.setModelVersionId("2210154d-e61a-4d7f-8fb9-0face1aee3f8");
-
- policy.setTarget(target);
- }
-
private void instantiateTargetCq(Policy policy) {
Target target = new Target();
@@ -336,18 +227,4 @@ public class SoActorServiceProviderTest {
return Serialization.gsonPretty.toJson(lst);
}
- /**
- * Reads an AAI vserver named-query response from a file.
- *
- * @param onset the ONSET event
- * @param fileName name of the file containing the JSON response
- * @return output from the AAI vserver named-query
- * @throws IOException if the file cannot be read
- */
- private AaiNqResponseWrapper loadAaiResponse(VirtualControlLoopEvent onset, String fileName) throws IOException {
- String resp = IOUtils.toString(getClass().getResource(fileName), StandardCharsets.UTF_8);
- AaiNqResponse aaiNqResponse = Serialization.gsonPretty.fromJson(resp, AaiNqResponse.class);
-
- return new AaiNqResponseWrapper(onset.getRequestId(), aaiNqResponse);
- }
}
diff --git a/models-interactions/model-actors/actor.vfc/src/main/java/org/onap/policy/controlloop/actor/vfc/VfcActorServiceProvider.java b/models-interactions/model-actors/actor.vfc/src/main/java/org/onap/policy/controlloop/actor/vfc/VfcActorServiceProvider.java
index a41d9e82d..482c25730 100644
--- a/models-interactions/model-actors/actor.vfc/src/main/java/org/onap/policy/controlloop/actor/vfc/VfcActorServiceProvider.java
+++ b/models-interactions/model-actors/actor.vfc/src/main/java/org/onap/policy/controlloop/actor/vfc/VfcActorServiceProvider.java
@@ -24,15 +24,11 @@ import com.google.common.collect.ImmutableList;
import com.google.common.collect.ImmutableMap;
import java.util.Collections;
import java.util.List;
-import java.util.UUID;
import org.onap.policy.aai.AaiCqResponse;
-import org.onap.policy.aai.AaiGetVnfResponse;
-import org.onap.policy.aai.AaiManager;
import org.onap.policy.controlloop.ControlLoopOperation;
import org.onap.policy.controlloop.VirtualControlLoopEvent;
import org.onap.policy.controlloop.actorserviceprovider.spi.Actor;
import org.onap.policy.controlloop.policy.Policy;
-import org.onap.policy.rest.RestManager;
import org.onap.policy.vfc.VfcHealActionVmInfo;
import org.onap.policy.vfc.VfcHealAdditionalParams;
import org.onap.policy.vfc.VfcHealRequest;
@@ -79,76 +75,6 @@ public class VfcActorServiceProvider implements Actor {
}
/**
- * Construct a request.
- *
- * @param onset the onset event
- * @param operation the control loop operation
- * @param policy the policy
- * @param vnfResponse the VNF response
- * @return the constructed request
- */
- public static VfcRequest constructRequest(VirtualControlLoopEvent onset, ControlLoopOperation operation,
- Policy policy, AaiGetVnfResponse vnfResponse, String aaiUrl, String aaiUsername, String aaiPassword) {
-
- // Construct an VFC request
- VfcRequest request = new VfcRequest();
- String serviceInstance = onset.getAai().get("service-instance.service-instance-id");
- if (serviceInstance == null || "".equals(serviceInstance)) {
- AaiGetVnfResponse tempVnfResp = vnfResponse;
- if (tempVnfResp == null) { // if the response is null, we haven't queried
- // This does the AAI query since we haven't already
- tempVnfResp = getAaiServiceInstance(onset, aaiUrl, aaiUsername, aaiPassword);
- if (tempVnfResp == null) {
- return null;
- }
- }
- serviceInstance = tempVnfResp.getServiceId();
- }
- request.setNsInstanceId(serviceInstance);
- request.setRequestId(onset.getRequestId());
- request.setHealRequest(new VfcHealRequest());
- request.getHealRequest().setVnfInstanceId(onset.getAai().get(GENERIC_VNF_ID));
- request.getHealRequest().setCause(operation.getMessage());
- request.getHealRequest().setAdditionalParams(new VfcHealAdditionalParams());
-
- if (policy.getRecipe().toLowerCase().equalsIgnoreCase(RECIPE_RESTART)) {
- request.getHealRequest().getAdditionalParams().setAction("restartvm");
- request.getHealRequest().getAdditionalParams().setActionInfo(new VfcHealActionVmInfo());
- request.getHealRequest().getAdditionalParams().getActionInfo()
- .setVmid(onset.getAai().get("vserver.vserver-id"));
- request.getHealRequest().getAdditionalParams().getActionInfo()
- .setVmname(onset.getAai().get("vserver.vserver-name"));
- } else {
- return null;
- }
- return request;
- }
-
- private static AaiGetVnfResponse getAaiServiceInstance(VirtualControlLoopEvent event, String aaiUrl,
- String aaiUsername, String aaiPassword) {
- AaiGetVnfResponse response = null;
- UUID requestId = event.getRequestId();
- String vnfName = event.getAai().get("generic-vnf.vnf-name");
- String vnfId = event.getAai().get(GENERIC_VNF_ID);
- try {
- if (vnfName != null) {
- String url = aaiUrl + "/aai/v11/network/generic-vnfs/generic-vnf?vnf-name=";
- response = new AaiManager(new RestManager()).getQueryByVnfName(url, aaiUsername, aaiPassword, requestId,
- vnfName);
- } else if (vnfId != null) {
- String url = aaiUrl + "/aai/v11/network/generic-vnfs/generic-vnf/";
- response = new AaiManager(new RestManager()).getQueryByVnfId(url, aaiUsername, aaiPassword, requestId,
- vnfId);
- } else {
- logger.error("getAAIServiceInstance failed");
- }
- } catch (Exception e) {
- logger.error("getAAIServiceInstance exception: ", e);
- }
- return response;
- }
-
- /**
* This method constructs the VFC request.
*
* @param onset onset object
diff --git a/models-interactions/model-actors/actor.vfc/src/test/java/org/onap/policy/controlloop/actor/vfc/VfcActorServiceProviderTest.java b/models-interactions/model-actors/actor.vfc/src/test/java/org/onap/policy/controlloop/actor/vfc/VfcActorServiceProviderTest.java
index 300cd29f0..db224b065 100644
--- a/models-interactions/model-actors/actor.vfc/src/test/java/org/onap/policy/controlloop/actor/vfc/VfcActorServiceProviderTest.java
+++ b/models-interactions/model-actors/actor.vfc/src/test/java/org/onap/policy/controlloop/actor/vfc/VfcActorServiceProviderTest.java
@@ -35,7 +35,6 @@ import org.junit.AfterClass;
import org.junit.BeforeClass;
import org.junit.Test;
import org.onap.policy.aai.AaiCqResponse;
-import org.onap.policy.aai.AaiGetVnfResponse;
import org.onap.policy.common.endpoints.http.server.HttpServletServerFactoryInstance;
import org.onap.policy.controlloop.ControlLoopOperation;
import org.onap.policy.controlloop.VirtualControlLoopEvent;
@@ -45,7 +44,6 @@ import org.onap.policy.vfc.VfcRequest;
public class VfcActorServiceProviderTest {
- private static final String LOCAL_URL = "http://localhost:6666";
private static final String DOROTHY_GALE_1939 = "dorothy.gale.1939";
private static final String CQ_RESPONSE_JSON = "aai/AaiCqResponse.json";
private static final String RESTART = "Restart";
@@ -65,53 +63,6 @@ public class VfcActorServiceProviderTest {
}
@Test
- public void testConstructRequest() {
- VirtualControlLoopEvent onset = new VirtualControlLoopEvent();
- ControlLoopOperation operation = new ControlLoopOperation();
-
- Policy policy = new Policy();
- policy.setRecipe("GoToOz");
-
- assertNull(VfcActorServiceProvider.constructRequest(onset, operation, policy, null, null, null, null));
-
- onset.getAai().put("generic-vnf.vnf-id", DOROTHY_GALE_1939);
- assertNull(VfcActorServiceProvider.constructRequest(onset, operation, policy, null, null, null, null));
-
- assertNull(VfcActorServiceProvider.constructRequest(onset, operation, policy, null, LOCAL_URL,
- "AAI", "AAI"));
-
- UUID requestId = UUID.randomUUID();
- onset.setRequestId(requestId);
- assertNull(VfcActorServiceProvider.constructRequest(onset, operation, policy, null, LOCAL_URL,
- "AAI", "AAI"));
-
- onset.getAai().put("generic-vnf.vnf-name", "Dorothy");
- assertNull(VfcActorServiceProvider.constructRequest(onset, operation, policy, null, LOCAL_URL,
- "AAI", null));
-
- assertNull(VfcActorServiceProvider.constructRequest(onset, operation, policy, null, LOCAL_URL,
- "AAI", "AAI"));
-
- onset.getAai().put("service-instance.service-instance-id", "");
- assertNull(VfcActorServiceProvider.constructRequest(onset, operation, policy, null, LOCAL_URL,
- "AAI", "AAI"));
-
- assertNull(VfcActorServiceProvider.constructRequest(onset, operation, policy, new AaiGetVnfResponse(),
- LOCAL_URL, "AAI", "AAI"));
-
- policy.setRecipe(RESTART);
- assertNotNull(VfcActorServiceProvider.constructRequest(onset, operation, policy, new AaiGetVnfResponse(),
- LOCAL_URL, "AAI", "AAI"));
-
- VfcRequest request = VfcActorServiceProvider.constructRequest(onset, operation, policy, new AaiGetVnfResponse(),
- LOCAL_URL, "AAI", "AAI");
-
- assertEquals(requestId, Objects.requireNonNull(request).getRequestId());
- assertEquals(DOROTHY_GALE_1939, request.getHealRequest().getVnfInstanceId());
- assertEquals("restartvm", request.getHealRequest().getAdditionalParams().getAction());
- }
-
- @Test
public void testMethods() {
VfcActorServiceProvider sp = new VfcActorServiceProvider();