Search in sources :

Example 1 with GetPlatformSshKeysResult

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);
    }
}
Also used : ExtendedCloudCredential(com.sequenceiq.cloudbreak.cloud.model.ExtendedCloudCredential) GetPlatformSshKeysRequest(com.sequenceiq.cloudbreak.cloud.event.platform.GetPlatformSshKeysRequest) GetPlatformSshKeysResult(com.sequenceiq.cloudbreak.cloud.event.platform.GetPlatformSshKeysResult) OperationException(com.sequenceiq.cloudbreak.service.stack.connector.OperationException)

Example 2 with GetPlatformSshKeysResult

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));
    }
}
Also used : GetPlatformSshKeysRequest(com.sequenceiq.cloudbreak.cloud.event.platform.GetPlatformSshKeysRequest) GetPlatformSshKeysResult(com.sequenceiq.cloudbreak.cloud.event.platform.GetPlatformSshKeysResult) CloudPlatformVariant(com.sequenceiq.cloudbreak.cloud.model.CloudPlatformVariant) CloudSshKeys(com.sequenceiq.cloudbreak.cloud.model.CloudSshKeys)

Aggregations

GetPlatformSshKeysRequest (com.sequenceiq.cloudbreak.cloud.event.platform.GetPlatformSshKeysRequest)2 GetPlatformSshKeysResult (com.sequenceiq.cloudbreak.cloud.event.platform.GetPlatformSshKeysResult)2 CloudPlatformVariant (com.sequenceiq.cloudbreak.cloud.model.CloudPlatformVariant)1 CloudSshKeys (com.sequenceiq.cloudbreak.cloud.model.CloudSshKeys)1 ExtendedCloudCredential (com.sequenceiq.cloudbreak.cloud.model.ExtendedCloudCredential)1 OperationException (com.sequenceiq.cloudbreak.service.stack.connector.OperationException)1