Search in sources :

Example 1 with VfModuleCustomization

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

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

the class ToscaResourceInstaller method createVfModuleCustomization.

protected VfModuleCustomization createVfModuleCustomization(IEntityDetails vfModuleEntityDetails, ToscaResourceStructure toscaResourceStructure, VfModule vfModule, IVfModuleData vfModuleData) {
    VfModuleCustomization vfModuleCustomization = new VfModuleCustomization();
    vfModuleCustomization.setModelCustomizationUUID(vfModuleData.getVfModuleModelCustomizationUUID());
    vfModuleCustomization.setVfModule(vfModule);
    String initialCount = getLeafPropertyValue(vfModuleEntityDetails, SdcPropertyNames.PROPERTY_NAME_INITIALCOUNT);
    if (initialCount != null && initialCount.length() > 0) {
        vfModuleCustomization.setInitialCount(Integer.valueOf(initialCount));
    }
    String availabilityZoneCount = getLeafPropertyValue(vfModuleEntityDetails, SdcPropertyNames.PROPERTY_NAME_AVAILABILITYZONECOUNT);
    if (availabilityZoneCount != null && availabilityZoneCount.length() > 0) {
        vfModuleCustomization.setAvailabilityZoneCount(Integer.valueOf(availabilityZoneCount));
    }
    vfModuleCustomization.setLabel(getLeafPropertyValue(vfModuleEntityDetails, SdcPropertyNames.PROPERTY_NAME_VFMODULELABEL));
    String maxInstances = getLeafPropertyValue(vfModuleEntityDetails, SdcPropertyNames.PROPERTY_NAME_MAXVFMODULEINSTANCES);
    if (maxInstances != null && maxInstances.length() > 0) {
        vfModuleCustomization.setMaxInstances(Integer.valueOf(maxInstances));
    }
    String minInstances = getLeafPropertyValue(vfModuleEntityDetails, SdcPropertyNames.PROPERTY_NAME_MINVFMODULEINSTANCES);
    if (minInstances != null && minInstances.length() > 0) {
        vfModuleCustomization.setMinInstances(Integer.valueOf(minInstances));
    }
    String skipPostInstConfText = getLeafPropertyValue(vfModuleEntityDetails, SKIP_POST_INST_CONF);
    if (skipPostInstConfText != null) {
        vfModuleCustomization.setSkipPostInstConf(Boolean.parseBoolean(getLeafPropertyValue(vfModuleEntityDetails, SKIP_POST_INST_CONF)));
    }
    return vfModuleCustomization;
}
Also used : VfModuleCustomization(org.onap.so.db.catalog.beans.VfModuleCustomization)

Example 3 with VfModuleCustomization

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

the class SkipCDSBuildingBlockListener method run.

/**
 * Skip the CDS Building block according to the Skip Flag.
 *
 * @param flowsToExecute - List of ExecuteBuildingBlock object.
 * @param execution - BuildingBlockExecution object
 * @param currentBB - ExecuteBuildingBlock object
 */
@Override
public void run(List<ExecuteBuildingBlock> flowsToExecute, ExecuteBuildingBlock currentBB, BuildingBlockExecution execution) {
    String resourceKey = currentBB.getBuildingBlock().getKey();
    List<Resource> resources = execution.getVariable("resources");
    Resource resource = resources.stream().filter(r -> resourceKey.equals(r.getResourceId())).findFirst().orElseThrow(() -> new IllegalArgumentException("Resource not found for key:" + resourceKey));
    String scope = currentBB.getBuildingBlock().getBpmnScope();
    if ("SERVICE".equalsIgnoreCase(scope)) {
        Service service = catalogDbClient.getServiceByID(resource.getModelVersionId());
        currentSequenceSkipCheck(execution, service.getSkipPostInstConf());
    } else if ("VNF".equalsIgnoreCase(scope) && containsIgnoreCaseAction(currentBB, vnfActions)) {
        VnfResourceCustomization vrc = catalogDbClient.getVnfResourceCustomizationByModelCustomizationUUID(resource.getModelCustomizationId());
        if (vrc != null) {
            logger.debug("getSkipPostInstConf value: " + vrc.getSkipPostInstConf());
            boolean skipConfigVNF = vrc.getSkipPostInstConf();
            currentSequenceSkipCheck(execution, skipConfigVNF);
        }
    } else if (currentBB.getBuildingBlock().getBpmnScope().equalsIgnoreCase("VFModule") && containsIgnoreCaseAction(currentBB, vFModuleAction)) {
        VfModuleCustomization vfc = catalogDbClient.getVfModuleCustomizationByModelCuztomizationUUID(resource.getModelCustomizationId());
        if (null != vfc) {
            logger.debug("getSkipPostInstConf value: " + vfc.getSkipPostInstConf().booleanValue());
            boolean skipVfModule = vfc.getSkipPostInstConf();
            currentSequenceSkipCheck(execution, skipVfModule);
        }
    } else if (currentBB.getBuildingBlock().getBpmnScope().equalsIgnoreCase("PNF") && containsIgnoreCaseAction(currentBB, pnfActions)) {
        PnfResourceCustomization pnfResourceCustomization = catalogDbClient.getPnfResourceCustomizationByModelCustomizationUUID(resource.getModelCustomizationId());
        if (null != pnfResourceCustomization) {
            logger.debug("getSkipPostInstConf value: " + pnfResourceCustomization.getSkipPostInstConf());
            boolean skipConfigPNF = pnfResourceCustomization.getSkipPostInstConf();
            currentSequenceSkipCheck(execution, skipConfigPNF);
        }
    }
}
Also used : PnfResourceCustomization(org.onap.so.db.catalog.beans.PnfResourceCustomization) Resource(org.onap.so.bpmn.infrastructure.workflow.tasks.Resource) Service(org.onap.so.db.catalog.beans.Service) VfModuleCustomization(org.onap.so.db.catalog.beans.VfModuleCustomization) VnfResourceCustomization(org.onap.so.db.catalog.beans.VnfResourceCustomization)

