Search in sources :

Example 1 with VnfResource

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

the class ToscaResourceInstaller method createVnfResource.

protected VnfResourceCustomization createVnfResource(IEntityDetails entityDetails, ToscaResourceStructure toscaResourceStructure, Service service) throws ArtifactInstallerException {
    VnfResourceCustomization vnfResourceCustomization = null;
    if (vnfResourceCustomization == null) {
        VnfResource vnfResource = findExistingVnfResource(service, entityDetails.getMetadata().getValue(SdcPropertyNames.PROPERTY_NAME_UUID));
        if (vnfResource == null) {
            vnfResource = createVnfResource(entityDetails);
        }
        vnfResourceCustomization = createVnfResourceCustomization(entityDetails, toscaResourceStructure, vnfResource);
        vnfResourceCustomization.setVnfResources(vnfResource);
        vnfResourceCustomization.setService(service);
        // setting resource input for vnf customization
        vnfResourceCustomization.setResourceInput(getResourceInput(toscaResourceStructure, vnfResourceCustomization.getModelCustomizationUUID()));
    }
    return vnfResourceCustomization;
}
Also used : VnfResource(org.onap.so.db.catalog.beans.VnfResource) VnfResourceCustomization(org.onap.so.db.catalog.beans.VnfResourceCustomization)

Example 2 with VnfResource

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

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

Example 4 with VnfResource

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

the class BaseTest method setUpVnfResource.

protected VnfResource setUpVnfResource() {
    VnfResource vnfResource = new VnfResource();
    vnfResource.setModelUUID("cb82ffd8-252a-11e7-93ae-92361f002671");
    vnfResource.setModelInvariantUUID("az82ffd8-252a-11e7-93ae-92361f002677");
    vnfResource.setModelVersion("testModelVersion");
    vnfResource.setOrchestrationMode("HEAT");
    return vnfResource;
}
Also used : VnfResource(org.onap.so.db.catalog.beans.VnfResource)

Example 5 with VnfResource

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

the class RequestHandlerUtils method getVnfOrVfModuleUri.

