Search in sources :

Example 16 with PnfResourceCustomization

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

the class ASDCControllerITTest method treatNotification_ValidPnfResource_With_Default_Software_Version_ExpectedOutput.

/**
 * Test with service-Ericservice-csar.csar to test default_software_version field.
 */
@Test
public void treatNotification_ValidPnfResource_With_Default_Software_Version_ExpectedOutput() {
    /**
     * service UUID/invariantUUID from global metadata in service-PnfServiceTestCds-template.yml.
     */
    // "77cf276e-905c-43f6-8d54-dda474be2f2e";
    String serviceUuid = "8e7b2bd7-6901-4cc2-b3fb-3b6a1d5631e3";
    // "913e6776-4bc3-49b9-b399-b5bb4690f0c7";
    String serviceInvariantUuid = "9a5f99c8-0492-4691-b29a-7360d9c3aae3";
    initMockAaiServer(serviceUuid, serviceInvariantUuid);
    NotificationDataImpl notificationData = new NotificationDataImpl();
    notificationData.setServiceUUID(serviceUuid);
    notificationData.setDistributionID(distributionId);
    notificationData.setServiceInvariantUUID(serviceInvariantUuid);
    notificationData.setServiceVersion("1.0");
    ResourceInfoImpl resourceInfo = constructPnfResourceInfoWithSWV();
    List<ResourceInfoImpl> resourceInfoList = new ArrayList<>();
    resourceInfoList.add(resourceInfo);
    notificationData.setResources(resourceInfoList);
    ArtifactInfoImpl artifactInfo = constructPnfServiceArtifactWithSWV();
    List<ArtifactInfoImpl> artifactInfoList = new ArrayList<>();
    artifactInfoList.add(artifactInfo);
    notificationData.setServiceArtifacts(artifactInfoList);
    try {
        asdcController.treatNotification(notificationData);
        logger.info("Checking the database for PNF ingestion");
        /**
         * Check the tosca csar entity, it should be the same as provided from NotficationData.
         */
        ToscaCsar toscaCsar = toscaCsarRepository.findById(artifactUuid).orElseThrow(() -> new EntityNotFoundException("Tosca csar: " + artifactUuid + " not found"));
        assertEquals("tosca csar UUID", artifactUuid, toscaCsar.getArtifactUUID());
        assertEquals("tosca csar name", "service-Ericservice-csar.csar", toscaCsar.getName());
        assertEquals("tosca csar version", "1.0", toscaCsar.getVersion());
        assertNull("tosca csar descrption", toscaCsar.getDescription());
        assertEquals("tosca csar checksum", "MANUAL_RECORD", toscaCsar.getArtifactChecksum());
        assertEquals("toscar csar URL", "/download/service-Ericservice-csar.csar", toscaCsar.getUrl());
        /**
         * Check the service entity, it should be the same as global metadata information in
         * service-Testservice140-template.yml inside csar.
         */
        Service service = serviceRepository.findById(serviceUuid).orElseThrow(() -> new EntityNotFoundException("Service: " + serviceUuid + " not found"));
        /**
         * Check PNF resource, it should be the same as metadata in the topology template in
         * service-PnfServiceTestCds-template.yml OR global metadata in the resource-PnfServiceTestCds-template.yml
         */
        String pnfResourceKey = "7a90f80b-a6f6-4597-8c48-80bda26b4823";
        /**
         * Check PNF resource customization, it should be the same as metadata in the topology template in
         * service-PnfServiceTestCds-template.yml OR global metadata in the resource-PnfServiceTestCds-template.yml
         */
        // "9f01263a-eaf7-4d98-a37b-3785f751903e";
        String pnfCustomizationKey = "c850a53b-b63e-4043-ab10-53aabda78d37";
        PnfResourceCustomization pnfCustomization = pnfCustomizationRepository.findById(pnfCustomizationKey).orElseThrow(() -> new EntityNotFoundException("PNF resource customization: " + pnfCustomizationKey + " not found"));
        assertEquals("model customizationUUID", pnfCustomizationKey, pnfCustomization.getModelCustomizationUUID());
        assertEquals("model instance name", "demo-PNF 1", pnfCustomization.getModelInstanceName());
        assertEquals("NF type", "", pnfCustomization.getNfType());
        assertEquals("NF Role", "", pnfCustomization.getNfRole());
        assertEquals("NF function", "", pnfCustomization.getNfFunction());
        assertEquals("NF naming code", "", pnfCustomization.getNfNamingCode());
        assertEquals("PNF resource model UUID", pnfResourceKey, pnfCustomization.getPnfResources().getModelUUID());
        assertEquals("Multi stage design", "", pnfCustomization.getMultiStageDesign());
        assertNull("resource input", pnfCustomization.getResourceInput());
        assertEquals("cds blueprint name(sdnc_model_name property)", "pm_control", pnfCustomization.getBlueprintName());
        assertEquals("cds blueprint version(sdnc_model_version property)", "1.0.0", pnfCustomization.getBlueprintVersion());
        assertEquals("default software version", "4.0.0", pnfCustomization.getDefaultSoftwareVersion());
        assertTrue("skip post instantiation configuration", pnfCustomization.getSkipPostInstConf());
        assertEquals("controller actor", "SO-REF-DATA", pnfCustomization.getControllerActor());
        /**
         * Check the pnf resource customization with service mapping
         */
        List<PnfResourceCustomization> pnfCustList = service.getPnfCustomizations();
        assertEquals("PNF resource customization entity", 1, pnfCustList.size());
        assertEquals(pnfCustomizationKey, pnfCustList.get(0).getModelCustomizationUUID());
        /**
         * Check the watchdog for component distribution status
         */
        List<WatchdogComponentDistributionStatus> distributionList = watchdogCDStatusRepository.findByDistributionId(this.distributionId);
        assertNotNull(distributionList);
        assertEquals(1, distributionList.size());
        WatchdogComponentDistributionStatus distributionStatus = distributionList.get(0);
        assertEquals("COMPONENT_DONE_OK", distributionStatus.getComponentDistributionStatus());
        assertEquals("SO", distributionStatus.getComponentName());
    } catch (Exception e) {
        logger.info(e.getMessage(), e);
        fail(e.getMessage());
    }
}
Also used : PnfResourceCustomization(org.onap.so.db.catalog.beans.PnfResourceCustomization) ArtifactInfoImpl(org.onap.so.asdc.client.test.emulators.ArtifactInfoImpl) WatchdogComponentDistributionStatus(org.onap.so.db.request.beans.WatchdogComponentDistributionStatus) ResourceInfoImpl(org.onap.so.asdc.client.test.emulators.ResourceInfoImpl) ArrayList(java.util.ArrayList) Service(org.onap.so.db.catalog.beans.Service) EntityNotFoundException(javax.persistence.EntityNotFoundException) EntityNotFoundException(javax.persistence.EntityNotFoundException) ASDCControllerException(org.onap.so.asdc.client.exceptions.ASDCControllerException) NotificationDataImpl(org.onap.so.asdc.client.test.emulators.NotificationDataImpl) ToscaCsar(org.onap.so.db.catalog.beans.ToscaCsar) BaseTest(org.onap.so.asdc.BaseTest) Test(org.junit.Test)

