diff options
Diffstat (limited to 'controlloop/common/actors/actor.so')
-rw-r--r-- | controlloop/common/actors/actor.so/src/main/java/org/onap/policy/controlloop/actor/so/SOActorServiceProvider.java | 36 |
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; |