private RecipeLookupResult getVnfOrVfModuleUri(ServiceInstancesRequest servInstReq, Actions action) throws ValidationException {
    ModelInfo modelInfo = servInstReq.getRequestDetails().getModelInfo();
    String vnfComponentType = modelInfo.getModelType().name();
    RelatedInstanceList[] instanceList = null;
    if (servInstReq.getRequestDetails() != null) {
        instanceList = servInstReq.getRequestDetails().getRelatedInstanceList();
    }
    Recipe recipe;
    String defaultSource = getDefaultModel(servInstReq);
    String modelCustomizationId = modelInfo.getModelCustomizationId();
    String modelCustomizationName = modelInfo.getModelCustomizationName();
    String relatedInstanceModelVersionId = null;
    String relatedInstanceModelInvariantId = null;
    String relatedInstanceVersion = null;
    String relatedInstanceModelCustomizationName = null;
    if (instanceList != null) {
        for (RelatedInstanceList relatedInstanceList : instanceList) {
            RelatedInstance relatedInstance = relatedInstanceList.getRelatedInstance();
            ModelInfo relatedInstanceModelInfo = relatedInstance.getModelInfo();
            if (relatedInstanceModelInfo.getModelType().equals(ModelType.service)) {
                relatedInstanceModelVersionId = relatedInstanceModelInfo.getModelVersionId();
                relatedInstanceVersion = relatedInstanceModelInfo.getModelVersion();
            }
            if (relatedInstanceModelInfo.getModelType().equals(ModelType.vnf)) {
                relatedInstanceModelVersionId = relatedInstanceModelInfo.getModelVersionId();
                relatedInstanceModelInvariantId = relatedInstanceModelInfo.getModelInvariantId();
                relatedInstanceVersion = relatedInstanceModelInfo.getModelVersion();
                relatedInstanceModelCustomizationName = relatedInstanceModelInfo.getModelCustomizationName();
            }
        }
        if (modelInfo.getModelType().equals(ModelType.vnf)) {
            // a. For a vnf request (only create, no update currently):
            // i. (v3-v4) If modelInfo.modelCustomizationId is provided, use it to validate catalog DB has record in
            // vnf_resource_customization.model_customization_uuid.
            // ii. (v2-v4) If modelInfo.modelCustomizationId is NOT provided (because it is a pre-1702 ASDC model or
            // pre-v3), then modelInfo.modelCustomizationName must have
            // been provided (else create request should be rejected). APIH should use the
            // relatedInstance.modelInfo[service].modelVersionId** + modelInfo[vnf].modelCustomizationName
            // to “join�? service_to_resource_customizations with vnf_resource_customization to confirm a
            // vnf_resource_customization.model_customization_uuid record exists.
            // **If relatedInstance.modelInfo[service].modelVersionId was not provided, use
            // relatedInstance.modelInfo[service].modelInvariantId + modelVersion instead to lookup modelVersionId
            // (MODEL_UUID) in SERVICE table.
            // iii. Regardless of how the value was provided/obtained above, APIH must always populate
            // vnfModelCustomizationId in bpmnRequest. It would be assumed it was MSO generated
            // during 1707 data migration if VID did not provide it originally on request.
            // iv. Note: continue to construct the “vnf-type�? value and pass to BPMN (must still be populated
            // in A&AI).
            // 1. If modelCustomizationName is NOT provided on a vnf/vfModule request, use modelCustomizationId to
            // look it up in our catalog to construct vnf-type value to pass to BPMN.
            VnfResource vnfResource = null;
            VnfResourceCustomization vrc = null;
            if (modelCustomizationId != null) {
                vrc = catalogDbClient.getVnfResourceCustomizationByModelCustomizationUUID(modelCustomizationId);
                if (vrc != null) {
                    vnfResource = vrc.getVnfResources();
                }
            } else {
                org.onap.so.db.catalog.beans.Service service = catalogDbClient.getServiceByID(relatedInstanceModelVersionId);
                if (service == null) {
                    service = catalogDbClient.getServiceByModelVersionAndModelInvariantUUID(relatedInstanceVersion, relatedInstanceModelInvariantId);
                }
                if (service == null) {
                    throw new ValidationException("service in relatedInstance");
                }
                for (VnfResourceCustomization vnfResourceCustom : service.getVnfCustomizations()) {
                    if (vnfResourceCustom.getModelInstanceName().equals(modelCustomizationName)) {
                        vrc = vnfResourceCustom;
                    }
                }
                if (vrc != null) {
                    vnfResource = vrc.getVnfResources();
                    modelInfo.setModelCustomizationId(vrc.getModelCustomizationUUID());
                    modelInfo.setModelCustomizationUuid(vrc.getModelCustomizationUUID());
                }
            }
            if (vnfResource == null) {
                throw new ValidationException("vnfResource");
            } else {
                if (modelInfo.getModelVersionId() == null) {
                    modelInfo.setModelVersionId(vnfResource.getModelUUID());
                }
            }
            VnfRecipe vnfRecipe = null;
            if (vrc != null) {
                String nfRole = vrc.getNfRole();
                if (nfRole != null) {
                    vnfRecipe = catalogDbClient.getFirstVnfRecipeByNfRoleAndAction(vrc.getNfRole(), action.toString());
                }
            }
            if (vnfRecipe == null) {
                vnfRecipe = catalogDbClient.getFirstVnfRecipeByNfRoleAndAction(defaultSource, action.toString());
            }
            if (vnfRecipe == null) {
                return null;
            }
            return new RecipeLookupResult(vnfRecipe.getOrchestrationUri(), vnfRecipe.getRecipeTimeout());
        } else {
            /*
                 * (v5-v7) If modelInfo.modelCustomizationId is NOT provided (because it is a pre-1702 ASDC model or
                 * pre-v3), then modelInfo.modelCustomizationName must have // been provided (else create request should
                 * be rejected). APIH should use the relatedInstance.modelInfo[vnf].modelVersionId +
                 * modelInfo[vnf].modelCustomizationName // to join vnf_to_resource_customizations with
                 * vf_resource_customization to confirm a vf_resource_customization.model_customization_uuid record
                 * exists. // Once the vnfs model_customization_uuid has been obtained, use it to find all vfModule
                 * customizations for that vnf customization in the vnf_res_custom_to_vf_module_custom join table. //
                 * For each vf_module_cust_model_customization_uuid value returned, use that UUID to query
                 * vf_module_customization table along with modelInfo[vfModule|volumeGroup].modelVersionId to // confirm
                 * record matches request data (and to identify the modelCustomizationId associated with the vfModule in
                 * the request). This means taking each record found // in vf_module_customization and looking up in
                 * vf_module (using vf_module_customization’s FK into vf_module) to find a match on
                 * MODEL_INVARIANT_UUID (modelInvariantId) // and MODEL_VERSION (modelVersion).
                 */
            VfModuleCustomization vfmc = null;
            VnfResource vnfr;
            VnfResourceCustomization vnfrc;
            VfModule vfModule = null;
            if (modelInfo.getModelCustomizationId() != null) {
                vfmc = catalogDbClient.getVfModuleCustomizationByModelCuztomizationUUID(modelInfo.getModelCustomizationId());
            } else {
                vnfr = catalogDbClient.getVnfResourceByModelUUID(relatedInstanceModelVersionId);
                if (vnfr == null) {
                    vnfr = catalogDbClient.getFirstVnfResourceByModelInvariantUUIDAndModelVersion(relatedInstanceModelInvariantId, relatedInstanceVersion);
                }
                vnfrc = catalogDbClient.getFirstVnfResourceCustomizationByModelInstanceNameAndVnfResources(relatedInstanceModelCustomizationName, vnfr);
                List<VfModuleCustomization> list = vnfrc.getVfModuleCustomizations();
                String vfModuleModelUUID = modelInfo.getModelVersionId();
                for (VfModuleCustomization vf : list) {
                    VfModuleCustomization vfmCustom;
                    if (vfModuleModelUUID != null) {
                        vfmCustom = catalogDbClient.getVfModuleCustomizationByModelCustomizationUUIDAndVfModuleModelUUID(vf.getModelCustomizationUUID(), vfModuleModelUUID);
                        if (vfmCustom != null) {
                            vfModule = vfmCustom.getVfModule();
                        }
                    } else {
                        vfmCustom = catalogDbClient.getVfModuleCustomizationByModelCuztomizationUUID(vf.getModelCustomizationUUID());
                        if (vfmCustom != null) {
                            vfModule = vfmCustom.getVfModule();
                        } else {
                            vfModule = catalogDbClient.getVfModuleByModelInvariantUUIDAndModelVersion(relatedInstanceModelInvariantId, relatedInstanceVersion);
                        }
                    }
                    if (vfModule != null) {
                        modelInfo.setModelCustomizationId(vf.getModelCustomizationUUID());
                        modelInfo.setModelCustomizationUuid(vf.getModelCustomizationUUID());
                        break;
                    }
                }
            }
            if (vfmc == null && vfModule == null) {
                throw new ValidationException("vfModuleCustomization");
            } else if (vfModule == null && vfmc != null) {
                // can't be null as vfModuleModelUUID is not-null property in
                vfModule = vfmc.getVfModule();
            // VfModuleCustomization table
            }
            if (modelInfo.getModelVersionId() == null) {
                modelInfo.setModelVersionId(vfModule.getModelUUID());
            }
            recipe = catalogDbClient.getFirstVnfComponentsRecipeByVfModuleModelUUIDAndVnfComponentTypeAndAction(vfModule.getModelUUID(), vnfComponentType, action.toString());
            if (recipe == null) {
                List<VfModule> vfModuleRecords = catalogDbClient.getVfModuleByModelInvariantUUIDOrderByModelVersionDesc(vfModule.getModelInvariantUUID());
                if (!vfModuleRecords.isEmpty()) {
                    for (VfModule record : vfModuleRecords) {
                        recipe = catalogDbClient.getFirstVnfComponentsRecipeByVfModuleModelUUIDAndVnfComponentTypeAndAction(record.getModelUUID(), vnfComponentType, action.toString());
                        if (recipe != null) {
                            break;
                        }
                    }
                }
            }
            if (recipe == null) {
                recipe = catalogDbClient.getFirstVnfComponentsRecipeByVfModuleModelUUIDAndVnfComponentTypeAndAction(defaultSource, vnfComponentType, action.toString());
                if (recipe == null) {
                    recipe = catalogDbClient.getFirstVnfComponentsRecipeByVnfComponentTypeAndAction(vnfComponentType, action.toString());
                }
                if (recipe == null) {
                    return null;
                }
            }
        }
    } else {
        if (modelInfo.getModelType().equals(ModelType.vnf)) {
            recipe = catalogDbClient.getFirstVnfRecipeByNfRoleAndAction(defaultSource, action.toString());
            if (recipe == null) {
                return null;
            }
        } else {
            recipe = catalogDbClient.getFirstVnfComponentsRecipeByVfModuleModelUUIDAndVnfComponentTypeAndAction(defaultSource, vnfComponentType, action.toString());
            if (recipe == null) {
                return null;
            }
        }
    }
    return new RecipeLookupResult(recipe.getOrchestrationUri(), recipe.getRecipeTimeout());
}
Also used : ModelInfo(org.onap.so.serviceinstancebeans.ModelInfo) ValidationException(org.onap.so.exceptions.ValidationException) RelatedInstanceList(org.onap.so.serviceinstancebeans.RelatedInstanceList) VnfRecipe(org.onap.so.db.catalog.beans.VnfRecipe) ServiceRecipe(org.onap.so.db.catalog.beans.ServiceRecipe) Recipe(org.onap.so.db.catalog.beans.Recipe) RelatedInstance(org.onap.so.serviceinstancebeans.RelatedInstance) VfModule(org.onap.so.db.catalog.beans.VfModule) VnfResource(org.onap.so.db.catalog.beans.VnfResource) VnfRecipe(org.onap.so.db.catalog.beans.VnfRecipe) VfModuleCustomization(org.onap.so.db.catalog.beans.VfModuleCustomization) VnfResourceCustomization(org.onap.so.db.catalog.beans.VnfResourceCustomization)