Example 17 with PnfResourceCustomization

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

the class ConfigCheckerDelegateTest method buildPnfResourceCustomization.

private PnfResourceCustomization buildPnfResourceCustomization() {
    PnfResourceCustomization pnfResourceCustomization = new PnfResourceCustomization();
    pnfResourceCustomization.setSkipPostInstConf(true);
    pnfResourceCustomization.setBlueprintName(TEST_PNF_RESOURCE_BLUEPRINT_NAME);
    pnfResourceCustomization.setBlueprintVersion(TEST_PNF_RESOURCE_BLUEPRINT_VERSION);
    pnfResourceCustomization.setModelInstanceName(TEST_PNF_RESOURCE_INSTANCE_NAME);
    pnfResourceCustomization.setModelCustomizationUUID(TEST_PNF_RESOURCE_CUSTOMIZATION_UUID);
    return pnfResourceCustomization;
}
Also used : PnfResourceCustomization(org.onap.so.db.catalog.beans.PnfResourceCustomization)

Example 18 with PnfResourceCustomization

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

the class ControllerExecution method setControllerActorScopeAction.

/**
 * Setting Controller Actor, Scope and Action Variables in BuildingBlockExecution object
 *
 * @param execution - BuildingBlockExecution object
 */
public void setControllerActorScopeAction(BuildingBlockExecution execution) {
    ExecuteBuildingBlock executeBuildingBlock = execution.getVariable(BUILDING_BLOCK);
    BuildingBlock buildingBlock = executeBuildingBlock.getBuildingBlock();
    String scope = Optional.ofNullable(buildingBlock.getBpmnScope()).orElseThrow(() -> new NullPointerException("BPMN Scope is NULL in the orchestration_flow_reference table "));
    String action = Optional.ofNullable(buildingBlock.getBpmnAction()).orElseThrow(() -> new NullPointerException("BPMN Action is NULL in the orchestration_flow_reference table "));
    String controllerActor;
    try {
        if (String.valueOf(scope).equals("pnf")) {
            Pnf pnf = getPnf(execution);
            String pnfModelUUID = pnf.getModelInfoPnf().getModelCustomizationUuid();
            PnfResourceCustomization pnfResourceCustomization = catalogDbClient.getPnfResourceCustomizationByModelCustomizationUUID(pnfModelUUID);
            controllerActor = Optional.ofNullable(pnfResourceCustomization.getControllerActor()).orElse("APPC");
            execution.setVariable(MSO_REQUEST_ID, execution.getGeneralBuildingBlock().getRequestContext().getMsoRequestId());
            execution.setVariable(PRC_BLUEPRINT_VERSION, pnfResourceCustomization.getBlueprintVersion());
            execution.setVariable(PRC_BLUEPRINT_NAME, pnfResourceCustomization.getBlueprintName());
        } else if ("service".equalsIgnoreCase(scope)) {
            GeneralBuildingBlock gbb = execution.getGeneralBuildingBlock();
            ModelInfoServiceInstance modelInfoServiceInstance = gbb.getServiceInstance().getModelInfoServiceInstance();
            controllerActor = Optional.ofNullable(modelInfoServiceInstance.getControllerActor()).orElse("CDS");
        } else {
            GenericVnf genericVnf = getGenericVnf(execution);
            String modelUuid = genericVnf.getModelInfoGenericVnf().getModelCustomizationUuid();
            VnfResourceCustomization vnfResourceCustomization = catalogDbClient.getVnfResourceCustomizationByModelCustomizationUUID(modelUuid);
            controllerActor = Optional.ofNullable(vnfResourceCustomization.getControllerActor()).orElse("APPC");
        }
        execution.setVariable(SCOPE, scope);
        execution.setVariable(ACTION, action);
        execution.setVariable(CONTROLLER_ACTOR, controllerActor);
        logger.debug("Executing Controller Execution for ControllerActor: {}, Scope: {} , Action: {}", controllerActor, scope, action);
    } catch (Exception ex) {
        logger.error("An exception occurred while fetching Controller Actor,Scope and Action ", ex);
        exceptionUtil.buildAndThrowWorkflowException(execution, 7000, ex);
    }
}
Also used : PnfResourceCustomization(org.onap.so.db.catalog.beans.PnfResourceCustomization) ExecuteBuildingBlock(org.onap.so.bpmn.servicedecomposition.entities.ExecuteBuildingBlock) GeneralBuildingBlock(org.onap.so.bpmn.servicedecomposition.entities.GeneralBuildingBlock) BuildingBlock(org.onap.so.bpmn.servicedecomposition.entities.BuildingBlock) ExecuteBuildingBlock(org.onap.so.bpmn.servicedecomposition.entities.ExecuteBuildingBlock) GeneralBuildingBlock(org.onap.so.bpmn.servicedecomposition.entities.GeneralBuildingBlock) GenericVnf(org.onap.so.bpmn.servicedecomposition.bbobjects.GenericVnf) Pnf(org.onap.so.bpmn.servicedecomposition.bbobjects.Pnf) VnfResourceCustomization(org.onap.so.db.catalog.beans.VnfResourceCustomization) BBObjectNotFoundException(org.onap.so.client.exception.BBObjectNotFoundException) ModelInfoServiceInstance(org.onap.so.bpmn.servicedecomposition.modelinfo.ModelInfoServiceInstance)

