Search in sources :

Example 1 with RequirementAssignment

use of org.onap.sdc.toscaparser.api.RequirementAssignment in project so by onap.

the class ToscaResourceInstaller method getVNFCGroupSequenceList.

private void getVNFCGroupSequenceList(List<String> strSequence, List<IEntityDetails> vnfcGroupDetails, List<IEntityDetails> vnfcMemberNodes, ISdcCsarHelper iSdcCsarHelper) {
    if (CollectionUtils.isEmpty(vnfcGroupDetails)) {
        return;
    }
    List<IEntityDetails> tempGroupList = new ArrayList<>();
    tempGroupList.addAll(vnfcGroupDetails);
    for (IEntityDetails vnfcGroup : vnfcGroupDetails) {
        List<IEntityDetails> members = vnfcGroup.getMemberNodes();
        for (IEntityDetails memberNode : members) {
            boolean isAllExists = true;
            List<RequirementAssignment> requirements = memberNode.getRequirements();
            if (requirements == null || requirements.isEmpty()) {
                continue;
            }
            for (RequirementAssignment rqa : requirements) {
                String name = rqa.getNodeTemplateName();
                for (IEntityDetails node : vnfcMemberNodes) {
                    if (name.equals(node.getName())) {
                        break;
                    }
                }
                isAllExists = false;
                break;
            }
            if (isAllExists) {
                strSequence.add(vnfcGroup.getName());
                tempGroupList.remove(vnfcGroupDetails);
                vnfcMemberNodes.addAll(vnfcGroupDetails);
            }
        }
        if (!tempGroupList.isEmpty() && tempGroupList.size() < vnfcGroupDetails.size()) {
            getVNFCGroupSequenceList(strSequence, tempGroupList, vnfcMemberNodes, iSdcCsarHelper);
        }
    }
}
Also used : IEntityDetails(org.onap.sdc.tosca.parser.api.IEntityDetails) ArrayList(java.util.ArrayList) RequirementAssignment(org.onap.sdc.toscaparser.api.RequirementAssignment)

Example 2 with RequirementAssignment

use of org.onap.sdc.toscaparser.api.RequirementAssignment in project so by onap.

the class ToscaResourceInstaller method getRequirementList.

List<IEntityDetails> getRequirementList(List<IEntityDetails> resultList, List<IEntityDetails> entityDetails, ISdcCsarHelper iSdcCsarHelper) {
    List<IEntityDetails> entities = new ArrayList<>();
    entityDetails.addAll(entityDetails);
    for (IEntityDetails entity : entityDetails) {
        List<RequirementAssignment> requirements = entity.getRequirements();
        for (RequirementAssignment ra : requirements) {
            String reqNode = ra.getNodeTemplateName();
            for (IEntityDetails rEntity : resultList) {
                if (rEntity.getName().equals(reqNode)) {
                    if (!resultList.contains(entityDetails)) {
                        resultList.add(entity);
                    }
                    if (entities.contains(entityDetails)) {
                        entities.remove(entityDetails);
                    }
                    break;
                }
            }
        }
    }
    if (!entities.isEmpty()) {
        getRequirementList(resultList, entities, iSdcCsarHelper);
    }
    return resultList;
}
Also used : IEntityDetails(org.onap.sdc.tosca.parser.api.IEntityDetails) ArrayList(java.util.ArrayList) RequirementAssignment(org.onap.sdc.toscaparser.api.RequirementAssignment)

Example 3 with RequirementAssignment

use of org.onap.sdc.toscaparser.api.RequirementAssignment in project so by onap.

the class ToscaResourceInstaller method createVFModuleResource.

