Search in sources :

Example 1 with GetPlatformEncryptionKeysRequest

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

the class CloudParameterService method getCloudEncryptionKeys.

@Retryable(value = GetCloudParameterException.class, maxAttempts = 5, backoff = @Backoff(delay = 1000, multiplier = 2, maxDelay = 10000))
public CloudEncryptionKeys getCloudEncryptionKeys(ExtendedCloudCredential cloudCredential, String region, String variant, Map<String, String> filters) {
    LOGGER.debug("Get platform encryptionKeys");
    GetPlatformEncryptionKeysRequest getPlatformEncryptionKeysRequest = new GetPlatformEncryptionKeysRequest(cloudCredential, cloudCredential, variant, region, filters);
    eventBus.notify(getPlatformEncryptionKeysRequest.selector(), Event.wrap(getPlatformEncryptionKeysRequest));
    try {
        GetPlatformEncryptionKeysResult res = getPlatformEncryptionKeysRequest.await();
        LOGGER.debug("Platform encryptionKeys result: {}", res);
        if (res.getStatus().equals(EventStatus.FAILED)) {
            LOGGER.debug("Failed to get platform encryptionKeys", res.getErrorDetails());
            throw new GetCloudParameterException("Failed to get encryption keys for the cloud provider. " + getCauseMessages(res.getErrorDetails()), res.getErrorDetails());
        }
        return res.getCloudEncryptionKeys();
    } catch (InterruptedException e) {
        LOGGER.error("Error while getting the platform encryptionKeys", e);
        throw new OperationException(e);
    }
}
Also used : GetPlatformEncryptionKeysRequest(com.sequenceiq.cloudbreak.cloud.event.platform.GetPlatformEncryptionKeysRequest) GetPlatformEncryptionKeysResult(com.sequenceiq.cloudbreak.cloud.event.platform.GetPlatformEncryptionKeysResult) OperationException(com.sequenceiq.cloudbreak.service.OperationException) Retryable(org.springframework.retry.annotation.Retryable)

Example 2 with GetPlatformEncryptionKeysRequest

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

the class GetPlatformEncryptionKeysHandler method accept.

@Override
public void accept(Event<GetPlatformEncryptionKeysRequest> getPlatformEncryptionKeysRequest) {
    LOGGER.debug("Received event: {}", getPlatformEncryptionKeysRequest);
    GetPlatformEncryptionKeysRequest request = getPlatformEncryptionKeysRequest.getData();
    try {
        CloudPlatformVariant cloudPlatformVariant = new CloudPlatformVariant(Platform.platform(request.getExtendedCloudCredential().getCloudPlatform()), Variant.variant(request.getVariant()));
        CloudEncryptionKeys encryptionKeys = cloudPlatformConnectors.get(cloudPlatformVariant).platformResources().encryptionKeys(request.getExtendedCloudCredential(), Region.region(request.getRegion()), request.getFilters());
        GetPlatformEncryptionKeysResult getPlatformEncryptionKeysResult = new GetPlatformEncryptionKeysResult(request.getResourceId(), encryptionKeys);
        request.getResult().onNext(getPlatformEncryptionKeysResult);
        LOGGER.debug("Query platform encryption keys types finished.");
    } catch (Exception e) {
        request.getResult().onNext(new GetPlatformEncryptionKeysResult(e.getMessage(), e, request.getResourceId()));
    }
}
Also used : CloudPlatformVariant(com.sequenceiq.cloudbreak.cloud.model.CloudPlatformVariant) GetPlatformEncryptionKeysRequest(com.sequenceiq.cloudbreak.cloud.event.platform.GetPlatformEncryptionKeysRequest) GetPlatformEncryptionKeysResult(com.sequenceiq.cloudbreak.cloud.event.platform.GetPlatformEncryptionKeysResult) CloudEncryptionKeys(com.sequenceiq.cloudbreak.cloud.model.CloudEncryptionKeys)

Aggregations

GetPlatformEncryptionKeysRequest (com.sequenceiq.cloudbreak.cloud.event.platform.GetPlatformEncryptionKeysRequest)2 GetPlatformEncryptionKeysResult (com.sequenceiq.cloudbreak.cloud.event.platform.GetPlatformEncryptionKeysResult)2 CloudEncryptionKeys (com.sequenceiq.cloudbreak.cloud.model.CloudEncryptionKeys)1 CloudPlatformVariant (com.sequenceiq.cloudbreak.cloud.model.CloudPlatformVariant)1 OperationException (com.sequenceiq.cloudbreak.service.OperationException)1 Retryable (org.springframework.retry.annotation.Retryable)1