Example 19 with PnfResourceCustomization

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

the class ControllerExecutionDE method getControllerActor.

/**
 * this method is used to get the controller actor, there could be few places to get the actor(ordered by priority),
 *
 * <ol>
 * <li>Execution Context, i.e, DelegateExecution</li>
 * <li>Resource customization table, pnf_resource_customization for PNF or vnf_resource_customization for VNF</li>
 * <li>controller_selection_reference, resource_type and action will be used to fetch from this table</li>
 * </ol>
 *
 * @param execution DelegateExecution instance
 * @param controllerScope controller scope, e.g, pnf, vnf, vfModule
 * @param resourceCustomizationUuid resource customization UUID, e.g, pnfCustomizationUuid, vnfCustomizationUuid
 * @param controllerAction controller action, e.g, configAssign, configDeploy
 * @return controller actor
 */
protected String getControllerActor(DelegateExecution execution, String controllerScope, String resourceCustomizationUuid, String controllerAction) {
    /**
     * Firstly, check the execution context for actor parameter.
     */
    String controllerActor = getParameterFromExecution(execution, CONTROLLER_ACTOR_PARAM);
    /**
     * If no meaningful controller actor value found in the execution context and the value is not SO-REF-DATA.
     */
    if (Strings.isNullOrEmpty(controllerActor) && !isSoRefControllerActor(controllerActor)) {
        /**
         * secondly, if no meaningful actor from execution context, getting from resource table in database.
         */
        if (isPnfResourceScope(controllerScope)) {
            PnfResourceCustomization pnfResourceCustomization = catalogDbClient.getPnfResourceCustomizationByModelCustomizationUUID(resourceCustomizationUuid);
            controllerActor = pnfResourceCustomization.getControllerActor();
        } else if (isVnfResourceScope(controllerScope)) {
            VnfResourceCustomization vnfResourceCustomization = catalogDbClient.getVnfResourceCustomizationByModelCustomizationUUID(resourceCustomizationUuid);
            controllerActor = vnfResourceCustomization.getControllerActor();
        } else {
            logger.warn("Unrecognized scope: {}", controllerScope);
        }
    }
    /**
     * Lastly, can NOT find the controller actor information from resource customization table or value is
     * SO-REF-DATA
     */
    if (Strings.isNullOrEmpty(controllerActor) || isSoRefControllerActor(controllerActor)) {
        String resourceType = getParameterFromExecution(execution, RESOURCE_TYPE_PARAM);
        ControllerSelectionReference reference = catalogDbClient.getControllerSelectionReferenceByVnfTypeAndActionCategory(resourceType, controllerAction);
        controllerActor = reference.getControllerName();
    }
    return controllerActor;
}
Also used : PnfResourceCustomization(org.onap.so.db.catalog.beans.PnfResourceCustomization) ControllerSelectionReference(org.onap.so.db.catalog.beans.ControllerSelectionReference) VnfResourceCustomization(org.onap.so.db.catalog.beans.VnfResourceCustomization)

