Search in sources :

Example 76 with VfModule

use of org.onap.so.bpmn.servicedecomposition.bbobjects.VfModule in project so by onap.

the class VnfAdapterCreateTasksTest method test_createVolumeGroupRequest_for_alaCarte_flow.

@Test
public void test_createVolumeGroupRequest_for_alaCarte_flow() throws Exception {
    RequestContext requestContext = setRequestContext();
    ServiceInstance serviceInstance = setServiceInstance();
    GenericVnf genericVnf = setGenericVnf();
    VolumeGroup volumeGroup = setVolumeGroup();
    volumeGroup.setOrchestrationStatus(OrchestrationStatus.ASSIGNED);
    VfModule vfModule = setVfModule();
    vfModule.setSelflink("vfModuleSelfLink");
    CloudRegion cloudRegion = setCloudRegion();
    OrchestrationContext orchestrationContext = setOrchestrationContext();
    orchestrationContext.setIsRollbackEnabled(true);
    CreateVolumeGroupRequest request = new CreateVolumeGroupRequest();
    request.setVolumeGroupId("volumeGroupStackId");
    when(extractPojosForBB.extractByKey(any(), ArgumentMatchers.eq(ResourceKey.GENERIC_VNF_ID))).thenReturn(genericVnf);
    when(extractPojosForBB.extractByKey(any(), ArgumentMatchers.eq(ResourceKey.VOLUME_GROUP_ID))).thenReturn(volumeGroup);
    when(extractPojosForBB.extractByKey(any(), ArgumentMatchers.eq(ResourceKey.VF_MODULE_ID))).thenReturn(vfModule);
    doReturn(request).when(vnfAdapterVolumeGroupResources).createVolumeGroupRequest(requestContext, cloudRegion, orchestrationContext, serviceInstance, genericVnf, volumeGroup, null);
    vnfAdapterCreateTasks.createVolumeGroupRequest(execution);
    verify(vnfAdapterVolumeGroupResources, times(1)).createVolumeGroupRequest(any(RequestContext.class), any(CloudRegion.class), any(OrchestrationContext.class), eq(serviceInstance), eq(genericVnf), eq(volumeGroup), ArgumentMatchers.isNull());
    assertEquals(request.toXmlString(), execution.getVariable("VNFREST_Request"));
}
Also used : CloudRegion(org.onap.so.bpmn.servicedecomposition.bbobjects.CloudRegion) CreateVolumeGroupRequest(org.onap.so.adapters.vnfrest.CreateVolumeGroupRequest) GenericVnf(org.onap.so.bpmn.servicedecomposition.bbobjects.GenericVnf) VolumeGroup(org.onap.so.bpmn.servicedecomposition.bbobjects.VolumeGroup) ServiceInstance(org.onap.so.bpmn.servicedecomposition.bbobjects.ServiceInstance) RequestContext(org.onap.so.bpmn.servicedecomposition.generalobjects.RequestContext) VfModule(org.onap.so.bpmn.servicedecomposition.bbobjects.VfModule) OrchestrationContext(org.onap.so.bpmn.servicedecomposition.generalobjects.OrchestrationContext) Test(org.junit.Test)

Example 77 with VfModule

use of org.onap.so.bpmn.servicedecomposition.bbobjects.VfModule in project so by onap.

the class VnfAdapterCreateTasksTest method test_createVfModuleWithVolumeGroup.

