Search in sources :

Example 36 with OperationException

use of com.sequenceiq.cloudbreak.service.OperationException in project cloudbreak by hortonworks.

the class CloudParameterService method getPrivateDnsZones.

@Retryable(value = GetCloudParameterException.class, maxAttempts = 5, backoff = @Backoff(delay = 1000, multiplier = 2, maxDelay = 10000))
public CloudPrivateDnsZones getPrivateDnsZones(ExtendedCloudCredential cloudCredential, String platformVariant, Map<String, String> filters) {
    LOGGER.debug("Get platform private DNS zones for credential: [{}]", cloudCredential.getName());
    GetPlatformPrivateDnsZonesRequest request = new GetPlatformPrivateDnsZonesRequest(cloudCredential, cloudCredential, platformVariant, null);
    eventBus.notify(request.selector(), Event.wrap(request));
    try {
        GetPlatformPrivateDnsZonesResult result = request.await();
        LOGGER.debug("Platform PrivateDnsZonesResult result: {}", result);
        if (result.getStatus().equals(EventStatus.FAILED)) {
            LOGGER.debug("Failed to get platform PrivateDnsZonesResult", result.getErrorDetails());
            throw new GetCloudParameterException(String.format("Failed to get private dns zones for the cloud provider: %s. %s", result.getStatusReason(), getCauseMessages(result.getErrorDetails())), result.getErrorDetails());
        }
        return result.getPrivateDnsZones();
    } catch (InterruptedException e) {
        LOGGER.error("Error while getting the platform PrivateDnsZonesResult", e);
        throw new OperationException(e);
    }
}
Also used : GetPlatformPrivateDnsZonesResult(com.sequenceiq.cloudbreak.cloud.event.platform.GetPlatformPrivateDnsZonesResult) GetPlatformPrivateDnsZonesRequest(com.sequenceiq.cloudbreak.cloud.event.platform.GetPlatformPrivateDnsZonesRequest) OperationException(com.sequenceiq.cloudbreak.service.OperationException) Retryable(org.springframework.retry.annotation.Retryable)

Example 37 with OperationException

use of com.sequenceiq.cloudbreak.service.OperationException in project cloudbreak by hortonworks.

the class CloudParameterService method getRegionsV2.

@Retryable(value = GetCloudParameterException.class, maxAttempts = 5, backoff = @Backoff(delay = 1000, multiplier = 2, maxDelay = 10000))
public CloudRegions getRegionsV2(ExtendedCloudCredential cloudCredential, String region, String variant, Map<String, String> filters, boolean availabilityZonesNeeded) {
    LOGGER.debug("Get platform regions");
    GetPlatformRegionsRequestV2 getPlatformRegionsRequest = new GetPlatformRegionsRequestV2(cloudCredential, cloudCredential, variant, region, filters, availabilityZonesNeeded);
    eventBus.notify(getPlatformRegionsRequest.selector(), Event.wrap(getPlatformRegionsRequest));
    try {
        GetPlatformRegionsResultV2 res = getPlatformRegionsRequest.await();
        LOGGER.debug("Platform regions result: {}", res);
        if (res.getStatus().equals(EventStatus.FAILED)) {
            LOGGER.debug("Failed to get platform regions", res.getErrorDetails());
            throw new GetCloudParameterException("Failed to get regions from the cloud provider due to network issues or invalid credential. " + getCauseMessages(res.getErrorDetails()), res.getErrorDetails());
        }
        return res.getCloudRegions();
    } catch (InterruptedException e) {
        LOGGER.error("Error while getting the platform regions", e);
        throw new OperationException(e);
    }
}
Also used : GetPlatformRegionsResultV2(com.sequenceiq.cloudbreak.cloud.event.platform.GetPlatformRegionsResultV2) GetPlatformRegionsRequestV2(com.sequenceiq.cloudbreak.cloud.event.platform.GetPlatformRegionsRequestV2) OperationException(com.sequenceiq.cloudbreak.service.OperationException) Retryable(org.springframework.retry.annotation.Retryable)

