Search in sources :

Example 1 with ValidationResult

use of com.sequenceiq.cloudbreak.cloud.event.setup.ValidationResult in project cloudbreak by hortonworks.

the class ProvisionValidationHandler method accept.

@Override
public void accept(Event<ValidationRequest> event) {
    LOGGER.info("Received event: {}", event);
    ValidationRequest request = event.getData();
    CloudContext cloudContext = request.getCloudContext();
    ValidationResult result;
    try {
        CloudConnector connector = cloudPlatformConnectors.get(cloudContext.getPlatformVariant());
        AuthenticatedContext ac = connector.authentication().authenticate(request.getCloudContext(), request.getCloudCredential());
        CloudStack cloudStack = request.getCloudStack();
        for (Validator v : connector.validators()) {
            v.validate(ac, cloudStack);
        }
        result = new ValidationResult(request);
    } catch (RuntimeException e) {
        result = new ValidationResult(e, request);
    }
    request.getResult().onNext(result);
    eventBus.notify(result.selector(), new Event<>(event.getHeaders(), result));
}
Also used : CloudConnector(com.sequenceiq.cloudbreak.cloud.CloudConnector) ValidationRequest(com.sequenceiq.cloudbreak.cloud.event.setup.ValidationRequest) CloudContext(com.sequenceiq.cloudbreak.cloud.context.CloudContext) AuthenticatedContext(com.sequenceiq.cloudbreak.cloud.context.AuthenticatedContext) ValidationResult(com.sequenceiq.cloudbreak.cloud.event.setup.ValidationResult) CloudStack(com.sequenceiq.cloudbreak.cloud.model.CloudStack) Validator(com.sequenceiq.cloudbreak.cloud.Validator)

Aggregations

CloudConnector (com.sequenceiq.cloudbreak.cloud.CloudConnector)1 Validator (com.sequenceiq.cloudbreak.cloud.Validator)1 AuthenticatedContext (com.sequenceiq.cloudbreak.cloud.context.AuthenticatedContext)1 CloudContext (com.sequenceiq.cloudbreak.cloud.context.CloudContext)1 ValidationRequest (com.sequenceiq.cloudbreak.cloud.event.setup.ValidationRequest)1 ValidationResult (com.sequenceiq.cloudbreak.cloud.event.setup.ValidationResult)1 CloudStack (com.sequenceiq.cloudbreak.cloud.model.CloudStack)1