@Test
public void test_createVfModuleWithVolumeGroup() throws Exception {
    RequestContext requestContext = setRequestContext();
    ServiceInstance serviceInstance = setServiceInstance();
    GenericVnf genericVnf = setGenericVnf();
    VfModule vfModule = setVfModule();
    VolumeGroup volumeGroup = setVolumeGroup();
    CloudRegion cloudRegion = setCloudRegion();
    OrchestrationContext orchestrationContext = setOrchestrationContext();
    orchestrationContext.setIsRollbackEnabled(true);
    CreateVfModuleRequest modRequest = new CreateVfModuleRequest();
    modRequest.setVfModuleId(vfModule.getVfModuleId());
    modRequest.setBaseVfModuleStackId("baseVfModuleStackId");
    modRequest.setVfModuleName(vfModule.getVfModuleName());
    CreateVfModuleRequest createVfModuleRequest = modRequest;
    String sdncVfModuleQueryResponse = "{someJson}";
    execution.setVariable("SDNCQueryResponse_" + vfModule.getVfModuleId(), sdncVfModuleQueryResponse);
    String sdncVnfQueryResponse = "{someJson}";
    execution.setVariable("SDNCQueryResponse_" + genericVnf.getVnfId(), sdncVnfQueryResponse);
    when(extractPojosForBB.extractByKey(any(), ArgumentMatchers.eq(ResourceKey.GENERIC_VNF_ID))).thenReturn(genericVnf);
    when(extractPojosForBB.extractByKey(any(), ArgumentMatchers.eq(ResourceKey.VOLUME_GROUP_ID))).thenReturn(volumeGroup);
    when(extractPojosForBB.extractByKey(any(), ArgumentMatchers.eq(ResourceKey.VF_MODULE_ID))).thenReturn(vfModule);
    doReturn(createVfModuleRequest).when(vnfAdapterVfModuleResources).createVfModuleRequest(requestContext, cloudRegion, orchestrationContext, serviceInstance, genericVnf, vfModule, volumeGroup, sdncVnfQueryResponse, sdncVfModuleQueryResponse);
    vnfAdapterCreateTasks.createVfModule(execution);
    verify(vnfAdapterVfModuleResources, times(1)).createVfModuleRequest(requestContext, cloudRegion, orchestrationContext, serviceInstance, genericVnf, vfModule, volumeGroup, sdncVnfQueryResponse, sdncVfModuleQueryResponse);
    assertEquals(execution.getVariable("VNFREST_Request"), createVfModuleRequest.toXmlString());
}
Also used : CloudRegion(org.onap.so.bpmn.servicedecomposition.bbobjects.CloudRegion) CreateVfModuleRequest(org.onap.so.adapters.vnfrest.CreateVfModuleRequest) GenericVnf(org.onap.so.bpmn.servicedecomposition.bbobjects.GenericVnf) VolumeGroup(org.onap.so.bpmn.servicedecomposition.bbobjects.VolumeGroup) ServiceInstance(org.onap.so.bpmn.servicedecomposition.bbobjects.ServiceInstance) RequestContext(org.onap.so.bpmn.servicedecomposition.generalobjects.RequestContext) VfModule(org.onap.so.bpmn.servicedecomposition.bbobjects.VfModule) OrchestrationContext(org.onap.so.bpmn.servicedecomposition.generalobjects.OrchestrationContext) Test(org.junit.Test)

Example 78 with VfModule

use of org.onap.so.bpmn.servicedecomposition.bbobjects.VfModule in project so by onap.

the class ExceptionBuilder method processAuditException.

