summaryrefslogtreecommitdiffstats
path: root/models-interactions
diff options
context:
space:
mode:
authorPamela Dragosh <pdragosh@research.att.com>2019-04-10 21:22:17 +0000
committerGerrit Code Review <gerrit@onap.org>2019-04-10 21:22:17 +0000
commit891bffd9f13177d96ad26acdfa7148d09e1d682a (patch)
tree5a2b16f697a73e62e47e229120959db9f109139f /models-interactions
parent52567cb059f90bb3114c4d4db3c758dd98b7b18b (diff)
parent38c89e3a57f168603faaf2ad4220105b2d54a9c8 (diff)
Merge "Custom Query Code"
Diffstat (limited to 'models-interactions')
-rw-r--r--models-interactions/model-actors/actor.so/src/main/java/org/onap/policy/controlloop/actor/so/SoActorServiceProvider.java314
-rw-r--r--models-interactions/model-actors/actor.so/src/test/java/org/onap/policy/controlloop/actor/so/SoActorServiceProviderTest.java111
-rw-r--r--models-interactions/model-actors/actor.so/src/test/resources/org/onap/policy/controlloop/actor/so/aai/AaiCqResponse.json673
-rw-r--r--models-interactions/model-actors/actor.so/src/test/resources/org/onap/policy/controlloop/actor/so/aai/AaiCqResponseMissing.json4
-rw-r--r--models-interactions/model-actors/actor.vfc/src/main/java/org/onap/policy/controlloop/actor/vfc/VfcActorServiceProvider.java50
-rw-r--r--models-interactions/model-actors/actor.vfc/src/test/java/org/onap/policy/controlloop/actor/vfc/VfcActorServiceProviderTest.java85
-rw-r--r--models-interactions/model-actors/actor.vfc/src/test/resources/org/onap/policy/controlloop/actor/vfc/aai/AaiCqResponse.json673
-rw-r--r--models-interactions/model-impl/aai/pom.xml90
-rw-r--r--models-interactions/model-impl/aai/src/main/java/org/onap/policy/aai/AaiCqResponse.java478
-rw-r--r--models-interactions/model-impl/aai/src/main/java/org/onap/policy/aai/AaiManager.java155
-rw-r--r--models-interactions/model-impl/aai/src/test/java/org/onap/policy/aai/AaiCqResponseTest.java278
-rw-r--r--models-interactions/model-impl/aai/src/test/java/org/onap/policy/aai/AaiManagerTest.java61
-rw-r--r--models-interactions/model-impl/aai/src/test/resources/org/onap/policy/aai/AaiCqResponse.json673
-rw-r--r--models-interactions/model-impl/aai/src/test/resources/org/onap/policy/aai/AaiMalformedCqResponse.json3
-rw-r--r--models-interactions/model-impl/aai/src/test/resources/org/onap/policy/aai/AaiTenantResponse.json8
-rw-r--r--models-interactions/model-impl/rest/src/main/java/org/onap/policy/rest/RestManager.java29
-rw-r--r--models-interactions/model-impl/rest/src/test/java/org/onap/policy/rest/PutTest.java51
17 files changed, 3615 insertions, 121 deletions
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 6d8fa4bd2..25b3a4eb8 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
@@ -28,6 +28,11 @@ import java.lang.reflect.Type;
import java.util.Collections;
import java.util.List;
import java.util.Map;
+import org.onap.aai.domain.yang.CloudRegion;
+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;
@@ -62,10 +67,10 @@ public class SoActorServiceProvider implements Actor {
private static final String RECIPE_VF_MODULE_CREATE = "VF Module Create";
private static final String RECIPE_VF_MODULE_DELETE = "VF Module Delete";
- private static final ImmutableList<String> recipes = ImmutableList.of(RECIPE_VF_MODULE_CREATE,
- RECIPE_VF_MODULE_DELETE);
- private static final ImmutableMap<String, List<String>> targets = new ImmutableMap.Builder<String, List<String>>()
- .put(RECIPE_VF_MODULE_CREATE, ImmutableList.of(TARGET_VFC))
+ private static final ImmutableList<String> recipes =
+ ImmutableList.of(RECIPE_VF_MODULE_CREATE, RECIPE_VF_MODULE_DELETE);
+ private static final ImmutableMap<String, List<String>> targets =
+ new ImmutableMap.Builder<String, List<String>>().put(RECIPE_VF_MODULE_CREATE, ImmutableList.of(TARGET_VFC))
.put(RECIPE_VF_MODULE_DELETE, ImmutableList.of(TARGET_VFC)).build();
// name of request parameters within policy payload
@@ -109,19 +114,17 @@ public class SoActorServiceProvider implements Actor {
}
/**
- * 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.
+ * 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 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) {
+ AaiNqResponseWrapper aaiResponseWrapper) {
if (!SO_ACTOR.equals(policy.getActor()) || !recipes().contains(policy.getRecipe())) {
return null;
}
@@ -138,10 +141,10 @@ public class SoActorServiceProvider implements Actor {
// Extract the items we're interested in from the response
try {
vnfItem = aaiResponseWrapper.getAaiNqResponse().getInventoryResponseItems().get(0).getItems()
- .getInventoryResponseItems().get(0);
+ .getInventoryResponseItems().get(0);
} catch (Exception e) {
logger.error("VNF Item not found in AAI response {}", Serialization.gsonPretty.toJson(aaiResponseWrapper),
- e);
+ e);
return null;
}
@@ -149,16 +152,16 @@ public class SoActorServiceProvider implements Actor {
vnfServiceItem = vnfItem.getItems().getInventoryResponseItems().get(0);
} catch (Exception e) {
logger.error("VNF Service Item not found in AAI response {}",
- Serialization.gsonPretty.toJson(aaiResponseWrapper), e);
+ Serialization.gsonPretty.toJson(aaiResponseWrapper), e);
return null;
}
try {
tenantItem = aaiResponseWrapper.getAaiNqResponse().getInventoryResponseItems().get(0).getItems()
- .getInventoryResponseItems().get(1);
+ .getInventoryResponseItems().get(1);
} catch (Exception e) {
logger.error("Tenant Item not found in AAI response {}",
- Serialization.gsonPretty.toJson(aaiResponseWrapper), e);
+ Serialization.gsonPretty.toJson(aaiResponseWrapper), e);
return null;
}
@@ -175,8 +178,7 @@ public class SoActorServiceProvider implements Actor {
// Construct SO Request for a policy's recipe
if (RECIPE_VF_MODULE_CREATE.equals(policy.getRecipe())) {
- return constructCreateRequest(aaiResponseWrapper, policy, tenantItem, vnfItem, vnfServiceItem,
- soModelInfo);
+ return constructCreateRequest(aaiResponseWrapper, policy, tenantItem, vnfItem, vnfServiceItem, soModelInfo);
} else if (RECIPE_VF_MODULE_DELETE.equals(policy.getRecipe())) {
return constructDeleteRequest(tenantItem, vnfItem, vnfServiceItem, soModelInfo, policy);
} else {
@@ -187,12 +189,9 @@ public class SoActorServiceProvider implements Actor {
private SoModelInfo prepareSoModelInfo(Policy policy) {
SoModelInfo soModelInfo = new SoModelInfo();
- if ((policy.getTarget() != null
- && (policy.getTarget().getModelCustomizationId() != null))
- && (policy.getTarget().getModelInvariantId() != null)
- && (policy.getTarget().getModelName() != null)
- && (policy.getTarget().getModelVersion() != null)
- && (policy.getTarget().getModelVersionId() != null)) {
+ if ((policy.getTarget() != null && (policy.getTarget().getModelCustomizationId() != null))
+ && (policy.getTarget().getModelInvariantId() != null) && (policy.getTarget().getModelName() != null)
+ && (policy.getTarget().getModelVersion() != null) && (policy.getTarget().getModelVersionId() != null)) {
soModelInfo.setModelCustomizationId(policy.getTarget().getModelCustomizationId());
soModelInfo.setModelInvariantId(policy.getTarget().getModelInvariantId());
@@ -210,17 +209,16 @@ 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
+ * @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) {
+ AaiNqInventoryResponseItem tenantItem, AaiNqInventoryResponseItem vnfItem,
+ AaiNqInventoryResponseItem vnfServiceItem, SoModelInfo vfModuleItem) {
SoRequest request = new SoRequest();
request.setOperationType(SoOperationType.SCALE_OUT);
//
@@ -283,9 +281,8 @@ public class SoActorServiceProvider implements Actor {
.setModelVersionId(prop.getPropertyValue());
}
}
- relatedInstanceListElement2.getRelatedInstance().getModelInfo()
- .setModelCustomizationName(vnfItem.getGenericVnf().getVnfType()
- .substring(vnfItem.getGenericVnf().getVnfType().lastIndexOf('/') + 1));
+ relatedInstanceListElement2.getRelatedInstance().getModelInfo().setModelCustomizationName(vnfItem
+ .getGenericVnf().getVnfType().substring(vnfItem.getGenericVnf().getVnfType().lastIndexOf('/') + 1));
relatedInstanceListElement2.getRelatedInstance().getModelInfo()
.setModelCustomizationId(vnfItem.getGenericVnf().getModelCustomizationId());
@@ -300,8 +297,8 @@ public class SoActorServiceProvider implements Actor {
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);
+ preserveInstanceIds(vnfItem.getGenericVnf().getVnfId(),
+ vnfServiceItem.getServiceInstance().getServiceInstanceId(), null);
if (logger.isDebugEnabled()) {
logger.debug("Constructed SO request: {}", Serialization.gsonPretty.toJson(request));
}
@@ -311,14 +308,14 @@ public class SoActorServiceProvider implements Actor {
/**
* 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
- * @param vfModuleItem vf module item from A&AI named-query response
+ * @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 delete vf-module request
*/
- private SoRequest constructDeleteRequest(AaiNqInventoryResponseItem tenantItem, AaiNqInventoryResponseItem
- vnfItem, AaiNqInventoryResponseItem vnfServiceItem, SoModelInfo vfModuleItem, Policy policy) {
+ private SoRequest constructDeleteRequest(AaiNqInventoryResponseItem tenantItem, AaiNqInventoryResponseItem vnfItem,
+ AaiNqInventoryResponseItem vnfServiceItem, SoModelInfo vfModuleItem, Policy policy) {
SoRequest request = new SoRequest();
request.setOperationType(SoOperationType.DELETE_VF_MODULE);
request.setRequestDetails(new SoRequestDetails());
@@ -332,8 +329,8 @@ public class SoActorServiceProvider implements Actor {
// 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);
+ preserveInstanceIds(vnfItem.getGenericVnf().getVnfId(),
+ vnfServiceItem.getServiceInstance().getServiceInstanceId(), null);
if (logger.isDebugEnabled()) {
logger.debug("Constructed SO request: {}", Serialization.gsonPretty.toJson(request));
@@ -363,14 +360,13 @@ public class SoActorServiceProvider implements Actor {
private SoCloudConfiguration constructCloudConfiguration(AaiNqInventoryResponseItem tenantItem) {
SoCloudConfiguration cloudConfiguration = new SoCloudConfiguration();
cloudConfiguration.setTenantId(tenantItem.getTenant().getTenantId());
- cloudConfiguration.setLcpCloudRegionId(tenantItem.getItems().getInventoryResponseItems().get(0)
- .getCloudRegion().getCloudRegionId());
+ 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.
+ * This method is needed to get the serviceInstanceId and vnfInstanceId which is used in the asyncSORestCall.
*
* @param requestId the request Id
* @param callback callback method
@@ -379,20 +375,19 @@ public class SoActorServiceProvider implements Actor {
* @param user username
* @param password password
*/
- public static void sendRequest(String requestId, SoManager.SoCallback callback, Object request,
- String url, String user, String password) {
+ public static void sendRequest(String requestId, SoManager.SoCallback callback, Object request, String url,
+ String user, String password) {
SoManager soManager = new SoManager(url, user, password);
soManager.asyncSoRestCall(requestId, callback, lastServiceItemServiceInstanceId, lastVNFItemVnfId,
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
+ * 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
+ * @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) {
@@ -445,17 +440,220 @@ public class SoActorServiceProvider implements Actor {
}
/**
- * This method is called to remember the last service instance ID, VNF Item VNF ID and vf module ID.
- * Note these fields are static, beware for multithreaded deployments
+ * This method is called to remember the last service instance ID, VNF Item VNF ID and vf module ID. Note these
+ * fields are static, beware for multithreaded deployments
*
* @param vnfInstanceId update the last VNF instance ID to this value
* @param serviceInstanceId update the last service instance ID to this value
* @param vfModuleId update the vfModule instance ID to this value
*/
private static void preserveInstanceIds(final String vnfInstanceId, final String serviceInstanceId,
- final String vfModuleId) {
+ final String vfModuleId) {
lastVNFItemVnfId = vnfInstanceId;
lastServiceItemServiceInstanceId = serviceInstanceId;
lastVfModuleItemVfModuleInstanceId = vfModuleId;
}
+
+ /**
+ * 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 aaiCqResponse response from A&AI custom query
+ * @return a SO request conforming to the lcm API using the DMAAP wrapper
+ */
+ public SoRequest constructRequestCq(VirtualControlLoopEvent onset, ControlLoopOperation operation, Policy policy,
+ AaiCqResponse aaiCqResponse) {
+ 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 (aaiCqResponse == null) {
+ return null;
+ }
+
+ GenericVnf vnfItem;
+ ServiceInstance vnfServiceItem;
+ Tenant tenantItem;
+ CloudRegion cloudRegionItem;
+
+ // Extract the items we're interested in from the response
+ try {
+ vnfItem = aaiCqResponse.getDefaultGenericVnf();
+ } catch (Exception e) {
+ logger.error("VNF Item not found in AAI response {}", Serialization.gsonPretty.toJson(aaiCqResponse), e);
+ return null;
+ }
+
+ try {
+ vnfServiceItem = aaiCqResponse.getServiceInstance();
+ } catch (Exception e) {
+ logger.error("VNF Service Item not found in AAI response {}",
+ Serialization.gsonPretty.toJson(aaiCqResponse), e);
+ return null;
+ }
+
+ try {
+ tenantItem = aaiCqResponse.getDefaultTenant();
+ } catch (Exception e) {
+ logger.error("Tenant Item not found in AAI response {}", Serialization.gsonPretty.toJson(aaiCqResponse), e);
+ return null;
+ }
+
+ try {
+ cloudRegionItem = aaiCqResponse.getDefaultCloudRegion();
+ } catch (Exception e) {
+ logger.error("Tenant Item not found in AAI response {}", Serialization.gsonPretty.toJson(aaiCqResponse), e);
+ return null;
+ }
+
+ SoModelInfo soModelInfo = prepareSoModelInfo(policy);
+
+ // Report the error vf module is not found
+ if (soModelInfo == null) {
+ logger.error("vf module is not found.");
+ return null;
+ }
+
+ // Construct SO Request for a policy's recipe
+ if (RECIPE_VF_MODULE_CREATE.equals(policy.getRecipe())) {
+ return constructCreateRequestCq(aaiCqResponse, policy, tenantItem, vnfItem, vnfServiceItem, soModelInfo,
+ cloudRegionItem);
+ } else if (RECIPE_VF_MODULE_DELETE.equals(policy.getRecipe())) {
+ return constructDeleteRequestCq(tenantItem, vnfItem, vnfServiceItem, soModelInfo, policy, cloudRegionItem);
+ } else {
+ return null;
+ }
+ }
+
+ /**
+ * Construct the So request, based on Custom Query response from A&AI.
+ *
+ * @param aaiCqResponse Custom query response from A&AI
+ * @param policy policy information
+ * @param tenantItem Tenant from CQ response
+ * @param vnfItem Generic VNF from CQ response
+ * @param vnfServiceItem Service Instance from CQ response
+ * @param vfModuleItem VF Module from CustomQuery response
+ * @param cloudRegionItem Cloud Region from Custom query response
+ * @return SoRequest well formed So Request
+ */
+ private SoRequest constructCreateRequestCq(AaiCqResponse aaiCqResponse, Policy policy, Tenant tenantItem,
+ GenericVnf vnfItem, ServiceInstance vnfServiceItem, SoModelInfo vfModuleItem, CloudRegion cloudRegionItem) {
+ 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(constructCloudConfigurationCq(tenantItem, cloudRegionItem));
+ // modelInfo
+ request.getRequestDetails().setModelInfo(vfModuleItem);
+
+ // requestInfo
+ request.getRequestDetails().setRequestInfo(constructRequestInfo());
+ String vfModuleName = aaiCqResponse.getDefaultVfModule().getVfModuleName();
+ request.getRequestDetails().getRequestInfo().setInstanceName(vfModuleName);
+
+ // relatedInstanceList
+ SoRelatedInstanceListElement relatedInstanceListElement1 = new SoRelatedInstanceListElement();
+ SoRelatedInstanceListElement relatedInstanceListElement2 = new SoRelatedInstanceListElement();
+ relatedInstanceListElement1.setRelatedInstance(new SoRelatedInstance());
+ relatedInstanceListElement2.setRelatedInstance(new SoRelatedInstance());
+
+ // Service Item (Note that Model Name and Model Version are not available in A&AI schema for ServiceInstance)
+ relatedInstanceListElement1.getRelatedInstance().setInstanceId(vnfServiceItem.getServiceInstanceId());
+ relatedInstanceListElement1.getRelatedInstance().setModelInfo(new SoModelInfo());
+ relatedInstanceListElement1.getRelatedInstance().getModelInfo().setModelType("service");
+ relatedInstanceListElement1.getRelatedInstance().getModelInfo()
+ .setModelInvariantId(vnfServiceItem.getModelInvariantId());
+ relatedInstanceListElement1.getRelatedInstance().getModelInfo()
+ .setModelVersionId(vnfServiceItem.getModelVersionId());
+
+
+ // VNF Item (Note that Model Name, Model Version, and Model Customization Name are not available in A&AI schema
+ // for Generic VNF)
+ relatedInstanceListElement2.getRelatedInstance().setInstanceId(vnfItem.getVnfId());
+ relatedInstanceListElement2.getRelatedInstance().setModelInfo(new SoModelInfo());
+ relatedInstanceListElement2.getRelatedInstance().getModelInfo().setModelType("vnf");
+ relatedInstanceListElement2.getRelatedInstance().getModelInfo()
+ .setModelInvariantId(vnfItem.getModelInvariantId());
+ relatedInstanceListElement2.getRelatedInstance().getModelInfo().setModelVersionId(vnfItem.getModelVersionId());
+ relatedInstanceListElement2.getRelatedInstance().getModelInfo()
+ .setModelCustomizationId(vnfItem.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.getVnfId(), vnfServiceItem.getServiceInstanceId(), null);
+ if (logger.isDebugEnabled()) {
+ logger.debug("Constructed SO request: {}", Serialization.gsonPretty.toJson(request));
+ }
+ return request;
+ }
+
+ /**
+ * constructs delete request for So.
+ *
+ * @param tenantItem Tenant from A&AI CQ request
+ * @param vnfItem Generic VNF from A&AI CQ request
+ * @param vnfServiceItem ServiceInstance from A&AI CQ request
+ * @param vfModuleItem VFModule from A&AI CQ request
+ * @param policy policy information
+ * @param cloudRegionItem CloudRegion from A&AI CQ request
+ * @return SoRequest deleted
+ */
+ private SoRequest constructDeleteRequestCq(Tenant tenantItem, GenericVnf vnfItem, ServiceInstance vnfServiceItem,
+ SoModelInfo vfModuleItem, Policy policy, CloudRegion cloudRegionItem) {
+ 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(constructCloudConfigurationCq(tenantItem, cloudRegionItem));
+ // 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.getVnfId(), vnfServiceItem.getServiceInstanceId(), null);
+
+ if (logger.isDebugEnabled()) {
+ logger.debug("Constructed SO request: {}", Serialization.gsonPretty.toJson(request));
+ }
+ return request;
+ }
+
+
+ /**
+ * Construct cloudConfiguration for the SO requestDetails. Overridden for custom query.
+ *
+ * @param tenantItem tenant item from A&AI named-query response
+ * @return SO cloud configuration
+ */
+ private SoCloudConfiguration constructCloudConfigurationCq(Tenant tenantItem, CloudRegion cloudRegionItem) {
+ SoCloudConfiguration cloudConfiguration = new SoCloudConfiguration();
+ cloudConfiguration.setTenantId(tenantItem.getTenantId());
+ cloudConfiguration.setLcpCloudRegionId(cloudRegionItem.getCloudRegionId());
+ return cloudConfiguration;
+ }
+
}
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 8b4bcf20a..7807e104d 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
@@ -36,7 +36,9 @@ import java.util.Map;
import java.util.TreeMap;
import java.util.UUID;
import org.apache.commons.io.IOUtils;
+import org.eclipse.persistence.exceptions.JAXBException;
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;
@@ -113,13 +115,13 @@ public class SoActorServiceProviderTest {
// response has no base VF module
assertNull(new SoActorServiceProvider().constructRequest(onset, operation, policy,
- loadAaiResponse(onset, "aai/AaiNqResponse-NoBase.json")));
+ 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")));
+ loadAaiResponse(onset, "aai/AaiNqResponse-NoNonBase.json")));
instantiateTarget(policy);
policy.setRecipe(VF_MODULE_DELETE);
@@ -135,12 +137,12 @@ public class SoActorServiceProviderTest {
// null tenant
aaiNqResp.getAaiNqResponse().getInventoryResponseItems().get(0).getItems().getInventoryResponseItems()
- .remove(1);
+ .remove(1);
assertNull(new SoActorServiceProvider().constructRequest(onset, operation, policy, aaiNqResp));
// null service item
aaiNqResp.getAaiNqResponse().getInventoryResponseItems().get(0).getItems().getInventoryResponseItems().get(0)
- .setItems(null);
+ .setItems(null);
assertNull(new SoActorServiceProvider().constructRequest(onset, operation, policy, aaiNqResp));
// null response
@@ -182,6 +184,107 @@ public class SoActorServiceProviderTest {
assertEquals(1, sp.recipeTargets(VF_MODULE_CREATE).size());
}
+ @Test
+ public void testConstructRequestCq() throws Exception {
+ VirtualControlLoopEvent onset = new VirtualControlLoopEvent();
+ final ControlLoopOperation operation = new ControlLoopOperation();
+ final AaiCqResponse aaiCqResp = loadAaiResponseCq("aai/AaiCqResponse.json");
+ final AaiCqResponse aaiCqRespMissing = loadAaiResponseCq("aai/AaiCqResponseMissing.json");
+ final UUID requestId = UUID.randomUUID();
+ onset.setRequestId(requestId);
+
+ Policy policy = new Policy();
+ policy.setActor("Dorothy");
+ policy.setRecipe("GoToOz");
+
+ instantiateTarget(policy);
+
+ assertNull(new SoActorServiceProvider().constructRequestCq(onset, operation, policy, aaiCqResp));
+
+ policy.setActor("SO");
+ assertNull(new SoActorServiceProvider().constructRequestCq(onset, operation, policy, aaiCqResp));
+
+ policy.setRecipe(VF_MODULE_CREATE);
+
+ // empty policy payload
+ SoRequest request = new SoActorServiceProvider().constructRequestCq(onset, operation, policy, aaiCqResp);
+ assertNotNull(request);
+
+ assertEquals("TestVM-0201-2", request.getRequestDetails().getRequestInfo().getInstanceName());
+ assertEquals("policy", request.getRequestDetails().getRequestInfo().getRequestorId());
+ assertEquals("cr-16197-01-as988q", request.getRequestDetails().getCloudConfiguration().getLcpCloudRegionId());
+
+ // non-empty policy payload
+ policy.setPayload(makePayload());
+ request = new SoActorServiceProvider().constructRequestCq(onset, operation, policy, aaiCqResp);
+ assertNotNull(request);
+ assertEquals(true, request.getRequestDetails().getRequestParameters().isUsePreload());
+ assertEquals("avalue", request.getRequestDetails().getRequestParameters().getUserParams().get(0).get("akey"));
+ assertEquals(1, request.getRequestDetails().getConfigurationParameters().size());
+ assertEquals("cvalue", 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().constructRequestCq(onset, operation, policy, aaiCqResp);
+ 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().constructRequestCq(onset, operation, policy, aaiCqResp);
+ assertNotNull(request);
+ assertNotNull(request.getRequestDetails().getRequestParameters());
+ assertNull(request.getRequestDetails().getConfigurationParameters());
+
+ // null response
+ assertNull(new SoActorServiceProvider().constructRequestCq(onset, operation, policy, null));
+
+
+ policy.setTarget(null);
+
+ // response has no non-base VF modules (other than the "dummy")
+ assertNull(new SoActorServiceProvider().constructRequestCq(onset, operation, policy,
+ loadAaiResponseCq("aai/AaiCqResponse.json")));
+
+ instantiateTarget(policy);
+ policy.setRecipe(VF_MODULE_DELETE);
+ SoRequest deleteRequest = new SoActorServiceProvider().constructRequestCq(onset, operation, policy, aaiCqResp);
+ 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
+ assertNull(new SoActorServiceProvider().constructRequestCq(onset, operation, policy, aaiCqRespMissing));
+
+ // null service item
+ assertNull(new SoActorServiceProvider().constructRequestCq(onset, operation, policy, aaiCqRespMissing));
+
+ assertNull(new SoActorServiceProvider().constructRequestCq(onset, operation, policy, null));
+ }
+
+ /**
+ * Reads an AAI vserver named-query response from a file.
+ *
+ * @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
+ * @throws JAXBException throws JAXBException
+ */
+ private AaiCqResponse loadAaiResponseCq(String fileName) throws IOException, JAXBException {
+ String resp = IOUtils.toString(getClass().getResource(fileName), StandardCharsets.UTF_8);
+ return new AaiCqResponse(resp);
+ }
+
+
+
/**
* Creates a policy payload containing request & configuration parameters.
*
diff --git a/models-interactions/model-actors/actor.so/src/test/resources/org/onap/policy/controlloop/actor/so/aai/AaiCqResponse.json b/models-interactions/model-actors/actor.so/src/test/resources/org/onap/policy/controlloop/actor/so/aai/AaiCqResponse.json
new file mode 100644
index 000000000..63d6f79ac
--- /dev/null
+++ b/models-interactions/model-actors/actor.so/src/test/resources/org/onap/policy/controlloop/actor/so/aai/AaiCqResponse.json
@@ -0,0 +1,673 @@
+{
+ "results": [
+ {
+ "vserver": {
+ "vserver-id": "e7f1db09-ff78-44fc-b256-69095c5556fb",
+ "vserver-name": "vfw-vm-0201-2",
+ "vserver-name2": "vfw-vm-0201-2",
+ "prov-status": "ACTIVE",
+ "vserver-selflink": "http://ecompctl1.research.att.com:8774/v2/3f2aaef74ecb4b19b35e26d0849fe9a2/servers/e7f1db09-ff78-44fc-b256-69095c5556fb",
+ "in-maint": false,
+ "is-closed-loop-disabled": false,
+ "resource-version": "1549553422524",
+ "relationship-list": {
+ "relationship": [
+ {
+ "related-to": "generic-vnf",
+ "related-link": "/aai/v11/network/generic-vnfs/generic-vnf/17044ef4-e7f3-46a1-af03-e2aa562f23ac",
+ "relationship-data": [
+ {
+ "relationship-key": "generic-vnf.vnf-id",
+ "relationship-value": "17044ef4-e7f3-46a1-af03-e2aa562f23ac"
+ }
+ ],
+ "related-to-property": [
+ {
+ "property-key": "generic-vnf.vnf-name",
+ "property-value": "TestVM-Vnf-0201-1"
+ }
+ ]
+ },
+ {
+ "related-to": "vnfc",
+ "related-link": "/aai/v11/network/vnfcs/vnfc/vfw",
+ "relationship-data": [
+ {
+ "relationship-key": "vnfc.vnfc-name",
+ "relationship-value": "vfw"
+ }
+ ]
+ },
+ {
+ "related-to": "vf-module",
+ "related-link": "/aai/v11/network/generic-vnfs/generic-vnf/17044ef4-e7f3-46a1-af03-e2aa562f23ac/vf-modules/vf-module/33f9e03d-2fbd-4e9c-8e73-ce6b12f0b3d2",
+ "relationship-data": [
+ {
+ "relationship-key": "generic-vnf.vnf-id",
+ "relationship-value": "17044ef4-e7f3-46a1-af03-e2aa562f23ac"
+ },
+ {
+ "relationship-key": "vf-module.vf-module-id",
+ "relationship-value": "33f9e03d-2fbd-4e9c-8e73-ce6b12f0b3d2"
+ }
+ ]
+ },
+ {
+ "related-to": "flavor",
+ "related-link": "/aai/v11/cloud-infrastructure/cloud-regions/cloud-region/CloudOwner/RegionOne/flavors/flavor/2",
+ "relationship-data": [
+ {
+ "relationship-key": "cloud-region.cloud-owner",
+ "relationship-value": "CloudOwner"
+ },
+ {
+ "relationship-key": "cloud-region.cloud-region-id",
+ "relationship-value": "RegionOne"
+ },
+ {
+ "relationship-key": "flavor.flavor-id",
+ "relationship-value": "2"
+ }
+ ],
+ "related-to-property": [
+ {
+ "property-key": "flavor.flavor-name",
+ "property-value": "m1.small"
+ }
+ ]
+ },
+ {
+ "related-to": "image",
+ "related-link": "/aai/v11/cloud-infrastructure/cloud-regions/cloud-region/CloudOwner/RegionOne/images/image/84be7136-301f-4f47-9585-3a2e0f9534af",
+ "relationship-data": [
+ {
+ "relationship-key": "cloud-region.cloud-owner",
+ "relationship-value": "CloudOwner"
+ },
+ {
+ "relationship-key": "cloud-region.cloud-region-id",
+ "relationship-value": "RegionOne"
+ },
+ {
+ "relationship-key": "image.image-id",
+ "relationship-value": "84be7136-301f-4f47-9585-3a2e0f9534af"
+ }
+ ],
+ "related-to-property": [
+ {
+ "property-key": "image.image-name",
+ "property-value": "unknown"
+ }
+ ]
+ }
+ ]
+ }
+ }
+ },
+ {
+ "generic-vnf": {
+ "vnf-id": "7b202620-2936-4b0d-b09c-60b411f10f64",
+ "vnf-name": "vLoadBalancerMS-Vnf-0211-1",
+ "vnf-type": "vLoadBalancerMS/vLoadBalancerMS 0",
+ "prov-status": "ACTIVE",
+ "equipment-role": "vLB",
+ "orchestration-status": "Active",
+ "ipv4-oam-address": "10.0.150.1",
+ "in-maint": true,
+ "is-closed-loop-disabled": false,
+ "resource-version": "1552311656338",
+ "model-invariant-id": "724ab1cf-6120-49e8-b909-849963bed1d6",
+ "model-version-id": "9d5944d8-2267-4799-824a-0f824e9a978d",
+ "model-customization-id": "efcd576d-a05e-4798-bb68-79e7d9c80f4c",
+ "nf-type": "ONAP-LOADBALANCER",
+ "nf-function": "LOADBALANCER",
+ "nf-role": "vLB",
+ "nf-naming-code": "vlb",
+ "selflink": "restconf/config/GENERIC-RESOURCE-API:services/service/101b8fc1-1796-4db1-a4e7-fe39c6a51558/service-data/vnfs/vnf/7b202620-2936-4b0d-b09c-60b411f10f64/vnf-data/vnf-topology/",
+ "relationship-list": {
+ "relationship": [
+ {
+ "related-to": "service-instance",
+ "related-link": "/aai/v11/business/customers/customer/Demonstration/service-subscriptions/service-subscription/vLB/service-instances/service-instance/101b8fc1-1796-4db1-a4e7-fe39c6a51558",
+ "relationship-data": [
+ {
+ "relationship-key": "customer.global-customer-id",
+ "relationship-value": "Demonstration"
+ },
+ {
+ "relationship-key": "service-subscription.service-type",
+ "relationship-value": "vLB"
+ },
+ {
+ "relationship-key": "service-instance.service-instance-id",
+ "relationship-value": "101b8fc1-1796-4db1-a4e7-fe39c6a51558"
+ }
+ ],
+ "related-to-property": [
+ {
+ "property-key": "service-instance.service-instance-name",
+ "property-value": "vLoadBalancerMS-0211-1"
+ }
+ ]
+ },
+ {
+ "related-to": "platform",
+ "related-link": "/aai/v11/business/platforms/platform/Test-Platform",
+ "relationship-data": [
+ {
+ "relationship-key": "platform.platform-name",
+ "relationship-value": "Test-Platform"
+ }
+ ]
+ },
+ {
+ "related-to": "line-of-business",
+ "related-link": "/aai/v11/business/lines-of-business/line-of-business/Test-Business",
+ "relationship-data": [
+ {
+ "relationship-key": "line-of-business.line-of-business-name",
+ "relationship-value": "Test-Business"
+ }
+ ]
+ },
+ {
+ "related-to": "vserver",
+ "related-link": "/aai/v11/cloud-infrastructure/cloud-regions/cloud-region/CloudOwner/RegionOne/tenants/tenant/3f2aaef74ecb4b19b35e26d0849fe9a2/vservers/vserver/58ca8df0-17b8-4aa2-8766-9c6c1a12cec8",
+ "relationship-data": [
+ {
+ "relationship-key": "cloud-region.cloud-owner",
+ "relationship-value": "CloudOwner"
+ },
+ {
+ "relationship-key": "cloud-region.cloud-region-id",
+ "relationship-value": "RegionOne"
+ },
+ {
+ "relationship-key": "tenant.tenant-id",
+ "relationship-value": "3f2aaef74ecb4b19b35e26d0849fe9a2"
+ },
+ {
+ "relationship-key": "vserver.vserver-id",
+ "relationship-value": "58ca8df0-17b8-4aa2-8766-9c6c1a12cec8"
+ }
+ ],
+ "related-to-property": [
+ {
+ "property-key": "vserver.vserver-name",
+ "property-value": "vdns-ms-0211-1"
+ }
+ ]
+ },
+ {
+ "related-to": "vserver",
+ "related-link": "/aai/v11/cloud-infrastructure/cloud-regions/cloud-region/CloudOwner/RegionOne/tenants/tenant/3f2aaef74ecb4b19b35e26d0849fe9a2/vservers/vserver/6c3b3714-e36c-45af-9f16-7d3a73d99497",
+ "relationship-data": [
+ {
+ "relationship-key": "cloud-region.cloud-owner",
+ "relationship-value": "CloudOwner"
+ },
+ {
+ "relationship-key": "cloud-region.cloud-region-id",
+ "relationship-value": "RegionOne"
+ },
+ {
+ "relationship-key": "tenant.tenant-id",
+ "relationship-value": "3f2aaef74ecb4b19b35e26d0849fe9a2"
+ },
+ {
+ "relationship-key": "vserver.vserver-id",
+ "relationship-value": "6c3b3714-e36c-45af-9f16-7d3a73d99497"
+ }
+ ],
+ "related-to-property": [
+ {
+ "property-key": "vserver.vserver-name",
+ "property-value": "vlb-ms-0211-1"
+ }
+ ]
+ },
+ {
+ "related-to": "availability-zone",
+ "related-link": "/aai/v11/cloud-infrastructure/cloud-regions/cloud-region/CloudOwner/RegionOne/availability-zones/availability-zone/nova",
+ "relationship-data": [
+ {
+ "relationship-key": "cloud-region.cloud-owner",
+ "relationship-value": "CloudOwner"
+ },
+ {
+ "relationship-key": "cloud-region.cloud-region-id",
+ "relationship-value": "RegionOne"
+ },
+ {
+ "relationship-key": "availability-zone.availability-zone-name",
+ "relationship-value": "nova"
+ }
+ ]
+ }
+ ]
+ },
+ "vf-modules": {
+ "vf-module": [
+ {
+ "vf-module-id": "e46c6636-9ce5-4b77-bb1b-455ce9edc892",
+ "vf-module-name": "vLoadBalancerMS-0211-1",
+ "heat-stack-id": "vLoadBalancerMS-0211-1/73360253-2dfe-46f6-bcd6-8662a81238ea",
+ "orchestration-status": "Active",
+ "is-base-vf-module": true,
+ "resource-version": "1552311559802",
+ "model-invariant-id": "d263fc6d-cfce-4e20-8337-e06f48b474e6",
+ "model-version-id": "24c0aa10-3979-402c-ad98-20124751b551",
+ "model-customization-id": "65382eb1-db84-466c-b9d7-4e0f1ba7105f",
+ "selflink": "restconf/config/GENERIC-RESOURCE-API:services/service/101b8fc1-1796-4db1-a4e7-fe39c6a51558/service-data/vnfs/vnf/7b202620-2936-4b0d-b09c-60b411f10f64/vnf-data/vf-modules/vf-module/e46c6636-9ce5-4b77-bb1b-455ce9edc892/vf-module-data/vf-module-topology/",
+ "relationship-list": {
+ "relationship": [
+ {
+ "related-to": "vserver",
+ "related-link": "/aai/v11/cloud-infrastructure/cloud-regions/cloud-region/CloudOwner/RegionOne/tenants/tenant/3f2aaef74ecb4b19b35e26d0849fe9a2/vservers/vserver/58ca8df0-17b8-4aa2-8766-9c6c1a12cec8",
+ "relationship-data": [
+ {
+ "relationship-key": "cloud-region.cloud-owner",
+ "relationship-value": "CloudOwner"
+ },
+ {
+ "relationship-key": "cloud-region.cloud-region-id",
+ "relationship-value": "RegionOne"
+ },
+ {
+ "relationship-key": "tenant.tenant-id",
+ "relationship-value": "3f2aaef74ecb4b19b35e26d0849fe9a2"
+ },
+ {
+ "relationship-key": "vserver.vserver-id",
+ "relationship-value": "58ca8df0-17b8-4aa2-8766-9c6c1a12cec8"
+ }
+ ],
+ "related-to-property": [
+ {
+ "property-key": "vserver.vserver-name",
+ "property-value": "vdns-ms-0211-1"
+ }
+ ]
+ },
+ {
+ "related-to": "vserver",
+ "related-link": "/aai/v11/cloud-infrastructure/cloud-regions/cloud-region/CloudOwner/RegionOne/tenants/tenant/3f2aaef74ecb4b19b35e26d0849fe9a2/vservers/vserver/6c3b3714-e36c-45af-9f16-7d3a73d99497",
+ "relationship-data": [
+ {
+ "relationship-key": "cloud-region.cloud-owner",
+ "relationship-value": "CloudOwner"
+ },
+ {
+ "relationship-key": "cloud-region.cloud-region-id",
+ "relationship-value": "RegionOne"
+ },
+ {
+ "relationship-key": "tenant.tenant-id",
+ "relationship-value": "3f2aaef74ecb4b19b35e26d0849fe9a2"
+ },
+ {
+ "relationship-key": "vserver.vserver-id",
+ "relationship-value": "6c3b3714-e36c-45af-9f16-7d3a73d99497"
+ }
+ ],
+ "related-to-property": [
+ {
+ "property-key": "vserver.vserver-name",
+ "property-value": "vlb-ms-0211-1"
+ }
+ ]
+ }
+ ]
+ }
+ }
+ ]
+ }
+ }
+ },
+ {
+ "service-instance": {
+ "service-instance-id": "101b8fc1-1796-4db1-a4e7-fe39c6a51558",
+ "service-instance-name": "vLoadBalancerMS-0211-1",
+ "environment-context": "General_Revenue-Bearing",
+ "workload-context": "Production",
+ "model-invariant-id": "1008a768-1b67-407e-88c6-58c82b34ef42",
+ "model-version-id": "81f8c1cd-f664-4450-b3a4-be645613ab32",
+ "resource-version": "1552311350334",
+ "selflink": "restconf/config/GENERIC-RESOURCE-API:services/service/101b8fc1-1796-4db1-a4e7-fe39c6a51558/service-data/service-topology/",
+ "orchestration-status": "Active",
+ "relationship-list": {
+ "relationship": [
+ {
+ "related-to": "project",
+ "related-link": "/aai/v11/business/projects/project/Test-Project",
+ "relationship-data": [
+ {
+ "relationship-key": "project.project-name",
+ "relationship-value": "Test-Project"
+ }
+ ]
+ },
+ {
+ "related-to": "generic-vnf",
+ "related-link": "/aai/v11/network/generic-vnfs/generic-vnf/7b202620-2936-4b0d-b09c-60b411f10f64",
+ "relationship-data": [
+ {
+ "relationship-key": "generic-vnf.vnf-id",
+ "relationship-value": "7b202620-2936-4b0d-b09c-60b411f10f64"
+ }
+ ],
+ "related-to-property": [
+ {
+ "property-key": "generic-vnf.vnf-name",
+ "property-value": "vLoadBalancerMS-Vnf-0211-1"
+ }
+ ]
+ },
+ {
+ "related-to": "owning-entity",
+ "related-link": "/aai/v11/business/owning-entities/owning-entity/bb94a687-4f3b-40a3-914e-e98037d5ebd2",
+ "relationship-data": [
+ {
+ "relationship-key": "owning-entity.owning-entity-id",
+ "relationship-value": "bb94a687-4f3b-40a3-914e-e98037d5ebd2"
+ }
+ ]
+ }
+ ]
+ }
+ }
+ },
+ {
+ "generic-vnf": {
+ "vnf-id": "17044ef4-e7f3-46a1-af03-e2aa562f23ac",
+ "vnf-name": "TestVM-Vnf-0201-1",
+ "vnf-type": "TestVM/TestVM 0",
+ "prov-status": "ACTIVE",
+ "equipment-role": "",
+ "orchestration-status": "Active",
+ "ipv4-oam-address": "10.0.70.1",
+ "in-maint": true,
+ "is-closed-loop-disabled": false,
+ "resource-version": "1549041636264",
+ "model-invariant-id": "6a4d7971-0778-4655-9eab-9d6031c7ad57",
+ "model-version-id": "fb6c673c-e5b6-4e0a-9baf-5e0089784de9",
+ "model-customization-id": "706a3100-dbe5-442e-86c3-c7b823abbec2",
+ "selflink": "restconf/config/GENERIC-RESOURCE-API:services/service/d41f8217-d464-4458-bf0a-fba33a0f1b31/service-data/vnfs/vnf/17044ef4-e7f3-46a1-af03-e2aa562f23ac/vnf-data/vnf-topology/",
+ "relationship-list": {
+ "relationship": [
+ {
+ "related-to": "service-instance",
+ "related-link": "/aai/v11/business/customers/customer/Demonstration/service-subscriptions/service-subscription/vFW/service-instances/service-instance/d41f8217-d464-4458-bf0a-fba33a0f1b31",
+ "relationship-data": [
+ {
+ "relationship-key": "customer.global-customer-id",
+ "relationship-value": "Demonstration"
+ },
+ {
+ "relationship-key": "service-subscription.service-type",
+ "relationship-value": "vFW"
+ },
+ {
+ "relationship-key": "service-instance.service-instance-id",
+ "relationship-value": "d41f8217-d464-4458-bf0a-fba33a0f1b31"
+ }
+ ],
+ "related-to-property": [
+ {
+ "property-key": "service-instance.service-instance-name",
+ "property-value": "TestVM-Service-0201-1"
+ }
+ ]
+ },
+ {
+ "related-to": "platform",
+ "related-link": "/aai/v11/business/platforms/platform/Test-Platform",
+ "relationship-data": [
+ {
+ "relationship-key": "platform.platform-name",
+ "relationship-value": "Test-Platform"
+ }
+ ]
+ },
+ {
+ "related-to": "line-of-business",
+ "related-link": "/aai/v11/business/lines-of-business/line-of-business/Test-Business",
+ "relationship-data": [
+ {
+ "relationship-key": "line-of-business.line-of-business-name",
+ "relationship-value": "Test-Business"
+ }
+ ]
+ },
+ {
+ "related-to": "vserver",
+ "related-link": "/aai/v11/cloud-infrastructure/cloud-regions/cloud-region/CloudOwner/RegionOne/tenants/tenant/3f2aaef74ecb4b19b35e26d0849fe9a2/vservers/vserver/e7f1db09-ff78-44fc-b256-69095c5556fb",
+ "relationship-data": [
+ {
+ "relationship-key": "cloud-region.cloud-owner",
+ "relationship-value": "CloudOwner"
+ },
+ {
+ "relationship-key": "cloud-region.cloud-region-id",
+ "relationship-value": "RegionOne"
+ },
+ {
+ "relationship-key": "tenant.tenant-id",
+ "relationship-value": "3f2aaef74ecb4b19b35e26d0849fe9a2"
+ },
+ {
+ "relationship-key": "vserver.vserver-id",
+ "relationship-value": "e7f1db09-ff78-44fc-b256-69095c5556fb"
+ }
+ ],
+ "related-to-property": [
+ {
+ "property-key": "vserver.vserver-name",
+ "property-value": "vfw-vm-0201-2"
+ }
+ ]
+ },
+ {
+ "related-to": "availability-zone",
+ "related-link": "/aai/v11/cloud-infrastructure/cloud-regions/cloud-region/CloudOwner/RegionTwo/availability-zones/availability-zone/zone-1",
+ "relationship-data": [
+ {
+ "relationship-key": "cloud-region.cloud-owner",
+ "relationship-value": "CloudOwner"
+ },
+ {
+ "relationship-key": "cloud-region.cloud-region-id",
+ "relationship-value": "RegionTwo"
+ },
+ {
+ "relationship-key": "availability-zone.availability-zone-name",
+ "relationship-value": "zone-1"
+ }
+ ]
+ }
+ ]
+ },
+ "vf-modules": {
+ "vf-module": [
+ {
+ "vf-module-id": "0afde97a-3e3f-4597-aec3-e5488c0f20b7",
+ "vf-module-name": "TestVM-0201-1",
+ "heat-stack-id": "TestVM-0201-1/aee4d7e5-b4a0-4261-b3cf-bb23348a3d99",
+ "orchestration-status": "Active",
+ "is-base-vf-module": true,
+ "resource-version": "1549039401119",
+ "model-invariant-id": "6af68fdb-6479-43e2-8989-938f06c994bd",
+ "model-version-id": "16d1834e-d834-431f-b064-98c469c6505d",
+ "model-customization-id": "29ffb122-22c8-48d2-b152-b52d9e81e910",
+ "selflink": "restconf/config/GENERIC-RESOURCE-API:services/service/d41f8217-d464-4458-bf0a-fba33a0f1b31/service-data/vnfs/vnf/17044ef4-e7f3-46a1-af03-e2aa562f23ac/vnf-data/vf-modules/vf-module/0afde97a-3e3f-4597-aec3-e5488c0f20b7/vf-module-data/vf-module-topology/"
+ },
+ {
+ "vf-module-id": "33f9e03d-2fbd-4e9c-8e73-ce6b12f0b3d2",
+ "vf-module-name": "TestVM-0201-2",
+ "heat-stack-id": "TestVM-0201-2/1b9db6b8-620b-46f1-935a-8a61c294a98b",
+ "orchestration-status": "Active",
+ "is-base-vf-module": true,
+ "resource-version": "1549041447373",
+ "model-invariant-id": "6af68fdb-6479-43e2-8989-938f06c994bd",
+ "model-version-id": "16d1834e-d834-431f-b064-98c469c6505d",
+ "model-customization-id": "29ffb122-22c8-48d2-b152-b52d9e81e910",
+ "selflink": "restconf/config/GENERIC-RESOURCE-API:services/service/d41f8217-d464-4458-bf0a-fba33a0f1b31/service-data/vnfs/vnf/17044ef4-e7f3-46a1-af03-e2aa562f23ac/vnf-data/vf-modules/vf-module/33f9e03d-2fbd-4e9c-8e73-ce6b12f0b3d2/vf-module-data/vf-module-topology/",
+ "relationship-list": {
+ "relationship": [
+ {
+ "related-to": "vserver",
+ "related-link": "/aai/v11/cloud-infrastructure/cloud-regions/cloud-region/CloudOwner/RegionOne/tenants/tenant/3f2aaef74ecb4b19b35e26d0849fe9a2/vservers/vserver/e7f1db09-ff78-44fc-b256-69095c5556fb",
+ "relationship-data": [
+ {
+ "relationship-key": "cloud-region.cloud-owner",
+ "relationship-value": "CloudOwner"
+ },
+ {
+ "relationship-key": "cloud-region.cloud-region-id",
+ "relationship-value": "RegionOne"
+ },
+ {
+ "relationship-key": "tenant.tenant-id",
+ "relationship-value": "3f2aaef74ecb4b19b35e26d0849fe9a2"
+ },
+ {
+ "relationship-key": "vserver.vserver-id",
+ "relationship-value": "e7f1db09-ff78-44fc-b256-69095c5556fb"
+ }
+ ],
+ "related-to-property": [
+ {
+ "property-key": "vserver.vserver-name",
+ "property-value": "vfw-vm-0201-2"
+ }
+ ]
+ }
+ ]
+ }
+ }
+ ]
+ }
+ }
+ },
+ {
+ "vf-module": {
+ "vf-module-id": "0afde97a-3e3f-4597-aec3-e5488c0f20b7",
+ "vf-module-name": "TestVM-0201-1",
+ "heat-stack-id": "TestVM-0201-1/aee4d7e5-b4a0-4261-b3cf-bb23348a3d99",
+ "orchestration-status": "Active",
+ "is-base-vf-module": true,
+ "resource-version": "1549039401119",
+ "model-invariant-id": "6af68fdb-6479-43e2-8989-938f06c994bd",
+ "model-version-id": "16d1834e-d834-431f-b064-98c469c6505d",
+ "model-customization-id": "29ffb122-22c8-48d2-b152-b52d9e81e910",
+ "selflink": "restconf/config/GENERIC-RESOURCE-API:services/service/d41f8217-d464-4458-bf0a-fba33a0f1b31/service-data/vnfs/vnf/17044ef4-e7f3-46a1-af03-e2aa562f23ac/vnf-data/vf-modules/vf-module/0afde97a-3e3f-4597-aec3-e5488c0f20b7/vf-module-data/vf-module-topology/"
+ }
+ },
+ {
+ "vf-module": {
+ "vf-module-id": "33f9e03d-2fbd-4e9c-8e73-ce6b12f0b3d2",
+ "vf-module-name": "TestVM-0201-2",
+ "heat-stack-id": "TestVM-0201-2/1b9db6b8-620b-46f1-935a-8a61c294a98b",
+ "orchestration-status": "Active",
+ "is-base-vf-module": true,
+ "resource-version": "1549041447373",
+ "model-invariant-id": "6af68fdb-6479-43e2-8989-938f06c994bd",
+ "model-version-id": "16d1834e-d834-431f-b064-98c469c6505d",
+ "model-customization-id": "29ffb122-22c8-48d2-b152-b52d9e81e910",
+ "selflink": "restconf/config/GENERIC-RESOURCE-API:services/service/d41f8217-d464-4458-bf0a-fba33a0f1b31/service-data/vnfs/vnf/17044ef4-e7f3-46a1-af03-e2aa562f23ac/vnf-data/vf-modules/vf-module/33f9e03d-2fbd-4e9c-8e73-ce6b12f0b3d2/vf-module-data/vf-module-topology/",
+ "relationship-list": {
+ "relationship": [
+ {
+ "related-to": "vserver",
+ "related-link": "/aai/v11/cloud-infrastructure/cloud-regions/cloud-region/CloudOwner/RegionOne/tenants/tenant/3f2aaef74ecb4b19b35e26d0849fe9a2/vservers/vserver/e7f1db09-ff78-44fc-b256-69095c5556fb",
+ "relationship-data": [
+ {
+ "relationship-key": "cloud-region.cloud-owner",
+ "relationship-value": "CloudOwner"
+ },
+ {
+ "relationship-key": "cloud-region.cloud-region-id",
+ "relationship-value": "RegionOne"
+ },
+ {
+ "relationship-key": "tenant.tenant-id",
+ "relationship-value": "3f2aaef74ecb4b19b35e26d0849fe9a2"
+ },
+ {
+ "relationship-key": "vserver.vserver-id",
+ "relationship-value": "e7f1db09-ff78-44fc-b256-69095c5556fb"
+ }
+ ],
+ "related-to-property": [
+ {
+ "property-key": "vserver.vserver-name",
+ "property-value": "vfw-vm-0201-2"
+ }
+ ]
+ }
+ ]
+ }
+ }
+ },
+ {
+ "tenant": {
+ "tenant-id": "tenant1-16197-as988q",
+ "tenant-name": "tenant-name-16197-as988q",
+ "resource-version": "1550769793637",
+ "vservers": {
+ "vserver": [
+ {
+ "vserver-id": "vserver1-16197-as988q",
+ "vserver-name": "vserverName",
+ "vserver-name2": "vserverTE-name2-as988q",
+ "prov-status": "ACTIVE",
+ "vserver-selflink": "TRINITY vserverLink",
+ "in-maint": false,
+ "is-closed-loop-disabled": false,
+ "resource-version": "1550769794551",
+ "relationship-list": {
+ "relationship": [
+ {
+ "related-to": "generic-vnf",
+ "relationship-label": "tosca.relationships.HostedOn",
+ "related-link": "/aai/v16/network/generic-vnfs/generic-vnf/VNF1-16197-as988q",
+ "relationship-data": [
+ {
+ "relationship-key": "generic-vnf.vnf-id",
+ "relationship-value": "VNF1-16197-as988q"
+ }
+ ],
+ "related-to-property": [
+ {
+ "property-key": "generic-vnf.vnf-name",
+ "property-value": "vnf1Name"
+ }
+ ]
+ }
+ ]
+ }
+ }
+ ]
+ }
+ }
+ },
+ {
+ "cloud-region": {
+ "cloud-owner": "co-16197-01-as988q",
+ "cloud-region-id": "cr-16197-01-as988q",
+ "resource-version": "1550769792672",
+ "orchestration-disabled": false,
+ "in-maint": false,
+ "tenants": {
+ "tenant": [
+ {
+ "tenant-id": "tenant1-16197-as988q",
+ "tenant-name": "tenant-name-16197-as988q",
+ "resource-version": "1550769793637"
+ }
+ ]
+ }
+ }
+ }
+ ]
+}
diff --git a/models-interactions/model-actors/actor.so/src/test/resources/org/onap/policy/controlloop/actor/so/aai/AaiCqResponseMissing.json b/models-interactions/model-actors/actor.so/src/test/resources/org/onap/policy/controlloop/actor/so/aai/AaiCqResponseMissing.json
new file mode 100644
index 000000000..29f1cdd8f
--- /dev/null
+++ b/models-interactions/model-actors/actor.so/src/test/resources/org/onap/policy/controlloop/actor/so/aai/AaiCqResponseMissing.json
@@ -0,0 +1,4 @@
+{
+ "results": [
+ ]
+}
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 23eb71996..61cf81da9 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
@@ -22,11 +22,10 @@ package org.onap.policy.controlloop.actor.vfc;
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;
@@ -146,4 +145,51 @@ public class VfcActorServiceProvider implements Actor {
}
return response;
}
+
+ /**
+ * This method constructs the VFC request.
+ *
+ * @param onset onset object
+ * @param operation operation object
+ * @param policy policy object
+ * @param aaiCqResponse response from aai custom query
+ * @return VfcRequest
+ */
+ public static VfcRequest constructRequestCq(VirtualControlLoopEvent onset, ControlLoopOperation operation,
+ Policy policy, AaiCqResponse aaiCqResponse) {
+
+ // Construct an VFC request
+ VfcRequest request = new VfcRequest();
+ String serviceInstance = onset.getAai().get("service-instance.service-instance-id");
+ if (serviceInstance == null || "".equals(serviceInstance)) {
+ // get service isntance from AaiCqResponse
+ if (aaiCqResponse == null) {
+ return null;
+ }
+ serviceInstance = aaiCqResponse.getServiceInstance().getServiceInstanceId();
+ // If the serviceInstanceId returned is null then return null
+ if (serviceInstance == null) {
+ return null;
+ }
+
+ }
+ request.setNsInstanceId(serviceInstance);
+ request.setRequestId(onset.getRequestId());
+ request.setHealRequest(new VfcHealRequest());
+ request.getHealRequest().setVnfInstanceId(onset.getAai().get("generic-vnf.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;
+ }
}
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 80ec3476e..8d5d5fae0 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
@@ -27,12 +27,16 @@ import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertNull;
import static org.junit.Assert.fail;
+import java.io.IOException;
+import java.nio.charset.StandardCharsets;
import java.util.Objects;
import java.util.UUID;
-
+import org.apache.commons.io.IOUtils;
+import org.eclipse.persistence.exceptions.JAXBException;
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.HttpServletServer;
import org.onap.policy.controlloop.ControlLoopOperation;
@@ -73,27 +77,34 @@ public class VfcActorServiceProviderTest {
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, "http://localhost:6666", "AAI", "AAI"));
+ assertNull(VfcActorServiceProvider.constructRequest(onset, operation, policy, null, "http://localhost:6666",
+ "AAI", "AAI"));
UUID requestId = UUID.randomUUID();
onset.setRequestId(requestId);
- assertNull(VfcActorServiceProvider.constructRequest(onset, operation, policy, null, "http://localhost:6666", "AAI", "AAI"));
+ assertNull(VfcActorServiceProvider.constructRequest(onset, operation, policy, null, "http://localhost:6666",
+ "AAI", "AAI"));
onset.getAai().put("generic-vnf.vnf-name", "Dorothy");
- assertNull(VfcActorServiceProvider.constructRequest(onset, operation, policy, null, "http://localhost:6666", "AAI", null));
+ assertNull(VfcActorServiceProvider.constructRequest(onset, operation, policy, null, "http://localhost:6666",
+ "AAI", null));
- assertNull(VfcActorServiceProvider.constructRequest(onset, operation, policy, null, "http://localhost:6666", "AAI", "AAI"));
+ assertNull(VfcActorServiceProvider.constructRequest(onset, operation, policy, null, "http://localhost:6666",
+ "AAI", "AAI"));
onset.getAai().put("service-instance.service-instance-id", "");
- assertNull(VfcActorServiceProvider.constructRequest(onset, operation, policy, null, "http://localhost:6666", "AAI", "AAI"));
+ assertNull(VfcActorServiceProvider.constructRequest(onset, operation, policy, null, "http://localhost:6666",
+ "AAI", "AAI"));
- assertNull(VfcActorServiceProvider.constructRequest(onset, operation, policy, new AaiGetVnfResponse(), "http://localhost:6666", "AAI", "AAI"));
+ assertNull(VfcActorServiceProvider.constructRequest(onset, operation, policy, new AaiGetVnfResponse(),
+ "http://localhost:6666", "AAI", "AAI"));
policy.setRecipe("Restart");
- assertNotNull(VfcActorServiceProvider.constructRequest(onset, operation, policy, new AaiGetVnfResponse(), "http://localhost:6666", "AAI", "AAI"));
+ assertNotNull(VfcActorServiceProvider.constructRequest(onset, operation, policy, new AaiGetVnfResponse(),
+ "http://localhost:6666", "AAI", "AAI"));
- VfcRequest request =
- VfcActorServiceProvider.constructRequest(onset, operation, policy, new AaiGetVnfResponse(), "http://localhost:6666", "AAI", "AAI");
+ VfcRequest request = VfcActorServiceProvider.constructRequest(onset, operation, policy, new AaiGetVnfResponse(),
+ "http://localhost:6666", "AAI", "AAI");
assertEquals(requestId, Objects.requireNonNull(request).getRequestId());
assertEquals("dorothy.gale.1939", request.getHealRequest().getVnfInstanceId());
@@ -110,4 +121,58 @@ public class VfcActorServiceProviderTest {
assertEquals("VM", sp.recipeTargets("Restart").get(0));
assertEquals(0, sp.recipePayloads("Restart").size());
}
+
+ @Test
+ public void testConstructRequestCq() throws IOException, JAXBException {
+ VirtualControlLoopEvent onset = new VirtualControlLoopEvent();
+ ControlLoopOperation operation = new ControlLoopOperation();
+
+ Policy policy = new Policy();
+ policy.setRecipe("GoToOz");
+
+ assertNull(VfcActorServiceProvider.constructRequestCq(onset, operation, policy, null));
+
+ onset.getAai().put("generic-vnf.vnf-id", "dorothy.gale.1939");
+ assertNull(VfcActorServiceProvider.constructRequestCq(onset, operation, policy, null));
+
+
+ UUID requestId = UUID.randomUUID();
+ onset.setRequestId(requestId);
+ assertNull(VfcActorServiceProvider.constructRequestCq(onset, operation, policy, null));
+
+ onset.getAai().put("generic-vnf.vnf-name", "Dorothy");
+ assertNull(VfcActorServiceProvider.constructRequestCq(onset, operation, policy, null));
+
+
+ onset.getAai().put("service-instance.service-instance-id", "");
+ assertNull(VfcActorServiceProvider.constructRequestCq(onset, operation, policy, null));
+
+ assertNull(VfcActorServiceProvider.constructRequestCq(onset, operation, policy,
+ loadAaiResponse("aai/AaiCqResponse.json")));
+
+ policy.setRecipe("Restart");
+ assertNotNull(VfcActorServiceProvider.constructRequestCq(onset, operation, policy,
+ loadAaiResponse("aai/AaiCqResponse.json")));
+
+ VfcRequest request = VfcActorServiceProvider.constructRequestCq(onset, operation, policy,
+ loadAaiResponse("aai/AaiCqResponse.json"));
+
+ assertEquals(requestId, Objects.requireNonNull(request).getRequestId());
+ assertEquals("dorothy.gale.1939", request.getHealRequest().getVnfInstanceId());
+ assertEquals("restartvm", request.getHealRequest().getAdditionalParams().getAction());
+ }
+
+ /**
+ * Reads an AAI vserver named-query response from a file.
+ *
+ * @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
+ * @throws JAXBException throws JAXBException
+ */
+ private AaiCqResponse loadAaiResponse(String fileName) throws IOException, JAXBException {
+ String resp = IOUtils.toString(getClass().getResource(fileName), StandardCharsets.UTF_8);
+ return new AaiCqResponse(resp);
+ }
+
}
diff --git a/models-interactions/model-actors/actor.vfc/src/test/resources/org/onap/policy/controlloop/actor/vfc/aai/AaiCqResponse.json b/models-interactions/model-actors/actor.vfc/src/test/resources/org/onap/policy/controlloop/actor/vfc/aai/AaiCqResponse.json
new file mode 100644
index 000000000..63d6f79ac
--- /dev/null
+++ b/models-interactions/model-actors/actor.vfc/src/test/resources/org/onap/policy/controlloop/actor/vfc/aai/AaiCqResponse.json
@@ -0,0 +1,673 @@
+{
+ "results": [
+ {
+ "vserver": {
+ "vserver-id": "e7f1db09-ff78-44fc-b256-69095c5556fb",
+ "vserver-name": "vfw-vm-0201-2",
+ "vserver-name2": "vfw-vm-0201-2",
+ "prov-status": "ACTIVE",
+ "vserver-selflink": "http://ecompctl1.research.att.com:8774/v2/3f2aaef74ecb4b19b35e26d0849fe9a2/servers/e7f1db09-ff78-44fc-b256-69095c5556fb",
+ "in-maint": false,
+ "is-closed-loop-disabled": false,
+ "resource-version": "1549553422524",
+ "relationship-list": {
+ "relationship": [
+ {
+ "related-to": "generic-vnf",
+ "related-link": "/aai/v11/network/generic-vnfs/generic-vnf/17044ef4-e7f3-46a1-af03-e2aa562f23ac",
+ "relationship-data": [
+ {
+ "relationship-key": "generic-vnf.vnf-id",
+ "relationship-value": "17044ef4-e7f3-46a1-af03-e2aa562f23ac"
+ }
+ ],
+ "related-to-property": [
+ {
+ "property-key": "generic-vnf.vnf-name",
+ "property-value": "TestVM-Vnf-0201-1"
+ }
+ ]
+ },
+ {
+ "related-to": "vnfc",
+ "related-link": "/aai/v11/network/vnfcs/vnfc/vfw",
+ "relationship-data": [
+ {
+ "relationship-key": "vnfc.vnfc-name",
+ "relationship-value": "vfw"
+ }
+ ]
+ },
+ {
+ "related-to": "vf-module",
+ "related-link": "/aai/v11/network/generic-vnfs/generic-vnf/17044ef4-e7f3-46a1-af03-e2aa562f23ac/vf-modules/vf-module/33f9e03d-2fbd-4e9c-8e73-ce6b12f0b3d2",
+ "relationship-data": [
+ {
+ "relationship-key": "generic-vnf.vnf-id",
+ "relationship-value": "17044ef4-e7f3-46a1-af03-e2aa562f23ac"
+ },
+ {
+ "relationship-key": "vf-module.vf-module-id",
+ "relationship-value": "33f9e03d-2fbd-4e9c-8e73-ce6b12f0b3d2"
+ }
+ ]
+ },
+ {
+ "related-to": "flavor",
+ "related-link": "/aai/v11/cloud-infrastructure/cloud-regions/cloud-region/CloudOwner/RegionOne/flavors/flavor/2",
+ "relationship-data": [
+ {
+ "relationship-key": "cloud-region.cloud-owner",
+ "relationship-value": "CloudOwner"
+ },
+ {
+ "relationship-key": "cloud-region.cloud-region-id",
+ "relationship-value": "RegionOne"
+ },
+ {
+ "relationship-key": "flavor.flavor-id",
+ "relationship-value": "2"
+ }
+ ],
+ "related-to-property": [
+ {
+ "property-key": "flavor.flavor-name",
+ "property-value": "m1.small"
+ }
+ ]
+ },
+ {
+ "related-to": "image",
+ "related-link": "/aai/v11/cloud-infrastructure/cloud-regions/cloud-region/CloudOwner/RegionOne/images/image/84be7136-301f-4f47-9585-3a2e0f9534af",
+ "relationship-data": [
+ {
+ "relationship-key": "cloud-region.cloud-owner",
+ "relationship-value": "CloudOwner"
+ },
+ {
+ "relationship-key": "cloud-region.cloud-region-id",
+ "relationship-value": "RegionOne"
+ },
+ {
+ "relationship-key": "image.image-id",
+ "relationship-value": "84be7136-301f-4f47-9585-3a2e0f9534af"
+ }
+ ],
+ "related-to-property": [
+ {
+ "property-key": "image.image-name",
+ "property-value": "unknown"
+ }
+ ]
+ }
+ ]
+ }
+ }
+ },
+ {
+ "generic-vnf": {
+ "vnf-id": "7b202620-2936-4b0d-b09c-60b411f10f64",
+ "vnf-name": "vLoadBalancerMS-Vnf-0211-1",
+ "vnf-type": "vLoadBalancerMS/vLoadBalancerMS 0",
+ "prov-status": "ACTIVE",
+ "equipment-role": "vLB",
+ "orchestration-status": "Active",
+ "ipv4-oam-address": "10.0.150.1",
+ "in-maint": true,
+ "is-closed-loop-disabled": false,
+ "resource-version": "1552311656338",
+ "model-invariant-id": "724ab1cf-6120-49e8-b909-849963bed1d6",
+ "model-version-id": "9d5944d8-2267-4799-824a-0f824e9a978d",
+ "model-customization-id": "efcd576d-a05e-4798-bb68-79e7d9c80f4c",
+ "nf-type": "ONAP-LOADBALANCER",
+ "nf-function": "LOADBALANCER",
+ "nf-role": "vLB",
+ "nf-naming-code": "vlb",
+ "selflink": "restconf/config/GENERIC-RESOURCE-API:services/service/101b8fc1-1796-4db1-a4e7-fe39c6a51558/service-data/vnfs/vnf/7b202620-2936-4b0d-b09c-60b411f10f64/vnf-data/vnf-topology/",
+ "relationship-list": {
+ "relationship": [
+ {
+ "related-to": "service-instance",
+ "related-link": "/aai/v11/business/customers/customer/Demonstration/service-subscriptions/service-subscription/vLB/service-instances/service-instance/101b8fc1-1796-4db1-a4e7-fe39c6a51558",
+ "relationship-data": [
+ {
+ "relationship-key": "customer.global-customer-id",
+ "relationship-value": "Demonstration"
+ },
+ {
+ "relationship-key": "service-subscription.service-type",
+ "relationship-value": "vLB"
+ },
+ {
+ "relationship-key": "service-instance.service-instance-id",
+ "relationship-value": "101b8fc1-1796-4db1-a4e7-fe39c6a51558"
+ }
+ ],
+ "related-to-property": [
+ {
+ "property-key": "service-instance.service-instance-name",
+ "property-value": "vLoadBalancerMS-0211-1"
+ }
+ ]
+ },
+ {
+ "related-to": "platform",
+ "related-link": "/aai/v11/business/platforms/platform/Test-Platform",
+ "relationship-data": [
+ {
+ "relationship-key": "platform.platform-name",
+ "relationship-value": "Test-Platform"
+ }
+ ]
+ },
+ {
+ "related-to": "line-of-business",
+ "related-link": "/aai/v11/business/lines-of-business/line-of-business/Test-Business",
+ "relationship-data": [
+ {
+ "relationship-key": "line-of-business.line-of-business-name",
+ "relationship-value": "Test-Business"
+ }
+ ]
+ },
+ {
+ "related-to": "vserver",
+ "related-link": "/aai/v11/cloud-infrastructure/cloud-regions/cloud-region/CloudOwner/RegionOne/tenants/tenant/3f2aaef74ecb4b19b35e26d0849fe9a2/vservers/vserver/58ca8df0-17b8-4aa2-8766-9c6c1a12cec8",
+ "relationship-data": [
+ {
+ "relationship-key": "cloud-region.cloud-owner",
+ "relationship-value": "CloudOwner"
+ },
+ {
+ "relationship-key": "cloud-region.cloud-region-id",
+ "relationship-value": "RegionOne"
+ },
+ {
+ "relationship-key": "tenant.tenant-id",
+ "relationship-value": "3f2aaef74ecb4b19b35e26d0849fe9a2"
+ },
+ {
+ "relationship-key": "vserver.vserver-id",
+ "relationship-value": "58ca8df0-17b8-4aa2-8766-9c6c1a12cec8"
+ }
+ ],
+ "related-to-property": [
+ {
+ "property-key": "vserver.vserver-name",
+ "property-value": "vdns-ms-0211-1"
+ }
+ ]
+ },
+ {
+ "related-to": "vserver",
+ "related-link": "/aai/v11/cloud-infrastructure/cloud-regions/cloud-region/CloudOwner/RegionOne/tenants/tenant/3f2aaef74ecb4b19b35e26d0849fe9a2/vservers/vserver/6c3b3714-e36c-45af-9f16-7d3a73d99497",
+ "relationship-data": [
+ {
+ "relationship-key": "cloud-region.cloud-owner",
+ "relationship-value": "CloudOwner"
+ },
+ {
+ "relationship-key": "cloud-region.cloud-region-id",
+ "relationship-value": "RegionOne"
+ },
+ {
+ "relationship-key": "tenant.tenant-id",
+ "relationship-value": "3f2aaef74ecb4b19b35e26d0849fe9a2"
+ },
+ {
+ "relationship-key": "vserver.vserver-id",
+ "relationship-value": "6c3b3714-e36c-45af-9f16-7d3a73d99497"
+ }
+ ],
+ "related-to-property": [
+ {
+ "property-key": "vserver.vserver-name",
+ "property-value": "vlb-ms-0211-1"
+ }
+ ]
+ },
+ {
+ "related-to": "availability-zone",
+ "related-link": "/aai/v11/cloud-infrastructure/cloud-regions/cloud-region/CloudOwner/RegionOne/availability-zones/availability-zone/nova",
+ "relationship-data": [
+ {
+ "relationship-key": "cloud-region.cloud-owner",
+ "relationship-value": "CloudOwner"
+ },
+ {
+ "relationship-key": "cloud-region.cloud-region-id",
+ "relationship-value": "RegionOne"
+ },
+ {
+ "relationship-key": "availability-zone.availability-zone-name",
+ "relationship-value": "nova"
+ }
+ ]
+ }
+ ]
+ },
+ "vf-modules": {
+ "vf-module": [
+ {
+ "vf-module-id": "e46c6636-9ce5-4b77-bb1b-455ce9edc892",
+ "vf-module-name": "vLoadBalancerMS-0211-1",
+ "heat-stack-id": "vLoadBalancerMS-0211-1/73360253-2dfe-46f6-bcd6-8662a81238ea",
+ "orchestration-status": "Active",
+ "is-base-vf-module": true,
+ "resource-version": "1552311559802",
+ "model-invariant-id": "d263fc6d-cfce-4e20-8337-e06f48b474e6",
+ "model-version-id": "24c0aa10-3979-402c-ad98-20124751b551",
+ "model-customization-id": "65382eb1-db84-466c-b9d7-4e0f1ba7105f",
+ "selflink": "restconf/config/GENERIC-RESOURCE-API:services/service/101b8fc1-1796-4db1-a4e7-fe39c6a51558/service-data/vnfs/vnf/7b202620-2936-4b0d-b09c-60b411f10f64/vnf-data/vf-modules/vf-module/e46c6636-9ce5-4b77-bb1b-455ce9edc892/vf-module-data/vf-module-topology/",
+ "relationship-list": {
+ "relationship": [
+ {
+ "related-to": "vserver",
+ "related-link": "/aai/v11/cloud-infrastructure/cloud-regions/cloud-region/CloudOwner/RegionOne/tenants/tenant/3f2aaef74ecb4b19b35e26d0849fe9a2/vservers/vserver/58ca8df0-17b8-4aa2-8766-9c6c1a12cec8",
+ "relationship-data": [
+ {
+ "relationship-key": "cloud-region.cloud-owner",
+ "relationship-value": "CloudOwner"
+ },
+ {
+ "relationship-key": "cloud-region.cloud-region-id",
+ "relationship-value": "RegionOne"
+ },
+ {
+ "relationship-key": "tenant.tenant-id",
+ "relationship-value": "3f2aaef74ecb4b19b35e26d0849fe9a2"
+ },
+ {
+ "relationship-key": "vserver.vserver-id",
+ "relationship-value": "58ca8df0-17b8-4aa2-8766-9c6c1a12cec8"
+ }
+ ],
+ "related-to-property": [
+ {
+ "property-key": "vserver.vserver-name",
+ "property-value": "vdns-ms-0211-1"
+ }
+ ]
+ },
+ {
+ "related-to": "vserver",
+ "related-link": "/aai/v11/cloud-infrastructure/cloud-regions/cloud-region/CloudOwner/RegionOne/tenants/tenant/3f2aaef74ecb4b19b35e26d0849fe9a2/vservers/vserver/6c3b3714-e36c-45af-9f16-7d3a73d99497",
+ "relationship-data": [
+ {
+ "relationship-key": "cloud-region.cloud-owner",
+ "relationship-value": "CloudOwner"
+ },
+ {
+ "relationship-key": "cloud-region.cloud-region-id",
+ "relationship-value": "RegionOne"
+ },
+ {
+ "relationship-key": "tenant.tenant-id",
+ "relationship-value": "3f2aaef74ecb4b19b35e26d0849fe9a2"
+ },
+ {
+ "relationship-key": "vserver.vserver-id",
+ "relationship-value": "6c3b3714-e36c-45af-9f16-7d3a73d99497"
+ }
+ ],
+ "related-to-property": [
+ {
+ "property-key": "vserver.vserver-name",
+ "property-value": "vlb-ms-0211-1"
+ }
+ ]
+ }
+ ]
+ }
+ }
+ ]
+ }
+ }
+ },
+ {
+ "service-instance": {
+ "service-instance-id": "101b8fc1-1796-4db1-a4e7-fe39c6a51558",
+ "service-instance-name": "vLoadBalancerMS-0211-1",
+ "environment-context": "General_Revenue-Bearing",
+ "workload-context": "Production",
+ "model-invariant-id": "1008a768-1b67-407e-88c6-58c82b34ef42",
+ "model-version-id": "81f8c1cd-f664-4450-b3a4-be645613ab32",
+ "resource-version": "1552311350334",
+ "selflink": "restconf/config/GENERIC-RESOURCE-API:services/service/101b8fc1-1796-4db1-a4e7-fe39c6a51558/service-data/service-topology/",
+ "orchestration-status": "Active",
+ "relationship-list": {
+ "relationship": [
+ {
+ "related-to": "project",
+ "related-link": "/aai/v11/business/projects/project/Test-Project",
+ "relationship-data": [
+ {
+ "relationship-key": "project.project-name",
+ "relationship-value": "Test-Project"
+ }
+ ]
+ },
+ {
+ "related-to": "generic-vnf",
+ "related-link": "/aai/v11/network/generic-vnfs/generic-vnf/7b202620-2936-4b0d-b09c-60b411f10f64",
+ "relationship-data": [
+ {
+ "relationship-key": "generic-vnf.vnf-id",
+ "relationship-value": "7b202620-2936-4b0d-b09c-60b411f10f64"
+ }
+ ],
+ "related-to-property": [
+ {
+ "property-key": "generic-vnf.vnf-name",
+ "property-value": "vLoadBalancerMS-Vnf-0211-1"
+ }
+ ]
+ },
+ {
+ "related-to": "owning-entity",
+ "related-link": "/aai/v11/business/owning-entities/owning-entity/bb94a687-4f3b-40a3-914e-e98037d5ebd2",
+ "relationship-data": [
+ {
+ "relationship-key": "owning-entity.owning-entity-id",
+ "relationship-value": "bb94a687-4f3b-40a3-914e-e98037d5ebd2"
+ }
+ ]
+ }
+ ]
+ }
+ }
+ },
+ {
+ "generic-vnf": {
+ "vnf-id": "17044ef4-e7f3-46a1-af03-e2aa562f23ac",
+ "vnf-name": "TestVM-Vnf-0201-1",
+ "vnf-type": "TestVM/TestVM 0",
+ "prov-status": "ACTIVE",
+ "equipment-role": "",
+ "orchestration-status": "Active",
+ "ipv4-oam-address": "10.0.70.1",
+ "in-maint": true,
+ "is-closed-loop-disabled": false,
+ "resource-version": "1549041636264",
+ "model-invariant-id": "6a4d7971-0778-4655-9eab-9d6031c7ad57",
+ "model-version-id": "fb6c673c-e5b6-4e0a-9baf-5e0089784de9",
+ "model-customization-id": "706a3100-dbe5-442e-86c3-c7b823abbec2",
+ "selflink": "restconf/config/GENERIC-RESOURCE-API:services/service/d41f8217-d464-4458-bf0a-fba33a0f1b31/service-data/vnfs/vnf/17044ef4-e7f3-46a1-af03-e2aa562f23ac/vnf-data/vnf-topology/",
+ "relationship-list": {
+ "relationship": [
+ {
+ "related-to": "service-instance",
+ "related-link": "/aai/v11/business/customers/customer/Demonstration/service-subscriptions/service-subscription/vFW/service-instances/service-instance/d41f8217-d464-4458-bf0a-fba33a0f1b31",
+ "relationship-data": [
+ {
+ "relationship-key": "customer.global-customer-id",
+ "relationship-value": "Demonstration"
+ },
+ {
+ "relationship-key": "service-subscription.service-type",
+ "relationship-value": "vFW"
+ },
+ {
+ "relationship-key": "service-instance.service-instance-id",
+ "relationship-value": "d41f8217-d464-4458-bf0a-fba33a0f1b31"
+ }
+ ],
+ "related-to-property": [
+ {
+ "property-key": "service-instance.service-instance-name",
+ "property-value": "TestVM-Service-0201-1"
+ }
+ ]
+ },
+ {
+ "related-to": "platform",
+ "related-link": "/aai/v11/business/platforms/platform/Test-Platform",
+ "relationship-data": [
+ {
+ "relationship-key": "platform.platform-name",
+ "relationship-value": "Test-Platform"
+ }
+ ]
+ },
+ {
+ "related-to": "line-of-business",
+ "related-link": "/aai/v11/business/lines-of-business/line-of-business/Test-Business",
+ "relationship-data": [
+ {
+ "relationship-key": "line-of-business.line-of-business-name",
+ "relationship-value": "Test-Business"
+ }
+ ]
+ },
+ {
+ "related-to": "vserver",
+ "related-link": "/aai/v11/cloud-infrastructure/cloud-regions/cloud-region/CloudOwner/RegionOne/tenants/tenant/3f2aaef74ecb4b19b35e26d0849fe9a2/vservers/vserver/e7f1db09-ff78-44fc-b256-69095c5556fb",
+ "relationship-data": [
+ {
+ "relationship-key": "cloud-region.cloud-owner",
+ "relationship-value": "CloudOwner"
+ },
+ {
+ "relationship-key": "cloud-region.cloud-region-id",
+ "relationship-value": "RegionOne"
+ },
+ {
+ "relationship-key": "tenant.tenant-id",
+ "relationship-value": "3f2aaef74ecb4b19b35e26d0849fe9a2"
+ },
+ {
+ "relationship-key": "vserver.vserver-id",
+ "relationship-value": "e7f1db09-ff78-44fc-b256-69095c5556fb"
+ }
+ ],
+ "related-to-property": [
+ {
+ "property-key": "vserver.vserver-name",
+ "property-value": "vfw-vm-0201-2"
+ }
+ ]
+ },
+ {
+ "related-to": "availability-zone",
+ "related-link": "/aai/v11/cloud-infrastructure/cloud-regions/cloud-region/CloudOwner/RegionTwo/availability-zones/availability-zone/zone-1",
+ "relationship-data": [
+ {
+ "relationship-key": "cloud-region.cloud-owner",
+ "relationship-value": "CloudOwner"
+ },
+ {
+ "relationship-key": "cloud-region.cloud-region-id",
+ "relationship-value": "RegionTwo"
+ },
+ {
+ "relationship-key": "availability-zone.availability-zone-name",
+ "relationship-value": "zone-1"
+ }
+ ]
+ }
+ ]
+ },
+ "vf-modules": {
+ "vf-module": [
+ {
+ "vf-module-id": "0afde97a-3e3f-4597-aec3-e5488c0f20b7",
+ "vf-module-name": "TestVM-0201-1",
+ "heat-stack-id": "TestVM-0201-1/aee4d7e5-b4a0-4261-b3cf-bb23348a3d99",
+ "orchestration-status": "Active",
+ "is-base-vf-module": true,
+ "resource-version": "1549039401119",
+ "model-invariant-id": "6af68fdb-6479-43e2-8989-938f06c994bd",
+ "model-version-id": "16d1834e-d834-431f-b064-98c469c6505d",
+ "model-customization-id": "29ffb122-22c8-48d2-b152-b52d9e81e910",
+ "selflink": "restconf/config/GENERIC-RESOURCE-API:services/service/d41f8217-d464-4458-bf0a-fba33a0f1b31/service-data/vnfs/vnf/17044ef4-e7f3-46a1-af03-e2aa562f23ac/vnf-data/vf-modules/vf-module/0afde97a-3e3f-4597-aec3-e5488c0f20b7/vf-module-data/vf-module-topology/"
+ },
+ {
+ "vf-module-id": "33f9e03d-2fbd-4e9c-8e73-ce6b12f0b3d2",
+ "vf-module-name": "TestVM-0201-2",
+ "heat-stack-id": "TestVM-0201-2/1b9db6b8-620b-46f1-935a-8a61c294a98b",
+ "orchestration-status": "Active",
+ "is-base-vf-module": true,
+ "resource-version": "1549041447373",
+ "model-invariant-id": "6af68fdb-6479-43e2-8989-938f06c994bd",
+ "model-version-id": "16d1834e-d834-431f-b064-98c469c6505d",
+ "model-customization-id": "29ffb122-22c8-48d2-b152-b52d9e81e910",
+ "selflink": "restconf/config/GENERIC-RESOURCE-API:services/service/d41f8217-d464-4458-bf0a-fba33a0f1b31/service-data/vnfs/vnf/17044ef4-e7f3-46a1-af03-e2aa562f23ac/vnf-data/vf-modules/vf-module/33f9e03d-2fbd-4e9c-8e73-ce6b12f0b3d2/vf-module-data/vf-module-topology/",
+ "relationship-list": {
+ "relationship": [
+ {
+ "related-to": "vserver",
+ "related-link": "/aai/v11/cloud-infrastructure/cloud-regions/cloud-region/CloudOwner/RegionOne/tenants/tenant/3f2aaef74ecb4b19b35e26d0849fe9a2/vservers/vserver/e7f1db09-ff78-44fc-b256-69095c5556fb",
+ "relationship-data": [
+ {
+ "relationship-key": "cloud-region.cloud-owner",
+ "relationship-value": "CloudOwner"
+ },
+ {
+ "relationship-key": "cloud-region.cloud-region-id",
+ "relationship-value": "RegionOne"
+ },
+ {
+ "relationship-key": "tenant.tenant-id",
+ "relationship-value": "3f2aaef74ecb4b19b35e26d0849fe9a2"
+ },
+ {
+ "relationship-key": "vserver.vserver-id",
+ "relationship-value": "e7f1db09-ff78-44fc-b256-69095c5556fb"
+ }
+ ],
+ "related-to-property": [
+ {
+ "property-key": "vserver.vserver-name",
+ "property-value": "vfw-vm-0201-2"
+ }
+ ]
+ }
+ ]
+ }
+ }
+ ]
+ }
+ }
+ },
+ {
+ "vf-module": {
+ "vf-module-id": "0afde97a-3e3f-4597-aec3-e5488c0f20b7",
+ "vf-module-name": "TestVM-0201-1",
+ "heat-stack-id": "TestVM-0201-1/aee4d7e5-b4a0-4261-b3cf-bb23348a3d99",
+ "orchestration-status": "Active",
+ "is-base-vf-module": true,
+ "resource-version": "1549039401119",
+ "model-invariant-id": "6af68fdb-6479-43e2-8989-938f06c994bd",
+ "model-version-id": "16d1834e-d834-431f-b064-98c469c6505d",
+ "model-customization-id": "29ffb122-22c8-48d2-b152-b52d9e81e910",
+ "selflink": "restconf/config/GENERIC-RESOURCE-API:services/service/d41f8217-d464-4458-bf0a-fba33a0f1b31/service-data/vnfs/vnf/17044ef4-e7f3-46a1-af03-e2aa562f23ac/vnf-data/vf-modules/vf-module/0afde97a-3e3f-4597-aec3-e5488c0f20b7/vf-module-data/vf-module-topology/"
+ }
+ },
+ {
+ "vf-module": {
+ "vf-module-id": "33f9e03d-2fbd-4e9c-8e73-ce6b12f0b3d2",
+ "vf-module-name": "TestVM-0201-2",
+ "heat-stack-id": "TestVM-0201-2/1b9db6b8-620b-46f1-935a-8a61c294a98b",
+ "orchestration-status": "Active",
+ "is-base-vf-module": true,
+ "resource-version": "1549041447373",
+ "model-invariant-id": "6af68fdb-6479-43e2-8989-938f06c994bd",
+ "model-version-id": "16d1834e-d834-431f-b064-98c469c6505d",
+ "model-customization-id": "29ffb122-22c8-48d2-b152-b52d9e81e910",
+ "selflink": "restconf/config/GENERIC-RESOURCE-API:services/service/d41f8217-d464-4458-bf0a-fba33a0f1b31/service-data/vnfs/vnf/17044ef4-e7f3-46a1-af03-e2aa562f23ac/vnf-data/vf-modules/vf-module/33f9e03d-2fbd-4e9c-8e73-ce6b12f0b3d2/vf-module-data/vf-module-topology/",
+ "relationship-list": {
+ "relationship": [
+ {
+ "related-to": "vserver",
+ "related-link": "/aai/v11/cloud-infrastructure/cloud-regions/cloud-region/CloudOwner/RegionOne/tenants/tenant/3f2aaef74ecb4b19b35e26d0849fe9a2/vservers/vserver/e7f1db09-ff78-44fc-b256-69095c5556fb",
+ "relationship-data": [
+ {
+ "relationship-key": "cloud-region.cloud-owner",
+ "relationship-value": "CloudOwner"
+ },
+ {
+ "relationship-key": "cloud-region.cloud-region-id",
+ "relationship-value": "RegionOne"
+ },
+ {
+ "relationship-key": "tenant.tenant-id",
+ "relationship-value": "3f2aaef74ecb4b19b35e26d0849fe9a2"
+ },
+ {
+ "relationship-key": "vserver.vserver-id",
+ "relationship-value": "e7f1db09-ff78-44fc-b256-69095c5556fb"
+ }
+ ],
+ "related-to-property": [
+ {
+ "property-key": "vserver.vserver-name",
+ "property-value": "vfw-vm-0201-2"
+ }
+ ]
+ }
+ ]
+ }
+ }
+ },
+ {
+ "tenant": {
+ "tenant-id": "tenant1-16197-as988q",
+ "tenant-name": "tenant-name-16197-as988q",
+ "resource-version": "1550769793637",
+ "vservers": {
+ "vserver": [
+ {
+ "vserver-id": "vserver1-16197-as988q",
+ "vserver-name": "vserverName",
+ "vserver-name2": "vserverTE-name2-as988q",
+ "prov-status": "ACTIVE",
+ "vserver-selflink": "TRINITY vserverLink",
+ "in-maint": false,
+ "is-closed-loop-disabled": false,
+ "resource-version": "1550769794551",
+ "relationship-list": {
+ "relationship": [
+ {
+ "related-to": "generic-vnf",
+ "relationship-label": "tosca.relationships.HostedOn",
+ "related-link": "/aai/v16/network/generic-vnfs/generic-vnf/VNF1-16197-as988q",
+ "relationship-data": [
+ {
+ "relationship-key": "generic-vnf.vnf-id",
+ "relationship-value": "VNF1-16197-as988q"
+ }
+ ],
+ "related-to-property": [
+ {
+ "property-key": "generic-vnf.vnf-name",
+ "property-value": "vnf1Name"
+ }
+ ]
+ }
+ ]
+ }
+ }
+ ]
+ }
+ }
+ },
+ {
+ "cloud-region": {
+ "cloud-owner": "co-16197-01-as988q",
+ "cloud-region-id": "cr-16197-01-as988q",
+ "resource-version": "1550769792672",
+ "orchestration-disabled": false,
+ "in-maint": false,
+ "tenants": {
+ "tenant": [
+ {
+ "tenant-id": "tenant1-16197-as988q",
+ "tenant-name": "tenant-name-16197-as988q",
+ "resource-version": "1550769793637"
+ }
+ ]
+ }
+ }
+ }
+ ]
+}
diff --git a/models-interactions/model-impl/aai/pom.xml b/models-interactions/model-impl/aai/pom.xml
index b086d2242..e52b443d0 100644
--- a/models-interactions/model-impl/aai/pom.xml
+++ b/models-interactions/model-impl/aai/pom.xml
@@ -20,49 +20,55 @@
-->
-<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
- <modelVersion>4.0.0</modelVersion>
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+ <modelVersion>4.0.0</modelVersion>
- <parent>
- <groupId>org.onap.policy.models.policy-models-interactions.model-impl</groupId>
- <artifactId>model-impl</artifactId>
- <version>2.0.0-SNAPSHOT</version>
- </parent>
+ <parent>
+ <groupId>org.onap.policy.models.policy-models-interactions.model-impl</groupId>
+ <artifactId>model-impl</artifactId>
+ <version>2.0.0-SNAPSHOT</version>
+ </parent>
- <artifactId>aai</artifactId>
+ <artifactId>aai</artifactId>
- <dependencies>
- <dependency>
- <groupId>com.google.code.gson</groupId>
- <artifactId>gson</artifactId>
- <scope>provided</scope>
- </dependency>
- <dependency>
- <groupId>org.onap.policy.models.policy-models-interactions.model-impl</groupId>
- <artifactId>rest</artifactId>
- <version>${project.version}</version>
- </dependency>
- <dependency>
- <groupId>junit</groupId>
- <artifactId>junit</artifactId>
- <scope>test</scope>
- </dependency>
- <dependency>
- <groupId>org.mockito</groupId>
- <artifactId>mockito-core</artifactId>
- <version>2.13.0</version>
- <scope>test</scope>
- </dependency>
- <dependency>
- <groupId>org.powermock</groupId>
- <artifactId>powermock-core</artifactId>
- <scope>test</scope>
- </dependency>
- <dependency>
- <groupId>org.onap.policy.common</groupId>
- <artifactId>policy-endpoints</artifactId>
- <version>${policy.common.version}</version>
- <scope>provided</scope>
- </dependency>
- </dependencies>
+ <dependencies>
+ <dependency>
+ <groupId>com.google.code.gson</groupId>
+ <artifactId>gson</artifactId>
+ <scope>provided</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.onap.policy.models.policy-models-interactions.model-impl</groupId>
+ <artifactId>rest</artifactId>
+ <version>${project.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>junit</groupId>
+ <artifactId>junit</artifactId>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.mockito</groupId>
+ <artifactId>mockito-core</artifactId>
+ <version>2.13.0</version>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.powermock</groupId>
+ <artifactId>powermock-core</artifactId>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.onap.policy.common</groupId>
+ <artifactId>policy-endpoints</artifactId>
+ <version>${policy.common.version}</version>
+ <scope>provided</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.onap.aai.schema-service</groupId>
+ <artifactId>aai-schema</artifactId>
+ <version>1.0.1</version>
+ </dependency>
+ </dependencies>
</project>
diff --git a/models-interactions/model-impl/aai/src/main/java/org/onap/policy/aai/AaiCqResponse.java b/models-interactions/model-impl/aai/src/main/java/org/onap/policy/aai/AaiCqResponse.java
new file mode 100644
index 000000000..8e9c580f4
--- /dev/null
+++ b/models-interactions/model-impl/aai/src/main/java/org/onap/policy/aai/AaiCqResponse.java
@@ -0,0 +1,478 @@
+/*-
+ * ============LICENSE_START=======================================================
+ *
+ * ================================================================================
+ * Copyright (C) 2019 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.policy.aai;
+
+import com.google.gson.annotations.SerializedName;
+import java.io.StringReader;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.LinkedList;
+import java.util.List;
+import java.util.Map;
+import javax.xml.bind.JAXBContext;
+import javax.xml.bind.JAXBException;
+import javax.xml.bind.Unmarshaller;
+import javax.xml.transform.stream.StreamSource;
+import org.eclipse.persistence.jaxb.JAXBContextFactory;
+import org.eclipse.persistence.jaxb.JAXBContextProperties;
+import org.json.JSONArray;
+import org.json.JSONObject;
+import org.onap.aai.domain.yang.CloudRegion;
+import org.onap.aai.domain.yang.GenericVnf;
+import org.onap.aai.domain.yang.Relationship;
+import org.onap.aai.domain.yang.RelationshipData;
+import org.onap.aai.domain.yang.ServiceInstance;
+import org.onap.aai.domain.yang.Tenant;
+import org.onap.aai.domain.yang.VfModule;
+import org.onap.aai.domain.yang.Vserver;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+public class AaiCqResponse {
+
+ private static final String GENERIC_VNF = "generic-vnf";
+ private static final String VF_MODULE = "vf-module";
+ private static final Logger LOGGER = LoggerFactory.getLogger(AaiCqResponse.class);
+ private static JAXBContext jaxbContext;
+ private static Unmarshaller unmarshaller;
+
+
+ // JABX initial stuff
+ static {
+ Map<String, Object> properties = new HashMap<>();
+ properties.put(JAXBContextProperties.MEDIA_TYPE, "application/json");
+ properties.put(JAXBContextProperties.JSON_INCLUDE_ROOT, false);
+ // Define JAXB context
+ try {
+ jaxbContext = JAXBContextFactory.createContext(new Class[] {Vserver.class, GenericVnf.class, VfModule.class,
+ CloudRegion.class, ServiceInstance.class, Tenant.class}, properties);
+ unmarshaller = jaxbContext.createUnmarshaller();
+ } catch (JAXBException e) {
+ LOGGER.error("Could not initialize JAXBContext", e);
+ LOGGER.info("Problem initiatlizing JAXBContext", e);
+ }
+ }
+
+ @SerializedName("results")
+ private List<Object> inventoryResponseItems = new LinkedList<>();
+
+
+ /**
+ * Constructor creates a custom query response from a valid json string.
+ *
+ * @param jsonString A&AI Custom Query response JSON string
+ */
+ public AaiCqResponse(String jsonString) {
+
+ // Read JSON String and add all AaiObjects
+ JSONObject responseObj = new JSONObject(jsonString);
+ JSONArray resultsArray = new JSONArray();
+ if (responseObj.has("results")) {
+ resultsArray = (JSONArray) responseObj.get("results");
+ }
+ for (int i = 0; i < resultsArray.length(); i++) {
+ // Object is a vserver
+ if (resultsArray.getJSONObject(i).has("vserver")) {
+
+ // Create the StreamSource by creating StringReader using the
+ // JSON input
+ StreamSource json = new StreamSource(
+ new StringReader(resultsArray.getJSONObject(i).getJSONObject("vserver").toString()));
+
+ // Getting the vserver pojo again from the json
+ Vserver vserver = this.getAaiObject(json, Vserver.class);
+ this.inventoryResponseItems.add(vserver);
+ }
+
+ // Object is a Generic VNF
+ if (resultsArray.getJSONObject(i).has(GENERIC_VNF)) {
+ // Create the StreamSource by creating StringReader using the
+ // JSON input
+ StreamSource json = new StreamSource(
+ new StringReader(resultsArray.getJSONObject(i).getJSONObject(GENERIC_VNF).toString()));
+
+ // Getting the generic vnf pojo again from the json
+ GenericVnf genericVnf = this.getAaiObject(json, GenericVnf.class);
+
+ this.inventoryResponseItems.add(genericVnf);
+ }
+
+ // Object is a Service Instance
+ if (resultsArray.getJSONObject(i).has("service-instance")) {
+
+ // Create the StreamSource by creating StringReader using the
+ // JSON input
+ StreamSource json = new StreamSource(
+ new StringReader(resultsArray.getJSONObject(i).getJSONObject("service-instance").toString()));
+
+ // Getting the employee pojo again from the json
+ ServiceInstance serviceInstance = this.getAaiObject(json, ServiceInstance.class);
+
+ this.inventoryResponseItems.add(serviceInstance);
+ }
+
+ // Object is a VF Module
+ if (resultsArray.getJSONObject(i).has(VF_MODULE)) {
+ // Create the StreamSource by creating StringReader using the
+ // JSON input
+ StreamSource json = new StreamSource(
+ new StringReader(resultsArray.getJSONObject(i).getJSONObject(VF_MODULE).toString()));
+
+ // Getting the vf module pojo again from the json
+ VfModule vfModule = this.getAaiObject(json, VfModule.class);
+
+ this.inventoryResponseItems.add(vfModule);
+ }
+
+ // Object is a CloudRegion
+ if (resultsArray.getJSONObject(i).has("cloud-region")) {
+ // Create the StreamSource by creating StringReader using the
+ // JSON input
+ StreamSource json = new StreamSource(
+ new StringReader(resultsArray.getJSONObject(i).getJSONObject("cloud-region").toString()));
+
+ // Getting the cloud region pojo again from the json
+ CloudRegion cloudRegion = this.getAaiObject(json, CloudRegion.class);
+
+ this.inventoryResponseItems.add(cloudRegion);
+ }
+
+ // Object is a Tenant
+ if (resultsArray.getJSONObject(i).has("tenant")) {
+ // Create the StreamSource by creating StringReader using the
+ // JSON input
+ StreamSource json = new StreamSource(
+ new StringReader(resultsArray.getJSONObject(i).getJSONObject("tenant").toString()));
+
+ // Getting the tenant pojo again from the json
+ Tenant tenant = this.getAaiObject(json, Tenant.class);
+
+ this.inventoryResponseItems.add(tenant);
+ }
+
+ }
+
+
+
+ }
+
+
+
+ private <T> T getAaiObject(StreamSource json, final Class<T> classOfResponse) {
+ try {
+ return unmarshaller.unmarshal(json, classOfResponse).getValue();
+ } catch (JAXBException e) {
+ LOGGER.error("JAXBCOntext error", e);
+ return null;
+ }
+ }
+
+ public List<Object> getInventoryResponseItems() {
+ return inventoryResponseItems;
+ }
+
+ public void setInventoryResponseItems(List<Object> inventoryResponseItems) {
+ this.inventoryResponseItems = inventoryResponseItems;
+ }
+
+ /**
+ * Get list of A&AI objects in the custom query.
+ *
+ * @param classOfResponse Class of the type of A&AI objects to be returned
+ * @return List A&AI objects matching the class
+ */
+ @SuppressWarnings("unchecked")
+ public <T> List<T> getItemListByType(Class<T> classOfResponse) {
+ List<T> returnItemList = new ArrayList<>();
+ for (Object i : this.inventoryResponseItems) {
+ if (i.getClass() == classOfResponse) {
+ returnItemList.add((T) i);
+ }
+ }
+ return returnItemList;
+
+ }
+
+ /**
+ * Get Service Instance.
+ *
+ * @return Service Instance
+ */
+ public ServiceInstance getServiceInstance() {
+ ServiceInstance serviceInstance = null;
+ for (Object i : this.inventoryResponseItems) {
+ if (i.getClass() == ServiceInstance.class) {
+ serviceInstance = (ServiceInstance) i;
+ }
+ }
+ return serviceInstance;
+
+ }
+
+ /**
+ * Get Tenant.
+ *
+ * @return Tenant
+ */
+ public Tenant getDefaultTenant() {
+ Tenant tenant = null;
+ for (Object i : this.inventoryResponseItems) {
+ if (i.getClass() == Tenant.class) {
+ tenant = (Tenant) i;
+ }
+ }
+ return tenant;
+
+ }
+
+ /**
+ * Get Cloud Region.
+ *
+ * @return Cloud Region
+ */
+ public CloudRegion getDefaultCloudRegion() {
+ CloudRegion cloudRegion = null;
+ for (Object i : this.inventoryResponseItems) {
+ if (i.getClass() == CloudRegion.class) {
+ cloudRegion = (CloudRegion) i;
+ }
+ }
+ return cloudRegion;
+
+ }
+
+ /**
+ * Get Generic Vnfs in the custom query.
+ *
+ * @return List of generic Vnf
+ */
+ public List<GenericVnf> getGenericVnfs() {
+ List<GenericVnf> genericVnfList = new ArrayList<>();
+ for (Object i : this.inventoryResponseItems) {
+ if (i.getClass() == GenericVnf.class) {
+ genericVnfList.add((GenericVnf) i);
+ }
+ }
+ return genericVnfList;
+
+ }
+
+
+ /**
+ * Returns a generic Vnf matching vnf name.
+ *
+ * @param vnfName Name of the vnf to match
+ * @return generic Vnf
+ */
+ public GenericVnf getGenericVnfByVnfName(String vnfName) {
+ List<GenericVnf> genericVnfList = new ArrayList<>();
+ GenericVnf genericVnf = null;
+ for (Object i : this.inventoryResponseItems) {
+ if (i.getClass() == GenericVnf.class) {
+ genericVnfList.add((GenericVnf) i);
+ }
+ }
+
+ for (GenericVnf genVnf : genericVnfList) {
+ if (vnfName.equals(genVnf.getVnfName())) {
+ genericVnf = genVnf;
+ }
+
+ }
+ return genericVnf;
+
+ }
+
+ /**
+ * Returns a generic Vnf matching model invariant ID.
+ *
+ * @param modelInvariantId Name of the vnf to match
+ * @return generic Vnf
+ */
+ public GenericVnf getGenericVnfByModelInvariantId(String modelInvariantId) {
+ List<GenericVnf> genericVnfList = new ArrayList<>();
+ GenericVnf genericVnf = null;
+ for (Object i : this.inventoryResponseItems) {
+ if (i.getClass() == GenericVnf.class) {
+ genericVnfList.add((GenericVnf) i);
+ }
+ }
+
+ for (GenericVnf genVnf : genericVnfList) {
+ if (modelInvariantId.equals(genVnf.getModelInvariantId())) {
+ genericVnf = genVnf;
+ }
+
+ }
+ return genericVnf;
+
+ }
+
+
+
+ /**
+ * Get the generic vnf associated with the vserver in the custom query.
+ *
+ * @return Generic VNF
+ */
+ public GenericVnf getDefaultGenericVnf() {
+ GenericVnf genericVnf = null;
+
+ // Get the vserver associated with the query
+ Vserver vserver = this.getVserver();
+
+ // Get the relationships of the vserver
+ List<Relationship> relations = vserver.getRelationshipList().getRelationship();
+
+ // Find the relationship of the genericVNF
+ String genericVnfId = "";
+ List<RelationshipData> relationshipData = null;
+
+ // Iterate through the list of relationships and get generic vnf relationship data
+ for (Relationship r : relations) {
+ // Get the name of generic-vnf related to this server
+ if (GENERIC_VNF.equals(r.getRelatedTo())) {
+ relationshipData = r.getRelationshipData();
+ }
+ }
+
+ // Iterate through relationship data, and get vnf-id
+ for (RelationshipData rd : relationshipData) {
+ // Get the id of the generic-vnf
+ if ("generic-vnf.vnf-id".equals(rd.getRelationshipKey())) {
+ genericVnfId = rd.getRelationshipValue();
+ }
+ }
+
+ // Get the list of generic vnfs
+ List<GenericVnf> genericVnfList = this.getGenericVnfs();
+
+ for (GenericVnf genVnf : genericVnfList) {
+ if (genericVnfId.equals(genVnf.getVnfId())) {
+ genericVnf = genVnf;
+ }
+ }
+
+ return genericVnf;
+ }
+
+
+ /**
+ * Get Vf Module associated with the vserver in the custom query.
+ *
+ * @return Vf Module
+ */
+ public VfModule getDefaultVfModule() {
+ GenericVnf genericVnf = null;
+ VfModule vfModule = null;
+
+ // Get the vserver associated with the query
+ Vserver vserver = this.getVserver();
+
+ // Get the relationships of the vserver
+ List<Relationship> relations = vserver.getRelationshipList().getRelationship();
+
+ // Find the relationship of VfModule
+ String vfModuleId = "";
+ List<RelationshipData> relationshipData = null;
+
+ // Iterate through the list of relationships and get vf module relationship data
+ for (Relationship r : relations) {
+ // Get relationship data of vfmodule related to this server
+ if (VF_MODULE.equals(r.getRelatedTo())) {
+ relationshipData = r.getRelationshipData();
+ }
+ }
+
+ // Iterate through relationship data, and get vf-module-id
+ for (RelationshipData rd : relationshipData) {
+ // Get the id of the vf-module
+ if ("vf-module.vf-module-id".equals(rd.getRelationshipKey())) {
+ vfModuleId = rd.getRelationshipValue();
+ }
+ }
+
+ // Get the generic VNF associated with this vserver query
+ genericVnf = this.getDefaultGenericVnf();
+
+ // Get the list of VFmodules associated with this generic Vnf
+ List<VfModule> vfModuleList = genericVnf.getVfModules().getVfModule();
+
+ for (VfModule vfMod : vfModuleList) {
+ if (vfModuleId.equals(vfMod.getVfModuleId())) {
+ vfModule = vfMod;
+ }
+ }
+
+ return vfModule;
+ }
+
+
+ /**
+ * Get vf modules in the custom query.
+ *
+ * @return List of VfModule
+ */
+ public List<VfModule> getAllVfModules() {
+ List<VfModule> vfModuleList = new ArrayList<>();
+
+ for (GenericVnf genVnf : this.getGenericVnfs()) {
+ vfModuleList.addAll(genVnf.getVfModules().getVfModule());
+ }
+ return vfModuleList;
+
+ }
+
+ /**
+ * Get Vf Module matching a specific VF module name.
+ *
+ * @return VfModule
+ */
+ public VfModule getVfModuleByVfModuleName(String vfModuleName) {
+ VfModule vfModule = null;
+
+ for (VfModule vfMod : this.getAllVfModules()) {
+ if (vfModuleName.equals(vfMod.getVfModuleName())) {
+ vfModule = vfMod;
+ }
+
+ }
+ return vfModule;
+ }
+
+ /**
+ * Get verver in the custom query.
+ *
+ * @return Vserver
+ */
+ public Vserver getVserver() {
+ Vserver vserver = null;
+ int index = 0;
+ while (this.inventoryResponseItems.get(index).getClass() != Vserver.class) {
+ index = index + 1;
+ }
+ vserver = (Vserver) this.inventoryResponseItems.get(index);
+ return vserver;
+
+ }
+
+}
+
diff --git a/models-interactions/model-impl/aai/src/main/java/org/onap/policy/aai/AaiManager.java b/models-interactions/model-impl/aai/src/main/java/org/onap/policy/aai/AaiManager.java
index bb772e6ca..f50f0cb9f 100644
--- a/models-interactions/model-impl/aai/src/main/java/org/onap/policy/aai/AaiManager.java
+++ b/models-interactions/model-impl/aai/src/main/java/org/onap/policy/aai/AaiManager.java
@@ -23,11 +23,11 @@
package org.onap.policy.aai;
import com.google.gson.JsonSyntaxException;
-
import java.util.HashMap;
import java.util.Map;
import java.util.UUID;
-
+import org.json.JSONArray;
+import org.json.JSONObject;
import org.onap.policy.aai.util.Serialization;
import org.onap.policy.common.endpoints.event.comm.Topic.CommInfrastructure;
import org.onap.policy.common.endpoints.utils.NetLoggerUtil;
@@ -49,6 +49,12 @@ public final class AaiManager {
// The REST manager used for processing REST calls for this AAI manager
private final RestManager restManager;
+ /** custom query URLs. */
+ private static String cqUrl = "/aai/v16/query?format=resource";
+ private static String tenantUrl = "/aai/v16/search/nodes-query?search-node-type=vserver&filter=vserver-name:";
+ private static String prefix = "/aai/v16";
+
+
/**
* Constructor, create the AAI manager with the specified REST manager.
*
@@ -59,6 +65,151 @@ public final class AaiManager {
}
/**
+ * Creates the custom query payload from a tenant query response.
+ *
+ * @param getResponse response from the tenant query
+ * @return String Payload
+ */
+ private String createCustomQueryPayload(String getResponse) {
+
+ if (getResponse == null) {
+ return null;
+ } else {
+ JSONObject responseObj = new JSONObject(getResponse);
+ JSONArray resultsArray = new JSONArray();
+ if (responseObj.has("result-data")) {
+ resultsArray = (JSONArray) responseObj.get("result-data");
+ } else {
+ return null;
+ }
+ String resourceLink = resultsArray.getJSONObject(0).getString("resource-link");
+ String start = resourceLink.replace(prefix, "");
+ String query = "query/closed-loop";
+ JSONObject payload = new JSONObject();
+ payload.put("start", start);
+ payload.put("query", query);
+ return payload.toString();
+
+ }
+ }
+
+
+ /**
+ * This method is used to get the information for custom query.
+ *
+ * @param url url of the get method
+ * @param username Aai username
+ * @param password Aai password
+ * @param requestId request ID
+ * @param vserver Id of the vserver
+ * @return String
+ */
+ private String getCustomQueryRequestPayload(String url, String username, String password, UUID requestId,
+ String vserver) {
+
+ String urlGet = url + tenantUrl;
+ String getResponse = getStringQuery(urlGet, username, password, requestId, vserver);
+ return createCustomQueryPayload(getResponse);
+ }
+
+
+
+ /**
+ * Calls Aai and returns a custom query response for a vserver.
+ *
+ * @param url Aai url
+ * @param username Aai Username
+ * @param password Aai Password
+ * @param requestId request ID
+ * @param vserver Vserver
+ * @return AaiCqResponse response from Aai for custom query
+ */
+ public AaiCqResponse getCustomQueryResponse(String url, String username, String password, UUID requestId,
+ String vserver) {
+
+ final Map<String, String> headers = createHeaders(requestId);
+
+ url = url + cqUrl;
+
+ logger.debug("RestManager.put before");
+ String requestJson = getCustomQueryRequestPayload(url, username, password, requestId, vserver);
+ NetLoggerUtil.log(EventType.OUT, CommInfrastructure.REST, url, requestJson);
+ Pair<Integer, String> httpDetails =
+ this.restManager.put(url, username, password, headers, "application/json", requestJson);
+ logger.debug("RestManager.put after");
+
+ if (httpDetails == null) {
+ logger.info("AAI POST Null Response to {}", url);
+ return null;
+ }
+
+ int httpResponseCode = httpDetails.first;
+
+ logger.info(url);
+ logger.info("{}", httpResponseCode);
+ logger.info(httpDetails.second);
+
+ if (httpDetails.second != null) {
+ String resp = httpDetails.second;
+ return new AaiCqResponse(resp);
+ }
+ return null;
+ }
+
+
+
+ /**
+ * Returns the string response of a get query.
+ *
+ * @param url Aai URL
+ * @param username Aai Username
+ * @param password Aai Password
+ * @param requestId AaiRequestId
+ * @param key Aai Key
+ * @return String returns the string from the get query
+ */
+ private String getStringQuery(final String url, final String username, final String password, final UUID requestId,
+ final String key) {
+
+ Map<String, String> headers = createHeaders(requestId);
+
+ String urlGet = url + key;
+
+ int attemptsLeft = 3;
+
+ while (attemptsLeft-- > 0) {
+ NetLoggerUtil.getNetworkLogger().info("[OUT|{}|{}|]", CommInfrastructure.REST, urlGet);
+ Pair<Integer, String> httpDetailsGet = restManager.get(urlGet, username, password, headers);
+ if (httpDetailsGet == null) {
+ logger.info("AAI GET Null Response to {}", urlGet);
+ return null;
+ }
+
+ int httpResponseCode = httpDetailsGet.first;
+
+ logger.info(urlGet);
+ logger.info("{}", httpResponseCode);
+ logger.info(httpDetailsGet.second);
+
+ if (httpResponseCode == 200) {
+ String responseGet = httpDetailsGet.second;
+ if (responseGet != null) {
+ return responseGet;
+ }
+ }
+ try {
+ Thread.sleep(1000);
+ } catch (InterruptedException e) {
+ Thread.currentThread().interrupt();
+ }
+
+ }
+
+ return null;
+ }
+
+
+ /**
* Post a query to A&AI.
*
* @param url the A&AI URL
diff --git a/models-interactions/model-impl/aai/src/test/java/org/onap/policy/aai/AaiCqResponseTest.java b/models-interactions/model-impl/aai/src/test/java/org/onap/policy/aai/AaiCqResponseTest.java
new file mode 100644
index 000000000..bfa0a5a4c
--- /dev/null
+++ b/models-interactions/model-impl/aai/src/test/java/org/onap/policy/aai/AaiCqResponseTest.java
@@ -0,0 +1,278 @@
+/*-
+ * ============LICENSE_START=======================================================
+ *
+ * ================================================================================
+ * Copyright (C) 2019 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.policy.aai;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertNull;
+
+import java.io.File;
+import java.nio.file.Files;
+import java.util.ArrayList;
+import java.util.List;
+import org.junit.Test;
+import org.onap.aai.domain.yang.CloudRegion;
+import org.onap.aai.domain.yang.GenericVnf;
+import org.onap.aai.domain.yang.ServiceInstance;
+import org.onap.aai.domain.yang.Tenant;
+import org.onap.aai.domain.yang.VfModule;
+import org.onap.aai.domain.yang.Vserver;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+public class AaiCqResponseTest {
+ private static final Logger LOGGER = LoggerFactory.getLogger(AaiCqResponseTest.class);
+ private static final String CQ_RESPONSE_SAMPLE = "src/test/resources/org/onap/policy/aai/AaiCqResponse.json";
+
+
+ @Test
+ public void testConstructor() throws Exception {
+ /*
+ * Read JSON String and add all AaiObjects
+ */
+
+ String responseString = "";
+ responseString = new String(Files.readAllBytes(new File(CQ_RESPONSE_SAMPLE).toPath()));
+
+ AaiCqResponse aaiCqResponse;
+ aaiCqResponse = new AaiCqResponse(responseString);
+ assertNotNull(aaiCqResponse);
+ assertNotNull(aaiCqResponse.getInventoryResponseItems());
+ }
+
+ @Test
+ public void testAaiMalformedCqResponse() throws Exception {
+ /*
+ * Read JSON String and add all AaiObjects
+ */
+
+ String responseString = "";
+ responseString = new String(Files
+ .readAllBytes(new File("src/test/resources/org/onap/policy/aai/AaiMalformedCqResponse.json").toPath()));
+
+ AaiCqResponse aaiCqResponse;
+ aaiCqResponse = new AaiCqResponse(responseString);
+ for (Object aaiObj : aaiCqResponse.getInventoryResponseItems()) {
+ assertNull(aaiObj);
+ }
+
+
+ }
+
+ @Test
+ public void testGetItemByList() throws Exception {
+ /*
+ * Read JSON String and add all AaiObjects
+ */
+
+ String responseString = "";
+ responseString = new String(Files.readAllBytes(new File(CQ_RESPONSE_SAMPLE).toPath()));
+
+ AaiCqResponse aaiCqResponse;
+ aaiCqResponse = new AaiCqResponse(responseString);
+ ArrayList<Vserver> vs = (ArrayList<Vserver>) aaiCqResponse.getItemListByType(Vserver.class);
+ assertNotNull(vs);
+ assertEquals("e7f1db09-ff78-44fc-b256-69095c5556fb", vs.get(0).getVserverId());
+ LOGGER.info(vs.get(0).getVserverId());
+
+ }
+
+ @Test
+ public void testGetServiceInstance() throws Exception {
+
+ String responseString = "";
+ responseString = new String(Files.readAllBytes(new File(CQ_RESPONSE_SAMPLE).toPath()));
+
+ AaiCqResponse aaiCqResponse;
+ aaiCqResponse = new AaiCqResponse(responseString);
+ ServiceInstance si = aaiCqResponse.getServiceInstance();
+ assertNotNull(si);
+ assertEquals("vLoadBalancerMS-0211-1", si.getServiceInstanceName());
+ LOGGER.info(si.getServiceInstanceName());
+ }
+
+ @Test
+ public void testGetDefaultCloudRegion() throws Exception {
+
+ String responseString = "";
+ responseString = new String(Files.readAllBytes(new File(CQ_RESPONSE_SAMPLE).toPath()));
+
+ AaiCqResponse aaiCqResponse;
+ aaiCqResponse = new AaiCqResponse(responseString);
+ CloudRegion cloudRegion = aaiCqResponse.getDefaultCloudRegion();
+ assertNotNull(cloudRegion);
+ assertEquals("cr-16197-01-as988q", cloudRegion.getCloudRegionId());
+ LOGGER.info(cloudRegion.getCloudRegionId());
+ }
+
+ @Test
+ public void testGetDefaultTenant() throws Exception {
+
+ String responseString = "";
+ responseString = new String(Files.readAllBytes(new File(CQ_RESPONSE_SAMPLE).toPath()));
+
+ AaiCqResponse aaiCqResponse;
+ aaiCqResponse = new AaiCqResponse(responseString);
+ Tenant tenant = aaiCqResponse.getDefaultTenant();
+ assertNotNull(tenant);
+ assertEquals("tenant1-16197-as988q", tenant.getTenantId());
+ LOGGER.info(tenant.getTenantId());
+ }
+
+
+
+ @Test
+ public void testGetGenericVnfs() throws Exception {
+
+ String responseString = "";
+ responseString = new String(Files.readAllBytes(new File(CQ_RESPONSE_SAMPLE).toPath()));
+
+ AaiCqResponse aaiCqResponse;
+ aaiCqResponse = new AaiCqResponse(responseString);
+ List<GenericVnf> genericVnfList = aaiCqResponse.getGenericVnfs();
+ assertNotNull(genericVnfList);
+ for (GenericVnf genVnf : genericVnfList) {
+ LOGGER.info(genVnf.getVnfName());
+ }
+
+ }
+
+
+
+ @Test
+ public void testGetDefaultGenericVnf() throws Exception {
+
+ String responseString = "";
+ responseString = new String(Files.readAllBytes(new File(CQ_RESPONSE_SAMPLE).toPath()));
+
+ AaiCqResponse aaiCqResponse;
+ aaiCqResponse = new AaiCqResponse(responseString);
+ GenericVnf genVnf = aaiCqResponse.getDefaultGenericVnf();
+ assertNotNull(genVnf);
+ assertEquals("TestVM-Vnf-0201-1", genVnf.getVnfName());
+ LOGGER.info(genVnf.getVnfName());
+
+ }
+
+ @Test
+ public void testGetGenericVnfByName() throws Exception {
+
+ String responseString = "";
+ responseString = new String(Files.readAllBytes(new File(CQ_RESPONSE_SAMPLE).toPath()));
+
+ AaiCqResponse aaiCqResponse;
+ aaiCqResponse = new AaiCqResponse(responseString);
+ GenericVnf genVnf = aaiCqResponse.getGenericVnfByVnfName("TestVM-Vnf-0201-1");
+ assertNotNull(genVnf);
+ assertEquals("17044ef4-e7f3-46a1-af03-e2aa562f23ac", genVnf.getVnfId());
+ LOGGER.info(genVnf.getVnfId());
+ }
+
+
+ @Test
+ public void testGetGenericVnfByModelInvariantId() throws Exception {
+
+ String responseString = "";
+ responseString = new String(Files.readAllBytes(new File(CQ_RESPONSE_SAMPLE).toPath()));
+
+ AaiCqResponse aaiCqResponse;
+ aaiCqResponse = new AaiCqResponse(responseString);
+ GenericVnf genVnf = aaiCqResponse.getGenericVnfByModelInvariantId("724ab1cf-6120-49e8-b909-849963bed1d6");
+ assertNotNull(genVnf);
+ assertEquals("724ab1cf-6120-49e8-b909-849963bed1d6", genVnf.getModelInvariantId());
+ LOGGER.info(genVnf.getModelInvariantId());
+ }
+
+ @Test
+ public void testGetAllVfModules() throws Exception {
+
+ String responseString = "";
+ responseString = new String(Files.readAllBytes(new File(CQ_RESPONSE_SAMPLE).toPath()));
+
+ AaiCqResponse aaiCqResponse;
+ aaiCqResponse = new AaiCqResponse(responseString);
+ List<VfModule> vfModuleList = aaiCqResponse.getAllVfModules();
+ assertNotNull(vfModuleList);
+ for (VfModule vfMod : vfModuleList) {
+ LOGGER.info(vfMod.getVfModuleName());
+ }
+
+ }
+
+
+ @Test
+ public void testGetVfModuleByVfModuleName() throws Exception {
+
+ String responseString = "";
+ responseString = new String(Files.readAllBytes(new File(CQ_RESPONSE_SAMPLE).toPath()));
+
+ AaiCqResponse aaiCqResponse;
+ aaiCqResponse = new AaiCqResponse(responseString);
+ VfModule vfModule = aaiCqResponse.getVfModuleByVfModuleName("vLoadBalancerMS-0211-1");
+ assertNotNull(vfModule);
+ assertEquals("vLoadBalancerMS-0211-1", vfModule.getVfModuleName());
+ LOGGER.info(vfModule.getVfModuleName());
+
+
+ }
+
+ @Test
+ public void testGetDefaultVfModule() throws Exception {
+
+ String responseString = "";
+ responseString = new String(Files.readAllBytes(new File(CQ_RESPONSE_SAMPLE).toPath()));
+
+ AaiCqResponse aaiCqResponse;
+ aaiCqResponse = new AaiCqResponse(responseString);
+ VfModule vfModule = aaiCqResponse.getDefaultVfModule();
+ assertNotNull(vfModule);
+ assertEquals("TestVM-0201-2", vfModule.getVfModuleName());
+ LOGGER.info(vfModule.getVfModuleName());
+ }
+
+ @Test
+ public void testGetVserver() throws Exception {
+
+ String responseString = "";
+ responseString = new String(Files.readAllBytes(new File(CQ_RESPONSE_SAMPLE).toPath()));
+
+ AaiCqResponse aaiCqResponse;
+ aaiCqResponse = new AaiCqResponse(responseString);
+ Vserver vserver = aaiCqResponse.getVserver();
+ assertNotNull(vserver);
+ assertEquals("vfw-vm-0201-2", vserver.getVserverName());
+ LOGGER.info(vserver.getVserverName());
+
+ }
+
+ /**
+ * Aai Cq sample response.
+ *
+ * @return String return response
+ * @throws Exception file read exception
+ */
+ public String getAaiCqResponse() throws Exception {
+ String responseString = "";
+ responseString = new String(Files.readAllBytes(new File(CQ_RESPONSE_SAMPLE).toPath()));
+ return responseString;
+ }
+
+}
diff --git a/models-interactions/model-impl/aai/src/test/java/org/onap/policy/aai/AaiManagerTest.java b/models-interactions/model-impl/aai/src/test/java/org/onap/policy/aai/AaiManagerTest.java
index 111042f6d..c453d89a1 100644
--- a/models-interactions/model-impl/aai/src/test/java/org/onap/policy/aai/AaiManagerTest.java
+++ b/models-interactions/model-impl/aai/src/test/java/org/onap/policy/aai/AaiManagerTest.java
@@ -31,10 +31,12 @@ import static org.mockito.ArgumentMatchers.startsWith;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.when;
+import java.io.File;
+import java.io.IOException;
+import java.nio.file.Files;
import java.util.HashMap;
import java.util.Map;
import java.util.UUID;
-
import org.junit.Before;
import org.junit.Test;
import org.onap.policy.aai.util.Serialization;
@@ -48,12 +50,18 @@ public class AaiManagerTest {
Pair<Integer, String> httpResponseErr0;
Pair<Integer, String> httpResponseErr1;
Pair<Integer, String> httpResponseWait;
+ Pair<Integer, String> httpTenantResponseOk;
+ Pair<Integer, String> httpCqResponseOk;
+
+ private static final String TENANT_RESPONSE_SAMPLE =
+ "src/test/resources/org/onap/policy/aai/AaiTenantResponse.json";
/**
* Set up test cases.
+ * @throws Exception if error occurs
*/
@Before
- public void beforeTestAaiManager() {
+ public void beforeTestAaiManager() throws Exception {
restManagerMock = mock(RestManager.class);
Map<String, String> expectedHeaders = new HashMap<>();
@@ -61,6 +69,10 @@ public class AaiManagerTest {
expectedHeaders.put("X-TransactionId", aaiNqRequestUuid.toString());
expectedHeaders.put("Accept", "application/json");
+ String aaiCqResponse = new AaiCqResponseTest().getAaiCqResponse();
+ String tenantResponse = this.getTenantQueryResponse();
+ httpCqResponseOk = restManagerMock.new Pair<>(200, aaiCqResponse);
+ httpTenantResponseOk = restManagerMock.new Pair<>(200, tenantResponse);
AaiNqResponse aaiNqResponse = new AaiNqResponseTest().getAaiNqResponse();
httpResponseOk = restManagerMock.new Pair<>(200, Serialization.gsonPretty.toJson(aaiNqResponse));
httpResponseErr0 = restManagerMock.new Pair<>(200, null);
@@ -69,6 +81,51 @@ public class AaiManagerTest {
}
@Test
+ public void testAaiCqResponse() {
+ AaiManager aaiManager = new AaiManager(restManagerMock);
+ assertNotNull(aaiManager);
+
+ UUID vserverNameRequestId = UUID.randomUUID();
+
+ when(restManagerMock.put(startsWith("http://testing.cq.query"), eq("Foo"), eq("Bar"), anyMap(), anyString(),
+ anyString())).thenReturn(httpCqResponseOk);
+
+ when(restManagerMock.get(startsWith("http://testing.cq.query"), eq("Foo"), eq("Bar"), anyMap()))
+ .thenReturn(httpTenantResponseOk);
+
+ AaiCqResponse aaiCqResponse =
+ aaiManager.getCustomQueryResponse("http://testing.cq.query", "Foo", "Bar", vserverNameRequestId, "Foo");
+ assertNotNull(aaiCqResponse);
+
+ when(restManagerMock.put(eq(""), eq("Foo"), eq("Bar"), anyMap(), anyString(), anyString()))
+ .thenReturn(httpResponseErr0);
+
+ when(restManagerMock.get(eq("/aai/v11/query?format=resource"), eq("Foo"), eq("Bar"), anyMap()))
+ .thenReturn(httpResponseErr0);
+
+ AaiCqResponse aaiCqResponseNull =
+ aaiManager.getCustomQueryResponse("", "Foo", "Bar", vserverNameRequestId, "Foo");
+ assertNull(aaiCqResponseNull);
+
+
+ when(restManagerMock.put(eq("Error"), eq("Foo"), eq("Bar"), anyMap(), anyString(), anyString()))
+ .thenReturn(httpResponseErr1);
+
+ when(restManagerMock.get(eq("Error/aai/v11/query?format=resource"), eq("Foo"), eq("Bar"), anyMap()))
+ .thenReturn(httpResponseErr1);
+
+ AaiCqResponse aaiCqResponseErr =
+ aaiManager.getCustomQueryResponse("Error", "Foo", "Bar", vserverNameRequestId, "Foo");
+ assertNull(aaiCqResponseErr);
+ }
+
+ private String getTenantQueryResponse() throws IOException {
+ String responseString = "";
+ responseString = new String(Files.readAllBytes(new File(TENANT_RESPONSE_SAMPLE).toPath()));
+ return responseString;
+ }
+
+ @Test
public void testAaiManagerAaiNqRequest() {
AaiManager aaiManager = new AaiManager(restManagerMock);
diff --git a/models-interactions/model-impl/aai/src/test/resources/org/onap/policy/aai/AaiCqResponse.json b/models-interactions/model-impl/aai/src/test/resources/org/onap/policy/aai/AaiCqResponse.json
new file mode 100644
index 000000000..63d6f79ac
--- /dev/null
+++ b/models-interactions/model-impl/aai/src/test/resources/org/onap/policy/aai/AaiCqResponse.json
@@ -0,0 +1,673 @@
+{
+ "results": [
+ {
+ "vserver": {
+ "vserver-id": "e7f1db09-ff78-44fc-b256-69095c5556fb",
+ "vserver-name": "vfw-vm-0201-2",
+ "vserver-name2": "vfw-vm-0201-2",
+ "prov-status": "ACTIVE",
+ "vserver-selflink": "http://ecompctl1.research.att.com:8774/v2/3f2aaef74ecb4b19b35e26d0849fe9a2/servers/e7f1db09-ff78-44fc-b256-69095c5556fb",
+ "in-maint": false,
+ "is-closed-loop-disabled": false,
+ "resource-version": "1549553422524",
+ "relationship-list": {
+ "relationship": [
+ {
+ "related-to": "generic-vnf",
+ "related-link": "/aai/v11/network/generic-vnfs/generic-vnf/17044ef4-e7f3-46a1-af03-e2aa562f23ac",
+ "relationship-data": [
+ {
+ "relationship-key": "generic-vnf.vnf-id",
+ "relationship-value": "17044ef4-e7f3-46a1-af03-e2aa562f23ac"
+ }
+ ],
+ "related-to-property": [
+ {
+ "property-key": "generic-vnf.vnf-name",
+ "property-value": "TestVM-Vnf-0201-1"
+ }
+ ]
+ },
+ {
+ "related-to": "vnfc",
+ "related-link": "/aai/v11/network/vnfcs/vnfc/vfw",
+ "relationship-data": [
+ {
+ "relationship-key": "vnfc.vnfc-name",
+ "relationship-value": "vfw"
+ }
+ ]
+ },
+ {
+ "related-to": "vf-module",
+ "related-link": "/aai/v11/network/generic-vnfs/generic-vnf/17044ef4-e7f3-46a1-af03-e2aa562f23ac/vf-modules/vf-module/33f9e03d-2fbd-4e9c-8e73-ce6b12f0b3d2",
+ "relationship-data": [
+ {
+ "relationship-key": "generic-vnf.vnf-id",
+ "relationship-value": "17044ef4-e7f3-46a1-af03-e2aa562f23ac"
+ },
+ {
+ "relationship-key": "vf-module.vf-module-id",
+ "relationship-value": "33f9e03d-2fbd-4e9c-8e73-ce6b12f0b3d2"
+ }
+ ]
+ },
+ {
+ "related-to": "flavor",
+ "related-link": "/aai/v11/cloud-infrastructure/cloud-regions/cloud-region/CloudOwner/RegionOne/flavors/flavor/2",
+ "relationship-data": [
+ {
+ "relationship-key": "cloud-region.cloud-owner",
+ "relationship-value": "CloudOwner"
+ },
+ {
+ "relationship-key": "cloud-region.cloud-region-id",
+ "relationship-value": "RegionOne"
+ },
+ {
+ "relationship-key": "flavor.flavor-id",
+ "relationship-value": "2"
+ }
+ ],
+ "related-to-property": [
+ {
+ "property-key": "flavor.flavor-name",
+ "property-value": "m1.small"
+ }
+ ]
+ },
+ {
+ "related-to": "image",
+ "related-link": "/aai/v11/cloud-infrastructure/cloud-regions/cloud-region/CloudOwner/RegionOne/images/image/84be7136-301f-4f47-9585-3a2e0f9534af",
+ "relationship-data": [
+ {
+ "relationship-key": "cloud-region.cloud-owner",
+ "relationship-value": "CloudOwner"
+ },
+ {
+ "relationship-key": "cloud-region.cloud-region-id",
+ "relationship-value": "RegionOne"
+ },
+ {
+ "relationship-key": "image.image-id",
+ "relationship-value": "84be7136-301f-4f47-9585-3a2e0f9534af"
+ }
+ ],
+ "related-to-property": [
+ {
+ "property-key": "image.image-name",
+ "property-value": "unknown"
+ }
+ ]
+ }
+ ]
+ }
+ }
+ },
+ {
+ "generic-vnf": {
+ "vnf-id": "7b202620-2936-4b0d-b09c-60b411f10f64",
+ "vnf-name": "vLoadBalancerMS-Vnf-0211-1",
+ "vnf-type": "vLoadBalancerMS/vLoadBalancerMS 0",
+ "prov-status": "ACTIVE",
+ "equipment-role": "vLB",
+ "orchestration-status": "Active",
+ "ipv4-oam-address": "10.0.150.1",
+ "in-maint": true,
+ "is-closed-loop-disabled": false,
+ "resource-version": "1552311656338",
+ "model-invariant-id": "724ab1cf-6120-49e8-b909-849963bed1d6",
+ "model-version-id": "9d5944d8-2267-4799-824a-0f824e9a978d",
+ "model-customization-id": "efcd576d-a05e-4798-bb68-79e7d9c80f4c",
+ "nf-type": "ONAP-LOADBALANCER",
+ "nf-function": "LOADBALANCER",
+ "nf-role": "vLB",
+ "nf-naming-code": "vlb",
+ "selflink": "restconf/config/GENERIC-RESOURCE-API:services/service/101b8fc1-1796-4db1-a4e7-fe39c6a51558/service-data/vnfs/vnf/7b202620-2936-4b0d-b09c-60b411f10f64/vnf-data/vnf-topology/",
+ "relationship-list": {
+ "relationship": [
+ {
+ "related-to": "service-instance",
+ "related-link": "/aai/v11/business/customers/customer/Demonstration/service-subscriptions/service-subscription/vLB/service-instances/service-instance/101b8fc1-1796-4db1-a4e7-fe39c6a51558",
+ "relationship-data": [
+ {
+ "relationship-key": "customer.global-customer-id",
+ "relationship-value": "Demonstration"
+ },
+ {
+ "relationship-key": "service-subscription.service-type",
+ "relationship-value": "vLB"
+ },
+ {
+ "relationship-key": "service-instance.service-instance-id",
+ "relationship-value": "101b8fc1-1796-4db1-a4e7-fe39c6a51558"
+ }
+ ],
+ "related-to-property": [
+ {
+ "property-key": "service-instance.service-instance-name",
+ "property-value": "vLoadBalancerMS-0211-1"
+ }
+ ]
+ },
+ {
+ "related-to": "platform",
+ "related-link": "/aai/v11/business/platforms/platform/Test-Platform",
+ "relationship-data": [
+ {
+ "relationship-key": "platform.platform-name",
+ "relationship-value": "Test-Platform"
+ }
+ ]
+ },
+ {
+ "related-to": "line-of-business",
+ "related-link": "/aai/v11/business/lines-of-business/line-of-business/Test-Business",
+ "relationship-data": [
+ {
+ "relationship-key": "line-of-business.line-of-business-name",
+ "relationship-value": "Test-Business"
+ }
+ ]
+ },
+ {
+ "related-to": "vserver",
+ "related-link": "/aai/v11/cloud-infrastructure/cloud-regions/cloud-region/CloudOwner/RegionOne/tenants/tenant/3f2aaef74ecb4b19b35e26d0849fe9a2/vservers/vserver/58ca8df0-17b8-4aa2-8766-9c6c1a12cec8",
+ "relationship-data": [
+ {
+ "relationship-key": "cloud-region.cloud-owner",
+ "relationship-value": "CloudOwner"
+ },
+ {
+ "relationship-key": "cloud-region.cloud-region-id",
+ "relationship-value": "RegionOne"
+ },
+ {
+ "relationship-key": "tenant.tenant-id",
+ "relationship-value": "3f2aaef74ecb4b19b35e26d0849fe9a2"
+ },
+ {
+ "relationship-key": "vserver.vserver-id",
+ "relationship-value": "58ca8df0-17b8-4aa2-8766-9c6c1a12cec8"
+ }
+ ],
+ "related-to-property": [
+ {
+ "property-key": "vserver.vserver-name",
+ "property-value": "vdns-ms-0211-1"
+ }
+ ]
+ },
+ {
+ "related-to": "vserver",
+ "related-link": "/aai/v11/cloud-infrastructure/cloud-regions/cloud-region/CloudOwner/RegionOne/tenants/tenant/3f2aaef74ecb4b19b35e26d0849fe9a2/vservers/vserver/6c3b3714-e36c-45af-9f16-7d3a73d99497",
+ "relationship-data": [
+ {
+ "relationship-key": "cloud-region.cloud-owner",
+ "relationship-value": "CloudOwner"
+ },
+ {
+ "relationship-key": "cloud-region.cloud-region-id",
+ "relationship-value": "RegionOne"
+ },
+ {
+ "relationship-key": "tenant.tenant-id",
+ "relationship-value": "3f2aaef74ecb4b19b35e26d0849fe9a2"
+ },
+ {
+ "relationship-key": "vserver.vserver-id",
+ "relationship-value": "6c3b3714-e36c-45af-9f16-7d3a73d99497"
+ }
+ ],
+ "related-to-property": [
+ {
+ "property-key": "vserver.vserver-name",
+ "property-value": "vlb-ms-0211-1"
+ }
+ ]
+ },
+ {
+ "related-to": "availability-zone",
+ "related-link": "/aai/v11/cloud-infrastructure/cloud-regions/cloud-region/CloudOwner/RegionOne/availability-zones/availability-zone/nova",
+ "relationship-data": [
+ {
+ "relationship-key": "cloud-region.cloud-owner",
+ "relationship-value": "CloudOwner"
+ },
+ {
+ "relationship-key": "cloud-region.cloud-region-id",
+ "relationship-value": "RegionOne"
+ },
+ {
+ "relationship-key": "availability-zone.availability-zone-name",
+ "relationship-value": "nova"
+ }
+ ]
+ }
+ ]
+ },
+ "vf-modules": {
+ "vf-module": [
+ {
+ "vf-module-id": "e46c6636-9ce5-4b77-bb1b-455ce9edc892",
+ "vf-module-name": "vLoadBalancerMS-0211-1",
+ "heat-stack-id": "vLoadBalancerMS-0211-1/73360253-2dfe-46f6-bcd6-8662a81238ea",
+ "orchestration-status": "Active",
+ "is-base-vf-module": true,
+ "resource-version": "1552311559802",
+ "model-invariant-id": "d263fc6d-cfce-4e20-8337-e06f48b474e6",
+ "model-version-id": "24c0aa10-3979-402c-ad98-20124751b551",
+ "model-customization-id": "65382eb1-db84-466c-b9d7-4e0f1ba7105f",
+ "selflink": "restconf/config/GENERIC-RESOURCE-API:services/service/101b8fc1-1796-4db1-a4e7-fe39c6a51558/service-data/vnfs/vnf/7b202620-2936-4b0d-b09c-60b411f10f64/vnf-data/vf-modules/vf-module/e46c6636-9ce5-4b77-bb1b-455ce9edc892/vf-module-data/vf-module-topology/",
+ "relationship-list": {
+ "relationship": [
+ {
+ "related-to": "vserver",
+ "related-link": "/aai/v11/cloud-infrastructure/cloud-regions/cloud-region/CloudOwner/RegionOne/tenants/tenant/3f2aaef74ecb4b19b35e26d0849fe9a2/vservers/vserver/58ca8df0-17b8-4aa2-8766-9c6c1a12cec8",
+ "relationship-data": [
+ {
+ "relationship-key": "cloud-region.cloud-owner",
+ "relationship-value": "CloudOwner"
+ },
+ {
+ "relationship-key": "cloud-region.cloud-region-id",
+ "relationship-value": "RegionOne"
+ },
+ {
+ "relationship-key": "tenant.tenant-id",
+ "relationship-value": "3f2aaef74ecb4b19b35e26d0849fe9a2"
+ },
+ {
+ "relationship-key": "vserver.vserver-id",
+ "relationship-value": "58ca8df0-17b8-4aa2-8766-9c6c1a12cec8"
+ }
+ ],
+ "related-to-property": [
+ {
+ "property-key": "vserver.vserver-name",
+ "property-value": "vdns-ms-0211-1"
+ }
+ ]
+ },
+ {
+ "related-to": "vserver",
+ "related-link": "/aai/v11/cloud-infrastructure/cloud-regions/cloud-region/CloudOwner/RegionOne/tenants/tenant/3f2aaef74ecb4b19b35e26d0849fe9a2/vservers/vserver/6c3b3714-e36c-45af-9f16-7d3a73d99497",
+ "relationship-data": [
+ {
+ "relationship-key": "cloud-region.cloud-owner",
+ "relationship-value": "CloudOwner"
+ },
+ {
+ "relationship-key": "cloud-region.cloud-region-id",
+ "relationship-value": "RegionOne"
+ },
+ {
+ "relationship-key": "tenant.tenant-id",
+ "relationship-value": "3f2aaef74ecb4b19b35e26d0849fe9a2"
+ },
+ {
+ "relationship-key": "vserver.vserver-id",
+ "relationship-value": "6c3b3714-e36c-45af-9f16-7d3a73d99497"
+ }
+ ],
+ "related-to-property": [
+ {
+ "property-key": "vserver.vserver-name",
+ "property-value": "vlb-ms-0211-1"
+ }
+ ]
+ }
+ ]
+ }
+ }
+ ]
+ }
+ }
+ },
+ {
+ "service-instance": {
+ "service-instance-id": "101b8fc1-1796-4db1-a4e7-fe39c6a51558",
+ "service-instance-name": "vLoadBalancerMS-0211-1",
+ "environment-context": "General_Revenue-Bearing",
+ "workload-context": "Production",
+ "model-invariant-id": "1008a768-1b67-407e-88c6-58c82b34ef42",
+ "model-version-id": "81f8c1cd-f664-4450-b3a4-be645613ab32",
+ "resource-version": "1552311350334",
+ "selflink": "restconf/config/GENERIC-RESOURCE-API:services/service/101b8fc1-1796-4db1-a4e7-fe39c6a51558/service-data/service-topology/",
+ "orchestration-status": "Active",
+ "relationship-list": {
+ "relationship": [
+ {
+ "related-to": "project",
+ "related-link": "/aai/v11/business/projects/project/Test-Project",
+ "relationship-data": [
+ {
+ "relationship-key": "project.project-name",
+ "relationship-value": "Test-Project"
+ }
+ ]
+ },
+ {
+ "related-to": "generic-vnf",
+ "related-link": "/aai/v11/network/generic-vnfs/generic-vnf/7b202620-2936-4b0d-b09c-60b411f10f64",
+ "relationship-data": [
+ {
+ "relationship-key": "generic-vnf.vnf-id",
+ "relationship-value": "7b202620-2936-4b0d-b09c-60b411f10f64"
+ }
+ ],
+ "related-to-property": [
+ {
+ "property-key": "generic-vnf.vnf-name",
+ "property-value": "vLoadBalancerMS-Vnf-0211-1"
+ }
+ ]
+ },
+ {
+ "related-to": "owning-entity",
+ "related-link": "/aai/v11/business/owning-entities/owning-entity/bb94a687-4f3b-40a3-914e-e98037d5ebd2",
+ "relationship-data": [
+ {
+ "relationship-key": "owning-entity.owning-entity-id",
+ "relationship-value": "bb94a687-4f3b-40a3-914e-e98037d5ebd2"
+ }
+ ]
+ }
+ ]
+ }
+ }
+ },
+ {
+ "generic-vnf": {
+ "vnf-id": "17044ef4-e7f3-46a1-af03-e2aa562f23ac",
+ "vnf-name": "TestVM-Vnf-0201-1",
+ "vnf-type": "TestVM/TestVM 0",
+ "prov-status": "ACTIVE",
+ "equipment-role": "",
+ "orchestration-status": "Active",
+ "ipv4-oam-address": "10.0.70.1",
+ "in-maint": true,
+ "is-closed-loop-disabled": false,
+ "resource-version": "1549041636264",
+ "model-invariant-id": "6a4d7971-0778-4655-9eab-9d6031c7ad57",
+ "model-version-id": "fb6c673c-e5b6-4e0a-9baf-5e0089784de9",
+ "model-customization-id": "706a3100-dbe5-442e-86c3-c7b823abbec2",
+ "selflink": "restconf/config/GENERIC-RESOURCE-API:services/service/d41f8217-d464-4458-bf0a-fba33a0f1b31/service-data/vnfs/vnf/17044ef4-e7f3-46a1-af03-e2aa562f23ac/vnf-data/vnf-topology/",
+ "relationship-list": {
+ "relationship": [
+ {
+ "related-to": "service-instance",
+ "related-link": "/aai/v11/business/customers/customer/Demonstration/service-subscriptions/service-subscription/vFW/service-instances/service-instance/d41f8217-d464-4458-bf0a-fba33a0f1b31",
+ "relationship-data": [
+ {
+ "relationship-key": "customer.global-customer-id",
+ "relationship-value": "Demonstration"
+ },
+ {
+ "relationship-key": "service-subscription.service-type",
+ "relationship-value": "vFW"
+ },
+ {
+ "relationship-key": "service-instance.service-instance-id",
+ "relationship-value": "d41f8217-d464-4458-bf0a-fba33a0f1b31"
+ }
+ ],
+ "related-to-property": [
+ {
+ "property-key": "service-instance.service-instance-name",
+ "property-value": "TestVM-Service-0201-1"
+ }
+ ]
+ },
+ {
+ "related-to": "platform",
+ "related-link": "/aai/v11/business/platforms/platform/Test-Platform",
+ "relationship-data": [
+ {
+ "relationship-key": "platform.platform-name",
+ "relationship-value": "Test-Platform"
+ }
+ ]
+ },
+ {
+ "related-to": "line-of-business",
+ "related-link": "/aai/v11/business/lines-of-business/line-of-business/Test-Business",
+ "relationship-data": [
+ {
+ "relationship-key": "line-of-business.line-of-business-name",
+ "relationship-value": "Test-Business"
+ }
+ ]
+ },
+ {
+ "related-to": "vserver",
+ "related-link": "/aai/v11/cloud-infrastructure/cloud-regions/cloud-region/CloudOwner/RegionOne/tenants/tenant/3f2aaef74ecb4b19b35e26d0849fe9a2/vservers/vserver/e7f1db09-ff78-44fc-b256-69095c5556fb",
+ "relationship-data": [
+ {
+ "relationship-key": "cloud-region.cloud-owner",
+ "relationship-value": "CloudOwner"
+ },
+ {
+ "relationship-key": "cloud-region.cloud-region-id",
+ "relationship-value": "RegionOne"
+ },
+ {
+ "relationship-key": "tenant.tenant-id",
+ "relationship-value": "3f2aaef74ecb4b19b35e26d0849fe9a2"
+ },
+ {
+ "relationship-key": "vserver.vserver-id",
+ "relationship-value": "e7f1db09-ff78-44fc-b256-69095c5556fb"
+ }
+ ],
+ "related-to-property": [
+ {
+ "property-key": "vserver.vserver-name",
+ "property-value": "vfw-vm-0201-2"
+ }
+ ]
+ },
+ {
+ "related-to": "availability-zone",
+ "related-link": "/aai/v11/cloud-infrastructure/cloud-regions/cloud-region/CloudOwner/RegionTwo/availability-zones/availability-zone/zone-1",
+ "relationship-data": [
+ {
+ "relationship-key": "cloud-region.cloud-owner",
+ "relationship-value": "CloudOwner"
+ },
+ {
+ "relationship-key": "cloud-region.cloud-region-id",
+ "relationship-value": "RegionTwo"
+ },
+ {
+ "relationship-key": "availability-zone.availability-zone-name",
+ "relationship-value": "zone-1"
+ }
+ ]
+ }
+ ]
+ },
+ "vf-modules": {
+ "vf-module": [
+ {
+ "vf-module-id": "0afde97a-3e3f-4597-aec3-e5488c0f20b7",
+ "vf-module-name": "TestVM-0201-1",
+ "heat-stack-id": "TestVM-0201-1/aee4d7e5-b4a0-4261-b3cf-bb23348a3d99",
+ "orchestration-status": "Active",
+ "is-base-vf-module": true,
+ "resource-version": "1549039401119",
+ "model-invariant-id": "6af68fdb-6479-43e2-8989-938f06c994bd",
+ "model-version-id": "16d1834e-d834-431f-b064-98c469c6505d",
+ "model-customization-id": "29ffb122-22c8-48d2-b152-b52d9e81e910",
+ "selflink": "restconf/config/GENERIC-RESOURCE-API:services/service/d41f8217-d464-4458-bf0a-fba33a0f1b31/service-data/vnfs/vnf/17044ef4-e7f3-46a1-af03-e2aa562f23ac/vnf-data/vf-modules/vf-module/0afde97a-3e3f-4597-aec3-e5488c0f20b7/vf-module-data/vf-module-topology/"
+ },
+ {
+ "vf-module-id": "33f9e03d-2fbd-4e9c-8e73-ce6b12f0b3d2",
+ "vf-module-name": "TestVM-0201-2",
+ "heat-stack-id": "TestVM-0201-2/1b9db6b8-620b-46f1-935a-8a61c294a98b",
+ "orchestration-status": "Active",
+ "is-base-vf-module": true,
+ "resource-version": "1549041447373",
+ "model-invariant-id": "6af68fdb-6479-43e2-8989-938f06c994bd",
+ "model-version-id": "16d1834e-d834-431f-b064-98c469c6505d",
+ "model-customization-id": "29ffb122-22c8-48d2-b152-b52d9e81e910",
+ "selflink": "restconf/config/GENERIC-RESOURCE-API:services/service/d41f8217-d464-4458-bf0a-fba33a0f1b31/service-data/vnfs/vnf/17044ef4-e7f3-46a1-af03-e2aa562f23ac/vnf-data/vf-modules/vf-module/33f9e03d-2fbd-4e9c-8e73-ce6b12f0b3d2/vf-module-data/vf-module-topology/",
+ "relationship-list": {
+ "relationship": [
+ {
+ "related-to": "vserver",
+ "related-link": "/aai/v11/cloud-infrastructure/cloud-regions/cloud-region/CloudOwner/RegionOne/tenants/tenant/3f2aaef74ecb4b19b35e26d0849fe9a2/vservers/vserver/e7f1db09-ff78-44fc-b256-69095c5556fb",
+ "relationship-data": [
+ {
+ "relationship-key": "cloud-region.cloud-owner",
+ "relationship-value": "CloudOwner"
+ },
+ {
+ "relationship-key": "cloud-region.cloud-region-id",
+ "relationship-value": "RegionOne"
+ },
+ {
+ "relationship-key": "tenant.tenant-id",
+ "relationship-value": "3f2aaef74ecb4b19b35e26d0849fe9a2"
+ },
+ {
+ "relationship-key": "vserver.vserver-id",
+ "relationship-value": "e7f1db09-ff78-44fc-b256-69095c5556fb"
+ }
+ ],
+ "related-to-property": [
+ {
+ "property-key": "vserver.vserver-name",
+ "property-value": "vfw-vm-0201-2"
+ }
+ ]
+ }
+ ]
+ }
+ }
+ ]
+ }
+ }
+ },
+ {
+ "vf-module": {
+ "vf-module-id": "0afde97a-3e3f-4597-aec3-e5488c0f20b7",
+ "vf-module-name": "TestVM-0201-1",
+ "heat-stack-id": "TestVM-0201-1/aee4d7e5-b4a0-4261-b3cf-bb23348a3d99",
+ "orchestration-status": "Active",
+ "is-base-vf-module": true,
+ "resource-version": "1549039401119",
+ "model-invariant-id": "6af68fdb-6479-43e2-8989-938f06c994bd",
+ "model-version-id": "16d1834e-d834-431f-b064-98c469c6505d",
+ "model-customization-id": "29ffb122-22c8-48d2-b152-b52d9e81e910",
+ "selflink": "restconf/config/GENERIC-RESOURCE-API:services/service/d41f8217-d464-4458-bf0a-fba33a0f1b31/service-data/vnfs/vnf/17044ef4-e7f3-46a1-af03-e2aa562f23ac/vnf-data/vf-modules/vf-module/0afde97a-3e3f-4597-aec3-e5488c0f20b7/vf-module-data/vf-module-topology/"
+ }
+ },
+ {
+ "vf-module": {
+ "vf-module-id": "33f9e03d-2fbd-4e9c-8e73-ce6b12f0b3d2",
+ "vf-module-name": "TestVM-0201-2",
+ "heat-stack-id": "TestVM-0201-2/1b9db6b8-620b-46f1-935a-8a61c294a98b",
+ "orchestration-status": "Active",
+ "is-base-vf-module": true,
+ "resource-version": "1549041447373",
+ "model-invariant-id": "6af68fdb-6479-43e2-8989-938f06c994bd",
+ "model-version-id": "16d1834e-d834-431f-b064-98c469c6505d",
+ "model-customization-id": "29ffb122-22c8-48d2-b152-b52d9e81e910",
+ "selflink": "restconf/config/GENERIC-RESOURCE-API:services/service/d41f8217-d464-4458-bf0a-fba33a0f1b31/service-data/vnfs/vnf/17044ef4-e7f3-46a1-af03-e2aa562f23ac/vnf-data/vf-modules/vf-module/33f9e03d-2fbd-4e9c-8e73-ce6b12f0b3d2/vf-module-data/vf-module-topology/",
+ "relationship-list": {
+ "relationship": [
+ {
+ "related-to": "vserver",
+ "related-link": "/aai/v11/cloud-infrastructure/cloud-regions/cloud-region/CloudOwner/RegionOne/tenants/tenant/3f2aaef74ecb4b19b35e26d0849fe9a2/vservers/vserver/e7f1db09-ff78-44fc-b256-69095c5556fb",
+ "relationship-data": [
+ {
+ "relationship-key": "cloud-region.cloud-owner",
+ "relationship-value": "CloudOwner"
+ },
+ {
+ "relationship-key": "cloud-region.cloud-region-id",
+ "relationship-value": "RegionOne"
+ },
+ {
+ "relationship-key": "tenant.tenant-id",
+ "relationship-value": "3f2aaef74ecb4b19b35e26d0849fe9a2"
+ },
+ {
+ "relationship-key": "vserver.vserver-id",
+ "relationship-value": "e7f1db09-ff78-44fc-b256-69095c5556fb"
+ }
+ ],
+ "related-to-property": [
+ {
+ "property-key": "vserver.vserver-name",
+ "property-value": "vfw-vm-0201-2"
+ }
+ ]
+ }
+ ]
+ }
+ }
+ },
+ {
+ "tenant": {
+ "tenant-id": "tenant1-16197-as988q",
+ "tenant-name": "tenant-name-16197-as988q",
+ "resource-version": "1550769793637",
+ "vservers": {
+ "vserver": [
+ {
+ "vserver-id": "vserver1-16197-as988q",
+ "vserver-name": "vserverName",
+ "vserver-name2": "vserverTE-name2-as988q",
+ "prov-status": "ACTIVE",
+ "vserver-selflink": "TRINITY vserverLink",
+ "in-maint": false,
+ "is-closed-loop-disabled": false,
+ "resource-version": "1550769794551",
+ "relationship-list": {
+ "relationship": [
+ {
+ "related-to": "generic-vnf",
+ "relationship-label": "tosca.relationships.HostedOn",
+ "related-link": "/aai/v16/network/generic-vnfs/generic-vnf/VNF1-16197-as988q",
+ "relationship-data": [
+ {
+ "relationship-key": "generic-vnf.vnf-id",
+ "relationship-value": "VNF1-16197-as988q"
+ }
+ ],
+ "related-to-property": [
+ {
+ "property-key": "generic-vnf.vnf-name",
+ "property-value": "vnf1Name"
+ }
+ ]
+ }
+ ]
+ }
+ }
+ ]
+ }
+ }
+ },
+ {
+ "cloud-region": {
+ "cloud-owner": "co-16197-01-as988q",
+ "cloud-region-id": "cr-16197-01-as988q",
+ "resource-version": "1550769792672",
+ "orchestration-disabled": false,
+ "in-maint": false,
+ "tenants": {
+ "tenant": [
+ {
+ "tenant-id": "tenant1-16197-as988q",
+ "tenant-name": "tenant-name-16197-as988q",
+ "resource-version": "1550769793637"
+ }
+ ]
+ }
+ }
+ }
+ ]
+}
diff --git a/models-interactions/model-impl/aai/src/test/resources/org/onap/policy/aai/AaiMalformedCqResponse.json b/models-interactions/model-impl/aai/src/test/resources/org/onap/policy/aai/AaiMalformedCqResponse.json
new file mode 100644
index 000000000..a9452a2e2
--- /dev/null
+++ b/models-interactions/model-impl/aai/src/test/resources/org/onap/policy/aai/AaiMalformedCqResponse.json
@@ -0,0 +1,3 @@
+{
+ "results": []
+} \ No newline at end of file
diff --git a/models-interactions/model-impl/aai/src/test/resources/org/onap/policy/aai/AaiTenantResponse.json b/models-interactions/model-impl/aai/src/test/resources/org/onap/policy/aai/AaiTenantResponse.json
new file mode 100644
index 000000000..62b690548
--- /dev/null
+++ b/models-interactions/model-impl/aai/src/test/resources/org/onap/policy/aai/AaiTenantResponse.json
@@ -0,0 +1,8 @@
+{
+ "result-data": [
+ {
+ "resource-type": "vserver",
+ "resource-link": "/aai/v11/cloud-infrastructure/cloud-regions/cloud-region/CloudOwner/RegionOne/tenants/tenant/3f2aaef74ecb4b19b35e26d0849fe9a2/vservers/vserver/6c3b3714-e36c-45af-9f16-7d3a73d99497"
+ }
+ ]
+} \ No newline at end of file
diff --git a/models-interactions/model-impl/rest/src/main/java/org/onap/policy/rest/RestManager.java b/models-interactions/model-impl/rest/src/main/java/org/onap/policy/rest/RestManager.java
index bbc30a715..f19ed7872 100644
--- a/models-interactions/model-impl/rest/src/main/java/org/onap/policy/rest/RestManager.java
+++ b/models-interactions/model-impl/rest/src/main/java/org/onap/policy/rest/RestManager.java
@@ -25,11 +25,11 @@ import java.nio.charset.Charset;
import java.util.Map;
import java.util.Map.Entry;
import javax.xml.bind.DatatypeConverter;
-
import org.apache.http.HttpHeaders;
import org.apache.http.HttpResponse;
import org.apache.http.client.methods.HttpGet;
import org.apache.http.client.methods.HttpPost;
+import org.apache.http.client.methods.HttpPut;
import org.apache.http.client.methods.HttpRequestBase;
import org.apache.http.conn.ssl.NoopHostnameVerifier;
import org.apache.http.entity.StringEntity;
@@ -54,6 +54,33 @@ public class RestManager {
}
/**
+ * Perform REST PUT.
+ *
+ * @param url the url
+ * @param username the user name
+ * @param password the password
+ * @param headers any headers
+ * @param contentType what the content type is
+ * @param body body to send
+ * @return the response status code and the body
+ */
+ public Pair<Integer, String> put(String url, String username, String password,
+ Map<String, String> headers, String contentType, String body) {
+ HttpPut put = new HttpPut(url);
+ addHeaders(put, username, password, headers);
+ put.addHeader("Content-Type", contentType);
+ try {
+ StringEntity input = new StringEntity(body);
+ input.setContentType(contentType);
+ put.setEntity(input);
+ } catch (Exception e) {
+ logger.error("put threw: ", e);
+ return null;
+ }
+ return sendRequest(put);
+ }
+
+ /**
* Perform REST Post.
*
* @param url the url
diff --git a/models-interactions/model-impl/rest/src/test/java/org/onap/policy/rest/PutTest.java b/models-interactions/model-impl/rest/src/test/java/org/onap/policy/rest/PutTest.java
new file mode 100644
index 000000000..3c7220554
--- /dev/null
+++ b/models-interactions/model-impl/rest/src/test/java/org/onap/policy/rest/PutTest.java
@@ -0,0 +1,51 @@
+/*
+ * ============LICENSE_START=======================================================
+ * rest
+ * ================================================================================
+ * Copyright (C) 2019 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.policy.rest;
+
+import static org.junit.Assert.assertEquals;
+
+import org.junit.Test;
+import org.onap.policy.rest.RestManager.Pair;
+
+public class PutTest {
+
+ @Test
+ public void testUsernameNull() {
+ RestManager mgr = new RestManager();
+ Pair<Integer, String> result = mgr.put("http://www.example.org", null, null, null, null, null);
+ assertEquals(null, result);
+ }
+
+ @Test
+ public void testUsernameEmpty() {
+ RestManager mgr = new RestManager();
+ Pair<Integer, String> result = mgr.put("http://www.example.org", "", null, null, null, null);
+ assertEquals(null, result);
+ }
+
+ @Test
+ public void testBodyNull() {
+ RestManager mgr = new RestManager();
+ Pair<Integer, String> result = mgr.put("http://www.example.org", "user", null, null, null, null);
+ assertEquals(null, result);
+ }
+}
+