Search in sources :

Example 1 with GetStackParamValidationResult

use of com.sequenceiq.cloudbreak.cloud.event.platform.GetStackParamValidationResult in project cloudbreak by hortonworks.

the class StackParameterService method getStackParams.

public List<StackParamValidation> getStackParams(String name, Credential credential) {
    LOGGER.debug("Get stack params");
    if (credential != null) {
        CloudContext cloudContext = new CloudContext(null, name, credential.cloudPlatform(), credential.getOwner());
        GetStackParamValidationRequest getStackParamValidationRequest = new GetStackParamValidationRequest(cloudContext);
        eventBus.notify(getStackParamValidationRequest.selector(), eventFactory.createEvent(getStackParamValidationRequest));
        try {
            GetStackParamValidationResult res = getStackParamValidationRequest.await();
            LOGGER.info("Get stack params result: {}", res);
            if (res.getStatus().equals(EventStatus.FAILED)) {
                LOGGER.error("Failed to get stack params", res.getErrorDetails());
                throw new OperationException(res.getErrorDetails());
            }
            return res.getStackParamValidations();
        } catch (InterruptedException e) {
            LOGGER.error("Error while getting the stack params", e);
            throw new OperationException(e);
        }
    } else {
        return Collections.emptyList();
    }
}
Also used : GetStackParamValidationResult(com.sequenceiq.cloudbreak.cloud.event.platform.GetStackParamValidationResult) CloudContext(com.sequenceiq.cloudbreak.cloud.context.CloudContext) GetStackParamValidationRequest(com.sequenceiq.cloudbreak.cloud.event.platform.GetStackParamValidationRequest) OperationException(com.sequenceiq.cloudbreak.service.stack.connector.OperationException)

Example 2 with GetStackParamValidationResult

use of com.sequenceiq.cloudbreak.cloud.event.platform.GetStackParamValidationResult in project cloudbreak by hortonworks.

the class GetStackParamValidationHandler method accept.

@Override
public void accept(Event<GetStackParamValidationRequest> getStackParametersRequestEvent) {
    LOGGER.info("Received event: {}", getStackParametersRequestEvent);
    GetStackParamValidationRequest request = getStackParametersRequestEvent.getData();
    try {
        CloudConnector aDefault = cloudPlatformConnectors.getDefault(request.getCloudContext().getPlatform());
        GetStackParamValidationResult getStackParamValidationResult = new GetStackParamValidationResult(request, aDefault.parameters().additionalStackParameters());
        request.getResult().onNext(getStackParamValidationResult);
        LOGGER.info("Query platform stack parameters finished.");
    } catch (RuntimeException e) {
        request.getResult().onNext(new GetStackParamValidationResult(e.getMessage(), e, request));
    }
}
Also used : CloudConnector(com.sequenceiq.cloudbreak.cloud.CloudConnector) GetStackParamValidationResult(com.sequenceiq.cloudbreak.cloud.event.platform.GetStackParamValidationResult) GetStackParamValidationRequest(com.sequenceiq.cloudbreak.cloud.event.platform.GetStackParamValidationRequest)

Aggregations

GetStackParamValidationRequest (com.sequenceiq.cloudbreak.cloud.event.platform.GetStackParamValidationRequest)2 GetStackParamValidationResult (com.sequenceiq.cloudbreak.cloud.event.platform.GetStackParamValidationResult)2 CloudConnector (com.sequenceiq.cloudbreak.cloud.CloudConnector)1 CloudContext (com.sequenceiq.cloudbreak.cloud.context.CloudContext)1 OperationException (com.sequenceiq.cloudbreak.service.stack.connector.OperationException)1