public void processAuditException(DelegateExecutionImpl execution, boolean flowShouldContinue) {
    logger.debug("Processing Audit Results");
    String auditListString = execution.getVariable("auditInventoryResult");
    String processKey = getProcessKey(execution.getDelegateExecution());
    if (auditListString != null) {
        StringBuilder errorMessage = new StringBuilder();
        try {
            ExtractPojosForBB extractPojosForBB = getExtractPojosForBB();
            VfModule module = extractPojosForBB.extractByKey(execution, ResourceKey.VF_MODULE_ID);
            String cloudRegionId = execution.getGeneralBuildingBlock().getCloudRegion().getLcpCloudRegionId();
            GraphInventoryCommonObjectMapperProvider objectMapper = new GraphInventoryCommonObjectMapperProvider();
            AAIObjectAuditList auditList = objectMapper.getMapper().readValue(auditListString, AAIObjectAuditList.class);
            errorMessage = errorMessage.append(auditList.getAuditType() + " VF-Module " + module.getVfModuleId() + " failed due to incomplete AAI vserver inventory population after stack " + auditList.getHeatStackName() + " was successfully " + auditList.getAuditType() + "d in cloud region " + cloudRegionId + ". MSO Audit indicates that the following was not " + auditList.getAuditType() + "d in AAI: ");
            Stream<AAIObjectAudit> vServerLInterfaceAuditStream = auditList.getAuditList().stream().filter(auditObject -> auditObject.getAaiObjectType().equals(Types.VSERVER.typeName()) || auditObject.getAaiObjectType().equals(Types.L_INTERFACE.typeName()));
            List<AAIObjectAudit> filteredAuditStream = vServerLInterfaceAuditStream.filter(a -> !a.isDoesObjectExist()).collect(Collectors.toList());
            for (AAIObjectAudit object : filteredAuditStream) {
                if (object.getAaiObjectType().equals(Types.L_INTERFACE.typeName())) {
                    LInterface li = objectMapper.getMapper().convertValue(object.getAaiObject(), LInterface.class);
                    errorMessage = errorMessage.append(Types.L_INTERFACE.typeName() + " " + li.getInterfaceId() + ", ");
                } else {
                    Vserver vs = objectMapper.getMapper().convertValue(object.getAaiObject(), Vserver.class);
                    errorMessage = errorMessage.append(Types.VSERVER.typeName() + " " + vs.getVserverId() + ", ");
                }
            }
            if (errorMessage.length() > 0) {
                errorMessage.setLength(errorMessage.length() - 2);
                errorMessage = errorMessage.append(".");
            }
        } catch (IOException | BBObjectNotFoundException e) {
            errorMessage = errorMessage.append("process objects in AAI. ");
            logger.error("Exception occurred in processAuditException", e);
        }
        if (flowShouldContinue) {
            execution.setVariable("StatusMessage", errorMessage.toString());
        } else {
            WorkflowException exception = new WorkflowException(processKey, 400, errorMessage.toString(), ONAPComponents.SO);
            execution.setVariable("WorkflowException", exception);
            execution.setVariable("WorkflowExceptionErrorMessage", errorMessage.toString());
            logger.info("Outgoing WorkflowException is {}", exception);
            logger.info("Throwing AAIInventoryFailure");
            throw new BpmnError("AAIInventoryFailure");
        }
    } else {
        String errorMessage = "Unable to process audit results due to auditInventoryResult being null";
        WorkflowException exception = new WorkflowException(processKey, 400, errorMessage, ONAPComponents.SO);
        execution.setVariable("WorkflowException", exception);
        execution.setVariable("WorkflowExceptionErrorMessage", errorMessage);
        logger.info("Outgoing WorkflowException is {}", exception);
        logger.info("Throwing AAIInventoryFailure");
        throw new BpmnError("AAIInventoryFailure");
    }
}
Also used : ONAPComponents(org.onap.logging.filter.base.ONAPComponents) Types(org.onap.aaiclient.client.generated.fluentbuilders.AAIFluentTypeBuilder.Types) LoggerFactory(org.slf4j.LoggerFactory) WorkflowException(org.onap.so.bpmn.core.WorkflowException) BpmnError(org.camunda.bpm.engine.delegate.BpmnError) MessageEnum(org.onap.so.logger.MessageEnum) DelegateExecutionImpl(org.onap.so.bpmn.common.DelegateExecutionImpl) ResourceKey(org.onap.so.bpmn.servicedecomposition.entities.ResourceKey) LInterface(org.onap.aai.domain.yang.LInterface) ExtractPojosForBB(org.onap.so.bpmn.servicedecomposition.tasks.ExtractPojosForBB) ErrorCode(org.onap.logging.filter.base.ErrorCode) Logger(org.slf4j.Logger) VfModule(org.onap.so.bpmn.servicedecomposition.bbobjects.VfModule) DelegateExecution(org.camunda.bpm.engine.delegate.DelegateExecution) IOException(java.io.IOException) Collectors(java.util.stream.Collectors) ONAPComponentsList(org.onap.logging.filter.base.ONAPComponentsList) AAIObjectAudit(org.onap.so.objects.audit.AAIObjectAudit) List(java.util.List) Component(org.springframework.stereotype.Component) Stream(java.util.stream.Stream) Vserver(org.onap.aai.domain.yang.Vserver) GraphInventoryCommonObjectMapperProvider(org.onap.aaiclient.client.graphinventory.GraphInventoryCommonObjectMapperProvider) BuildingBlockExecution(org.onap.so.bpmn.common.BuildingBlockExecution) LoggingAnchor(org.onap.so.logger.LoggingAnchor) AAIObjectAuditList(org.onap.so.objects.audit.AAIObjectAuditList) Components(org.onap.so.utils.Components) Vserver(org.onap.aai.domain.yang.Vserver) WorkflowException(org.onap.so.bpmn.core.WorkflowException) IOException(java.io.IOException) AAIObjectAudit(org.onap.so.objects.audit.AAIObjectAudit) VfModule(org.onap.so.bpmn.servicedecomposition.bbobjects.VfModule) AAIObjectAuditList(org.onap.so.objects.audit.AAIObjectAuditList) ExtractPojosForBB(org.onap.so.bpmn.servicedecomposition.tasks.ExtractPojosForBB) LInterface(org.onap.aai.domain.yang.LInterface) GraphInventoryCommonObjectMapperProvider(org.onap.aaiclient.client.graphinventory.GraphInventoryCommonObjectMapperProvider) BpmnError(org.camunda.bpm.engine.delegate.BpmnError)