protected VfModuleCustomization createVFModuleResource(IEntityDetails vfModuleEntityDetails, ToscaResourceStructure toscaResourceStructure, VfResourceStructure vfResourceStructure, IVfModuleData vfModuleData, VnfResourceCustomization vnfResource, Service service, Set<CvnfcCustomization> existingCvnfcSet, Set<VnfcCustomization> existingVnfcSet, List<CvnfcConfigurationCustomization> existingCvnfcConfigurationCustom) {
    VfModuleCustomization vfModuleCustomization = findExistingVfModuleCustomization(vnfResource, vfModuleData.getVfModuleModelCustomizationUUID());
    if (vfModuleCustomization == null) {
        VfModule vfModule = findExistingVfModule(vnfResource, vfModuleEntityDetails.getMetadata().getValue(SdcPropertyNames.PROPERTY_NAME_VFMODULEMODELUUID));
        Metadata vfMetadata = vfModuleEntityDetails.getMetadata();
        if (vfModule == null)
            vfModule = createVfModule(vfModuleEntityDetails, toscaResourceStructure, vfModuleData, vfMetadata);
        vfModuleCustomization = createVfModuleCustomization(vfModuleEntityDetails, toscaResourceStructure, vfModule, vfModuleData);
        vfModuleCustomization.setVnfCustomization(vnfResource);
        setHeatInformationForVfModule(toscaResourceStructure, vfResourceStructure, vfModule, vfModuleCustomization, vfMetadata);
        vfModuleCustomization.setVfModule(vfModule);
        vfModule.getVfModuleCustomization().add(vfModuleCustomization);
        vnfResource.getVfModuleCustomizations().add(vfModuleCustomization);
    } else {
        vfResourceStructure.setAlreadyDeployed(true);
    }
    // ******************************************************************************************************************
    // * Extract VFC's and CVFC's then add them to VFModule
    // ******************************************************************************************************************
    List<CvnfcConfigurationCustomization> cvnfcConfigurationCustomizations = new ArrayList<>();
    List<CvnfcCustomization> cvnfcCustomizations = new ArrayList<>();
    Set<VnfcCustomization> vnfcCustomizations = new HashSet<>();
    // Only set the CVNFC if this vfModule group is a member of it.
    List<IEntityDetails> groupMembers = getEntityDetails(toscaResourceStructure, EntityQuery.newBuilder("org.openecomp.groups.VfModule").uUID(vfModuleCustomization.getVfModule().getModelUUID()), TopologyTemplateQuery.newBuilder(SdcTypes.VF), false);
    String vfModuleMemberName = null;
    // Extract CVFC lists
    List<IEntityDetails> cvnfcEntityList = getEntityDetails(toscaResourceStructure, EntityQuery.newBuilder(SdcTypes.CVFC), TopologyTemplateQuery.newBuilder(SdcTypes.VF), false);
    for (IEntityDetails cvfcEntity : cvnfcEntityList) {
        boolean cvnfcVfModuleNameMatch = false;
        for (IEntityDetails entity : groupMembers) {
            List<IEntityDetails> groupMembersNodes = entity.getMemberNodes();
            for (IEntityDetails groupMember : groupMembersNodes) {
                vfModuleMemberName = groupMember.getName();
                if (vfModuleMemberName.equalsIgnoreCase(cvfcEntity.getName())) {
                    cvnfcVfModuleNameMatch = true;
                    break;
                }
            }
        }
        if (vfModuleMemberName != null && cvnfcVfModuleNameMatch) {
            // Extract associated VFC - Should always be just one
            List<IEntityDetails> vfcEntityList = getEntityDetails(toscaResourceStructure, EntityQuery.newBuilder(SdcTypes.VFC), TopologyTemplateQuery.newBuilder(SdcTypes.CVFC).customizationUUID(cvfcEntity.getMetadata().getValue(SdcPropertyNames.PROPERTY_NAME_CUSTOMIZATIONUUID)), false);
            for (IEntityDetails vfcEntity : vfcEntityList) {
                VnfcCustomization vnfcCustomization = new VnfcCustomization();
                VnfcCustomization existingVnfcCustomization = null;
                existingVnfcCustomization = findExistingVfc(existingVnfcSet, vfcEntity.getMetadata().getValue(SdcPropertyNames.PROPERTY_NAME_CUSTOMIZATIONUUID));
                if (existingVnfcCustomization == null) {
                    vnfcCustomization = new VnfcCustomization();
                } else {
                    vnfcCustomization = existingVnfcCustomization;
                }
                // Only Add Abstract VNFC's to our DB, ignore all others
                if (existingVnfcCustomization == null && vfcEntity.getMetadata().getValue(SdcPropertyNames.PROPERTY_NAME_SUBCATEGORY).equalsIgnoreCase("Abstract")) {
                    vnfcCustomization.setModelCustomizationUUID(vfcEntity.getMetadata().getValue(SdcPropertyNames.PROPERTY_NAME_CUSTOMIZATIONUUID));
                    vnfcCustomization.setModelInstanceName(vfcEntity.getName());
                    vnfcCustomization.setModelInvariantUUID(vfcEntity.getMetadata().getValue(SdcPropertyNames.PROPERTY_NAME_INVARIANTUUID));
                    vnfcCustomization.setModelName(vfcEntity.getMetadata().getValue(SdcPropertyNames.PROPERTY_NAME_NAME));
                    vnfcCustomization.setModelUUID(vfcEntity.getMetadata().getValue(SdcPropertyNames.PROPERTY_NAME_UUID));
                    vnfcCustomization.setModelVersion(testNull(vfcEntity.getMetadata().getValue(SdcPropertyNames.PROPERTY_NAME_VERSION)));
                    vnfcCustomization.setDescription(testNull(vfcEntity.getMetadata().getValue(SdcPropertyNames.PROPERTY_NAME_DESCRIPTION)));
                    vnfcCustomization.setToscaNodeType(testNull(vfcEntity.getToscaType()));
                    vnfcCustomizations.add(vnfcCustomization);
                    existingVnfcSet.add(vnfcCustomization);
                }
                // skip adding that record to our DB.
                if (vnfcCustomization.getModelCustomizationUUID() != null) {
                    CvnfcCustomization cvnfcCustomization = new CvnfcCustomization();
                    cvnfcCustomization.setModelCustomizationUUID(cvfcEntity.getMetadata().getValue(SdcPropertyNames.PROPERTY_NAME_CUSTOMIZATIONUUID));
                    cvnfcCustomization.setModelInstanceName(cvfcEntity.getName());
                    cvnfcCustomization.setModelInvariantUUID(cvfcEntity.getMetadata().getValue(SdcPropertyNames.PROPERTY_NAME_INVARIANTUUID));
                    cvnfcCustomization.setModelName(cvfcEntity.getMetadata().getValue(SdcPropertyNames.PROPERTY_NAME_NAME));
                    cvnfcCustomization.setModelUUID(cvfcEntity.getMetadata().getValue(SdcPropertyNames.PROPERTY_NAME_UUID));
                    cvnfcCustomization.setModelVersion(testNull(cvfcEntity.getMetadata().getValue(SdcPropertyNames.PROPERTY_NAME_VERSION)));
                    cvnfcCustomization.setDescription(testNull(cvfcEntity.getMetadata().getValue(SdcPropertyNames.PROPERTY_NAME_DESCRIPTION)));
                    cvnfcCustomization.setToscaNodeType(testNull(cvfcEntity.getToscaType()));
                    if (existingVnfcCustomization != null) {
                        cvnfcCustomization.setVnfcCustomization(existingVnfcCustomization);
                    } else {
                        cvnfcCustomization.setVnfcCustomization(vnfcCustomization);
                    }
                    cvnfcCustomization.setNfcFunction(getLeafPropertyValue(cvfcEntity, "nfc_function"));
                    cvnfcCustomization.setNfcNamingCode(getLeafPropertyValue(cvfcEntity, "nfc_naming_code"));
                    cvnfcCustomization.setVfModuleCustomization(vfModuleCustomization);
                    // *****************************************************************************************************************************************
                    // * Extract Fabric Configuration
                    // *****************************************************************************************************************************************
                    List<IEntityDetails> fabricEntityList = getEntityDetails(toscaResourceStructure, EntityQuery.newBuilder(SdcTypes.CONFIGURATION), TopologyTemplateQuery.newBuilder(SdcTypes.VF), false);
                    for (IEntityDetails fabricEntity : fabricEntityList) {
                        List<RequirementAssignment> requirements = fabricEntity.getRequirements();
                        for (RequirementAssignment requirement : requirements) {
                            if (requirement.getNodeTemplateName().equals(cvfcEntity.getName())) {
                                ConfigurationResource fabricConfig = null;
                                ConfigurationResource existingConfig = findExistingConfiguration(existingCvnfcConfigurationCustom, fabricEntity.getMetadata().getValue(SdcPropertyNames.PROPERTY_NAME_UUID));
                                if (existingConfig == null) {
                                    fabricConfig = createFabricConfiguration(fabricEntity, toscaResourceStructure);
                                } else {
                                    fabricConfig = existingConfig;
                                }
                                CvnfcConfigurationCustomization cvnfcConfigurationCustomization = createCvnfcConfigurationCustomization(fabricEntity, toscaResourceStructure, vnfResource, vfModuleCustomization, cvnfcCustomization, fabricConfig, vfModuleMemberName);
                                cvnfcConfigurationCustomizations.add(cvnfcConfigurationCustomization);
                                existingCvnfcConfigurationCustom.add(cvnfcConfigurationCustomization);
                            }
                        }
                    }
                    cvnfcCustomization.setCvnfcConfigurationCustomization(cvnfcConfigurationCustomizations);
                    cvnfcCustomizations.add(cvnfcCustomization);
                    existingCvnfcSet.add(cvnfcCustomization);
                }
            }
        }
    }
    vfModuleCustomization.setCvnfcCustomization(cvnfcCustomizations);
    return vfModuleCustomization;
}
Also used : Metadata(org.onap.sdc.toscaparser.api.elements.Metadata) ArrayList(java.util.ArrayList) VfModule(org.onap.so.db.catalog.beans.VfModule) ConfigurationResource(org.onap.so.db.catalog.beans.ConfigurationResource) RequirementAssignment(org.onap.sdc.toscaparser.api.RequirementAssignment) IEntityDetails(org.onap.sdc.tosca.parser.api.IEntityDetails) CvnfcCustomization(org.onap.so.db.catalog.beans.CvnfcCustomization) CvnfcConfigurationCustomization(org.onap.so.db.catalog.beans.CvnfcConfigurationCustomization) VnfcCustomization(org.onap.so.db.catalog.beans.VnfcCustomization) VfModuleCustomization(org.onap.so.db.catalog.beans.VfModuleCustomization) HashSet(java.util.HashSet)

