Search in sources :

Example 1 with GenericVnf

use of org.onap.aai.domain.yang.GenericVnf in project so by onap.

the class MonitorVnfmNodeTask method getNodeStatus.

/**
 * Check the final status of vnf in A&AI
 *
 * @param execution {@link org.onap.so.bpmn.common.DelegateExecutionImpl}
 */
public void getNodeStatus(final BuildingBlockExecution execution) {
    try {
        LOGGER.debug("Executing getNodeStatus  ...");
        final org.onap.so.bpmn.servicedecomposition.bbobjects.GenericVnf vnf = extractPojosForBB.extractByKey(execution, GENERIC_VNF_ID);
        final String vnfId = vnf.getVnfId();
        LOGGER.debug("Query A&AI for generic VNF using vnfID: {}", vnfId);
        final Optional<GenericVnf> aaiGenericVnfOptional = aaiVnfResources.getGenericVnf(vnfId);
        if (!aaiGenericVnfOptional.isPresent()) {
            throw new GenericVnfNotFoundException("Unable to find generic vnf in A&AI using vnfID: " + vnfId);
        }
        final GenericVnf genericVnf = aaiGenericVnfOptional.get();
        final String orchestrationStatus = genericVnf.getOrchestrationStatus();
        LOGGER.debug("Found generic vnf with orchestration status : {}", orchestrationStatus);
        execution.setVariable(getNodeStatusVariableName(), isOrchestrationStatusValid(orchestrationStatus));
    } catch (final Exception exception) {
        LOGGER.error("Unable to get vnf from AAI", exception);
        exceptionUtil.buildAndThrowWorkflowException(execution, 1220, exception);
    }
}
Also used : GenericVnf(org.onap.aai.domain.yang.GenericVnf) GenericVnfNotFoundException(org.onap.so.bpmn.infrastructure.adapter.vnfm.tasks.exception.GenericVnfNotFoundException) GenericVnfNotFoundException(org.onap.so.bpmn.infrastructure.adapter.vnfm.tasks.exception.GenericVnfNotFoundException)

Example 2 with GenericVnf

use of org.onap.aai.domain.yang.GenericVnf in project so by onap.

the class BpmnRequestBuilder method buildVFModuleDeleteRequest.

public ServiceInstancesRequest buildVFModuleDeleteRequest(String vnfId, String vfModuleId, ModelType modelType) throws AAIEntityNotFound {
    GenericVnf vnf = aaiDataRet.getGenericVnf(vnfId);
    if (vnf == null) {
        throw new AAIEntityNotFound(GENERIC_VNF_NOT_FOUND_IN_INVENTORY_VNF_ID + vnfId);
    }
    VfModule vfModule = aaiDataRet.getAAIVfModule(vnfId, vfModuleId);
    if (vfModule == null) {
        throw new AAIEntityNotFound(VF_MODULE_NOT_FOUND_IN_INVENTORY_VNF_ID + vnfId + " vfModuleId: " + vfModuleId);
    }
    return createServiceInstancesRequest(vnf, vfModule, modelType);
}
Also used : GenericVnf(org.onap.aai.domain.yang.GenericVnf) AAIEntityNotFound(org.onap.so.apihandlerinfra.infra.rest.exception.AAIEntityNotFound) VfModule(org.onap.aai.domain.yang.VfModule)

Example 3 with GenericVnf

use of org.onap.aai.domain.yang.GenericVnf in project so by onap.

the class BpmnRequestBuilder method buildVolumeGroupDeleteRequest.

public ServiceInstancesRequest buildVolumeGroupDeleteRequest(String vnfId, String volumeGroupId) throws AAIEntityNotFound {
    GenericVnf vnf = aaiDataRet.getGenericVnf(vnfId);
    if (vnf == null) {
        throw new AAIEntityNotFound(GENERIC_VNF_NOT_FOUND_IN_INVENTORY_VNF_ID + vnfId);
    }
    VolumeGroup volumeGroup = aaiDataRet.getVolumeGroup(vnfId, volumeGroupId);
    if (volumeGroup == null) {
        throw new AAIEntityNotFound(VF_MODULE_NOT_FOUND_IN_INVENTORY_VNF_ID + vnfId + " volumeGroupId: " + volumeGroupId);
    }
    return createServiceInstancesRequest(vnf, volumeGroup);
}
Also used : GenericVnf(org.onap.aai.domain.yang.GenericVnf) VolumeGroup(org.onap.aai.domain.yang.VolumeGroup) AAIEntityNotFound(org.onap.so.apihandlerinfra.infra.rest.exception.AAIEntityNotFound)

Example 4 with GenericVnf

use of org.onap.aai.domain.yang.GenericVnf in project so by onap.

the class AaiResourceIdValidator method validateVnfResourceIdInAAI.