Example 79 with VfModule

use of org.onap.so.bpmn.servicedecomposition.bbobjects.VfModule in project so by onap.

the class CreateVFModule method createInventoryVariable.

public void createInventoryVariable(BuildingBlockExecution execution) {
    try {
        GeneralBuildingBlock gBBInput = execution.getGeneralBuildingBlock();
        VfModule vfModule = extractPojosForBB.extractByKey(execution, ResourceKey.VF_MODULE_ID);
        GenericVnf vnf = extractPojosForBB.extractByKey(execution, ResourceKey.GENERIC_VNF_ID);
        CloudInformation cloudInformation = new CloudInformation();
        cloudInformation.setOwner(gBBInput.getCloudRegion().getCloudOwner());
        cloudInformation.setRegionId(gBBInput.getCloudRegion().getLcpCloudRegionId());
        String tenantId = gBBInput.getTenant().getTenantId();
        if (tenantId == null) {
            tenantId = gBBInput.getCloudRegion().getTenantId();
        }
        cloudInformation.setTenantId(tenantId);
        cloudInformation.setTenantName(gBBInput.getTenant().getTenantName());
        cloudInformation.setTenantContext(gBBInput.getTenant().getTenantContext());
        cloudInformation.setTemplateInstanceId(execution.getVariable("heatStackId"));
        cloudInformation.setNodeType(getNodeType(gBBInput.getCloudRegion()));
        cloudInformation.setVnfName(vnf.getVnfName());
        cloudInformation.setVnfId(vnf.getVnfId());
        cloudInformation.setVfModuleId(vfModule.getVfModuleId());
        execution.setVariable("cloudInformation", cloudInformation);
    } catch (Exception e) {
        logger.error("Error building CloudInformation Object for NC Inventory", e);
        exceptionUtil.buildAndThrowWorkflowException(execution, 7000, e);
    }
}
Also used : GeneralBuildingBlock(org.onap.so.bpmn.servicedecomposition.entities.GeneralBuildingBlock) GenericVnf(org.onap.so.bpmn.servicedecomposition.bbobjects.GenericVnf) CloudInformation(org.onap.so.cloud.resource.beans.CloudInformation) VfModule(org.onap.so.bpmn.servicedecomposition.bbobjects.VfModule)

Example 80 with VfModule

use of org.onap.so.bpmn.servicedecomposition.bbobjects.VfModule in project so by onap.

the class SDNCQueryTasks method queryVfModule.

/**
 * BPMN access method to query the SDNC for fetching the VfModule details.
 *
 * It will get the vnf details according to service instance id, vnf id & Vf module id.
 *
 * @param execution
 * @throws Exception
 */
