Search in sources :

Example 16 with Metadata

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

the class ToscaResourceInstaller method createVFCInstanceGroupMembers.

private void createVFCInstanceGroupMembers(VnfcInstanceGroupCustomization vfcInstanceGroupCustom, IEntityDetails vfcModuleEntity, List<Input> inputList, Set<VnfcCustomization> existingVnfcGroupSet) {
    List<IEntityDetails> members = vfcModuleEntity.getMemberNodes();
    if (!CollectionUtils.isEmpty(members)) {
        for (IEntityDetails vfcEntity : members) {
            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<VnfcCustomization> vnfcCustomizations = vfcInstanceGroupCustom.getVnfcCustomizations();
                if (vnfcCustomizations == null) {
                    vnfcCustomizations = new ArrayList<>();
                    vfcInstanceGroupCustom.setVnfcCustomizations(vnfcCustomizations);
                }
                vnfcCustomizations.add(vnfcCustomization);
                existingVnfcGroupSet.add(vnfcCustomization);
            }
        }
    }
}
Also used : IEntityDetails(org.onap.sdc.tosca.parser.api.IEntityDetails) Metadata(org.onap.sdc.toscaparser.api.elements.Metadata) VnfcCustomization(org.onap.so.db.catalog.beans.VnfcCustomization)

Example 17 with Metadata

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

the class ToscaResourceInstaller method installTheVfResource.

@Transactional(rollbackFor = { ArtifactInstallerException.class })
public void installTheVfResource(ToscaResourceStructure toscaResourceStruct, VfResourceStructure vfResourceStruct) throws ArtifactInstallerException {
    VfResourceStructure vfResourceStructure = vfResourceStruct;
    extractHeatInformation(toscaResourceStruct, vfResourceStructure);
    // PCLO: in case of deployment failure, use a string that will represent
    // the type of artifact that failed...
    List<ASDCElementInfo> artifactListForLogging = new ArrayList<>();
    try {
        createToscaCsar(toscaResourceStruct);
        createService(toscaResourceStruct, vfResourceStruct);
        Service service = toscaResourceStruct.getCatalogService();
        createServiceInfo(toscaResourceStruct, service);
        List<IEntityDetails> vfEntityList = getEntityDetails(toscaResourceStruct, EntityQuery.newBuilder(SdcTypes.VF), TopologyTemplateQuery.newBuilder(SdcTypes.SERVICE), false);
        List<IEntityDetails> arEntityDetails = new ArrayList<IEntityDetails>();
        for (IEntityDetails vfEntityDetails : vfEntityList) {
            Metadata metadata = vfEntityDetails.getMetadata();
            String category = metadata.getValue(SdcPropertyNames.PROPERTY_NAME_CATEGORY);
            if (ALLOTTED_RESOURCE.equalsIgnoreCase(category)) {
                arEntityDetails.add(vfEntityDetails);
            }
            processVfModules(vfEntityDetails, toscaResourceStruct, vfResourceStructure, service, metadata);
        }
        processResourceSequence(toscaResourceStruct, service);
        processAllottedResources(arEntityDetails, toscaResourceStruct, service);
        processNetworks(toscaResourceStruct, service);
        // process Network Collections
        processNetworkCollections(toscaResourceStruct, service);
        // Process Service Proxy & Configuration
        processServiceProxyAndConfiguration(toscaResourceStruct, service);
        logger.info("Saving Service: {} ", service.getModelName());
        service = serviceRepo.save(service);
        correlateConfigCustomResources(service);
        workflowResource.processWorkflows(vfResourceStructure);
        WatchdogComponentDistributionStatus status = new WatchdogComponentDistributionStatus(vfResourceStruct.getNotification().getDistributionID(), MSO);
        status.setComponentDistributionStatus(DistributionStatusEnum.COMPONENT_DONE_OK.name());
        watchdogCDStatusRepository.save(status);
        toscaResourceStruct.setSuccessfulDeployment();
    } catch (Exception e) {
        logger.debug("Exception :", e);
        WatchdogComponentDistributionStatus status = new WatchdogComponentDistributionStatus(vfResourceStruct.getNotification().getDistributionID(), MSO);
        status.setComponentDistributionStatus(DistributionStatusEnum.COMPONENT_DONE_ERROR.name());
        watchdogCDStatusRepository.save(status);
        Throwable dbExceptionToCapture = e;
        while (!(dbExceptionToCapture instanceof ConstraintViolationException || dbExceptionToCapture instanceof LockAcquisitionException) && (dbExceptionToCapture.getCause() != null)) {
            dbExceptionToCapture = dbExceptionToCapture.getCause();
        }
        if (dbExceptionToCapture instanceof ConstraintViolationException || dbExceptionToCapture instanceof LockAcquisitionException) {
            logger.warn(LoggingAnchor.FIVE, MessageEnum.ASDC_ARTIFACT_ALREADY_DEPLOYED.toString(), vfResourceStructure.getResourceInstance().getResourceName(), vfResourceStructure.getNotification().getServiceVersion(), ErrorCode.DataError.getValue(), "Exception - ASCDC Artifact already deployed", e);
        } else {
            String elementToLog = (!artifactListForLogging.isEmpty() ? artifactListForLogging.get(artifactListForLogging.size() - 1).toString() : "No element listed");
            logger.error(LoggingAnchor.FOUR, MessageEnum.ASDC_ARTIFACT_INSTALL_EXC.toString(), elementToLog, ErrorCode.DataError.getValue(), "Exception caught during installation of " + vfResourceStructure.getResourceInstance().getResourceName() + ". Transaction rollback", e);
            throw new ArtifactInstallerException("Exception caught during installation of " + vfResourceStructure.getResourceInstance().getResourceName() + ". Transaction rollback.", e);
        }
    }
}
Also used : ASDCElementInfo(org.onap.so.asdc.installer.ASDCElementInfo) WatchdogComponentDistributionStatus(org.onap.so.db.request.beans.WatchdogComponentDistributionStatus) ArrayList(java.util.ArrayList) Metadata(org.onap.sdc.toscaparser.api.elements.Metadata) Service(org.onap.so.db.catalog.beans.Service) ObjectOptimisticLockingFailureException(org.springframework.orm.ObjectOptimisticLockingFailureException) LockAcquisitionException(org.hibernate.exception.LockAcquisitionException) ArtifactInstallerException(org.onap.so.asdc.client.exceptions.ArtifactInstallerException) ConstraintViolationException(org.hibernate.exception.ConstraintViolationException) JsonProcessingException(com.fasterxml.jackson.core.JsonProcessingException) VfResourceStructure(org.onap.so.asdc.installer.VfResourceStructure) IEntityDetails(org.onap.sdc.tosca.parser.api.IEntityDetails) ConstraintViolationException(org.hibernate.exception.ConstraintViolationException) ArtifactInstallerException(org.onap.so.asdc.client.exceptions.ArtifactInstallerException) LockAcquisitionException(org.hibernate.exception.LockAcquisitionException) Transactional(org.springframework.transaction.annotation.Transactional)

