Search in sources :

Example 1 with OrchestrationStatusValidationException

use of org.onap.so.client.exception.OrchestrationStatusValidationException in project so by onap.

the class OrchestrationStatusValidator method getOrchestrationStatus.

private OrchestrationStatus getOrchestrationStatus(BuildingBlockExecution execution, String buildingBlockFlowName, BuildingBlockDetail buildingBlockDetail) throws BBObjectNotFoundException, OrchestrationStatusValidationException {
    OrchestrationStatus orchestrationStatus = null;
    switch(buildingBlockDetail.getResourceType()) {
        case SERVICE:
            ServiceInstance serviceInstance = extractPojosForBB.extractByKey(execution, ResourceKey.SERVICE_INSTANCE_ID);
            orchestrationStatus = serviceInstance.getOrchestrationStatus();
            break;
        case VNF:
            GenericVnf genericVnf = extractPojosForBB.extractByKey(execution, ResourceKey.GENERIC_VNF_ID);
            orchestrationStatus = genericVnf.getOrchestrationStatus();
            break;
        case VF_MODULE:
            VfModule vfModule = extractPojosForBB.extractByKey(execution, ResourceKey.VF_MODULE_ID);
            orchestrationStatus = vfModule.getOrchestrationStatus();
            break;
        case VOLUME_GROUP:
            VolumeGroup volumeGroup = extractPojosForBB.extractByKey(execution, ResourceKey.VOLUME_GROUP_ID);
            orchestrationStatus = volumeGroup.getOrchestrationStatus();
            break;
        case NETWORK:
            L3Network network = extractPojosForBB.extractByKey(execution, ResourceKey.NETWORK_ID);
            orchestrationStatus = network.getOrchestrationStatus();
            break;
        case NETWORK_COLLECTION:
            Collection networkCollection = getNetworkCollection(execution);
            orchestrationStatus = networkCollection.getOrchestrationStatus();
            break;
        case CONFIGURATION:
            Configuration configuration = extractPojosForBB.extractByKey(execution, ResourceKey.CONFIGURATION_ID);
            orchestrationStatus = configuration.getOrchestrationStatus();
            break;
        case INSTANCE_GROUP:
            InstanceGroup instanceGroup = extractPojosForBB.extractByKey(execution, ResourceKey.INSTANCE_GROUP_ID);
            orchestrationStatus = instanceGroup.getOrchestrationStatus();
            break;
        case NO_VALIDATE:
            // short circuit and exit method
            execution.setVariable(ORCHESTRATION_STATUS_VALIDATION_RESULT, OrchestrationStatusValidationDirective.VALIDATION_SKIPPED);
            break;
        default:
            // code
            throw new OrchestrationStatusValidationException(String.format(UNKNOWN_RESOURCE_TYPE, buildingBlockFlowName, buildingBlockDetail.getResourceType(), buildingBlockDetail.getTargetAction()));
    }
    return orchestrationStatus;
}
Also used : L3Network(org.onap.so.bpmn.servicedecomposition.bbobjects.L3Network) GenericVnf(org.onap.so.bpmn.servicedecomposition.bbobjects.GenericVnf) Configuration(org.onap.so.bpmn.servicedecomposition.bbobjects.Configuration) VolumeGroup(org.onap.so.bpmn.servicedecomposition.bbobjects.VolumeGroup) ServiceInstance(org.onap.so.bpmn.servicedecomposition.bbobjects.ServiceInstance) Collection(org.onap.so.bpmn.servicedecomposition.bbobjects.Collection) OrchestrationStatusValidationException(org.onap.so.client.exception.OrchestrationStatusValidationException) OrchestrationStatus(org.onap.so.db.catalog.beans.OrchestrationStatus) VfModule(org.onap.so.bpmn.servicedecomposition.bbobjects.VfModule) InstanceGroup(org.onap.so.bpmn.servicedecomposition.bbobjects.InstanceGroup)

Example 2 with OrchestrationStatusValidationException

use of org.onap.so.client.exception.OrchestrationStatusValidationException in project so by onap.

the class OrchestrationStatusValidator method validateOrchestrationStatus.

/**
 * This method validate's the status of the OrchestrationStatus against the buildingBlockDetail ResourceType
 */
