summaryrefslogtreecommitdiffstats
path: root/controlloop/common/actors
diff options
context:
space:
mode:
authorPiyush Garg <piyush.garg1@amdocs.com>2018-09-07 09:11:00 +0530
committerPiyush Garg <piyush.garg1@amdocs.com>2018-09-10 18:56:50 +0530
commit38ec336ca105b38d272d1d86b8ee56bafc524acb (patch)
treeb9df8c82f8b951471e8bc1440087f92d8b3d5204 /controlloop/common/actors
parent1edf5cb1278f8c920599196e5722c1237face1da (diff)
Fix new sonar issue with vfModuleItem
find the last non-base vf module item from AAI response and use the same to construct create or delete vf module SO request Change-Id: I3b9b97ac3008f6e4f7952662d9e4262f77dbeec4 Issue-ID: POLICY-1079 Signed-off-by: Piyush Garg <piyush.garg1@amdocs.com>
Diffstat (limited to 'controlloop/common/actors')
-rw-r--r--controlloop/common/actors/actor.so/src/main/java/org/onap/policy/controlloop/actor/so/SOActorServiceProvider.java36
1 files changed, 14 insertions, 22 deletions
diff --git a/controlloop/common/actors/actor.so/src/main/java/org/onap/policy/controlloop/actor/so/SOActorServiceProvider.java b/controlloop/common/actors/actor.so/src/main/java/org/onap/policy/controlloop/actor/so/SOActorServiceProvider.java
index ce49dda46..5285d54bd 100644
--- a/controlloop/common/actors/actor.so/src/main/java/org/onap/policy/controlloop/actor/so/SOActorServiceProvider.java
+++ b/controlloop/common/actors/actor.so/src/main/java/org/onap/policy/controlloop/actor/so/SOActorServiceProvider.java
@@ -166,9 +166,10 @@ 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);
+ return constructCreateRequest(aaiResponseWrapper, policy, tenantItem, vnfItem, vnfServiceItem,
+ vfModuleItem);
} else if (RECIPE_VF_MODULE_DELETE.equals(policy.getRecipe())) {
- return constructDeleteRequest(aaiResponseWrapper, tenantItem, vnfItem, vnfServiceItem);
+ return constructDeleteRequest(aaiResponseWrapper, tenantItem, vnfItem, vnfServiceItem, vfModuleItem);
} else {
return null;
}
@@ -182,11 +183,13 @@ public class SOActorServiceProvider implements Actor {
* @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) {
- AaiNqInventoryResponseItem vfModuleItem = findVfModule(aaiResponseWrapper, false);
+ private SORequest constructCreateRequest(AaiNqResponseWrapper aaiResponseWrapper, Policy policy,
+ AaiNqInventoryResponseItem tenantItem, AaiNqInventoryResponseItem vnfItem,
+ AaiNqInventoryResponseItem vnfServiceItem,
+ AaiNqInventoryResponseItem vfModuleItem) {
SORequest request = new SORequest();
request.setOperationType(SoOperationType.SCALE_OUT);
//
@@ -291,13 +294,12 @@ public class SOActorServiceProvider implements Actor {
* @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(AaiNqResponseWrapper aaiResponseWrapper, AaiNqInventoryResponseItem
- tenantItem, AaiNqInventoryResponseItem vnfItem, AaiNqInventoryResponseItem vnfServiceItem) {
- // find the last non-base vf-module to delete
- AaiNqInventoryResponseItem vfModuleItem = findVfModuleToDelete(aaiResponseWrapper);
-
+ tenantItem, AaiNqInventoryResponseItem vnfItem, AaiNqInventoryResponseItem vnfServiceItem,
+ AaiNqInventoryResponseItem vfModuleItem) {
SORequest request = new SORequest();
request.setOperationType(SoOperationType.DELETE_VF_MODULE);
request.setRequestDetails(new SORequestDetails());
@@ -385,6 +387,7 @@ public class SOActorServiceProvider implements Actor {
/**
* 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
@@ -393,21 +396,9 @@ public class SOActorServiceProvider implements Actor {
*/
private AaiNqInventoryResponseItem findVfModule(AaiNqResponseWrapper aaiResponseWrapper, boolean baseFlag) {
List<AaiNqInventoryResponseItem> lst = aaiResponseWrapper.getVfModuleItems(baseFlag);
- return (lst == null || lst.isEmpty() ? null : lst.get(0));
- }
-
- /**
- * Find the VF module item to delete from AAI response.
- *
- * @param aaiResponseWrapper the AAI response containing the VF modules
- * @return VF module item to delete or null if the non-base vfModule was not found
- */
- private AaiNqInventoryResponseItem findVfModuleToDelete(AaiNqResponseWrapper aaiResponseWrapper) {
- List<AaiNqInventoryResponseItem> lst = aaiResponseWrapper.getVfModuleItems(false);
return (lst == null || lst.isEmpty() ? null : lst.get(lst.size() - 1));
}
-
/**
* Builds the request parameters from the policy payload.
*
@@ -455,7 +446,8 @@ public class SOActorServiceProvider implements Actor {
* @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) {
+ private static void preserveInstanceIds(final String vnfInstanceId, final String serviceInstanceId,
+ final String vfModuleId) {
lastVNFItemVnfId = vnfInstanceId;
lastServiceItemServiceInstanceId = serviceInstanceId;
lastVfModuleItemVfModuleInstanceId = vfModuleId;