Example 38 with OperationException

use of com.sequenceiq.cloudbreak.service.OperationException in project cloudbreak by hortonworks.

the class CloudParameterService method getRegions.

@Retryable(value = GetCloudParameterException.class, maxAttempts = 5, backoff = @Backoff(delay = 1000, multiplier = 2, maxDelay = 10000))
public PlatformRegions getRegions() {
    LOGGER.debug("Get platform regions");
    GetPlatformRegionsRequest getPlatformRegionsRequest = new GetPlatformRegionsRequest();
    eventBus.notify(getPlatformRegionsRequest.selector(), eventFactory.createEvent(getPlatformRegionsRequest));
    try {
        GetPlatformRegionsResult res = getPlatformRegionsRequest.await();
        LOGGER.debug("Platform regions result: {}", res);
        if (res.getStatus().equals(EventStatus.FAILED)) {
            LOGGER.debug("Failed to get platform regions", res.getErrorDetails());
            throw new GetCloudParameterException(getCauseMessages(res.getErrorDetails()), res.getErrorDetails());
        }
        return res.getPlatformRegions();
    } catch (InterruptedException e) {
        LOGGER.error("Error while getting the platform regions", e);
        throw new OperationException(e);
    }
}
Also used : GetPlatformRegionsResult(com.sequenceiq.cloudbreak.cloud.event.platform.GetPlatformRegionsResult) GetPlatformRegionsRequest(com.sequenceiq.cloudbreak.cloud.event.platform.GetPlatformRegionsRequest) OperationException(com.sequenceiq.cloudbreak.service.OperationException) Retryable(org.springframework.retry.annotation.Retryable)

Example 39 with OperationException

use of com.sequenceiq.cloudbreak.service.OperationException in project cloudbreak by hortonworks.

the class CloudParameterService method getCloudNetworks.

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

Example 40 with OperationException

use of com.sequenceiq.cloudbreak.service.OperationException 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)

Aggregations

OperationException (com.sequenceiq.cloudbreak.service.OperationException)47 Retryable (org.springframework.retry.annotation.Retryable)19 CloudContext (com.sequenceiq.cloudbreak.cloud.context.CloudContext)16 CloudCredential (com.sequenceiq.cloudbreak.cloud.model.CloudCredential)11 Location (com.sequenceiq.cloudbreak.cloud.model.Location)6 GetPlatformTemplateResult (com.sequenceiq.cloudbreak.cloud.event.platform.GetPlatformTemplateResult)5 Credential (com.sequenceiq.cloudbreak.dto.credential.Credential)5 BadRequestException (javax.ws.rs.BadRequestException)5 PlatformParameterRequest (com.sequenceiq.cloudbreak.cloud.event.platform.PlatformParameterRequest)4 PlatformParameterResult (com.sequenceiq.cloudbreak.cloud.event.platform.PlatformParameterResult)4 CloudInstance (com.sequenceiq.cloudbreak.cloud.model.CloudInstance)4 Stack (com.sequenceiq.cloudbreak.domain.stack.Stack)4 ThreadBasedUserCrnProvider (com.sequenceiq.cloudbreak.auth.ThreadBasedUserCrnProvider)3 RegionAwareInternalCrnGeneratorFactory (com.sequenceiq.cloudbreak.auth.crn.RegionAwareInternalCrnGeneratorFactory)3 EventStatus (com.sequenceiq.cloudbreak.cloud.event.model.EventStatus)3 CloudResource (com.sequenceiq.cloudbreak.cloud.model.CloudResource)3 CloudStack (com.sequenceiq.cloudbreak.cloud.model.CloudStack)3 ExtendedCloudCredential (com.sequenceiq.cloudbreak.cloud.model.ExtendedCloudCredential)3 List (java.util.List)3 Collectors (java.util.stream.Collectors)3