Search in sources :

Example 16 with OperationException

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

the class StackTemplateService method waitGetTemplate.

public String waitGetTemplate(GetPlatformTemplateRequest getPlatformTemplateRequest) {
    try {
        GetPlatformTemplateResult res = getPlatformTemplateRequest.await();
        LOGGER.debug("Get template result: {}", res);
        if (res.getStatus().equals(EventStatus.FAILED)) {
            LOGGER.error("Failed to get template", res.getErrorDetails());
            throw new OperationException(res.getErrorDetails());
        }
        return res.getTemplate();
    } catch (InterruptedException e) {
        LOGGER.error("Error while getting template: " + getPlatformTemplateRequest.getCloudContext(), e);
        throw new OperationException(e);
    }
}
Also used : GetPlatformTemplateResult(com.sequenceiq.cloudbreak.cloud.event.platform.GetPlatformTemplateResult) OperationException(com.sequenceiq.cloudbreak.service.OperationException)

Example 17 with OperationException

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

the class CloudParameterService method getDiskTypes.

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

Example 18 with OperationException

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

the class CloudParameterService method getCloudSshKeys.

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

Example 19 with OperationException

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

the class CloudParameterService method getCloudAccessConfigs.

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

Example 20 with OperationException

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

the class CloudParameterService method getVmTypesV2.

@Retryable(value = GetCloudParameterException.class, maxAttempts = 5, backoff = @Backoff(delay = 1000, multiplier = 2, maxDelay = 10000))
public CloudVmTypes getVmTypesV2(ExtendedCloudCredential cloudCredential, String region, String variant, CdpResourceType stackType, Map<String, String> filters) {
    LOGGER.debug("Get platform vmtypes");
    boolean hasEnableDistroxInstanceTypesEnabled = entitlementService.enableDistroxInstanceTypesEnabled(cloudCredential.getAccountId());
    GetPlatformVmTypesRequest getPlatformVmTypesRequest = new GetPlatformVmTypesRequest(cloudCredential, cloudCredential, variant, region, stackType, hasEnableDistroxInstanceTypesEnabled, filters);
    eventBus.notify(getPlatformVmTypesRequest.selector(), Event.wrap(getPlatformVmTypesRequest));
    try {
        GetPlatformVmTypesResult res = getPlatformVmTypesRequest.await();
        LOGGER.debug("Platform vmtypes result: {}", res);
        if (res.getStatus().equals(EventStatus.FAILED)) {
            LOGGER.debug("Failed to get platform vmtypes", res.getErrorDetails());
            throw new GetCloudParameterException("Failed to get VM types for the cloud provider. " + getCauseMessages(res.getErrorDetails()), res.getErrorDetails());
        }
        return res.getCloudVmTypes();
    } catch (InterruptedException e) {
        LOGGER.error("Error while getting the platform vmtypes", e);
        throw new OperationException(e);
    }
}
Also used : GetPlatformVmTypesResult(com.sequenceiq.cloudbreak.cloud.event.platform.GetPlatformVmTypesResult) GetPlatformVmTypesRequest(com.sequenceiq.cloudbreak.cloud.event.platform.GetPlatformVmTypesRequest) 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