use of com.sequenceiq.cloudbreak.cloud.event.platform.GetPlatformSshKeysResult in project cloudbreak by hortonworks.
the class CloudParameterService method getCloudSshKeys.
public CloudSshKeys getCloudSshKeys(Credential credential, String region, String variant, Map<String, String> filters) {
LOGGER.debug("Get platform sshkeys");
ExtendedCloudCredential cloudCredential = credentialToExtendedCloudCredentialConverter.convert(credential);
GetPlatformSshKeysRequest getPlatformSshKeysRequest = new GetPlatformSshKeysRequest(cloudCredential, cloudCredential, variant, region, filters);
eventBus.notify(getPlatformSshKeysRequest.selector(), eventFactory.createEvent(getPlatformSshKeysRequest));
try {
GetPlatformSshKeysResult res = getPlatformSshKeysRequest.await();
LOGGER.info("Platform sshkeys types result: {}", res);
if (res.getStatus().equals(EventStatus.FAILED)) {
LOGGER.error("Failed to get platform sshkeys", res.getErrorDetails());
throw new GetCloudParameterException("Failed to get SSH keys for the cloud provider", res.getErrorDetails());
}
return res.getCloudSshKeys();
} catch (InterruptedException e) {
LOGGER.error("Error while getting the platform sshkeys", e);
throw new OperationException(e);
}
}
use of com.sequenceiq.cloudbreak.cloud.event.platform.GetPlatformSshKeysResult in project cloudbreak by hortonworks.
the class GetPlatformSshKeysHandler method accept.
@Override
public void accept(Event<GetPlatformSshKeysRequest> getPlatformSshKeysRequest) {
LOGGER.info("Received event: {}", getPlatformSshKeysRequest);
GetPlatformSshKeysRequest request = getPlatformSshKeysRequest.getData();
try {
CloudPlatformVariant cloudPlatformVariant = new CloudPlatformVariant(Platform.platform(request.getExtendedCloudCredential().getCloudPlatform()), Variant.variant(request.getVariant()));
CloudSshKeys cloudSshKeys = cloudPlatformConnectors.get(cloudPlatformVariant).platformResources().sshKeys(request.getCloudCredential(), Region.region(request.getRegion()), request.getFilters());
GetPlatformSshKeysResult getPlatformSshKeysResult = new GetPlatformSshKeysResult(request, cloudSshKeys);
request.getResult().onNext(getPlatformSshKeysResult);
LOGGER.info("Query platform networks types finished.");
} catch (RuntimeException e) {
request.getResult().onNext(new GetPlatformSshKeysResult(e.getMessage(), e, request));
}
}
Aggregations