use of com.sequenceiq.cloudbreak.cloud.event.platform.GetPlatformEncryptionKeysResult 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);
}
}
use of com.sequenceiq.cloudbreak.cloud.event.platform.GetPlatformEncryptionKeysResult 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()));
}
}
Aggregations