public void validateOrchestrationStatus(BuildingBlockExecution execution) {
    try {
        execution.setVariable(ORCHESTRATION_STATUS_VALIDATION_RESULT, null);
        String buildingBlockFlowName = execution.getFlowToBeCalled();
        BuildingBlockDetail buildingBlockDetail = catalogDbClient.getBuildingBlockDetail(buildingBlockFlowName);
        if (buildingBlockDetail == null) {
            throw new OrchestrationStatusValidationException(String.format(BUILDING_BLOCK_DETAIL_NOT_FOUND, buildingBlockFlowName));
        }
        OrchestrationStatus orchestrationStatus = getOrchestrationStatus(execution, buildingBlockFlowName, buildingBlockDetail);
        if (buildingBlockDetail.getResourceType().equals(ResourceType.NO_VALIDATE)) {
            return;
        }
        if (orchestrationStatus == null) {
            throw new OrchestrationStatusValidationException("The resource's orchstration status is null. Cannot perform task on a null orchestration status");
        }
        OrchestrationStatusStateTransitionDirective orchestrationStatusStateTransitionDirective = catalogDbClient.getOrchestrationStatusStateTransitionDirective(buildingBlockDetail.getResourceType(), orchestrationStatus, buildingBlockDetail.getTargetAction());
        if (orchestrationStatusStateTransitionDirective.getFlowDirective() == OrchestrationStatusValidationDirective.FAIL) {
            throw new OrchestrationStatusValidationException(String.format(ORCHESTRATION_VALIDATION_FAIL, buildingBlockDetail.getResourceType(), buildingBlockDetail.getTargetAction(), orchestrationStatus));
        }
        execution.setVariable(ORCHESTRATION_STATUS_VALIDATION_RESULT, orchestrationStatusStateTransitionDirective.getFlowDirective());
        if (buildingBlockFlowName.matches("Create(.*)|Delete(.*)") && orchestrationStatusStateTransitionDirective.getFlowDirective() == OrchestrationStatusValidationDirective.SILENT_SUCCESS) {
            updatedResourceStatus(execution, buildingBlockDetail);
        }
    } catch (BBObjectNotFoundException ex) {
        logger.error("Error occurred for bb object notfound in OrchestrationStatusValidator validateOrchestrationStatus ", ex);
        if (execution.getFlowToBeCalled().contains("Unassign")) {
            execution.setVariable(ORCHESTRATION_STATUS_VALIDATION_RESULT, OrchestrationStatusValidationDirective.SILENT_SUCCESS);
        } else {
            exceptionBuilder.buildAndThrowWorkflowException(execution, 7000, ex);
        }
    } catch (Exception e) {
        logger.error("Exception occurred", e);
        exceptionBuilder.buildAndThrowWorkflowException(execution, 7000, e);
    }
}
Also used : OrchestrationStatusStateTransitionDirective(org.onap.so.db.catalog.beans.OrchestrationStatusStateTransitionDirective) BBObjectNotFoundException(org.onap.so.client.exception.BBObjectNotFoundException) BuildingBlockDetail(org.onap.so.db.catalog.beans.BuildingBlockDetail) OrchestrationStatusValidationException(org.onap.so.client.exception.OrchestrationStatusValidationException) OrchestrationStatus(org.onap.so.db.catalog.beans.OrchestrationStatus) OrchestrationStatusValidationException(org.onap.so.client.exception.OrchestrationStatusValidationException) BBObjectNotFoundException(org.onap.so.client.exception.BBObjectNotFoundException) HttpClientErrorException(org.springframework.web.client.HttpClientErrorException)

Aggregations

OrchestrationStatusValidationException (org.onap.so.client.exception.OrchestrationStatusValidationException)2 OrchestrationStatus (org.onap.so.db.catalog.beans.OrchestrationStatus)2 Collection (org.onap.so.bpmn.servicedecomposition.bbobjects.Collection)1 Configuration (org.onap.so.bpmn.servicedecomposition.bbobjects.Configuration)1 GenericVnf (org.onap.so.bpmn.servicedecomposition.bbobjects.GenericVnf)1 InstanceGroup (org.onap.so.bpmn.servicedecomposition.bbobjects.InstanceGroup)1 L3Network (org.onap.so.bpmn.servicedecomposition.bbobjects.L3Network)1 ServiceInstance (org.onap.so.bpmn.servicedecomposition.bbobjects.ServiceInstance)1 VfModule (org.onap.so.bpmn.servicedecomposition.bbobjects.VfModule)1 VolumeGroup (org.onap.so.bpmn.servicedecomposition.bbobjects.VolumeGroup)1 BBObjectNotFoundException (org.onap.so.client.exception.BBObjectNotFoundException)1 BuildingBlockDetail (org.onap.so.db.catalog.beans.BuildingBlockDetail)1 OrchestrationStatusStateTransitionDirective (org.onap.so.db.catalog.beans.OrchestrationStatusStateTransitionDirective)1 HttpClientErrorException (org.springframework.web.client.HttpClientErrorException)1