protected String validateVnfResourceIdInAAI(String generatedResourceId, String instanceName, RequestDetails reqDetails, WorkflowResourceIds workflowResourceIds) throws DuplicateNameException {
    Optional<GenericVnf> vnf = bbInputSetupUtils.getRelatedVnfByNameFromServiceInstance(workflowResourceIds.getServiceInstanceId(), instanceName);
    if (vnf.isPresent()) {
        if (vnf.get().getModelCustomizationId().equalsIgnoreCase(reqDetails.getModelInfo().getModelCustomizationId())) {
            return vnf.get().getVnfId();
        } else {
            throw new DuplicateNameException("generic-vnf", String.format(NAME_EXISTS_WITH_DIFF_CUSTOMIZATION_ID, instanceName, vnf.get().getModelCustomizationId()));
        }
    }
    GenericVnfs vnfs = bbInputSetupUtils.getAAIVnfsGloballyByName(instanceName);
    if (vnfs != null) {
        throw new DuplicateNameException("generic-vnf", String.format(NAME_EXISTS_WITH_DIFF_PARENT, instanceName, vnfs.getGenericVnf().get(0).getVnfId()));
    }
    return generatedResourceId;
}
Also used : GenericVnf(org.onap.aai.domain.yang.GenericVnf) DuplicateNameException(org.onap.so.bpmn.servicedecomposition.tasks.exceptions.DuplicateNameException) GenericVnfs(org.onap.aai.domain.yang.GenericVnfs)

Example 5 with GenericVnf

use of org.onap.aai.domain.yang.GenericVnf in project so by onap.

the class ServiceEBBLoader method traverseServiceInstanceMSOVnfs.

private void traverseServiceInstanceMSOVnfs(List<Resource> resourceList, Resource serviceResource, List<Pair<WorkflowType, String>> aaiResourceIds, org.onap.so.bpmn.servicedecomposition.bbobjects.ServiceInstance serviceInstanceMSO) {
    if (serviceInstanceMSO.getVnfs() == null) {
        return;
    }
    for (org.onap.so.bpmn.servicedecomposition.bbobjects.GenericVnf vnf : serviceInstanceMSO.getVnfs()) {
        aaiResourceIds.add(new Pair<>(WorkflowType.VNF, vnf.getVnfId()));
        GenericVnf genericVnf = bbInputSetupUtils.getAAIGenericVnf(vnf.getVnfId());
        Resource vnfResource = new Resource(WorkflowType.VNF, vnf.getVnfId(), false, serviceResource);
        vnfResource.setVnfCustomizationId(genericVnf.getModelCustomizationId());
        vnfResource.setModelCustomizationId(genericVnf.getModelCustomizationId());
        vnfResource.setModelVersionId(genericVnf.getModelVersionId());
        resourceList.add(vnfResource);
        traverseVnfModules(resourceList, vnfResource, aaiResourceIds, vnf);
        if (vnf.getVolumeGroups() != null) {
            for (org.onap.so.bpmn.servicedecomposition.bbobjects.VolumeGroup volumeGroup : vnf.getVolumeGroups()) {
                aaiResourceIds.add(new Pair<>(WorkflowType.VOLUMEGROUP, volumeGroup.getVolumeGroupId()));
                resourceList.add(new Resource(WorkflowType.VOLUMEGROUP, volumeGroup.getVolumeGroupId(), false, vnfResource));
            }
        }
    }
}
Also used : GenericVnf(org.onap.aai.domain.yang.GenericVnf) Resource(org.onap.so.bpmn.infrastructure.workflow.tasks.Resource)

Aggregations

GenericVnf (org.onap.aai.domain.yang.GenericVnf)49 Test (org.junit.Test)36 RequestDetails (org.onap.so.serviceinstancebeans.RequestDetails)15 WorkflowResourceIds (org.onap.so.bpmn.servicedecomposition.entities.WorkflowResourceIds)11 File (java.io.File)9 GenericVnfs (org.onap.aai.domain.yang.GenericVnfs)9 BuildingBlock (org.onap.so.bpmn.servicedecomposition.entities.BuildingBlock)9 ExecuteBuildingBlock (org.onap.so.bpmn.servicedecomposition.entities.ExecuteBuildingBlock)9 VfModule (org.onap.aai.domain.yang.VfModule)8 BaseTaskTest (org.onap.so.bpmn.BaseTaskTest)8 AAIPluralResourceUri (org.onap.aaiclient.client.aai.entities.uri.AAIPluralResourceUri)7 ArrayList (java.util.ArrayList)6 RestClient (org.onap.so.client.RestClient)6 CoreMatchers.containsString (org.hamcrest.CoreMatchers.containsString)5 ArgumentMatchers.anyString (org.mockito.ArgumentMatchers.anyString)5 GeneralBuildingBlock (org.onap.so.bpmn.servicedecomposition.entities.GeneralBuildingBlock)4 ResourceKey (org.onap.so.bpmn.servicedecomposition.entities.ResourceKey)4 List (java.util.List)3 DelegateExecution (org.camunda.bpm.engine.delegate.DelegateExecution)3 ServiceInstance (org.onap.aai.domain.yang.ServiceInstance)3