From 61070c9c6b665fdea79b3ccdfeafc3a6b50d262e Mon Sep 17 00:00:00 2001 From: Avi Ziv Date: Wed, 26 Jul 2017 17:37:57 +0300 Subject: [SDC] Full OnBoard health-check and NFoD support Change-Id: I606f8a52c7e6d2bd5558f824957d890e552c5423 Signed-off-by: Avi Ziv --- .../pom.xml | 10 + .../pom.xml.versionsBackup | 108 ------ .../errors/VendorSoftwareProductErrorCodes.java | 5 + .../services/ManualVspDataCollectionService.java | 421 +++++++++++++++++++++ .../composition/CompositionDataExtractorImpl.java | 12 +- .../CompositionEntityDataManagerImpl.java | 35 -- 6 files changed, 445 insertions(+), 146 deletions(-) delete mode 100644 openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-core/pom.xml.versionsBackup create mode 100644 openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-core/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/services/ManualVspDataCollectionService.java (limited to 'openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-core') diff --git a/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-core/pom.xml b/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-core/pom.xml index 343f4aef62..afee456fc3 100644 --- a/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-core/pom.xml +++ b/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-core/pom.xml @@ -116,6 +116,16 @@ openecomp-tosca-datatype ${openecomp.sdc.common.version} + + org.openecomp.sdc + openecomp-sdc-tosca-generator-api + 1.1.0-SNAPSHOT + + + org.openecomp.sdc + openecomp-sdc-vendor-license-api + 1.1.0-SNAPSHOT + diff --git a/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-core/pom.xml.versionsBackup b/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-core/pom.xml.versionsBackup deleted file mode 100644 index 634e0874ac..0000000000 --- a/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-core/pom.xml.versionsBackup +++ /dev/null @@ -1,108 +0,0 @@ - - - 4.0.0 - - openecomp-sdc-vendor-software-product-core - 1.0-SNAPSHOT - - - org.openecomp.sdc - openecomp-sdc-vendor-software-product-lib - 1.0-SNAPSHOT - - - - - org.openecomp.sdc - openecomp-sdc-vendor-software-product-api - 1.0-SNAPSHOT - - - org.openecomp.core - openecomp-nosqldb-api - 1.0-SNAPSHOT - - - org.freemarker - freemarker - 2.3.23 - - - org.testng - testng - ${testng.version} - test - - - org.openecomp.core - openecomp-config-lib - 1.0-SNAPSHOT - - - org.openecomp.sdc - openecomp-sdc-model-impl - 1.0-SNAPSHOT - test - - - org.apache.xmlgraphics - fop - 2.1 - - - com.fasterxml.jackson.dataformat - jackson-dataformat-xml - 2.7.4 - - - commons-io - commons-io - 2.5 - - - org.mockito - mockito-all - 1.10.19 - - - junit - junit - 4.12 - test - - - org.openecomp.sdc.common - openecomp-configuration-management-core - 1707.0.0-SNAPSHOT - runtime - - - org.slf4j - slf4j-log4j12 - - - - - org.openecomp.sdc.common - openecomp-configuration-management-api - 1707.0.0-SNAPSHOT - - - - - - - org.apache.maven.plugins - maven-surefire-plugin - 2.19.1 - - false - true - - - - - - \ No newline at end of file diff --git a/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-core/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/errors/VendorSoftwareProductErrorCodes.java b/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-core/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/errors/VendorSoftwareProductErrorCodes.java index 5284b9a74f..d87059e89c 100644 --- a/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-core/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/errors/VendorSoftwareProductErrorCodes.java +++ b/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-core/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/errors/VendorSoftwareProductErrorCodes.java @@ -64,6 +64,7 @@ public class VendorSoftwareProductErrorCodes { "VSP_ONBOARD_METHOD_UPDATE_NOT_ALLOWED"; public static final String DUPLICATE_NIC_NAME_NOT_ALLOWED = "DUPLICATE_NIC_NAME_NOT_ALLOWED"; + public static final String NIC_NAME_FORMAT_NOT_ALLOWED = "NIC_NAME_FORMAT_NOT_ALLOWED"; public static final String NULL_NETWORKID_NOT_ALLOWED = "NULL_NETWORKID_NOT_ALLOWED"; @@ -102,6 +103,7 @@ public class VendorSoftwareProductErrorCodes { ADD_IMAGE_NOT_ALLOWED_IN_HEAT_ONBOARDING = "ADD_IMAGE_NOT_ALLOWED_IN_HEAT_ONBOARDING"; public static final String DUPLICATE_IMAGE_NAME_NOT_ALLOWED = "DUPLICATE_IMAGE_NAME_NOT_ALLOWED"; + public static final String IMAGE_NAME_FORMAT_NOT_ALLOWED = "IMAGE_NAME_FORMAT_NOT_ALLOWED"; public static final String VFC_IMAGE_INVALID_FORMAT = "VFC_IMAGE_INVALID_FORMAT"; public static final String FEATURE_GROUP_NOT_EXIST_FOR_VSP = "FEATURE_GROUP_NOT_EXIST_FOR_VSP"; @@ -115,8 +117,11 @@ public class VendorSoftwareProductErrorCodes { = "SAME_VFC_ASSOCIATION_MORE_THAN_ONCE_NOT_ALLOWED"; public static final String DUPLICATE_DEPLOYMENT_FLAVOR_MODEL_NOT_ALLOWED = "DUPLICATE_DEPLOYMENT_FLAVOR_MODEL_NOT_ALLOWED"; + public static final String DEPLOYMENT_FLAVOR_NAME_FORMAT_NOT_ALLOWED = + "DEPLOYMENT_FLAVOR_NAME_FORMAT_NOT_ALLOWED"; public static final String INVALID_COMPUTE_FLAVOR_ID = "INVALID_COMPUTE_FLAVOR_ID"; public static final String DUPLICATE_COMPUTE_NAME_NOT_ALLOWED = "DUPLICATE_COMPUTE_NAME_NOT_ALLOWED"; + public static final String COMPUTE_NAME_FORMAT_NOT_ALLOWED = "COMPUTE_NAME_FORMAT_NOT_ALLOWED"; public static final String DELETE_IMAGE_NOT_ALLOWED = "DELETE_IMAGE_NOT_ALLOWED"; public static final String UPDATE_IMAGE_NOT_ALLOWED = "UPDATE_IMAGE_NOT_ALLOWED"; diff --git a/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-core/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/services/ManualVspDataCollectionService.java b/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-core/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/services/ManualVspDataCollectionService.java new file mode 100644 index 0000000000..1499bccec2 --- /dev/null +++ b/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-core/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/services/ManualVspDataCollectionService.java @@ -0,0 +1,421 @@ +package org.openecomp.sdc.vendorsoftwareproduct.services; + +import org.apache.commons.collections4.CollectionUtils; +import org.apache.commons.lang.StringUtils; +import org.openecomp.core.utilities.json.JsonUtil; +import org.openecomp.sdc.datatypes.error.ErrorLevel; +import org.openecomp.sdc.generator.datatypes.tosca.ComputeFlavor; +import org.openecomp.sdc.generator.datatypes.tosca.DeploymentFlavorModel; +import org.openecomp.sdc.generator.datatypes.tosca.LicenseFlavor; +import org.openecomp.sdc.generator.datatypes.tosca.MultiFlavorVfcImage; +import org.openecomp.sdc.generator.datatypes.tosca.VendorInfo; +import org.openecomp.sdc.logging.context.impl.MdcDataErrorMessage; +import org.openecomp.sdc.logging.types.LoggerConstants; +import org.openecomp.sdc.logging.types.LoggerErrorCode; +import org.openecomp.sdc.logging.types.LoggerTragetServiceName; +import org.openecomp.sdc.vendorlicense.dao.types.FeatureGroupEntity; +import org.openecomp.sdc.vendorlicense.dao.types.FeatureGroupModel; +import org.openecomp.sdc.vendorlicense.facade.VendorLicenseFacade; +import org.openecomp.sdc.vendorlicense.facade.VendorLicenseFacadeFactory; +import org.openecomp.sdc.vendorsoftwareproduct.dao.ComponentDao; +import org.openecomp.sdc.vendorsoftwareproduct.dao.ComponentDaoFactory; +import org.openecomp.sdc.vendorsoftwareproduct.dao.ComputeDao; +import org.openecomp.sdc.vendorsoftwareproduct.dao.ComputeDaoFactory; +import org.openecomp.sdc.vendorsoftwareproduct.dao.ImageDao; +import org.openecomp.sdc.vendorsoftwareproduct.dao.ImageDaoFactory; +import org.openecomp.sdc.vendorsoftwareproduct.dao.NicDao; +import org.openecomp.sdc.vendorsoftwareproduct.dao.NicDaoFactory; +import org.openecomp.sdc.vendorsoftwareproduct.dao.VendorSoftwareProductDao; +import org.openecomp.sdc.vendorsoftwareproduct.dao.VendorSoftwareProductDaoFactory; +import org.openecomp.sdc.vendorsoftwareproduct.dao.VendorSoftwareProductInfoDao; +import org.openecomp.sdc.vendorsoftwareproduct.dao.VendorSoftwareProductInfoDaoFactory; +import org.openecomp.sdc.vendorsoftwareproduct.dao.type.ComponentEntity; +import org.openecomp.sdc.vendorsoftwareproduct.dao.type.ComputeEntity; +import org.openecomp.sdc.vendorsoftwareproduct.dao.type.DeploymentFlavorEntity; +import org.openecomp.sdc.vendorsoftwareproduct.dao.type.ImageEntity; +import org.openecomp.sdc.vendorsoftwareproduct.dao.type.NicEntity; +import org.openecomp.sdc.vendorsoftwareproduct.dao.type.VspDetails; +import org.openecomp.sdc.vendorsoftwareproduct.types.composition.ComponentComputeAssociation; +import org.openecomp.sdc.vendorsoftwareproduct.types.composition.ComponentData; +import org.openecomp.sdc.vendorsoftwareproduct.types.composition.DeploymentFlavor; +import org.openecomp.sdc.vendorsoftwareproduct.types.composition.Image; +import org.openecomp.sdc.vendorsoftwareproduct.types.composition.Nic; +import org.openecomp.sdc.vendorsoftwareproduct.types.questionnaire.component.compute.Compute; +import org.openecomp.sdc.vendorsoftwareproduct.types.questionnaire.component.image.ImageDetails; +import org.openecomp.sdc.versioning.dao.types.Version; + +import java.util.ArrayList; +import java.util.Collection; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.Objects; +import java.util.Optional; + + +public class ManualVspDataCollectionService { + + private static final VendorSoftwareProductDao vendorSoftwareProductDao = + VendorSoftwareProductDaoFactory.getInstance().createInterface(); + private static final VendorSoftwareProductInfoDao vendorSoftwareProductInfoDao = + VendorSoftwareProductInfoDaoFactory.getInstance().createInterface(); + private static final ComputeDao computeDao = + ComputeDaoFactory.getInstance().createInterface(); + private static final ImageDao imageDao = + ImageDaoFactory.getInstance().createInterface(); + private static final ComponentDao componentDao = + ComponentDaoFactory.getInstance().createInterface(); + + private static final NicDao nicDao = + NicDaoFactory.getInstance().createInterface(); + private static final VendorLicenseFacade vendorLicenseFacade = + VendorLicenseFacadeFactory.getInstance().createInterface(); + + + /** + * Gets vendor name for the vsp. + * + * @param vspId the vsp id + * @param version the version + * @param user the user + * @return the release vendor name + */ + public Optional getReleaseVendor(String vspId, Version version, String user) { + String vendorName = null; + VspDetails vspDetails = vendorSoftwareProductInfoDao.get(new VspDetails(vspId, version)); + if (Objects.nonNull(vspDetails)) { + vendorName = vspDetails.getVendorName(); + } + return Optional.ofNullable(vendorName); + } + + /** + * Gets the deployment flavor data for manually onboarded VSPs. + * + * @param vspId the vsp id + * @param version the version + * @param user the user + * @return the allowed flavors + */ + public Map getAllowedFlavors(String vspId, Version version, + String user) { + Map allowedFlavors = new HashMap<>(); + Collection deploymentFlavorEntities = + vendorSoftwareProductDao.listDeploymentFlavors(vspId, version); + if (CollectionUtils.isNotEmpty(deploymentFlavorEntities)) { + for (DeploymentFlavorEntity deploymentFlavorEntity : deploymentFlavorEntities) { + DeploymentFlavor deploymentFlavorCompositionData = + deploymentFlavorEntity.getDeploymentFlavorCompositionData(); + + VspDetails vspDetails = vendorSoftwareProductInfoDao.get(new VspDetails(vspId, version)); + String vspVlmId; + Version vlmVersion; + if (Objects.nonNull(vspDetails)) { + vspVlmId = vspDetails.getVendorId(); + vlmVersion = vspDetails.getVlmVersion(); + if (StringUtils.isNotEmpty(vspVlmId)) { + DeploymentFlavorModel deploymentFlavorModel = new DeploymentFlavorModel(); + String featureGroupId = deploymentFlavorCompositionData.getFeatureGroupId(); + if (Objects.isNull(featureGroupId)) { + //No feature group associated with deployment flavor. So excluding this deployment + // flavor for Tosca model + continue; + } + //Gather and set License flavor info + LicenseFlavor licenseFlavor = getLicenseFlavor(featureGroupId); + deploymentFlavorModel.setLicense_flavor(licenseFlavor); + //Get sp_part_number + Optional partNumber = getPartNumber(vspVlmId, vlmVersion, featureGroupId, + user); + partNumber.ifPresent(deploymentFlavorModel::setSp_part_number); + //Gather and set Vendor Info + String vendorModel = deploymentFlavorCompositionData.getModel(); + Optional vendorInfo = getVendorInfo(vspVlmId, vendorModel, vlmVersion, + featureGroupId, user); + vendorInfo.ifPresent(deploymentFlavorModel::setVendor_info); + //Gather and set Compute info + List componentComputeAssociations = + deploymentFlavorCompositionData.getComponentComputeAssociations(); + if (CollectionUtils.isNotEmpty(componentComputeAssociations)) { + for (ComponentComputeAssociation componentComputeAssociation : + componentComputeAssociations) { + String componentId = componentComputeAssociation.getComponentId(); + String computeFlavorId = componentComputeAssociation.getComputeFlavorId(); + Optional computeFlavor = + getComputeFlavor(vspId, version, componentId, computeFlavorId, user); + computeFlavor.ifPresent(deploymentFlavorModel::setCompute_flavor); + } + } + partNumber.ifPresent(spPartNumber -> allowedFlavors.put(spPartNumber, + deploymentFlavorModel)); + } + } + } + } + return allowedFlavors; + } + + /** + * Gets the component image data for manually onboarded VSPs. + * + * @param vspId the vsp id + * @param version the version + * @param user the user + * @return the vsp component images + */ + public Map> getVspComponentImages(String vspId, + Version version, + String user) { + Map> vspComponentImages = new HashMap<>(); + Collection deploymentFlavorEntities = + vendorSoftwareProductDao.listDeploymentFlavors(vspId, version); + for (DeploymentFlavorEntity deploymentFlavorEntity : deploymentFlavorEntities) { + DeploymentFlavor deploymentFlavorCompositionData = + deploymentFlavorEntity.getDeploymentFlavorCompositionData(); + + List componentComputeAssociations = + deploymentFlavorCompositionData.getComponentComputeAssociations(); + if (CollectionUtils.isNotEmpty(componentComputeAssociations)) { + for (ComponentComputeAssociation componentComputeAssociation : + componentComputeAssociations) { + String componentId = componentComputeAssociation.getComponentId(); + List componentImages = + getComponentImages(vspId, version, componentId, user); + if (CollectionUtils.isNotEmpty(componentImages)) { + vspComponentImages.put(componentId, componentImages); + } + } + } + } + return vspComponentImages; + } + + /** + * Gets the component data for manually onboarded VSPs. + * + * @param vspId the vsp id + * @param version the version + * @param user the user + * @return the vsp components + */ + public Map getVspComponents(String vspId, Version version, String user) { + Map componentIdNameMap = new HashMap<>(); + Collection deploymentFlavorEntities = + vendorSoftwareProductDao.listDeploymentFlavors(vspId, version); + for (DeploymentFlavorEntity deploymentFlavorEntity : deploymentFlavorEntities) { + DeploymentFlavor deploymentFlavorCompositionData = + deploymentFlavorEntity.getDeploymentFlavorCompositionData(); + + List componentComputeAssociations = + deploymentFlavorCompositionData.getComponentComputeAssociations(); + if (CollectionUtils.isNotEmpty(componentComputeAssociations)) { + for (ComponentComputeAssociation componentComputeAssociation : + componentComputeAssociations) { + String componentId = componentComputeAssociation.getComponentId(); + Optional componentName = getComponentName(vspId, version, componentId, user); + componentName.ifPresent(name -> componentIdNameMap.put(componentId, name)); + } + } + } + return componentIdNameMap; + } + + /** + * Gets the NIC data for manually onboarded VSPs. + * + * @param vspId the vsp id + * @param version the version + * @param user the user + * @return the vsp component nics + */ + public Map> getVspComponentNics(String vspId, Version version, String user) { + Map> vspComponentNics = new HashMap<>(); + Collection deploymentFlavorEntities = + vendorSoftwareProductDao.listDeploymentFlavors(vspId, version); + if (CollectionUtils.isNotEmpty(deploymentFlavorEntities)) { + for (DeploymentFlavorEntity deploymentFlavorEntity : deploymentFlavorEntities) { + DeploymentFlavor deploymentFlavorCompositionData = + deploymentFlavorEntity.getDeploymentFlavorCompositionData(); + if (Objects.nonNull(deploymentFlavorCompositionData)) { + List componentComputeAssociations = + deploymentFlavorCompositionData.getComponentComputeAssociations(); + if (CollectionUtils.isNotEmpty(componentComputeAssociations)) { + for (ComponentComputeAssociation componentComputeAssociation : + componentComputeAssociations) { + String componentId = componentComputeAssociation.getComponentId(); + List componentNics = getComponentNics(vspId, version, componentId, user); + if (CollectionUtils.isNotEmpty(componentNics)) { + vspComponentNics.put(componentId, componentNics); + } + } + } + } + } + } + return vspComponentNics; + } + + private List getComponentNics(String vspId, Version version, String componentId, + String user) { + List componentNics = new ArrayList<>(); + Collection nics = nicDao.list(new NicEntity(vspId, version, componentId, null)); + if (Objects.nonNull(nics)) { + for (NicEntity nic : nics) { + String nicId = nic.getId(); + NicEntity nicEntity = nicDao.get(new NicEntity(vspId, version, componentId, nicId)); + if (Objects.nonNull(nicEntity) + && Objects.nonNull(nicEntity.getCompositionData())) { + componentNics.add(nicEntity.getNicCompositionData()); + } + } + } + return componentNics; + } + + private LicenseFlavor getLicenseFlavor(String featureGroupId) { + LicenseFlavor licenseFlavor = new LicenseFlavor(); + licenseFlavor.setFeature_group_uuid(featureGroupId); + return licenseFlavor; + } + + private Optional getPartNumber(String vlmId, Version version, + String featureGroupId, String user) { + FeatureGroupModel featureGroup = getFeatureGroup(vlmId, version, featureGroupId, user); + if (Objects.nonNull(featureGroup)) { + return Optional.ofNullable(featureGroup.getFeatureGroup().getPartNumber()); + } + return Optional.empty(); + } + + private Optional getVendorInfo(String vlmId, String vendorModel, Version version, + String featureGroupId, String user) { + VendorInfo vendorInfo = null; + FeatureGroupModel featureGroup = getFeatureGroup(vlmId, version, featureGroupId, user); + if (Objects.nonNull(featureGroup)) { + //Process Feature group to get Manufacturer ref no. + String manufacturerReferenceNumber = featureGroup.getEntityManufacturerReferenceNumber(); + vendorInfo = new VendorInfo(); + vendorInfo.setVendor_model(vendorModel); + if (Objects.nonNull(manufacturerReferenceNumber)) { + vendorInfo.setManufacturer_reference_number(manufacturerReferenceNumber); + } + } + return Optional.ofNullable(vendorInfo); + } + + private Optional getComputeFlavor(String vspId, Version version, + String componentId, String computeFlavorId, + String user) { + ComputeFlavor computeFlavor = null; + ComputeEntity computeQuestionnaire = null; + try { + computeQuestionnaire = computeDao.getQuestionnaireData(vspId, version, componentId, + computeFlavorId); + } catch (Exception ex) { + computeQuestionnaire = null; + MdcDataErrorMessage.createErrorMessageAndUpdateMdc(LoggerConstants.TARGET_ENTITY_API, + LoggerTragetServiceName.COLLECT_MANUAL_VSP_TOSCA_DATA, ErrorLevel.INFO.name(), + LoggerErrorCode.DATA_ERROR.getErrorCode(), "Failed to get compute questionnaire : " + + ex.getMessage()); + } + if (Objects.nonNull(computeQuestionnaire)) { + String computeQuestionnaireData = computeQuestionnaire.getQuestionnaireData(); + if (Objects.nonNull(computeQuestionnaireData)) { + Compute compute; + try { + compute = JsonUtil.json2Object(computeQuestionnaireData, Compute.class); + } catch (Exception ex) { + compute = null; + MdcDataErrorMessage.createErrorMessageAndUpdateMdc(LoggerConstants.TARGET_ENTITY_API, + LoggerTragetServiceName.COLLECT_MANUAL_VSP_TOSCA_DATA, ErrorLevel.INFO.name(), + LoggerErrorCode.DATA_ERROR.getErrorCode(), "Unable to parse compute questionnaire : " + + ex.getMessage()); + } + if (Objects.nonNull(compute.getVmSizing())) { + computeFlavor = new ComputeFlavor(); + if (Objects.nonNull(compute.getVmSizing().getNumOfCPUs())) { + computeFlavor.setNum_cpus(compute.getVmSizing().getNumOfCPUs()); + } + if (Objects.nonNull(compute.getVmSizing().getFileSystemSizeGB())) { + computeFlavor.setDisk_size(compute.getVmSizing().getFileSystemSizeGB() + " GB"); + } + if (Objects.nonNull(compute.getVmSizing().getMemoryRAM())) { + computeFlavor.setMem_size(compute.getVmSizing().getMemoryRAM()); + } + } + } + } + return Optional.ofNullable(computeFlavor); + } + + private FeatureGroupModel getFeatureGroup(String vlmId, Version version, String featureGroupId, + String user) { + FeatureGroupEntity fgInput = new FeatureGroupEntity(); + fgInput.setVendorLicenseModelId(vlmId); + fgInput.setVersion(version); + fgInput.setId(featureGroupId); + return vendorLicenseFacade.getFeatureGroupModel(fgInput, user); + } + + private Optional getComponentName(String vspId, Version version, String componentId, + String user) { + + ComponentEntity componentEntity = + componentDao.get(new ComponentEntity(vspId, version, componentId)); + if (Objects.nonNull(componentEntity) + && Objects.nonNull(componentEntity.getComponentCompositionData())) { + ComponentData componentCompositionData = componentEntity.getComponentCompositionData(); + return Optional.ofNullable(componentCompositionData.getDisplayName()); + } + return Optional.empty(); + } + + private List getComponentImages(String vspId, Version version, + String componentId, String user) { + List multiFlavorVfcImages = new ArrayList<>(); + MultiFlavorVfcImage multiFlavorVfcImage = null; + Collection componentImages = + vendorSoftwareProductDao.listImages(vspId, version, componentId); + if (Objects.nonNull(componentImages)) { + for (ImageEntity componentImage : componentImages) { + String imageId = componentImage.getId(); + ImageEntity imageEntity = vendorSoftwareProductDao.getImage(vspId, version, componentId, + imageId); + ImageEntity imageQuestionnaireDataEntity = imageDao.getQuestionnaireData(vspId, version, + componentId, imageId); + Image imageCompositionData = imageEntity.getImageCompositionData(); + if (Objects.nonNull(imageEntity) + && Objects.nonNull(imageQuestionnaireDataEntity) + && Objects.nonNull(imageCompositionData)) { + ImageDetails imageDetails; + try { + imageDetails = JsonUtil.json2Object(imageQuestionnaireDataEntity + .getQuestionnaireData(), ImageDetails.class); + } catch (Exception ex) { + imageDetails = null; + MdcDataErrorMessage.createErrorMessageAndUpdateMdc(LoggerConstants.TARGET_ENTITY_API, + LoggerTragetServiceName.COLLECT_MANUAL_VSP_TOSCA_DATA, ErrorLevel.INFO.name(), + LoggerErrorCode.DATA_ERROR.getErrorCode(), "Unable to parse image questionnaire : " + + ex.getMessage()); + } + if (Objects.nonNull(imageDetails) + && Objects.nonNull(imageDetails.getVersion())) { + //Image version is used as a key for the image block + //So excluding the population if questionnaire data is absent or invalid + multiFlavorVfcImage = new MultiFlavorVfcImage(); + multiFlavorVfcImage.setSoftware_version(imageDetails.getVersion()); + if (Objects.nonNull(imageCompositionData.getFileName())) { + multiFlavorVfcImage.setFile_name(imageCompositionData.getFileName()); + } + if (Objects.nonNull(imageDetails.getMd5())) { + multiFlavorVfcImage.setFile_hash(imageDetails.getMd5()); + } + multiFlavorVfcImage.setFile_hash_type("md5"); + multiFlavorVfcImages.add(multiFlavorVfcImage); + } + } + } + } + return multiFlavorVfcImages; + } +} diff --git a/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-core/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/services/impl/composition/CompositionDataExtractorImpl.java b/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-core/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/services/impl/composition/CompositionDataExtractorImpl.java index 6b55ffc714..a16fea19ab 100644 --- a/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-core/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/services/impl/composition/CompositionDataExtractorImpl.java +++ b/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-core/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/services/impl/composition/CompositionDataExtractorImpl.java @@ -338,7 +338,7 @@ public class CompositionDataExtractorImpl implements CompositionDataExtractor { if (obj instanceof String) { images.add((String) obj); } else { - HashMap objMap = new ObjectMapper().convertValue(obj,HashMap.class); + Map objMap = new ObjectMapper().convertValue(obj,Map.class); images.add(getInputs(toscaServiceModel,objMap.get("get_input"))); } } @@ -364,7 +364,7 @@ public class CompositionDataExtractorImpl implements CompositionDataExtractor { if (obj instanceof String) { computes.add((String) obj); } else { - HashMap objMap = new ObjectMapper().convertValue(obj, HashMap.class); + Map objMap = new ObjectMapper().convertValue(obj, Map.class); computes.add(getInputs(toscaServiceModel, objMap.get("get_input"))); } } @@ -387,7 +387,13 @@ public class CompositionDataExtractorImpl implements CompositionDataExtractor { for (Map.Entry inputEntry : serviceTemplate .getTopology_template().getInputs().entrySet()) { if (inputEntry.getKey().equals(inputValue)) { - return (String)inputEntry.getValue().get_default(); + String value; + try { + value= (String) inputEntry.getValue().get_default(); + } catch (Exception e) { + value = inputEntry.getValue().get_default().toString(); + } + return value; } } } diff --git a/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-core/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/services/impl/composition/CompositionEntityDataManagerImpl.java b/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-core/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/services/impl/composition/CompositionEntityDataManagerImpl.java index 71f5fa1d41..7d5d57dc37 100644 --- a/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-core/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/services/impl/composition/CompositionEntityDataManagerImpl.java +++ b/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-core/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/services/impl/composition/CompositionEntityDataManagerImpl.java @@ -224,7 +224,6 @@ public class CompositionEntityDataManagerImpl implements CompositionEntityDataMa Map networkIdByName = saveNetworks(vspId, version, compositionData); saveComponents(vspId, version, compositionData, networkIdByName); - saveDeploymentFlavors(vspId, version, compositionData); mdcDataDebugMessage.debugExitMessage(null); } @@ -688,38 +687,4 @@ public class CompositionEntityDataManagerImpl implements CompositionEntityDataMa } } - public void saveDeploymentFlavors(String vspId, Version version, - CompositionData compositionData) { - - mdcDataDebugMessage.debugEntryMessage(null, null); - - if (CollectionUtils.isNotEmpty(compositionData.getComponents())) { - DeploymentFlavorEntity deploymentFlavorEntity = new DeploymentFlavorEntity(vspId, version, - null); - DeploymentFlavor deploymentFlavor = new DeploymentFlavor(); - VspDetails vendorSoftwareProductInfo = - vspInfoDao.get(new VspDetails(vspId, version)); - if (vendorSoftwareProductInfo.getName() != null) { - deploymentFlavor.setModel(vendorSoftwareProductInfo.getName()); - List componentComputeAssociationList = new ArrayList<>(); - Collection computes= vendorSoftwareProductDao.listComputesByVsp(vspId, - version); - for (ComputeEntity compute : computes) { - ComponentComputeAssociation componentComputeAssociation = new - ComponentComputeAssociation(); - if (compute.getComponentId() != null && compute.getId() != null){ - componentComputeAssociation.setComponentId(compute.getComponentId()); - componentComputeAssociation.setComputeFlavorId(compute.getId()); - componentComputeAssociationList.add(componentComputeAssociation); - } - } - deploymentFlavor.setComponentComputeAssociations(componentComputeAssociationList); - } - deploymentFlavorEntity.setDeploymentFlavorCompositionData(deploymentFlavor); - createDeploymentFlavor(deploymentFlavorEntity); - } - - mdcDataDebugMessage.debugExitMessage(null, null); - } - } -- cgit 1.2.3-korg