Aggregations

PnfResourceCustomization (org.onap.so.db.catalog.beans.PnfResourceCustomization)19 Test (org.junit.Test)7 VnfResourceCustomization (org.onap.so.db.catalog.beans.VnfResourceCustomization)5 ArrayList (java.util.ArrayList)4 PnfResource (org.onap.so.db.catalog.beans.PnfResource)4 Service (org.onap.so.db.catalog.beans.Service)4 EntityNotFoundException (javax.persistence.EntityNotFoundException)3 CatalogDbAdapterBaseTest (org.onap.so.adapters.catalogdb.CatalogDbAdapterBaseTest)3 BaseTest (org.onap.so.asdc.BaseTest)3 ASDCControllerException (org.onap.so.asdc.client.exceptions.ASDCControllerException)3 ArtifactInfoImpl (org.onap.so.asdc.client.test.emulators.ArtifactInfoImpl)3 NotificationDataImpl (org.onap.so.asdc.client.test.emulators.NotificationDataImpl)3 ResourceInfoImpl (org.onap.so.asdc.client.test.emulators.ResourceInfoImpl)3 ToscaCsar (org.onap.so.db.catalog.beans.ToscaCsar)3 WatchdogComponentDistributionStatus (org.onap.so.db.request.beans.WatchdogComponentDistributionStatus)3 Map (java.util.Map)2 Pnf (org.onap.aai.domain.yang.Pnf)2 Metadata (org.onap.sdc.toscaparser.api.elements.Metadata)2 Resource (org.onap.so.bpmn.infrastructure.workflow.tasks.Resource)2 BuildingBlock (org.onap.so.bpmn.servicedecomposition.entities.BuildingBlock)2