From 00257f37f7a030f1a93dc3dd67686c9fc10fafe0 Mon Sep 17 00:00:00 2001 From: "Merkel, Jeff" Date: Fri, 18 Oct 2019 10:56:10 -0400 Subject: - Update ResourceInput column length and check - Update ResourceInput column length and check for existing vnfc's. Issue-ID: SO-2462 Signed-off-by: Benjamin, Max (mb388a) Change-Id: I0b0168453d3c20bb6d88a33ec82788f449bf3593 --- .../installer/heat/ToscaResourceInstaller.java | 63 ++++++++++++---------- 1 file changed, 36 insertions(+), 27 deletions(-) (limited to 'asdc-controller/src') diff --git a/asdc-controller/src/main/java/org/onap/so/asdc/installer/heat/ToscaResourceInstaller.java b/asdc-controller/src/main/java/org/onap/so/asdc/installer/heat/ToscaResourceInstaller.java index 8b3bccf892..00ca74b5f4 100644 --- a/asdc-controller/src/main/java/org/onap/so/asdc/installer/heat/ToscaResourceInstaller.java +++ b/asdc-controller/src/main/java/org/onap/so/asdc/installer/heat/ToscaResourceInstaller.java @@ -1068,10 +1068,11 @@ public class ToscaResourceInstaller { EntityQuery.newBuilder("org.openecomp.groups.VfcInstanceGroup"), TopologyTemplateQuery.newBuilder(SdcTypes.VF).customizationUUID(vfCustomizationUUID), false); + Set existingVnfcGroupSet = new HashSet<>(); for (IEntityDetails groupEntity : vfcEntityList) { - VnfcInstanceGroupCustomization vnfcInstanceGroupCustomization = - createVNFCInstanceGroup(groupEntity, nodeTemplate, vnfResource, toscaResourceStruct); + VnfcInstanceGroupCustomization vnfcInstanceGroupCustomization = createVNFCInstanceGroup(groupEntity, + nodeTemplate, vnfResource, toscaResourceStruct, existingVnfcGroupSet); vnfcInstanceGroupCustomizationRepo.saveAndFlush(vnfcInstanceGroupCustomization); } @@ -1888,7 +1889,7 @@ public class ToscaResourceInstaller { protected VnfcInstanceGroupCustomization createVNFCInstanceGroup(IEntityDetails vfcInstanceEntity, NodeTemplate vnfcNodeTemplate, VnfResourceCustomization vnfResourceCustomization, - ToscaResourceStructure toscaResourceStructure) { + ToscaResourceStructure toscaResourceStructure, Set existingVnfcGroupSet) { Metadata instanceMetadata = vfcInstanceEntity.getMetadata(); @@ -1958,39 +1959,47 @@ public class ToscaResourceInstaller { vfcInstanceGroupCustom.setInstanceGroup(vfcInstanceGroup); ArrayList inputs = vnfcNodeTemplate.getSubMappingToscaTemplate().getInputs(); - createVFCInstanceGroupMembers(vfcInstanceGroupCustom, vfcInstanceEntity, inputs); + createVFCInstanceGroupMembers(vfcInstanceGroupCustom, vfcInstanceEntity, inputs, existingVnfcGroupSet); return vfcInstanceGroupCustom; } private void createVFCInstanceGroupMembers(VnfcInstanceGroupCustomization vfcInstanceGroupCustom, - IEntityDetails vfcModuleEntity, List inputList) { + IEntityDetails vfcModuleEntity, List inputList, Set existingVnfcGroupSet) { List members = vfcModuleEntity.getMemberNodes(); if (!CollectionUtils.isEmpty(members)) { for (IEntityDetails vfcEntity : members) { - VnfcCustomization vnfcCustomization = new VnfcCustomization(); - - Metadata metadata = vfcEntity.getMetadata(); - vnfcCustomization - .setModelCustomizationUUID(metadata.getValue(SdcPropertyNames.PROPERTY_NAME_CUSTOMIZATIONUUID)); - vnfcCustomization.setModelInstanceName(vfcEntity.getName()); - vnfcCustomization.setModelUUID(metadata.getValue(SdcPropertyNames.PROPERTY_NAME_UUID)); - vnfcCustomization - .setModelInvariantUUID(metadata.getValue(SdcPropertyNames.PROPERTY_NAME_INVARIANTUUID)); - vnfcCustomization.setModelVersion(metadata.getValue(SdcPropertyNames.PROPERTY_NAME_VERSION)); - vnfcCustomization.setModelName(metadata.getValue(SdcPropertyNames.PROPERTY_NAME_NAME)); - vnfcCustomization.setToscaNodeType(testNull(vfcEntity.getToscaType())); - vnfcCustomization - .setDescription(testNull(metadata.getValue(SdcPropertyNames.PROPERTY_NAME_DESCRIPTION))); - vnfcCustomization.setResourceInput(getVnfcResourceInput(vfcEntity, inputList)); - vnfcCustomization.setVnfcInstanceGroupCustomization(vfcInstanceGroupCustom); - List vnfcCustomizations = vfcInstanceGroupCustom.getVnfcCustomizations(); - - if (vnfcCustomizations == null) { - vnfcCustomizations = new ArrayList<>(); - vfcInstanceGroupCustom.setVnfcCustomizations(vnfcCustomizations); + + VnfcCustomization existingVfcGroup = findExistingVfc(existingVnfcGroupSet, + vfcEntity.getMetadata().getValue(SdcPropertyNames.PROPERTY_NAME_CUSTOMIZATIONUUID)); + + if (existingVfcGroup == null) { + VnfcCustomization vnfcCustomization = new VnfcCustomization(); + + Metadata metadata = vfcEntity.getMetadata(); + vnfcCustomization.setModelCustomizationUUID( + metadata.getValue(SdcPropertyNames.PROPERTY_NAME_CUSTOMIZATIONUUID)); + vnfcCustomization.setModelInstanceName(vfcEntity.getName()); + vnfcCustomization.setModelUUID(metadata.getValue(SdcPropertyNames.PROPERTY_NAME_UUID)); + vnfcCustomization + .setModelInvariantUUID(metadata.getValue(SdcPropertyNames.PROPERTY_NAME_INVARIANTUUID)); + vnfcCustomization.setModelVersion(metadata.getValue(SdcPropertyNames.PROPERTY_NAME_VERSION)); + vnfcCustomization.setModelName(metadata.getValue(SdcPropertyNames.PROPERTY_NAME_NAME)); + vnfcCustomization.setToscaNodeType(testNull(vfcEntity.getToscaType())); + vnfcCustomization + .setDescription(testNull(metadata.getValue(SdcPropertyNames.PROPERTY_NAME_DESCRIPTION))); + vnfcCustomization.setResourceInput(getVnfcResourceInput(vfcEntity, inputList)); + vnfcCustomization.setVnfcInstanceGroupCustomization(vfcInstanceGroupCustom); + List vnfcCustomizations = vfcInstanceGroupCustom.getVnfcCustomizations(); + + if (vnfcCustomizations == null) { + vnfcCustomizations = new ArrayList<>(); + vfcInstanceGroupCustom.setVnfcCustomizations(vnfcCustomizations); + } + vnfcCustomizations.add(vnfcCustomization); + + existingVnfcGroupSet.add(vnfcCustomization); } - vnfcCustomizations.add(vnfcCustomization); } } } -- cgit 1.2.3-korg