Example 18 with Metadata

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

the class ToscaResourceInstaller method createPnfResourceCustomization.

/**
 * Construct the {@link PnfResourceCustomization} from {@link IEntityDetails} object.
 */
private PnfResourceCustomization createPnfResourceCustomization(IEntityDetails entityDetails, PnfResource pnfResource) {
    PnfResourceCustomization pnfResourceCustomization = new PnfResourceCustomization();
    Metadata metadata = entityDetails.getMetadata();
    Map<String, Property> properties = entityDetails.getProperties();
    pnfResourceCustomization.setModelCustomizationUUID(testNull(metadata.getValue(SdcPropertyNames.PROPERTY_NAME_CUSTOMIZATIONUUID)));
    pnfResourceCustomization.setModelInstanceName(entityDetails.getName());
    pnfResourceCustomization.setNfFunction(getStringValue(properties.get(SdcPropertyNames.PROPERTY_NAME_NFFUNCTION)));
    pnfResourceCustomization.setNfNamingCode(getStringValue(properties.get(SdcPropertyNames.PROPERTY_NAME_NFCODE)));
    pnfResourceCustomization.setNfRole(getStringValue(properties.get(SdcPropertyNames.PROPERTY_NAME_NFROLE)));
    pnfResourceCustomization.setNfType(getStringValue(properties.get(SdcPropertyNames.PROPERTY_NAME_NFTYPE)));
    pnfResourceCustomization.setMultiStageDesign(getStringValue(properties.get(MULTI_STAGE_DESIGN)));
    pnfResourceCustomization.setBlueprintName(getStringValue(properties.get(SDNC_MODEL_NAME)));
    pnfResourceCustomization.setBlueprintVersion(getStringValue(properties.get(SDNC_MODEL_VERSION)));
    pnfResourceCustomization.setSkipPostInstConf(getBooleanValue(properties.get(SKIP_POST_INST_CONF)));
    pnfResourceCustomization.setControllerActor(getStringValue(properties.get(CONTROLLER_ACTOR)));
    pnfResourceCustomization.setDefaultSoftwareVersion(extractDefaultSoftwareVersionFromSwVersions(properties));
    pnfResourceCustomization.setPnfResources(pnfResource);
    return pnfResourceCustomization;
}
Also used : PnfResourceCustomization(org.onap.so.db.catalog.beans.PnfResourceCustomization) Metadata(org.onap.sdc.toscaparser.api.elements.Metadata) Property(org.onap.sdc.toscaparser.api.Property)

