Search in sources :

Example 1 with OperationStateEnum

use of org.onap.so.adapters.etsisol003adapter.lcm.v1.model.OperationStateEnum in project so by onap.

the class MonitorVnfmDeleteJobTask method checkIfOperationWasSuccessful.

/**
 * Check the final status of delete throw exception if not completed successfully
 *
 * @param execution {@link org.onap.so.bpmn.common.DelegateExecutionImpl}
 */
public void checkIfOperationWasSuccessful(final BuildingBlockExecution execution) {
    LOGGER.debug("Executing checkIfOperationWasSuccessful  ...");
    final Optional<OperationStateEnum> operationStatusOption = execution.getVariable(OPERATION_STATUS_PARAM_NAME);
    final DeleteVnfResponse deleteVnfResponse = execution.getVariable(DELETE_VNF_RESPONSE_PARAM_NAME);
    if (operationStatusOption == null || !operationStatusOption.isPresent()) {
        final String message = "Unable to delete jobId: " + (deleteVnfResponse != null ? deleteVnfResponse.getJobId() : "null") + "Unable to retrieve OperationStatus";
        LOGGER.error(message);
        exceptionUtil.buildAndThrowWorkflowException(execution, 1214, message);
    } else if (operationStatusOption != null && operationStatusOption.isPresent()) {
        final OperationStateEnum operationStatus = operationStatusOption.get();
        if (operationStatus != OperationStateEnum.COMPLETED) {
            final String message = "Unable to Delete jobId: " + (deleteVnfResponse != null ? deleteVnfResponse.getJobId() : "null") + " OperationStatus: " + operationStatus;
            LOGGER.error(message);
            exceptionUtil.buildAndThrowWorkflowException(execution, 1215, message);
        }
        LOGGER.debug("Successfully completed Deletion of job {}", deleteVnfResponse);
    }
}
Also used : OperationStateEnum(org.onap.so.adapters.etsisol003adapter.lcm.v1.model.OperationStateEnum) DeleteVnfResponse(org.onap.so.adapters.etsisol003adapter.lcm.v1.model.DeleteVnfResponse)

Example 2 with OperationStateEnum

use of org.onap.so.adapters.etsisol003adapter.lcm.v1.model.OperationStateEnum in project so by onap.

the class MonitorVnfmJobTask method getOperationStatus.

/**
 * This method calls the Vnfm adapter and gets the Operation status of the job
 *
 * @param execution {@link org.onap.so.bpmn.common.DelegateExecutionImpl}
 * @param jobId unique job id
 * @return Operation State
 */
protected Optional<OperationStateEnum> getOperationStatus(final BuildingBlockExecution execution, final String jobId) {
    final Optional<QueryJobResponse> instantiateOperationJobStatus = vnfmAdapterServiceProvider.getInstantiateOperationJobStatus(jobId);
    if (instantiateOperationJobStatus.isPresent()) {
        final QueryJobResponse queryJobResponse = instantiateOperationJobStatus.get();
        if (!OPERATION_RETRIEVAL_STATES.contains(queryJobResponse.getOperationStatusRetrievalStatus())) {
            final String message = "Recevied invalid operation reterivel state: " + queryJobResponse.getOperationStatusRetrievalStatus();
            LOGGER.error(message);
            exceptionUtil.buildAndThrowWorkflowException(execution, 1203, message);
        }
        if (queryJobResponse.getOperationState() != null) {
            final OperationStateEnum operationStatus = queryJobResponse.getOperationState();
            LOGGER.debug("Operation {} with {} and operation retrieval status : {}", queryJobResponse.getId(), operationStatus, queryJobResponse.getOperationStatusRetrievalStatus());
            return Optional.of(queryJobResponse.getOperationState());
        }
        LOGGER.debug("Operation {} without operationStatus and operation retrieval status :{}", queryJobResponse.getId(), queryJobResponse.getOperationStatusRetrievalStatus());
    }
    return Optional.absent();
}
Also used : QueryJobResponse(org.onap.so.adapters.etsisol003adapter.lcm.v1.model.QueryJobResponse) OperationStateEnum(org.onap.so.adapters.etsisol003adapter.lcm.v1.model.OperationStateEnum)

Example 3 with OperationStateEnum

use of org.onap.so.adapters.etsisol003adapter.lcm.v1.model.OperationStateEnum in project so by onap.

the class MonitorVnfmCreateJobTask method checkIfOperationWasSuccessful.

/**
 * Check the final status of instantiation throw exception if not completed successfully
 *
 * @param execution {@link org.onap.so.bpmn.common.DelegateExecutionImpl}
 */
public void checkIfOperationWasSuccessful(final BuildingBlockExecution execution) {
    LOGGER.debug("Executing checkIfOperationWasSuccessful  ...");
    final Optional<OperationStateEnum> operationStatusOption = execution.getVariable(OPERATION_STATUS_PARAM_NAME);
    final CreateVnfResponse vnfInstantiateResponse = execution.getVariable(CREATE_VNF_RESPONSE_PARAM_NAME);
    if (operationStatusOption == null || !operationStatusOption.isPresent()) {
        final String message = "Unable to instantiate jobId: " + (vnfInstantiateResponse != null ? vnfInstantiateResponse.getJobId() : "null") + "Unable to retrieve OperationStatus";
        LOGGER.error(message);
        exceptionUtil.buildAndThrowWorkflowException(execution, 1206, message);
    } else if (operationStatusOption != null && operationStatusOption.isPresent()) {
        final OperationStateEnum operationStatus = operationStatusOption.get();
        if (operationStatus != OperationStateEnum.COMPLETED) {
            final String message = "Unable to instantiate jobId: " + (vnfInstantiateResponse != null ? vnfInstantiateResponse.getJobId() : "null") + " OperationStatus: " + operationStatus;
            LOGGER.error(message);
            exceptionUtil.buildAndThrowWorkflowException(execution, 1207, message);
        }
        LOGGER.debug("Successfully completed instatiation of job {}", vnfInstantiateResponse);
    }
}
Also used : CreateVnfResponse(org.onap.so.adapters.etsisol003adapter.lcm.v1.model.CreateVnfResponse) OperationStateEnum(org.onap.so.adapters.etsisol003adapter.lcm.v1.model.OperationStateEnum)

Aggregations

OperationStateEnum (org.onap.so.adapters.etsisol003adapter.lcm.v1.model.OperationStateEnum)3 CreateVnfResponse (org.onap.so.adapters.etsisol003adapter.lcm.v1.model.CreateVnfResponse)1 DeleteVnfResponse (org.onap.so.adapters.etsisol003adapter.lcm.v1.model.DeleteVnfResponse)1 QueryJobResponse (org.onap.so.adapters.etsisol003adapter.lcm.v1.model.QueryJobResponse)1