Search in sources :

Example 1 with PnfResourceCustomization

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

the class GenericPnfDispatcher method execute.

@Override
public void execute(DelegateExecution delegateExecution) throws Exception {
    logger.debug("Running execute block for activity id: {}, name: {}", delegateExecution.getCurrentActivityId(), delegateExecution.getCurrentActivityName());
    RequestDetails bpmnRequestDetails = requestVerification(delegateExecution);
    final String serviceInstanceName = bpmnRequestDetails.getRequestInfo().getInstanceName();
    final String pnfName;
    if (delegateExecution.getVariable(PNF_NAME) == null || String.valueOf(delegateExecution.getVariable(PNF_NAME)).trim().isEmpty()) {
        pnfName = bpmnRequestDetails.getRequestParameters().getUserParamValue(PNF_NAME);
    } else {
        pnfName = String.valueOf(delegateExecution.getVariable(PNF_NAME));
    }
    final String serviceModelUuid = bpmnRequestDetails.getModelInfo().getModelUuid();
    final List<Map<String, Object>> userParams = bpmnRequestDetails.getRequestParameters().getUserParams();
    final Pnf pnf = getPnfByPnfName(delegateExecution, pnfName);
    final List<PnfResourceCustomization> pnfCustomizations = getPnfResourceCustomizations(delegateExecution, serviceModelUuid);
    final PnfResourceCustomization pnfResourceCustomization = pnfCustomizations.get(0);
    final String payload = bpmnRequestDetails.getRequestParameters().getPayload();
    populateExecution(delegateExecution, bpmnRequestDetails, pnfResourceCustomization, pnf, serviceInstanceName, pnfName, serviceModelUuid, userParams, payload);
    logger.trace("Completed dispatcher request for PNF.");
}
Also used : PnfResourceCustomization(org.onap.so.db.catalog.beans.PnfResourceCustomization) Pnf(org.onap.aai.domain.yang.Pnf) Map(java.util.Map) RequestDetails(org.onap.so.serviceinstancebeans.RequestDetails)

Example 2 with PnfResourceCustomization

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

the class ControllerExecutionBB 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, BuildingBlockExecution</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 BuildingBlockExecution 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 name
 */
@Override
protected String getControllerActor(BuildingBlockExecution 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)) {
        /**
         * For BuildingBlockExecution, we should try to get the resource information from Cached metadata.
         *
         * As the current cached metadata doesn't support controller actor, we use the
         * {@link org.onap.so.db.catalog.client.CatalogDbClient} to fetch information. Once the change is done in
         * cached metadata, this part should be refactored as well.
         */
        if (isPnfResourceScope(controllerScope)) {
            PnfResourceCustomization pnfResourceCustomization = catalogDbClient.getPnfResourceCustomizationByModelCustomizationUUID(resourceCustomizationUuid);
            controllerActor = pnfResourceCustomization.getControllerActor();
        } else if (isServiceResourceScope(controllerScope)) {
            return controllerActor;
        } 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 the return 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)

Example 3 with PnfResourceCustomization

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

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

the class ASDCControllerITTest method treatNotification_ValidPnfResource_ExpectedOutput.

/**
 * Test with service-pnfservice.csar.
 */