Example 19 with Metadata

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

the class ToscaResourceInstaller method processVfModules.

protected void processVfModules(IEntityDetails vfEntityDetails, ToscaResourceStructure toscaResourceStruct, VfResourceStructure vfResourceStructure, Service service, Metadata metadata) throws Exception {
    String vfCustomizationCategory = vfEntityDetails.getMetadata().getValue(SdcPropertyNames.PROPERTY_NAME_CATEGORY);
    logger.debug("VF Category is: {} ", vfCustomizationCategory);
    String vfCustomizationUUID = vfEntityDetails.getMetadata().getValue(SdcPropertyNames.PROPERTY_NAME_CUSTOMIZATIONUUID);
    logger.debug("VFCustomizationUUID= {}", vfCustomizationUUID);
    IResourceInstance vfNotificationResource = vfResourceStructure.getResourceInstance();
    // Make sure the VF ResourceCustomizationUUID from the notification and tosca customizations match before
    // comparing their VF Modules UUID's
    logger.debug("Checking if Notification VF ResourceCustomizationUUID: {} matches Tosca VF Customization UUID: {}", vfNotificationResource.getResourceCustomizationUUID(), vfCustomizationUUID);
    if (vfCustomizationUUID.equals(vfNotificationResource.getResourceCustomizationUUID())) {
        logger.debug("vfCustomizationUUID: {}  matches vfNotificationResource CustomizationUUID ", vfCustomizationUUID);
        VnfResourceCustomization vnfResource = createVnfResource(vfEntityDetails, toscaResourceStruct, service);
        if (vfResourceStructure.getVfModuleStructure() != null && !vfResourceStructure.getVfModuleStructure().isEmpty()) {
            Set<CvnfcCustomization> existingCvnfcSet = new HashSet<>();
            Set<VnfcCustomization> existingVnfcSet = new HashSet<>();
            List<CvnfcConfigurationCustomization> existingCvnfcConfigurationCustom = new ArrayList<>();
            for (VfModuleStructure vfModuleStructure : vfResourceStructure.getVfModuleStructure()) {
                logger.debug("vfModuleStructure: {}", vfModuleStructure);
                List<IEntityDetails> vfModuleEntityList = getEntityDetails(toscaResourceStruct, EntityQuery.newBuilder("org.openecomp.groups.VfModule"), TopologyTemplateQuery.newBuilder(SdcTypes.SERVICE).customizationUUID(vfCustomizationUUID), false);
                IVfModuleData vfMetadata = vfModuleStructure.getVfModuleMetadata();
                logger.debug("Comparing Vf_Modules_Metadata CustomizationUUID : " + vfMetadata.getVfModuleModelCustomizationUUID());
                Optional<IEntityDetails> matchingObject = vfModuleEntityList.stream().peek(group -> logger.debug("To Csar Group VFModuleModelCustomizationUUID " + group.getMetadata().getValue("vfModuleModelCustomizationUUID"))).filter(group -> group.getMetadata().getValue("vfModuleModelCustomizationUUID").equals(vfMetadata.getVfModuleModelCustomizationUUID())).findFirst();
                if (matchingObject.isPresent()) {
                    VfModuleCustomization vfModuleCustomization = createVFModuleResource(matchingObject.get(), toscaResourceStruct, vfResourceStructure, vfMetadata, vnfResource, service, existingCvnfcSet, existingVnfcSet, existingCvnfcConfigurationCustom);
                    vfModuleCustomization.getVfModule().setVnfResources(vnfResource.getVnfResources());
                } else
                    throw new Exception("Cannot find matching VFModule Customization in Csar for Vf_Modules_Metadata: " + vfMetadata.getVfModuleModelCustomizationUUID());
            }
        }
        // Check for VNFC Instance Group info and add it if there is
        List<IEntityDetails> vfcEntityList = getEntityDetails(toscaResourceStruct, EntityQuery.newBuilder("org.openecomp.groups.VfcInstanceGroup"), TopologyTemplateQuery.newBuilder(SdcTypes.VF).customizationUUID(vfCustomizationUUID), false);
        Set<VnfcCustomization> existingVnfcGroupSet = new HashSet<>();
        for (IEntityDetails groupEntity : vfcEntityList) {
            VnfcInstanceGroupCustomization vnfcInstanceGroupCustomization = createVNFCInstanceGroup(groupEntity, vfEntityDetails, vnfResource, toscaResourceStruct, existingVnfcGroupSet);
            vnfcInstanceGroupCustomizationRepo.saveAndFlush(vnfcInstanceGroupCustomization);
        }
        List<String> seqResult = processVNFCGroupSequence(toscaResourceStruct, vfcEntityList);
        if (!CollectionUtils.isEmpty(seqResult)) {
            String resultStr = seqResult.stream().collect(Collectors.joining(","));
            vnfResource.setVnfcInstanceGroupOrder(resultStr);
            logger.debug("vnfcGroupOrder result for service uuid {}: {}", service.getModelUUID(), resultStr);
        }
        // add this vnfResource with existing vnfResource for this service
        addVnfCustomization(service, vnfResource);
    } else {
        logger.debug("Notification VF ResourceCustomizationUUID: " + vfNotificationResource.getResourceCustomizationUUID() + " doesn't match " + "Tosca VF Customization UUID: " + vfCustomizationUUID);
    }
}
Also used : 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) IResourceInstance(org.onap.sdc.api.notification.IResourceInstance) ArrayList(java.util.ArrayList) VfModuleStructure(org.onap.so.asdc.installer.VfModuleStructure) ObjectOptimisticLockingFailureException(org.springframework.orm.ObjectOptimisticLockingFailureException) LockAcquisitionException(org.hibernate.exception.LockAcquisitionException) ArtifactInstallerException(org.onap.so.asdc.client.exceptions.ArtifactInstallerException) ConstraintViolationException(org.hibernate.exception.ConstraintViolationException) JsonProcessingException(com.fasterxml.jackson.core.JsonProcessingException) VnfcInstanceGroupCustomization(org.onap.so.db.catalog.beans.VnfcInstanceGroupCustomization) IEntityDetails(org.onap.sdc.tosca.parser.api.IEntityDetails) CvnfcCustomization(org.onap.so.db.catalog.beans.CvnfcCustomization) IVfModuleData(org.onap.so.asdc.installer.IVfModuleData) VnfcCustomization(org.onap.so.db.catalog.beans.VnfcCustomization) CvnfcConfigurationCustomization(org.onap.so.db.catalog.beans.CvnfcConfigurationCustomization) VfModuleCustomization(org.onap.so.db.catalog.beans.VfModuleCustomization) VnfResourceCustomization(org.onap.so.db.catalog.beans.VnfResourceCustomization) HashSet(java.util.HashSet)