public void queryVfModule(BuildingBlockExecution execution) throws BBObjectNotFoundException {
    ServiceInstance serviceInstance = extractPojosForBB.extractByKey(execution, ResourceKey.SERVICE_INSTANCE_ID);
    GenericVnf genericVnf = extractPojosForBB.extractByKey(execution, ResourceKey.GENERIC_VNF_ID);
    VfModule vfModule = extractPojosForBB.extractByKey(execution, ResourceKey.VF_MODULE_ID);
    String selfLink = "restconf/config/GENERIC-RESOURCE-API:services/service/" + serviceInstance.getServiceInstanceId() + "/service-data/vnfs/vnf/" + genericVnf.getVnfId() + "/vnf-data/vf-modules/vf-module/" + vfModule.getVfModuleId() + "/vf-module-data/vf-module-topology/";
    try {
        if (vfModule.getSelflink() == null || (vfModule.getSelflink() != null && vfModule.getSelflink().isEmpty())) {
            vfModule.setSelflink(selfLink);
        }
        if (vfModule.getSelflink() != null && !vfModule.getSelflink().isEmpty()) {
            String response = sdncVfModuleResources.queryVfModule(vfModule);
            execution.setVariable(SDNCQUERY_RESPONSE + vfModule.getVfModuleId(), response);
        } else {
            throw new Exception("Vf Module " + vfModule.getVfModuleId() + " exists in gBuildingBlock but does not have a selflink value");
        }
    } catch (BadResponseException ex) {
        logger.error("Exception occurred for BadResponse ", ex);
        if (!ex.getMessage().equals(NO_RESPONSE_FROM_SDNC)) {
            exceptionUtil.buildAndThrowWorkflowException(execution, 7000, ex, ONAPComponents.SDNC);
        } else {
            exceptionUtil.buildAndThrowWorkflowException(execution, 7000, ex, ONAPComponents.SO);
        }
    } catch (Exception ex) {
        logger.error("Exception occurred", ex);
        exceptionUtil.buildAndThrowWorkflowException(execution, 7000, ex);
    }
}
Also used : GenericVnf(org.onap.so.bpmn.servicedecomposition.bbobjects.GenericVnf) BadResponseException(org.onap.so.client.exception.BadResponseException) ServiceInstance(org.onap.so.bpmn.servicedecomposition.bbobjects.ServiceInstance) VfModule(org.onap.so.bpmn.servicedecomposition.bbobjects.VfModule) BadResponseException(org.onap.so.client.exception.BadResponseException) BBObjectNotFoundException(org.onap.so.client.exception.BBObjectNotFoundException)

Aggregations

VfModule (org.onap.so.bpmn.servicedecomposition.bbobjects.VfModule)97 GenericVnf (org.onap.so.bpmn.servicedecomposition.bbobjects.GenericVnf)74 ServiceInstance (org.onap.so.bpmn.servicedecomposition.bbobjects.ServiceInstance)53 Test (org.junit.Test)46 ModelInfoVfModule (org.onap.so.bpmn.servicedecomposition.modelinfo.ModelInfoVfModule)45 RequestContext (org.onap.so.bpmn.servicedecomposition.generalobjects.RequestContext)37 CloudRegion (org.onap.so.bpmn.servicedecomposition.bbobjects.CloudRegion)35 ModelInfoServiceInstance (org.onap.so.bpmn.servicedecomposition.modelinfo.ModelInfoServiceInstance)30 GeneralBuildingBlock (org.onap.so.bpmn.servicedecomposition.entities.GeneralBuildingBlock)27 ModelInfoGenericVnf (org.onap.so.bpmn.servicedecomposition.modelinfo.ModelInfoGenericVnf)27 HashMap (java.util.HashMap)22 VolumeGroup (org.onap.so.bpmn.servicedecomposition.bbobjects.VolumeGroup)20 OrchestrationContext (org.onap.so.bpmn.servicedecomposition.generalobjects.OrchestrationContext)18 CreateVfModuleRequest (org.onap.so.adapters.vnfrest.CreateVfModuleRequest)14 ModelInfo (org.onap.so.serviceinstancebeans.ModelInfo)14 BBObjectNotFoundException (org.onap.so.client.exception.BBObjectNotFoundException)13 ResourceKey (org.onap.so.bpmn.servicedecomposition.entities.ResourceKey)12 Service (org.onap.so.db.catalog.beans.Service)12 Map (java.util.Map)11 Customer (org.onap.so.bpmn.servicedecomposition.bbobjects.Customer)11