Example 4 with RequirementAssignment

use of org.onap.sdc.toscaparser.api.RequirementAssignment in project so by onap.

the class ToscaResourceInstaller method processServiceProxyAndConfiguration.

protected void processServiceProxyAndConfiguration(ToscaResourceStructure toscaResourceStruct, Service service) {
    List<IEntityDetails> spEntityList = getEntityDetails(toscaResourceStruct, EntityQuery.newBuilder(SdcTypes.SERVICE_PROXY), TopologyTemplateQuery.newBuilder(SdcTypes.SERVICE), false);
    List<IEntityDetails> configEntityList = getEntityDetails(toscaResourceStruct, EntityQuery.newBuilder(SdcTypes.CONFIGURATION), TopologyTemplateQuery.newBuilder(SdcTypes.SERVICE), false);
    List<ServiceProxyResourceCustomization> serviceProxyList = new ArrayList<>();
    List<ConfigurationResourceCustomization> configurationResourceList = new ArrayList<>();
    ServiceProxyResourceCustomization serviceProxy = null;
    if (spEntityList != null) {
        for (IEntityDetails spEntity : spEntityList) {
            serviceProxy = createServiceProxy(spEntity, service, toscaResourceStruct);
            serviceProxyList.add(serviceProxy);
            for (IEntityDetails configEntity : configEntityList) {
                List<RequirementAssignment> requirements = configEntity.getRequirements();
                for (RequirementAssignment requirement : requirements) {
                    if (requirement.getNodeTemplateName().equals(spEntity.getName())) {
                        ConfigurationResourceCustomization configurationResource = createConfiguration(configEntity, toscaResourceStruct, serviceProxy, service, configurationResourceList);
                        Optional<ConfigurationResourceCustomization> matchingObject = configurationResourceList.stream().filter(configurationResourceCustomization -> configEntity.getMetadata().getValue(SdcPropertyNames.PROPERTY_NAME_CUSTOMIZATIONUUID).equals(configurationResource.getModelCustomizationUUID())).filter(configurationResourceCustomization -> configurationResourceCustomization.getModelInstanceName().equals(configurationResource.getModelInstanceName())).findFirst();
                        if (!matchingObject.isPresent()) {
                            configurationResourceList.add(configurationResource);
                        }
                        break;
                    }
                }
            }
        }
    }
    service.setConfigurationCustomizations(configurationResourceList);
    service.setServiceProxyCustomizations(serviceProxyList);
}
Also used : IEntityDetails(org.onap.sdc.tosca.parser.api.IEntityDetails) NetworkInstanceGroup(org.onap.so.db.catalog.beans.NetworkInstanceGroup) ObjectOptimisticLockingFailureException(org.springframework.orm.ObjectOptimisticLockingFailureException) Property(org.onap.sdc.toscaparser.api.Property) VfModule(org.onap.so.db.catalog.beans.VfModule) PnfResourceRepository(org.onap.so.db.catalog.data.repository.PnfResourceRepository) Autowired(org.springframework.beans.factory.annotation.Autowired) WatchdogComponentDistributionStatusRepository(org.onap.so.db.request.data.repository.WatchdogComponentDistributionStatusRepository) EntityQueryBuilder(org.onap.sdc.tosca.parser.elements.queries.EntityQuery.EntityQueryBuilder) Matcher(java.util.regex.Matcher) VnfcCustomizationRepository(org.onap.so.db.catalog.data.repository.VnfcCustomizationRepository) Service(org.onap.so.db.catalog.beans.Service) VFModuleRepository(org.onap.so.db.catalog.data.repository.VFModuleRepository) Map(java.util.Map) ResourceStructure(org.onap.so.asdc.installer.ResourceStructure) EntityQuery(org.onap.sdc.tosca.parser.elements.queries.EntityQuery) VFCInstanceGroup(org.onap.so.db.catalog.beans.VFCInstanceGroup) ExternalServiceToInternalServiceRepository(org.onap.so.db.catalog.data.repository.ExternalServiceToInternalServiceRepository) ConfigurationResourceCustomization(org.onap.so.db.catalog.beans.ConfigurationResourceCustomization) VnfcInstanceGroupCustomizationRepository(org.onap.so.db.catalog.data.repository.VnfcInstanceGroupCustomizationRepository) VnfcCustomization(org.onap.so.db.catalog.beans.VnfcCustomization) VfResourceStructure(org.onap.so.asdc.installer.VfResourceStructure) HeatEnvironment(org.onap.so.db.catalog.beans.HeatEnvironment) WatchdogDistributionStatus(org.onap.so.db.request.beans.WatchdogDistributionStatus) VfModuleArtifact(org.onap.so.asdc.installer.VfModuleArtifact) SdcTypes(org.onap.sdc.tosca.parser.enums.SdcTypes) HeatFiles(org.onap.so.db.catalog.beans.HeatFiles) HeatEnvironmentRepository(org.onap.so.db.catalog.data.repository.HeatEnvironmentRepository) Set(java.util.Set) CollectionResourceInstanceGroupCustomization(org.onap.so.db.catalog.beans.CollectionResourceInstanceGroupCustomization) PnfResourceCustomization(org.onap.so.db.catalog.beans.PnfResourceCustomization) ASDCConfiguration(org.onap.so.asdc.client.ASDCConfiguration) ConfigurationResource(org.onap.so.db.catalog.beans.ConfigurationResource) NodeTemplate(org.onap.sdc.toscaparser.api.NodeTemplate) AllottedResource(org.onap.so.db.catalog.beans.AllottedResource) IArtifactInfo(org.onap.sdc.api.notification.IArtifactInfo) NetworkResourceCustomizationRepository(org.onap.so.db.catalog.data.repository.NetworkResourceCustomizationRepository) CollectionUtils(org.springframework.util.CollectionUtils) ConfigurationResourceCustomizationRepository(org.onap.so.db.catalog.data.repository.ConfigurationResourceCustomizationRepository) NetworkResource(org.onap.so.db.catalog.beans.NetworkResource) LockAcquisitionException(org.hibernate.exception.LockAcquisitionException) CollectionResource(org.onap.so.db.catalog.beans.CollectionResource) InstanceGroupRepository(org.onap.so.db.catalog.data.repository.InstanceGroupRepository) CollectionResourceRepository(org.onap.so.db.catalog.data.repository.CollectionResourceRepository) IVfModuleData(org.onap.so.asdc.installer.IVfModuleData) ASDCElementInfo(org.onap.so.asdc.installer.ASDCElementInfo) ArrayList(java.util.ArrayList) LinkedHashMap(java.util.LinkedHashMap) IResourceInstance(org.onap.sdc.api.notification.IResourceInstance) VFModuleCustomizationRepository(org.onap.so.db.catalog.data.repository.VFModuleCustomizationRepository) TopologyTemplateQueryBuilder(org.onap.sdc.tosca.parser.elements.queries.TopologyTemplateQuery.TopologyTemplateQueryBuilder) InstanceGroupType(org.onap.so.db.catalog.beans.InstanceGroupType) AllottedResourceRepository(org.onap.so.db.catalog.data.repository.AllottedResourceRepository) VnfResource(org.onap.so.db.catalog.beans.VnfResource) HeatFilesRepository(org.onap.so.db.catalog.data.repository.HeatFilesRepository) VfModuleCustomization(org.onap.so.db.catalog.beans.VfModuleCustomization) ErrorCode(org.onap.logging.filter.base.ErrorCode) CollectionNetworkResourceCustomization(org.onap.so.db.catalog.beans.CollectionNetworkResourceCustomization) ISdcCsarHelper(org.onap.sdc.tosca.parser.api.ISdcCsarHelper) InstanceGroup(org.onap.so.db.catalog.beans.InstanceGroup) CvnfcCustomization(org.onap.so.db.catalog.beans.CvnfcCustomization) ArtifactInstallerException(org.onap.so.asdc.client.exceptions.ArtifactInstallerException) HeatTemplate(org.onap.so.db.catalog.beans.HeatTemplate) RequirementAssignment(org.onap.sdc.toscaparser.api.RequirementAssignment) PnfResource(org.onap.so.db.catalog.beans.PnfResource) ToscaCsarRepository(org.onap.so.db.catalog.data.repository.ToscaCsarRepository) TopologyTemplateQuery(org.onap.sdc.tosca.parser.elements.queries.TopologyTemplateQuery) Date(java.util.Date) LoggerFactory(org.slf4j.LoggerFactory) PnfResourceStructure(org.onap.so.asdc.installer.PnfResourceStructure) IEntityDetails(org.onap.sdc.tosca.parser.api.IEntityDetails) ServiceProxyResourceCustomization(org.onap.so.db.catalog.beans.ServiceProxyResourceCustomization) CapabilityAssignment(org.onap.sdc.toscaparser.api.CapabilityAssignment) Input(org.onap.sdc.toscaparser.api.parameters.Input) MessageEnum(org.onap.so.logger.MessageEnum) SubType(org.onap.so.db.catalog.beans.SubType) NetworkResourceRepository(org.onap.so.db.catalog.data.repository.NetworkResourceRepository) ConstraintViolationException(org.hibernate.exception.ConstraintViolationException) WatchdogServiceModVerIdLookupRepository(org.onap.so.db.request.data.repository.WatchdogServiceModVerIdLookupRepository) Timestamp(java.sql.Timestamp) Collection(java.util.Collection) YamlEditor(org.onap.so.asdc.util.YamlEditor) TempNetworkHeatTemplateRepository(org.onap.so.db.catalog.data.repository.TempNetworkHeatTemplateRepository) Collectors(java.util.stream.Collectors) List(java.util.List) ServiceInfo(org.onap.so.db.catalog.beans.ServiceInfo) Optional(java.util.Optional) LoggingAnchor(org.onap.so.logger.LoggingAnchor) Pattern(java.util.regex.Pattern) BigDecimalVersion(org.onap.so.asdc.installer.BigDecimalVersion) WatchdogDistributionStatusRepository(org.onap.so.db.request.data.repository.WatchdogDistributionStatusRepository) TempNetworkHeatTemplateLookup(org.onap.so.db.catalog.beans.TempNetworkHeatTemplateLookup) ServiceArtifact(org.onap.so.db.catalog.beans.ServiceArtifact) WatchdogServiceModVerIdLookup(org.onap.so.db.request.beans.WatchdogServiceModVerIdLookup) HashMap(java.util.HashMap) CvnfcCustomizationRepository(org.onap.so.db.catalog.data.repository.CvnfcCustomizationRepository) ServiceProxyResourceCustomizationRepository(org.onap.so.db.catalog.data.repository.ServiceProxyResourceCustomizationRepository) HeatTemplateParam(org.onap.so.db.catalog.beans.HeatTemplateParam) VnfResourceCustomization(org.onap.so.db.catalog.beans.VnfResourceCustomization) ConfigurationResourceRepository(org.onap.so.db.catalog.data.repository.ConfigurationResourceRepository) HashSet(java.util.HashSet) AllottedResourceCustomizationRepository(org.onap.so.db.catalog.data.repository.AllottedResourceCustomizationRepository) PnfCustomizationRepository(org.onap.so.db.catalog.data.repository.PnfCustomizationRepository) CollectionResourceCustomizationRepository(org.onap.so.db.catalog.data.repository.CollectionResourceCustomizationRepository) DistributionStatusEnum(org.onap.sdc.utils.DistributionStatusEnum) WatchdogComponentDistributionStatus(org.onap.so.db.request.beans.WatchdogComponentDistributionStatus) Logger(org.slf4j.Logger) EntityTemplateType(org.onap.sdc.tosca.parser.enums.EntityTemplateType) IStatusData(org.onap.sdc.api.notification.IStatusData) NetworkCollectionResourceCustomization(org.onap.so.db.catalog.beans.NetworkCollectionResourceCustomization) VnfResourceRepository(org.onap.so.db.catalog.data.repository.VnfResourceRepository) ObjectMapper(com.fasterxml.jackson.databind.ObjectMapper) JsonProcessingException(com.fasterxml.jackson.core.JsonProcessingException) HeatTemplateRepository(org.onap.so.db.catalog.data.repository.HeatTemplateRepository) VfModuleStructure(org.onap.so.asdc.installer.VfModuleStructure) VnfcInstanceGroupCustomization(org.onap.so.db.catalog.beans.VnfcInstanceGroupCustomization) ToscaCsar(org.onap.so.db.catalog.beans.ToscaCsar) NetworkResourceCustomization(org.onap.so.db.catalog.beans.NetworkResourceCustomization) Metadata(org.onap.sdc.toscaparser.api.elements.Metadata) ToscaResourceStructure(org.onap.so.asdc.installer.ToscaResourceStructure) Component(org.springframework.stereotype.Component) CvnfcConfigurationCustomization(org.onap.so.db.catalog.beans.CvnfcConfigurationCustomization) ServiceRepository(org.onap.so.db.catalog.data.repository.ServiceRepository) SdcPropertyNames(org.onap.sdc.tosca.parser.impl.SdcPropertyNames) AllottedResourceCustomization(org.onap.so.db.catalog.beans.AllottedResourceCustomization) GetInput(org.onap.sdc.toscaparser.api.functions.GetInput) Collections(java.util.Collections) WorkflowResource(org.onap.so.asdc.installer.bpmn.WorkflowResource) Transactional(org.springframework.transaction.annotation.Transactional) ServiceProxyResourceCustomization(org.onap.so.db.catalog.beans.ServiceProxyResourceCustomization) ArrayList(java.util.ArrayList) ConfigurationResourceCustomization(org.onap.so.db.catalog.beans.ConfigurationResourceCustomization) RequirementAssignment(org.onap.sdc.toscaparser.api.RequirementAssignment)