Example 20 with Metadata

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

the class ToscaResourceInstaller method createVNFCInstanceGroup.

protected VnfcInstanceGroupCustomization createVNFCInstanceGroup(IEntityDetails vfcInstanceEntity, IEntityDetails vfEntityDetails, VnfResourceCustomization vnfResourceCustomization, ToscaResourceStructure toscaResourceStructure, Set<VnfcCustomization> existingVnfcGroupSet) {
    Metadata instanceMetadata = vfcInstanceEntity.getMetadata();
    InstanceGroup existingInstanceGroup = instanceGroupRepo.findByModelUUID(instanceMetadata.getValue(SdcPropertyNames.PROPERTY_NAME_UUID));
    VFCInstanceGroup vfcInstanceGroup;
    if (existingInstanceGroup == null) {
        // Populate InstanceGroup
        vfcInstanceGroup = new VFCInstanceGroup();
        vfcInstanceGroup.setModelName(instanceMetadata.getValue(SdcPropertyNames.PROPERTY_NAME_NAME));
        vfcInstanceGroup.setModelInvariantUUID(instanceMetadata.getValue(SdcPropertyNames.PROPERTY_NAME_INVARIANTUUID));
        vfcInstanceGroup.setModelUUID(instanceMetadata.getValue(SdcPropertyNames.PROPERTY_NAME_UUID));
        vfcInstanceGroup.setModelVersion(instanceMetadata.getValue(SdcPropertyNames.PROPERTY_NAME_VERSION));
        vfcInstanceGroup.setToscaNodeType(vfcInstanceEntity.getToscaType());
        // Set Role
        vfcInstanceGroup.setRole("SUB-INTERFACE");
        // Set type
        vfcInstanceGroup.setType(InstanceGroupType.VNFC);
    } else {
        vfcInstanceGroup = (VFCInstanceGroup) existingInstanceGroup;
    }
    // Populate VNFCInstanceGroupCustomization
    VnfcInstanceGroupCustomization vfcInstanceGroupCustom = new VnfcInstanceGroupCustomization();
    vfcInstanceGroupCustom.setVnfResourceCust(vnfResourceCustomization);
    vnfResourceCustomization.getVnfcInstanceGroupCustomizations().add(vfcInstanceGroupCustom);
    vfcInstanceGroupCustom.setInstanceGroup(vfcInstanceGroup);
    vfcInstanceGroup.getVnfcInstanceGroupCustomizations().add(vfcInstanceGroupCustom);
    vfcInstanceGroupCustom.setDescription(instanceMetadata.getValue(SdcPropertyNames.PROPERTY_NAME_DESCRIPTION));
    String getInputName = null;
    Map<String, Property> groupProperties = vfcInstanceEntity.getProperties();
    for (String key : groupProperties.keySet()) {
        Property property = groupProperties.get(key);
        String vfcName = property.getName();
        if (vfcName != null) {
            if (vfcName.equals("vfc_instance_group_function")) {
                String vfcValue = property.getValue().toString();
                int getInputIndex = vfcValue.indexOf("{get_input=");
                if (getInputIndex > -1) {
                    getInputName = vfcValue.substring(getInputIndex + 11, vfcValue.length() - 1);
                }
            }
        }
    }
    List<IEntityDetails> serviceEntityList = getEntityDetails(toscaResourceStructure, EntityQuery.newBuilder(SdcTypes.VF).customizationUUID(vnfResourceCustomization.getModelCustomizationUUID()), TopologyTemplateQuery.newBuilder(SdcTypes.SERVICE), false);
    if (serviceEntityList != null && !serviceEntityList.isEmpty()) {
        vfcInstanceGroupCustom.setFunction(getLeafPropertyValue(serviceEntityList.get(0), getInputName));
    }
    vfcInstanceGroupCustom.setInstanceGroup(vfcInstanceGroup);
    List<Input> inputs = vfEntityDetails.getInputs();
    createVFCInstanceGroupMembers(vfcInstanceGroupCustom, vfcInstanceEntity, inputs, existingVnfcGroupSet);
    return vfcInstanceGroupCustom;
}
Also used : IEntityDetails(org.onap.sdc.tosca.parser.api.IEntityDetails) Input(org.onap.sdc.toscaparser.api.parameters.Input) GetInput(org.onap.sdc.toscaparser.api.functions.GetInput) VFCInstanceGroup(org.onap.so.db.catalog.beans.VFCInstanceGroup) Metadata(org.onap.sdc.toscaparser.api.elements.Metadata) Property(org.onap.sdc.toscaparser.api.Property) NetworkInstanceGroup(org.onap.so.db.catalog.beans.NetworkInstanceGroup) VFCInstanceGroup(org.onap.so.db.catalog.beans.VFCInstanceGroup) InstanceGroup(org.onap.so.db.catalog.beans.InstanceGroup) VnfcInstanceGroupCustomization(org.onap.so.db.catalog.beans.VnfcInstanceGroupCustomization)