@Test
public void treatNotification_ValidPnfResource_ExpectedOutput() {
    /**
     * service UUID/invariantUUID from global metadata in service-PnfServiceTestCds-template.yml.
     */
    String serviceUuid = "77cf276e-905c-43f6-8d54-dda474be2f2e";
    String serviceInvariantUuid = "913e6776-4bc3-49b9-b399-b5bb4690f0c7";
    initMockAaiServer(serviceUuid, serviceInvariantUuid);
    NotificationDataImpl notificationData = new NotificationDataImpl();
    notificationData.setServiceUUID(serviceUuid);
    notificationData.setDistributionID(distributionId);
    notificationData.setServiceInvariantUUID(serviceInvariantUuid);
    notificationData.setServiceVersion("1.0");
    ResourceInfoImpl resourceInfo = constructPnfResourceInfo();
    List<ResourceInfoImpl> resourceInfoList = new ArrayList<>();
    resourceInfoList.add(resourceInfo);
    notificationData.setResources(resourceInfoList);
    ArtifactInfoImpl artifactInfo = constructPnfServiceArtifact();
    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-pnfservice.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-pnfservice.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"));
        assertEquals("model UUID", serviceUuid, service.getModelUUID());
        assertEquals("model name", "PNF Service Test CDS", service.getModelName());
        assertEquals("model invariantUUID", serviceInvariantUuid, service.getModelInvariantUUID());
        assertEquals("model version", "1.0", service.getModelVersion());
        assertEquals("description", "123123", service.getDescription().trim());
        assertEquals("tosca csar artifact UUID", artifactUuid, service.getCsar().getArtifactUUID());
        assertEquals("service type", "", service.getServiceType());
        assertEquals("service role", "", service.getServiceRole());
        assertEquals("environment context", "General_Revenue-Bearing", service.getEnvironmentContext());
        assertEquals("service category", "Network L1-3", service.getCategory());
        assertNull("workload context", service.getWorkloadContext());
        assertEquals("resource order", "PNF CDS Test", service.getResourceOrder());
        assertEquals("CDS blueprint name", "Blueprint140", service.getBlueprintName());
        assertEquals("CDS blueprint version", "v1.4.0", service.getBlueprintVersion());
        assertEquals("controller actor", "SO-REF-DATA", service.getControllerActor());
        /**
         * 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 = "aa5d0562-80e7-43e9-af74-3085e57ab09f";
        PnfResource pnfResource = pnfResourceRepository.findById(pnfResourceKey).orElseThrow(() -> new EntityNotFoundException("PNF resource:" + pnfResourceKey + " not found"));
        assertNull("orchestration mode", pnfResource.getOrchestrationMode());
        assertEquals("Description", "123123", pnfResource.getDescription().trim());
        assertEquals("model UUID", pnfResourceKey, pnfResource.getModelUUID());
        assertEquals("model invariant UUID", "17d9d183-cee5-4a46-b5c4-6d5203f7d2e8", pnfResource.getModelInvariantUUID());
        assertEquals("model version", "1.0", pnfResource.getModelVersion());
        assertEquals("model name", "PNF CDS Test", pnfResource.getModelName());
        assertEquals("tosca node type", "org.openecomp.resource.pnf.PnfCdsTest", pnfResource.getToscaNodeType());
        assertEquals("resource category", "Application L4+", pnfResource.getCategory());
        assertEquals("resource sub category", "Firewall", pnfResource.getSubCategory());
        /**
         * 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
         */
        String pnfCustomizationKey = "9f01263a-eaf7-4d98-a37b-3785f751903e";
        PnfResourceCustomization pnfCustomization = pnfCustomizationRepository.findById(pnfCustomizationKey).orElseThrow(() -> new EntityNotFoundException("PNF resource customization: " + pnfCustomizationKey + " not found"));
        assertEquals("model customizationUUID", pnfCustomizationKey, pnfCustomization.getModelCustomizationUUID());
        assertEquals("model instance name", "PNF CDS Test 0", pnfCustomization.getModelInstanceName());
        assertEquals("NF type", "", pnfCustomization.getNfType());
        assertEquals("NF Role", "nf", pnfCustomization.getNfRole());
        assertEquals("NF function", "nf", 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)", "Blueprint140", pnfCustomization.getBlueprintName());
        assertEquals("cds blueprint version(sdnc_model_version property)", "v1.4.0", pnfCustomization.getBlueprintVersion());
        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) PnfResource(org.onap.so.db.catalog.beans.PnfResource) 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 5 with PnfResourceCustomization

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

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