Example 5 with RequirementAssignment

use of org.onap.sdc.toscaparser.api.RequirementAssignment in project so by onap.

the class ToscaResourceInstaller method processResourceSequence.

// This method retrieve resource sequence from csar file
void processResourceSequence(ToscaResourceStructure toscaResourceStructure, Service service) {
    List<String> resouceSequence = new ArrayList<>();
    List<IEntityDetails> resultList = new ArrayList<>();
    ISdcCsarHelper iSdcCsarHelper = toscaResourceStructure.getSdcCsarHelper();
    List<IEntityDetails> vfEntityList = getEntityDetails(toscaResourceStructure, EntityQuery.newBuilder(EntityTemplateType.NODE_TEMPLATE), TopologyTemplateQuery.newBuilder(SdcTypes.SERVICE), false);
    List<IEntityDetails> entities = new ArrayList<>();
    entities.addAll(vfEntityList);
    for (IEntityDetails entityDetails : vfEntityList) {
        List<RequirementAssignment> requirements = entityDetails.getRequirements();
        if (requirements == null || requirements.isEmpty()) {
            resultList.add(entityDetails);
            entities.remove(entityDetails);
        }
    }
    resultList = getRequirementList(resultList, entities, iSdcCsarHelper);
    for (IEntityDetails entity : resultList) {
        String templateName = entity.getMetadata().getValue("name");
        if (!resouceSequence.contains(templateName)) {
            resouceSequence.add(templateName);
        }
    }
    String resourceSeqStr = resouceSequence.stream().collect(Collectors.joining(","));
    service.setResourceOrder(resourceSeqStr);
    logger.debug(" resourceSeq for service uuid {}: {}", service.getModelUUID(), resourceSeqStr);
}
Also used : IEntityDetails(org.onap.sdc.tosca.parser.api.IEntityDetails) ISdcCsarHelper(org.onap.sdc.tosca.parser.api.ISdcCsarHelper) ArrayList(java.util.ArrayList) RequirementAssignment(org.onap.sdc.toscaparser.api.RequirementAssignment)

