Search in sources :

Example 1 with CvnfcConfigurationCustomization

use of org.onap.so.db.catalog.beans.CvnfcConfigurationCustomization 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 2 with CvnfcConfigurationCustomization

use of org.onap.so.db.catalog.beans.CvnfcConfigurationCustomization in project so by onap.

the class BBInputSetupMapperLayerTest method testmapCatalogConfigurationToFabricConfiguration.

@Test
public void testmapCatalogConfigurationToFabricConfiguration() {
    String modelCustUUID = "modelCustomizationUUID";
    String modelInvariantUUID = "modelInvariantUUID";
    String modelVersionUUID = "modelUUID";
    String policyName = "policyName";
    ModelInfoConfiguration expected = new ModelInfoConfiguration();
    expected.setModelCustomizationId(modelCustUUID);
    expected.setModelInvariantId(modelInvariantUUID);
    expected.setModelVersionId(modelVersionUUID);
    expected.setPolicyName(policyName);
    CvnfcConfigurationCustomization fabricCustomization = new CvnfcConfigurationCustomization();
    fabricCustomization.setCvnfcCustomization(new CvnfcCustomization());
    fabricCustomization.getCvnfcCustomization().setVnfcCustomization(new VnfcCustomization());
    fabricCustomization.setPolicyName(policyName);
    fabricCustomization.setModelCustomizationUUID(modelCustUUID);
    ConfigurationResource configurationResource = new ConfigurationResource();
    configurationResource.setModelUUID(modelVersionUUID);
    configurationResource.setModelInvariantUUID(modelInvariantUUID);
    fabricCustomization.setConfigurationResource(configurationResource);
    ModelInfoConfiguration actual = bbInputSetupMapperLayer.mapCatalogConfigurationToConfiguration(fabricCustomization);
    assertThat(actual, sameBeanAs(expected));
}
Also used : ModelInfoConfiguration(org.onap.so.bpmn.servicedecomposition.modelinfo.ModelInfoConfiguration) CvnfcCustomization(org.onap.so.db.catalog.beans.CvnfcCustomization) CvnfcConfigurationCustomization(org.onap.so.db.catalog.beans.CvnfcConfigurationCustomization) VnfcCustomization(org.onap.so.db.catalog.beans.VnfcCustomization) ConfigurationResource(org.onap.so.db.catalog.beans.ConfigurationResource) Test(org.junit.Test)

Example 3 with CvnfcConfigurationCustomization

use of org.onap.so.db.catalog.beans.CvnfcConfigurationCustomization in project so by onap.

the class UserParamsServiceTraversal method setConfigurationWorkFlowTypeToResourceList.

private void setConfigurationWorkFlowTypeToResourceList(List<Resource> resourceList, Resource vnfResource, Service validate, Vnfs vnf, VfModules vfModule, Resource resource) {
    if (!vnfCustomizationUUID.isEmpty() && !vfModuleCustomizationUUID.isEmpty()) {
        List<CvnfcConfigurationCustomization> configs = traverseCatalogDbForConfiguration(validate.getModelInfo().getModelVersionId());
        for (CvnfcConfigurationCustomization config : configs) {
            Resource configResource = new Resource(WorkflowType.CONFIGURATION, config.getConfigurationResource().getModelUUID(), false, vnfResource);
            resource.setVnfCustomizationId(vnf.getModelInfo().getModelCustomizationId());
            resource.setVfModuleCustomizationId(vfModule.getModelInfo().getModelCustomizationId());
            resourceList.add(configResource);
        }
    }
}
Also used : Resource(org.onap.so.bpmn.infrastructure.workflow.tasks.Resource) CvnfcConfigurationCustomization(org.onap.so.db.catalog.beans.CvnfcConfigurationCustomization)

Example 4 with CvnfcConfigurationCustomization

use of org.onap.so.db.catalog.beans.CvnfcConfigurationCustomization in project so by onap.

the class BBInputSetupTest method testPopulateFabricConfiguration.