Aggregations

VnfResource (org.onap.so.db.catalog.beans.VnfResource)21 Test (org.junit.Test)10 VfModule (org.onap.so.db.catalog.beans.VfModule)9 VfModuleCustomization (org.onap.so.db.catalog.beans.VfModuleCustomization)9 ArrayList (java.util.ArrayList)8 VnfResourceCustomization (org.onap.so.db.catalog.beans.VnfResourceCustomization)8 HashMap (java.util.HashMap)5 CatalogDbAdapterBaseTest (org.onap.so.adapters.catalogdb.CatalogDbAdapterBaseTest)5 HeatEnvironment (org.onap.so.db.catalog.beans.HeatEnvironment)5 HeatTemplate (org.onap.so.db.catalog.beans.HeatTemplate)5 CvnfcCustomization (org.onap.so.db.catalog.beans.CvnfcCustomization)4 HeatTemplateParam (org.onap.so.db.catalog.beans.HeatTemplateParam)4 VnfcCustomization (org.onap.so.db.catalog.beans.VnfcCustomization)4 Transactional (org.springframework.transaction.annotation.Transactional)4 JsonParseException (com.fasterxml.jackson.core.JsonParseException)3 VnfException (org.onap.so.adapters.vnf.exceptions.VnfException)3 CloudSite (org.onap.so.db.catalog.beans.CloudSite)3 HeatFiles (org.onap.so.db.catalog.beans.HeatFiles)3 MavenLikeVersioning (org.onap.so.db.catalog.utils.MavenLikeVersioning)3 MsoException (org.onap.so.openstack.exceptions.MsoException)3