Example 4 with VfModuleCustomization

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

the class CvnfcCustomizationRepositoryTest method createAndGetAllTest.

@Test
@Transactional
public void createAndGetAllTest() throws Exception {
    CvnfcCustomization cvnfcCustomization = setUpCvnfcCustomization();
    cvnfcCustomization.setModelCustomizationUUID("cf9f6efc-9f14-11e8-98d0-529269fb1459");
    VfModuleCustomization vfModuleCustomization = new VfModuleCustomization();
    vfModuleCustomization.setModelCustomizationUUID("cf9f6efc-9f14-11e8-98d0-529269fb1459");
    VfModule vFModule = setUpVfModule();
    VnfResource vnfResource = setUpVnfResource();
    vFModule.setVnfResources(vnfResource);
    vfModuleCustomization.setVfModule(vFModule);
    cvnfcCustomization.setVfModuleCustomization(vfModuleCustomization);
    VnfResourceCustomization vnfResourceCustomization = new VnfResourceCustomization();
    vnfResourceCustomization.setModelCustomizationUUID("cf9f6efc-9f14-11e8-98d0-529269fb1459");
    vnfResourceCustomization.setModelInstanceName("testModelInstanceName");
    List<VnfResourceCustomization> vnfResourceCustomizations = new ArrayList<>();
    vnfResourceCustomizations.add(vnfResourceCustomization);
    vnfResourceCustomization.setVnfResources(vnfResource);
    VnfcCustomization vnfcCustomization = setUpVnfcCustomization();
    vnfcCustomization.setModelCustomizationUUID("d95d704a-9ff2-11e8-98d0-529269fb1459");
    cvnfcCustomizationRepository.save(cvnfcCustomization);
    List<CvnfcCustomization> cvnfcCustomizationList = cvnfcCustomizationRepository.findAll();
    boolean matchFound = false;
    for (CvnfcCustomization foundCvnfcCustomization : cvnfcCustomizationList) {
        if (foundCvnfcCustomization.getDescription().equalsIgnoreCase(cvnfcCustomization.getDescription())) {
            assertThat(cvnfcCustomization, sameBeanAs(foundCvnfcCustomization).ignoring("id").ignoring("created").ignoring("vnfVfmoduleCvnfcConfigurationCustomization").ignoring("vnfResourceCusteModelCustomizationUUID"));
            matchFound = true;
            break;
        }
    }
    Assert.assertTrue(matchFound);
}
Also used : VnfResource(org.onap.so.db.catalog.beans.VnfResource) CvnfcCustomization(org.onap.so.db.catalog.beans.CvnfcCustomization) ArrayList(java.util.ArrayList) VnfcCustomization(org.onap.so.db.catalog.beans.VnfcCustomization) VfModuleCustomization(org.onap.so.db.catalog.beans.VfModuleCustomization) VfModule(org.onap.so.db.catalog.beans.VfModule) VnfResourceCustomization(org.onap.so.db.catalog.beans.VnfResourceCustomization) Test(org.junit.Test) BaseTest(org.onap.so.db.catalog.BaseTest) Transactional(org.springframework.transaction.annotation.Transactional)

