diff options
Diffstat (limited to 'controlloop/common/actors')
-rw-r--r-- | controlloop/common/actors/actor.so/src/main/java/org/onap/policy/controlloop/actor/so/SOActorServiceProvider.java | 35 |
1 files changed, 34 insertions, 1 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 543114cad..4385ce272 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 @@ -196,7 +196,22 @@ public class SOActorServiceProvider implements Actor { // // requestInfo // - request.getRequestDetails().getRequestInfo().setInstanceName(vnfItem.getItems().getInventoryResponseItems().get(baseIndex).getVfModule().getVfModuleName().replace("Vfmodule", "vDNS")); + String instanceName = vnfItem.getItems().getInventoryResponseItems().get(baseIndex).getVfModule() + .getVfModuleName().replace("Vfmodule", "vDNS"); + int numberOfNonBaseModules = findNonBaseModules(vnfItem.getItems().getInventoryResponseItems()); + // Code to create unique VF Module names across the invocations. + if (numberOfNonBaseModules == 1) { + int instanceNumber = 1; + instanceName = instanceName.concat("-").concat(String.valueOf(instanceNumber)); + request.getRequestDetails().getRequestInfo().setInstanceName(instanceName); + } else if (numberOfNonBaseModules > 1) { + int instanceNumber = numberOfNonBaseModules + 1; + instanceName = instanceName.concat("-").concat(String.valueOf(instanceNumber)); + request.getRequestDetails().getRequestInfo().setInstanceName(instanceName); + } else { + request.getRequestDetails().getRequestInfo().setInstanceName(vnfItem.getItems().getInventoryResponseItems() + .get(baseIndex).getVfModule().getVfModuleName().replace("Vfmodule", "vDNS")); + } request.getRequestDetails().getRequestInfo().setSource("POLICY"); request.getRequestDetails().getRequestInfo().setSuppressRollback(false); request.getRequestDetails().getRequestInfo().setRequestorId("policy"); @@ -324,6 +339,24 @@ public class SOActorServiceProvider implements Actor { return -1; } + + /** + * Find the number of non base modules present in API response object. + * + * @param inventoryResponseItems + * @return number of non base index modules + */ + + private int findNonBaseModules(List<AAINQInventoryResponseItem> inventoryResponseItems) { + int nonBaseModuleCount = 0; + for (AAINQInventoryResponseItem invenoryResponseItem : inventoryResponseItems) { + if (invenoryResponseItem.getVfModule() != null + && (!invenoryResponseItem.getVfModule().getIsBaseVfModule())) { + nonBaseModuleCount++; + } + } + return nonBaseModuleCount; + } /** * This method is called to remember the last service instance ID and VNF Item VNF ID. Note these fields are static, beware for multithreaded deployments |