Search in sources :

Example 1 with Metadata

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

the class ToscaResourceInstaller method getConfigurationResource.

protected ConfigurationResource getConfigurationResource(IEntityDetails configEntity) {
    Metadata metadata = configEntity.getMetadata();
    ConfigurationResource configResource = new ConfigurationResource();
    configResource.setModelName(metadata.getValue(SdcPropertyNames.PROPERTY_NAME_NAME));
    configResource.setModelInvariantUUID(metadata.getValue(SdcPropertyNames.PROPERTY_NAME_INVARIANTUUID));
    configResource.setModelUUID(metadata.getValue(SdcPropertyNames.PROPERTY_NAME_UUID));
    configResource.setModelVersion(metadata.getValue(SdcPropertyNames.PROPERTY_NAME_VERSION));
    configResource.setDescription(metadata.getValue(SdcPropertyNames.PROPERTY_NAME_DESCRIPTION));
    configResource.setToscaNodeType(configEntity.getToscaType());
    return configResource;
}
Also used : Metadata(org.onap.sdc.toscaparser.api.elements.Metadata) ConfigurationResource(org.onap.so.db.catalog.beans.ConfigurationResource)

Example 2 with Metadata

use of org.onap.sdc.toscaparser.api.elements.Metadata 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 3 with Metadata

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

the class ToscaResourceInstaller method createServiceProxy.

protected ServiceProxyResourceCustomization createServiceProxy(IEntityDetails spEntity, Service service, ToscaResourceStructure toscaResourceStructure) {
    Metadata spMetadata = spEntity.getMetadata();
    ServiceProxyResourceCustomization spCustomizationResource = new ServiceProxyResourceCustomization();
    Set<ServiceProxyResourceCustomization> serviceProxyCustomizationSet = new HashSet<>();
    spCustomizationResource.setModelName(spMetadata.getValue(SdcPropertyNames.PROPERTY_NAME_NAME));
    spCustomizationResource.setModelInvariantUUID(spMetadata.getValue(SdcPropertyNames.PROPERTY_NAME_INVARIANTUUID));
    spCustomizationResource.setModelUUID(spMetadata.getValue(SdcPropertyNames.PROPERTY_NAME_UUID));
    spCustomizationResource.setModelVersion(spMetadata.getValue(SdcPropertyNames.PROPERTY_NAME_VERSION));
    spCustomizationResource.setDescription(spMetadata.getValue(SdcPropertyNames.PROPERTY_NAME_DESCRIPTION));
    spCustomizationResource.setModelCustomizationUUID(spMetadata.getValue(SdcPropertyNames.PROPERTY_NAME_CUSTOMIZATIONUUID));
    spCustomizationResource.setModelInstanceName(spEntity.getName());
    spCustomizationResource.setToscaNodeType(spEntity.getToscaType());
    String sourceServiceUUID = spMetadata.getValue("sourceModelUuid");
    Service sourceService = serviceRepo.findOneByModelUUID(sourceServiceUUID);
    spCustomizationResource.setSourceService(sourceService);
    spCustomizationResource.setToscaNodeType(spEntity.getToscaType());
    serviceProxyCustomizationSet.add(spCustomizationResource);
    toscaResourceStructure.setCatalogServiceProxyResourceCustomization(spCustomizationResource);
    return spCustomizationResource;
}
Also used : ServiceProxyResourceCustomization(org.onap.so.db.catalog.beans.ServiceProxyResourceCustomization) Metadata(org.onap.sdc.toscaparser.api.elements.Metadata) Service(org.onap.so.db.catalog.beans.Service) HashSet(java.util.HashSet)

Example 4 with Metadata

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

the class ToscaResourceInstaller method processPnfResources.

/**
 * This is used to process the PNF specific resource, including resource and resource_customization.
 * {@link IEntityDetails} based API is used to retrieve information. Please check {@link ISdcCsarHelper} for
 * details.
 */