Example 5 with VfModuleCustomization

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

the class CvnfcCustomizationRepositoryTest method createAndGetCvnfcCustomizationTest.

@Test
@Transactional
public void createAndGetCvnfcCustomizationTest() throws Exception {
    CvnfcCustomization cvnfcCustomization = setUpCvnfcCustomization();
    cvnfcCustomization.setModelCustomizationUUID("cf9f6efc-9f14-11e8-98d0-529269fb1459");
    VfModuleCustomization vfModuleCustomization = new VfModuleCustomization();
    vfModuleCustomization.setModelCustomizationUUID("cf9f6efc-9f14-11e8-98d0-529269fb1459");
    VfModule vFModule = setUpVfModule();
    VnfResource vnfResource = setUpVnfResource();
    vFModule.setVnfResources(vnfResource);
    vfModuleCustomization.setVfModule(vFModule);
    cvnfcCustomization.setVfModuleCustomization(vfModuleCustomization);
    VnfResourceCustomization vnfResourceCustomization = new VnfResourceCustomization();
    vnfResourceCustomization.setModelCustomizationUUID("cf9f6efc-9f14-11e8-98d0-529269fb1459");
    vnfResourceCustomization.setModelInstanceName("testModelInstanceName");
    List<VnfResourceCustomization> vnfResourceCustomizations = new ArrayList<>();
    vnfResourceCustomizations.add(vnfResourceCustomization);
    vnfResourceCustomization.setVnfResources(vnfResource);
    VnfcCustomization vnfcCustomization = setUpVnfcCustomization();
    vnfcCustomization.setModelCustomizationUUID("d95d704a-9ff2-11e8-98d0-529269fb1459");
    cvnfcCustomizationRepository.save(cvnfcCustomization);
    CvnfcCustomization cvnfcCustomizationList = cvnfcCustomizationRepository.findOneByModelCustomizationUUID("cf9f6efc-9f14-11e8-98d0-529269fb1459");
    assertThat(cvnfcCustomization, sameBeanAs(cvnfcCustomizationList).ignoring("id").ignoring("created").ignoring("vnfVfmoduleCvnfcConfigurationCustomization").ignoring("vnfResourceCusteModelCustomizationUUID"));
}
Also used : VnfResource(org.onap.so.db.catalog.beans.VnfResource) CvnfcCustomization(org.onap.so.db.catalog.beans.CvnfcCustomization) ArrayList(java.util.ArrayList) VnfcCustomization(org.onap.so.db.catalog.beans.VnfcCustomization) VfModuleCustomization(org.onap.so.db.catalog.beans.VfModuleCustomization) VfModule(org.onap.so.db.catalog.beans.VfModule) VnfResourceCustomization(org.onap.so.db.catalog.beans.VnfResourceCustomization) Test(org.junit.Test) BaseTest(org.onap.so.db.catalog.BaseTest) Transactional(org.springframework.transaction.annotation.Transactional)

Aggregations

VfModuleCustomization (org.onap.so.db.catalog.beans.VfModuleCustomization)57 Test (org.junit.Test)35 ArrayList (java.util.ArrayList)29 HeatEnvironment (org.onap.so.db.catalog.beans.HeatEnvironment)23 HeatTemplate (org.onap.so.db.catalog.beans.HeatTemplate)23 VfModule (org.onap.so.db.catalog.beans.VfModule)20 List (java.util.List)15 ExecuteBuildingBlock (org.onap.so.bpmn.servicedecomposition.entities.ExecuteBuildingBlock)14 BaseTaskTest (org.onap.so.bpmn.BaseTaskTest)13 VnfResourceCustomization (org.onap.so.db.catalog.beans.VnfResourceCustomization)13 HashMap (java.util.HashMap)12 CoreMatchers.containsString (org.hamcrest.CoreMatchers.containsString)12 ArgumentMatchers.anyList (org.mockito.ArgumentMatchers.anyList)12 ArgumentMatchers.anyString (org.mockito.ArgumentMatchers.anyString)12 RelationshipList (org.onap.aai.domain.yang.RelationshipList)12 VfModule (org.onap.aai.domain.yang.VfModule)12 NorthBoundRequest (org.onap.so.db.catalog.beans.macro.NorthBoundRequest)12 Service (org.onap.so.db.catalog.beans.Service)11 VnfResource (org.onap.so.db.catalog.beans.VnfResource)10 Map (java.util.Map)7