Search in sources :

Example 1 with PlatformParameterRequest

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

the class ServiceProviderConnectorAdapter method getPlatformParameters.

public PlatformParameters getPlatformParameters(Stack stack) {
    LOGGER.debug("Get platform parameters for: {}", stack);
    Location location = location(region(stack.getRegion()), availabilityZone(stack.getAvailabilityZone()));
    CloudContext cloudContext = new CloudContext(stack.getId(), stack.getName(), stack.cloudPlatform(), stack.getOwner(), stack.getPlatformVariant(), location);
    CloudCredential cloudCredential = credentialConverter.convert(stack.getCredential());
    PlatformParameterRequest parameterRequest = new PlatformParameterRequest(cloudContext, cloudCredential);
    eventBus.notify(parameterRequest.selector(), eventFactory.createEvent(parameterRequest));
    try {
        PlatformParameterResult res = parameterRequest.await();
        LOGGER.info("Platform parameter result: {}", res);
        if (res.getStatus().equals(EventStatus.FAILED)) {
            LOGGER.error("Failed to get platform parameters", res.getErrorDetails());
            throw new OperationException(res.getErrorDetails());
        }
        return res.getPlatformParameters();
    } catch (InterruptedException e) {
        LOGGER.error("Error while getting platform parameters: " + cloudContext, e);
        throw new OperationException(e);
    }
}
Also used : CloudCredential(com.sequenceiq.cloudbreak.cloud.model.CloudCredential) CloudContext(com.sequenceiq.cloudbreak.cloud.context.CloudContext) PlatformParameterRequest(com.sequenceiq.cloudbreak.cloud.event.platform.PlatformParameterRequest) PlatformParameterResult(com.sequenceiq.cloudbreak.cloud.event.platform.PlatformParameterResult) OperationException(com.sequenceiq.cloudbreak.service.stack.connector.OperationException) Location(com.sequenceiq.cloudbreak.cloud.model.Location)

Example 2 with PlatformParameterRequest

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

the class PlatformParameterHandler method accept.

@Override
public void accept(Event<PlatformParameterRequest> platformParameterRequestEvent) {
    LOGGER.info("Received event: {}", platformParameterRequestEvent);
    PlatformParameterRequest request = platformParameterRequestEvent.getData();
    try {
        CloudConnector connector = cloudPlatformConnectors.get(request.getCloudContext().getPlatformVariant());
        PlatformParameters platformParameters = connector.parameters();
        PlatformParameterResult platformParameterResult = new PlatformParameterResult(request, platformParameters);
        request.getResult().onNext(platformParameterResult);
        LOGGER.info("Query platform parameters finished.");
    } catch (RuntimeException e) {
        request.getResult().onNext(new PlatformParameterResult(e.getMessage(), e, request));
    }
}
Also used : CloudConnector(com.sequenceiq.cloudbreak.cloud.CloudConnector) PlatformParameterRequest(com.sequenceiq.cloudbreak.cloud.event.platform.PlatformParameterRequest) PlatformParameters(com.sequenceiq.cloudbreak.cloud.PlatformParameters) PlatformParameterResult(com.sequenceiq.cloudbreak.cloud.event.platform.PlatformParameterResult)

Aggregations

PlatformParameterRequest (com.sequenceiq.cloudbreak.cloud.event.platform.PlatformParameterRequest)2 PlatformParameterResult (com.sequenceiq.cloudbreak.cloud.event.platform.PlatformParameterResult)2 CloudConnector (com.sequenceiq.cloudbreak.cloud.CloudConnector)1 PlatformParameters (com.sequenceiq.cloudbreak.cloud.PlatformParameters)1 CloudContext (com.sequenceiq.cloudbreak.cloud.context.CloudContext)1 CloudCredential (com.sequenceiq.cloudbreak.cloud.model.CloudCredential)1 Location (com.sequenceiq.cloudbreak.cloud.model.Location)1 OperationException (com.sequenceiq.cloudbreak.service.stack.connector.OperationException)1