Search in sources :

Example 1 with ParametersValidationResult

use of com.sequenceiq.cloudbreak.cloud.event.validation.ParametersValidationResult in project cloudbreak by hortonworks.

the class ParametersValidationHandler method accept.

@Override
public void accept(Event<ParametersValidationRequest> requestEvent) {
    LOGGER.debug("Received event: {}", requestEvent);
    ParametersValidationRequest request = requestEvent.getData();
    try {
        CloudConnector<Object> connector = cloudPlatformConnectors.get(request.getCloudContext().getPlatformVariant());
        AuthenticatedContext auth = connector.authentication().authenticate(request.getCloudContext(), request.getCloudCredential());
        connector.setup().validateParameters(auth, request.getParameters());
        request.getResult().onNext(new ParametersValidationResult(request.getResourceId()));
    } catch (Exception e) {
        request.getResult().onNext(new ParametersValidationResult(e.getMessage(), e, request.getResourceId()));
    }
}
Also used : ParametersValidationRequest(com.sequenceiq.cloudbreak.cloud.event.validation.ParametersValidationRequest) ParametersValidationResult(com.sequenceiq.cloudbreak.cloud.event.validation.ParametersValidationResult) AuthenticatedContext(com.sequenceiq.cloudbreak.cloud.context.AuthenticatedContext)

Example 2 with ParametersValidationResult

use of com.sequenceiq.cloudbreak.cloud.event.validation.ParametersValidationResult in project cloudbreak by hortonworks.

the class ParametersValidator method waitResult.

public void waitResult(ParametersValidationRequest parametersValidationRequest, ValidationResult.ValidationResultBuilder validationBuilder) {
    if (parametersValidationRequest != null) {
        try {
            ParametersValidationResult result = parametersValidationRequest.await();
            LOGGER.info("Parameter validation result: {}", result);
            Exception exception = result.getErrorDetails();
            if (exception != null) {
                validationBuilder.error(result.getStatusReason());
            }
        } catch (InterruptedException e) {
            LOGGER.error("Error while sending the parameters validation request", e);
            validationBuilder.error(e.getMessage());
        }
    }
}
Also used : ParametersValidationResult(com.sequenceiq.cloudbreak.cloud.event.validation.ParametersValidationResult)

Aggregations

ParametersValidationResult (com.sequenceiq.cloudbreak.cloud.event.validation.ParametersValidationResult)2 AuthenticatedContext (com.sequenceiq.cloudbreak.cloud.context.AuthenticatedContext)1 ParametersValidationRequest (com.sequenceiq.cloudbreak.cloud.event.validation.ParametersValidationRequest)1