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 --- .../V7.3__UpdateVnfcCustResourceInputLength.sql | 4 ++ .../installer/heat/ToscaResourceInstaller.java | 63 ++++++++++++---------- 2 files changed, 40 insertions(+), 27 deletions(-) create mode 100644 adapters/mso-catalog-db-adapter/src/main/resources/db/migration/V7.3__UpdateVnfcCustResourceInputLength.sql diff --git a/adapters/mso-catalog-db-adapter/src/main/resources/db/migration/V7.3__UpdateVnfcCustResourceInputLength.sql b/adapters/mso-catalog-db-adapter/src/main/resources/db/migration/V7.3__UpdateVnfcCustResourceInputLength.sql new file mode 100644 index 0000000000..66c01538f7 --- /dev/null +++ b/adapters/mso-catalog-db-adapter/src/main/resources/db/migration/V7.3__UpdateVnfcCustResourceInputLength.sql @@ -0,0 +1,4 @@ +use catalogdb; + +ALTER TABLE vnfc_customization + MODIFY IF EXISTS RESOURCE_INPUT varchar(20000); \ No newline at end of file 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