@Test
public void testPopulateFabricConfiguration() throws JsonParseException, JsonMappingException, IOException {
    String instanceName = "configurationName";
    ModelInfo modelInfo = new ModelInfo();
    modelInfo.setModelCustomizationUuid("72d9d1cd-f46d-447a-abdb-451d6fb05fa9");
    ServiceInstance serviceInstance = new ServiceInstance();
    Configuration configuration = new Configuration();
    configuration.setConfigurationId("configurationId");
    configuration.setConfigurationName("configurationName");
    configuration.setConfigurationSubType("Fabric Config");
    serviceInstance.getConfigurations().add(configuration);
    String resourceId = "configurationId";
    String vnfcName = "vnfcName";
    // Mock service
    Service service = mapper.readValue(new File(RESOURCE_PATH + "CatalogDBService_getServiceInstanceNOAAIInput.json"), Service.class);
    Map<ResourceKey, String> lookupKeyMap = new HashMap<>();
    lookupKeyMap.put(ResourceKey.CONFIGURATION_ID, "configurationId");
    String bbName = AssignFlows.FABRIC_CONFIGURATION.toString();
    ConfigurationResourceKeys configResourceKeys = prepareConfigurationResourceKeys();
    configResourceKeys.setVnfcName(vnfcName);
    Vnfc vnfc = new Vnfc();
    vnfc.setVnfcName(vnfcName);
    RequestDetails requestDetails = new RequestDetails();
    ServiceModel serviceModel = new ServiceModel();
    serviceModel.setCurrentService(service);
    CvnfcConfigurationCustomization vnfVfmoduleCvnfcConfigurationCustomization = new CvnfcConfigurationCustomization();
    ConfigurationResource configurationResource = new ConfigurationResource();
    configurationResource.setModelUUID("modelUUID");
    configurationResource.setModelInvariantUUID("modelInvariantUUID");
    vnfVfmoduleCvnfcConfigurationCustomization.setConfigurationResource(configurationResource);
    doReturn(null).when(SPY_bbInputSetup).findConfigurationResourceCustomization(modelInfo, service);
    doReturn(vnfc).when(SPY_bbInputSetup).getVnfcToConfiguration(vnfcName);
    BBInputSetupParameter parameter = new BBInputSetupParameter.Builder().setRequestId(REQUEST_ID).setModelInfo(modelInfo).setService(service).setBbName(bbName).setServiceInstance(serviceInstance).setLookupKeyMap(lookupKeyMap).setResourceId(resourceId).setInstanceName(instanceName).setConfigurationResourceKeys(configResourceKeys).setRequestDetails(requestDetails).setServiceModel(serviceModel).build();
    SPY_bbInputSetup.populateConfiguration(parameter);
    verify(SPY_bbInputSetup, times(1)).mapCatalogConfiguration(configuration, modelInfo, service, configResourceKeys);
}
Also used : ModelInfo(org.onap.so.serviceinstancebeans.ModelInfo) CloudConfiguration(org.onap.so.serviceinstancebeans.CloudConfiguration) Configuration(org.onap.so.bpmn.servicedecomposition.bbobjects.Configuration) HashMap(java.util.HashMap) AAIFluentTypeBuilder(org.onap.aaiclient.client.generated.fluentbuilders.AAIFluentTypeBuilder) ServiceInstance(org.onap.so.bpmn.servicedecomposition.bbobjects.ServiceInstance) ModelInfoServiceInstance(org.onap.so.bpmn.servicedecomposition.modelinfo.ModelInfoServiceInstance) Service(org.onap.so.db.catalog.beans.Service) ConfigurationResource(org.onap.so.db.catalog.beans.ConfigurationResource) RequestDetails(org.onap.so.serviceinstancebeans.RequestDetails) ResourceKey(org.onap.so.bpmn.servicedecomposition.entities.ResourceKey) ServiceModel(org.onap.so.bpmn.servicedecomposition.entities.ServiceModel) ConfigurationResourceKeys(org.onap.so.bpmn.servicedecomposition.entities.ConfigurationResourceKeys) BaseBBInputSetupTestHelper.prepareConfigurationResourceKeys(org.onap.so.bpmn.servicedecomposition.tasks.BaseBBInputSetupTestHelper.prepareConfigurationResourceKeys) CvnfcConfigurationCustomization(org.onap.so.db.catalog.beans.CvnfcConfigurationCustomization) File(java.io.File) Vnfc(org.onap.so.bpmn.servicedecomposition.bbobjects.Vnfc) Test(org.junit.Test)