Aggregations

Metadata (org.onap.sdc.toscaparser.api.elements.Metadata)31 IEntityDetails (org.onap.sdc.tosca.parser.api.IEntityDetails)10 ToscaResourceStructure (org.onap.so.asdc.installer.ToscaResourceStructure)10 Property (org.onap.sdc.toscaparser.api.Property)9 Input (org.onap.sdc.toscaparser.api.parameters.Input)9 ArrayList (java.util.ArrayList)8 Test (org.junit.Test)8 Service (org.onap.so.db.catalog.beans.Service)7 HashMap (java.util.HashMap)6 HashSet (java.util.HashSet)6 ISdcCsarHelper (org.onap.sdc.tosca.parser.api.ISdcCsarHelper)6 NodeTemplate (org.onap.sdc.toscaparser.api.NodeTemplate)6 GetInput (org.onap.sdc.toscaparser.api.functions.GetInput)6 ConfigurationResource (org.onap.so.db.catalog.beans.ConfigurationResource)6 Map (java.util.Map)5 VfResourceStructure (org.onap.so.asdc.installer.VfResourceStructure)5 JsonProcessingException (com.fasterxml.jackson.core.JsonProcessingException)4 NetworkInstanceGroup (org.onap.so.db.catalog.beans.NetworkInstanceGroup)4 NetworkResource (org.onap.so.db.catalog.beans.NetworkResource)4 TempNetworkHeatTemplateLookup (org.onap.so.db.catalog.beans.TempNetworkHeatTemplateLookup)4