protected void processPnfResources(ToscaResourceStructure toscaResourceStruct, Service service, PnfResourceStructure resourceStructure) throws Exception {
    logger.info("Processing PNF resource: {}", resourceStructure.getResourceInstance().getResourceUUID());
    ISdcCsarHelper sdcCsarHelper = toscaResourceStruct.getSdcCsarHelper();
    EntityQuery entityQuery = EntityQuery.newBuilder(SdcTypes.PNF).build();
    TopologyTemplateQuery topologyTemplateQuery = TopologyTemplateQuery.newBuilder(SdcTypes.SERVICE).build();
    List<IEntityDetails> entityDetailsList = sdcCsarHelper.getEntity(entityQuery, topologyTemplateQuery, false);
    for (IEntityDetails entityDetails : entityDetailsList) {
        Metadata metadata = entityDetails.getMetadata();
        String customizationUUID = metadata.getValue(SdcPropertyNames.PROPERTY_NAME_CUSTOMIZATIONUUID);
        String modelUuid = metadata.getValue(SdcPropertyNames.PROPERTY_NAME_UUID);
        String notifCustomizationUUID = resourceStructure.getResourceInstance().getResourceCustomizationUUID();
        if (customizationUUID != null && customizationUUID.equals(notifCustomizationUUID)) {
            logger.info("Resource customization UUID: {} is the same as notified resource customizationUUID: {}", customizationUUID, notifCustomizationUUID);
            if (checkExistingPnfResourceCutomization(customizationUUID)) {
                logger.info("Resource customization UUID: {} already deployed", customizationUUID);
            } else {
                PnfResource pnfResource = findExistingPnfResource(service, modelUuid);
                if (pnfResource == null) {
                    pnfResource = createPnfResource(entityDetails);
                }
                PnfResourceCustomization pnfResourceCustomization = createPnfResourceCustomization(entityDetails, pnfResource);
                pnfResource.getPnfResourceCustomizations().add(pnfResourceCustomization);
                toscaResourceStruct.setPnfResourceCustomization(pnfResourceCustomization);
                service.getPnfCustomizations().add(pnfResourceCustomization);
            }
        } else {
            logger.warn("Resource customization UUID: {} is NOT the same as notified resource customizationUUID: {}", customizationUUID, notifCustomizationUUID);
        }
    }
}
Also used : IEntityDetails(org.onap.sdc.tosca.parser.api.IEntityDetails) PnfResourceCustomization(org.onap.so.db.catalog.beans.PnfResourceCustomization) TopologyTemplateQuery(org.onap.sdc.tosca.parser.elements.queries.TopologyTemplateQuery) ISdcCsarHelper(org.onap.sdc.tosca.parser.api.ISdcCsarHelper) PnfResource(org.onap.so.db.catalog.beans.PnfResource) Metadata(org.onap.sdc.toscaparser.api.elements.Metadata) EntityQuery(org.onap.sdc.tosca.parser.elements.queries.EntityQuery)

Example 5 with Metadata

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

the class ToscaResourceInstaller method processAllottedResources.

protected void processAllottedResources(List<IEntityDetails> arEntityDetails, ToscaResourceStructure toscaResourceStruct, Service service) throws ArtifactInstallerException {
    List<IEntityDetails> pnfAREntityList = getEntityDetails(toscaResourceStruct, EntityQuery.newBuilder(SdcTypes.PNF), TopologyTemplateQuery.newBuilder(SdcTypes.SERVICE), false);
    for (IEntityDetails pnfEntity : pnfAREntityList) {
        Metadata metadata = pnfEntity.getMetadata();
        String category = metadata.getValue(SdcPropertyNames.PROPERTY_NAME_CATEGORY);
        if (ALLOTTED_RESOURCE.equalsIgnoreCase(category)) {
            arEntityDetails.add(pnfEntity);
        }
    }
    if (arEntityDetails != null) {
        for (IEntityDetails arEntity : arEntityDetails) {
            AllottedResourceCustomization allottedResource = createAllottedResource(arEntity, toscaResourceStruct, service);
            String resourceInput = getResourceInput(toscaResourceStruct, allottedResource.getModelCustomizationUUID());
            if (!"{}".equals(resourceInput)) {
                allottedResource.setResourceInput(resourceInput);
            }
            if (!service.getAllottedCustomizations().contains(allottedResource)) {
                service.getAllottedCustomizations().add(allottedResource);
            }
        }
    }
}
Also used : IEntityDetails(org.onap.sdc.tosca.parser.api.IEntityDetails) Metadata(org.onap.sdc.toscaparser.api.elements.Metadata) AllottedResourceCustomization(org.onap.so.db.catalog.beans.AllottedResourceCustomization)

Aggregations

Metadata (org.onap.sdc.toscaparser.api.elements.Metadata)28 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 ArrayList (java.util.ArrayList)8 Test (org.junit.Test)8 Input (org.onap.sdc.toscaparser.api.parameters.Input)8 Service (org.onap.so.db.catalog.beans.Service)7 HashSet (java.util.HashSet)6 ISdcCsarHelper (org.onap.sdc.tosca.parser.api.ISdcCsarHelper)6 GetInput (org.onap.sdc.toscaparser.api.functions.GetInput)6 ConfigurationResource (org.onap.so.db.catalog.beans.ConfigurationResource)6 VfResourceStructure (org.onap.so.asdc.installer.VfResourceStructure)5 JsonProcessingException (com.fasterxml.jackson.core.JsonProcessingException)4 HashMap (java.util.HashMap)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 ConstraintViolationException (org.hibernate.exception.ConstraintViolationException)3 LockAcquisitionException (org.hibernate.exception.LockAcquisitionException)3