Example 5 with CvnfcConfigurationCustomization

use of org.onap.so.db.catalog.beans.CvnfcConfigurationCustomization in project so by onap.

the class BBInputSetup method mapCatalogConfiguration.

protected void mapCatalogConfiguration(Configuration configuration, ModelInfo modelInfo, Service service, ConfigurationResourceKeys configurationResourceKeys) {
    ConfigurationResourceCustomization configurationResourceCustomization = findConfigurationResourceCustomization(modelInfo, service);
    CvnfcConfigurationCustomization vnfVfmoduleCvnfcConfigurationCustomization = findVnfVfmoduleCvnfcConfigurationCustomization(service.getModelUUID(), configurationResourceKeys.getVfModuleCustomizationUUID(), configurationResourceKeys.getVnfResourceCustomizationUUID(), configurationResourceKeys.getCvnfcCustomizationUUID(), configurationResourceCustomization);
    if (configurationResourceCustomization != null && vnfVfmoduleCvnfcConfigurationCustomization != null) {
        configuration.setModelInfoConfiguration(this.mapperLayer.mapCatalogConfigurationToConfiguration(configurationResourceCustomization, vnfVfmoduleCvnfcConfigurationCustomization));
    } else {
        logger.debug("for Fabric configuration mapping by VF MODULE CUST UUID: " + configurationResourceKeys.getVfModuleCustomizationUUID());
        vnfVfmoduleCvnfcConfigurationCustomization = findVnfVfmoduleCvnfcConfigurationCustomization(service.getModelUUID(), configurationResourceKeys.getVnfResourceCustomizationUUID(), configurationResourceKeys.getVfModuleCustomizationUUID(), configurationResourceKeys.getCvnfcCustomizationUUID());
        if (vnfVfmoduleCvnfcConfigurationCustomization != null) {
            configuration.setModelInfoConfiguration(this.mapperLayer.mapCatalogConfigurationToConfiguration(vnfVfmoduleCvnfcConfigurationCustomization));
        }
    }
}
Also used : CvnfcConfigurationCustomization(org.onap.so.db.catalog.beans.CvnfcConfigurationCustomization) ConfigurationResourceCustomization(org.onap.so.db.catalog.beans.ConfigurationResourceCustomization)

Aggregations

CvnfcConfigurationCustomization (org.onap.so.db.catalog.beans.CvnfcConfigurationCustomization)18 ConfigurationResource (org.onap.so.db.catalog.beans.ConfigurationResource)11 ArrayList (java.util.ArrayList)9 Test (org.junit.Test)9 CvnfcCustomization (org.onap.so.db.catalog.beans.CvnfcCustomization)9 List (java.util.List)6 ExecuteBuildingBlock (org.onap.so.bpmn.servicedecomposition.entities.ExecuteBuildingBlock)5 BaseTaskTest (org.onap.so.bpmn.BaseTaskTest)4 VnfcCustomization (org.onap.so.db.catalog.beans.VnfcCustomization)4 DelegateExecution (org.camunda.bpm.engine.delegate.DelegateExecution)3 GenericVnf (org.onap.aai.domain.yang.GenericVnf)3 ServiceInstance (org.onap.aai.domain.yang.ServiceInstance)3 VfModule (org.onap.aai.domain.yang.VfModule)3 Metadata (org.onap.sdc.toscaparser.api.elements.Metadata)3 BuildingBlock (org.onap.so.bpmn.servicedecomposition.entities.BuildingBlock)3 WorkflowResourceIds (org.onap.so.bpmn.servicedecomposition.entities.WorkflowResourceIds)3 ConfigurationResourceCustomization (org.onap.so.db.catalog.beans.ConfigurationResourceCustomization)3 Service (org.onap.so.db.catalog.beans.Service)3 RelatedInstanceList (org.onap.so.serviceinstancebeans.RelatedInstanceList)3 JsonProcessingException (com.fasterxml.jackson.core.JsonProcessingException)2