Search in sources :

Example 1 with CheckPlatformVariantRequest

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

the class ServiceProviderConnectorAdapter method checkAndGetPlatformVariant.

public Variant checkAndGetPlatformVariant(Stack stack) {
    LOGGER.debug("Get platform variant 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());
    CheckPlatformVariantRequest checkPlatformVariantRequest = new CheckPlatformVariantRequest(cloudContext, cloudCredential);
    eventBus.notify(checkPlatformVariantRequest.selector(), eventFactory.createEvent(checkPlatformVariantRequest));
    try {
        CheckPlatformVariantResult res = checkPlatformVariantRequest.await();
        LOGGER.info("Platform variant result: {}", res);
        if (res.getStatus().equals(EventStatus.FAILED)) {
            LOGGER.error("Failed to get platform variant", res.getErrorDetails());
            throw new OperationException(res.getErrorDetails());
        }
        return res.getDefaultPlatformVariant();
    } catch (InterruptedException e) {
        LOGGER.error("Error while getting the platform variant: " + cloudContext, e);
        throw new OperationException(e);
    }
}
Also used : CheckPlatformVariantRequest(com.sequenceiq.cloudbreak.cloud.event.platform.CheckPlatformVariantRequest) CloudCredential(com.sequenceiq.cloudbreak.cloud.model.CloudCredential) CloudContext(com.sequenceiq.cloudbreak.cloud.context.CloudContext) CheckPlatformVariantResult(com.sequenceiq.cloudbreak.cloud.event.platform.CheckPlatformVariantResult) OperationException(com.sequenceiq.cloudbreak.service.stack.connector.OperationException) Location(com.sequenceiq.cloudbreak.cloud.model.Location)

Example 2 with CheckPlatformVariantRequest

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

the class CheckPlatformVariantHandler method accept.

@Override
public void accept(Event<CheckPlatformVariantRequest> defaultPlatformVariantRequestEvent) {
    LOGGER.info("Received event: {}", defaultPlatformVariantRequestEvent);
    CheckPlatformVariantRequest request = defaultPlatformVariantRequestEvent.getData();
    try {
        CloudConnector cc = cloudPlatformConnectors.get(request.getCloudContext().getPlatform(), request.getCloudContext().getVariant());
        Variant defaultVariant = cc.variant();
        CheckPlatformVariantResult platformParameterResult = new CheckPlatformVariantResult(request, defaultVariant);
        request.getResult().onNext(platformParameterResult);
        LOGGER.info("Query platform variant finished.");
    } catch (RuntimeException e) {
        request.getResult().onNext(new CheckPlatformVariantResult(e.getMessage(), e, request));
    }
}
Also used : Variant(com.sequenceiq.cloudbreak.cloud.model.Variant) CloudConnector(com.sequenceiq.cloudbreak.cloud.CloudConnector) CheckPlatformVariantRequest(com.sequenceiq.cloudbreak.cloud.event.platform.CheckPlatformVariantRequest) CheckPlatformVariantResult(com.sequenceiq.cloudbreak.cloud.event.platform.CheckPlatformVariantResult)

Aggregations

CheckPlatformVariantRequest (com.sequenceiq.cloudbreak.cloud.event.platform.CheckPlatformVariantRequest)2 CheckPlatformVariantResult (com.sequenceiq.cloudbreak.cloud.event.platform.CheckPlatformVariantResult)2 CloudConnector (com.sequenceiq.cloudbreak.cloud.CloudConnector)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 Variant (com.sequenceiq.cloudbreak.cloud.model.Variant)1 OperationException (com.sequenceiq.cloudbreak.service.stack.connector.OperationException)1