summaryrefslogtreecommitdiffstats
path: root/models-interactions/model-actors/actor.so/src/main
diff options
context:
space:
mode:
authorPamela Dragosh <pdragosh@research.att.com>2019-04-09 08:24:14 -0400
committerPamela Dragosh <pdragosh@research.att.com>2019-04-09 08:24:21 -0400
commit7e63a8833ae226738d858a3ff1aaf715f9b51d6b (patch)
tree96efb370cffa1db2c3482b5a9991df043a3eb8ac /models-interactions/model-actors/actor.so/src/main
parentc54b9408a10c0060e35be2ee0b5bac6a24e9153a (diff)
Parse new model ids from operational policy
Companion review to https://gerrit.onap.org/r/#/c/84235/ Copies the required changes into policy/models. Issue-ID: POLICY-1545 Change-Id: I43fec36f60b5409d9e3df9d925de06209c81fd01 Signed-off-by: Pamela Dragosh <pdragosh@research.att.com>
Diffstat (limited to 'models-interactions/model-actors/actor.so/src/main')
-rw-r--r--models-interactions/model-actors/actor.so/src/main/java/org/onap/policy/controlloop/actor/so/SoActorServiceProvider.java64
1 files changed, 32 insertions, 32 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 2a14bb19a..6d8fa4bd2 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
@@ -164,10 +164,11 @@ public class SoActorServiceProvider implements Actor {
// Find the index for base vf module and non-base vf module
AaiNqInventoryResponseItem baseItem = findVfModule(aaiResponseWrapper, true);
- AaiNqInventoryResponseItem vfModuleItem = findVfModule(aaiResponseWrapper, false);
+
+ SoModelInfo soModelInfo = prepareSoModelInfo(policy);
// Report the error if either base vf module or non-base vf module is not found
- if (baseItem == null || vfModuleItem == null) {
+ if (baseItem == null || soModelInfo == null) {
logger.error("Either base or non-base vf module is not found from AAI response.");
return null;
}
@@ -175,9 +176,31 @@ 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,
- vfModuleItem);
+ soModelInfo);
} else if (RECIPE_VF_MODULE_DELETE.equals(policy.getRecipe())) {
- return constructDeleteRequest(tenantItem, vnfItem, vnfServiceItem, vfModuleItem);
+ return constructDeleteRequest(tenantItem, vnfItem, vnfServiceItem, soModelInfo, policy);
+ } else {
+ return null;
+ }
+ }
+
+ 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)) {
+
+ soModelInfo.setModelCustomizationId(policy.getTarget().getModelCustomizationId());
+ soModelInfo.setModelInvariantId(policy.getTarget().getModelInvariantId());
+ soModelInfo.setModelName(policy.getTarget().getModelName());
+ soModelInfo.setModelVersion(policy.getTarget().getModelVersion());
+ soModelInfo.setModelVersionId(policy.getTarget().getModelVersionId());
+
+ return soModelInfo;
} else {
return null;
}
@@ -197,7 +220,7 @@ public class SoActorServiceProvider implements Actor {
private SoRequest constructCreateRequest(AaiNqResponseWrapper aaiResponseWrapper, Policy policy,
AaiNqInventoryResponseItem tenantItem, AaiNqInventoryResponseItem vnfItem,
AaiNqInventoryResponseItem vnfServiceItem,
- AaiNqInventoryResponseItem vfModuleItem) {
+ SoModelInfo vfModuleItem) {
SoRequest request = new SoRequest();
request.setOperationType(SoOperationType.SCALE_OUT);
//
@@ -211,8 +234,7 @@ public class SoActorServiceProvider implements Actor {
// cloudConfiguration
request.getRequestDetails().setCloudConfiguration(constructCloudConfiguration(tenantItem));
// modelInfo
- request.getRequestDetails().setModelInfo(constructVfModuleModelInfo(vfModuleItem));
- request.getRequestDetails().getModelInfo().setModelVersionId(vfModuleItem.getVfModule().getModelVersionId());
+ request.getRequestDetails().setModelInfo(vfModuleItem);
// requestInfo
request.getRequestDetails().setRequestInfo(constructRequestInfo());
@@ -296,7 +318,7 @@ public class SoActorServiceProvider implements Actor {
* @return SO delete vf-module request
*/
private SoRequest constructDeleteRequest(AaiNqInventoryResponseItem tenantItem, AaiNqInventoryResponseItem
- vnfItem, AaiNqInventoryResponseItem vnfServiceItem, AaiNqInventoryResponseItem vfModuleItem) {
+ vnfItem, AaiNqInventoryResponseItem vnfServiceItem, SoModelInfo vfModuleItem, Policy policy) {
SoRequest request = new SoRequest();
request.setOperationType(SoOperationType.DELETE_VF_MODULE);
request.setRequestDetails(new SoRequestDetails());
@@ -306,12 +328,12 @@ public class SoActorServiceProvider implements Actor {
// cloudConfiguration
request.getRequestDetails().setCloudConfiguration(constructCloudConfiguration(tenantItem));
// modelInfo
- request.getRequestDetails().setModelInfo(constructVfModuleModelInfo(vfModuleItem));
+ request.getRequestDetails().setModelInfo(prepareSoModelInfo(policy));
// requestInfo
request.getRequestDetails().setRequestInfo(constructRequestInfo());
// Save the instance IDs for the VNF, service and vfModule to static fields
preserveInstanceIds(vnfItem.getGenericVnf().getVnfId(), vnfServiceItem.getServiceInstance()
- .getServiceInstanceId(), vfModuleItem.getVfModule().getVfModuleId());
+ .getServiceInstanceId(), null);
if (logger.isDebugEnabled()) {
logger.debug("Constructed SO request: {}", Serialization.gsonPretty.toJson(request));
@@ -333,28 +355,6 @@ public class SoActorServiceProvider implements Actor {
}
/**
- * Construct modelInfo of the vfModule for the SO requestDetails.
- *
- * @param vfModuleItem vf module item from A&AI named-query response
- * @return SO Model info for the vfModule
- */
- private SoModelInfo constructVfModuleModelInfo(AaiNqInventoryResponseItem vfModuleItem) {
- SoModelInfo soModelInfo = new SoModelInfo();
- soModelInfo.setModelType("vfModule");
- soModelInfo.setModelInvariantId(vfModuleItem.getVfModule().getModelInvariantId());
- soModelInfo.setModelCustomizationId(vfModuleItem.getVfModule().getModelCustomizationId());
-
- for (AaiNqExtraProperty prop : vfModuleItem.getExtraProperties().getExtraProperty()) {
- if (prop.getPropertyName().equals(MODEL_NAME_PROPERTY_KEY)) {
- soModelInfo.setModelName(prop.getPropertyValue());
- } else if (prop.getPropertyName().equals(MODEL_VERSION_PROPERTY_KEY)) {
- soModelInfo.setModelVersion(prop.getPropertyValue());
- }
- }
- return soModelInfo;
- }
-
- /**
* Construct cloudConfiguration for the SO requestDetails.
*
* @param tenantItem tenant item from A&AI named-query response