Search in sources :

Example 21 with OperationException

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

the class CloudParameterService method getPlatformVariants.

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

Example 22 with OperationException

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

the class CloudParameterService method getRecommendation.

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

Example 23 with OperationException

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

the class CloudParameterService method getPublicIpPools.

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

Example 24 with OperationException

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

the class CloudParameterService method getGateways.

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

Example 25 with OperationException

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

the class CloudParameterService method getResourceGroups.

@Retryable(value = GetCloudParameterException.class, maxAttempts = 5, backoff = @Backoff(delay = 1000, multiplier = 2, maxDelay = 10000))
public CloudResourceGroups getResourceGroups(ExtendedCloudCredential cloudCredential, String region, String platformVariant, Map<String, String> filters) {
    LOGGER.debug("Get platform resource groups for credential: [{}]", cloudCredential.getName());
    GetPlatformResourceGroupsRequest request = new GetPlatformResourceGroupsRequest(cloudCredential, cloudCredential, platformVariant, region, null);
    eventBus.notify(request.selector(), Event.wrap(request));
    try {
        GetPlatformResourceGroupsResult result = request.await();
        LOGGER.debug("Platform ResourceGroupsResult result: {}", result);
        if (result.getStatus().equals(EventStatus.FAILED)) {
            LOGGER.debug("Failed to get platform ResourceGroupsResult", result.getErrorDetails());
            throw new GetCloudParameterException(String.format("Failed to get resource groups tables for the cloud provider: %s. %s", result.getStatusReason(), getCauseMessages(result.getErrorDetails())), result.getErrorDetails());
        }
        return result.getResourceGroups();
    } catch (InterruptedException e) {
        LOGGER.error("Error while getting the platform ResourceGroupsResult", e);
        throw new OperationException(e);
    }
}
Also used : GetPlatformResourceGroupsRequest(com.sequenceiq.cloudbreak.cloud.event.platform.GetPlatformResourceGroupsRequest) GetPlatformResourceGroupsResult(com.sequenceiq.cloudbreak.cloud.event.platform.GetPlatformResourceGroupsResult) 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