Aggregations

ArrayList (java.util.ArrayList)7 RequirementAssignment (org.onap.sdc.toscaparser.api.RequirementAssignment)7 IEntityDetails (org.onap.sdc.tosca.parser.api.IEntityDetails)6 ISdcCsarHelper (org.onap.sdc.tosca.parser.api.ISdcCsarHelper)3 HashSet (java.util.HashSet)2 List (java.util.List)2 LockAcquisitionException (org.hibernate.exception.LockAcquisitionException)2 NodeTemplate (org.onap.sdc.toscaparser.api.NodeTemplate)2 Metadata (org.onap.sdc.toscaparser.api.elements.Metadata)2 ArtifactInstallerException (org.onap.so.asdc.client.exceptions.ArtifactInstallerException)2 ConfigurationResource (org.onap.so.db.catalog.beans.ConfigurationResource)2 CvnfcConfigurationCustomization (org.onap.so.db.catalog.beans.CvnfcConfigurationCustomization)2 CvnfcCustomization (org.onap.so.db.catalog.beans.CvnfcCustomization)2 VfModule (org.onap.so.db.catalog.beans.VfModule)2 VfModuleCustomization (org.onap.so.db.catalog.beans.VfModuleCustomization)2 VnfcCustomization (org.onap.so.db.catalog.beans.VnfcCustomization)2 JsonProcessingException (com.fasterxml.jackson.core.JsonProcessingException)1 ObjectMapper (com.fasterxml.jackson.databind.ObjectMapper)1 Method (java.lang.reflect.Method)1 Timestamp (java.sql.Timestamp)1