Search in sources :

Example 41 with OperationException

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

the class CloudParameterService method getSecurityGroups.

@Retryable(value = GetCloudParameterException.class, maxAttempts = 5, backoff = @Backoff(delay = 1000, multiplier = 2, maxDelay = 10000))
public CloudSecurityGroups getSecurityGroups(ExtendedCloudCredential cloudCredential, String region, String variant, Map<String, String> filters) {
    LOGGER.debug("Get platform securitygroups");
    GetPlatformSecurityGroupsRequest getPlatformSecurityGroupsRequest = new GetPlatformSecurityGroupsRequest(cloudCredential, cloudCredential, variant, region, filters);
    eventBus.notify(getPlatformSecurityGroupsRequest.selector(), eventFactory.createEvent(getPlatformSecurityGroupsRequest));
    try {
        GetPlatformSecurityGroupsResult res = getPlatformSecurityGroupsRequest.await();
        LOGGER.debug("Platform securitygroups types result: {}", res);
        if (res.getStatus().equals(EventStatus.FAILED)) {
            LOGGER.debug("Failed to get platform securitygroups", res.getErrorDetails());
            throw new GetCloudParameterException("Failed to get security groups 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 BadRequestException(res.getStatusReason());
        }
        return res.getCloudSecurityGroups();
    } catch (InterruptedException e) {
        LOGGER.error("Error while getting the platform securitygroups", e);
        throw new OperationException(e);
    }
}
Also used : GetPlatformSecurityGroupsRequest(com.sequenceiq.cloudbreak.cloud.event.platform.GetPlatformSecurityGroupsRequest) GetPlatformSecurityGroupsResult(com.sequenceiq.cloudbreak.cloud.event.platform.GetPlatformSecurityGroupsResult) BadRequestException(javax.ws.rs.BadRequestException) OperationException(com.sequenceiq.cloudbreak.service.OperationException) Retryable(org.springframework.retry.annotation.Retryable)

Example 42 with OperationException

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

the class CloudParameterService method getInstanceGroupParameters.

@Retryable(value = GetCloudParameterException.class, maxAttempts = 5, backoff = @Backoff(delay = 1000, multiplier = 2, maxDelay = 10000))
public Map<String, InstanceGroupParameterResponse> getInstanceGroupParameters(ExtendedCloudCredential cloudCredential, Set<InstanceGroupParameterRequest> instanceGroups) {
    LOGGER.debug("Get platform instanceGroupParameters");
    GetPlatformInstanceGroupParameterRequest getPlatformInstanceGroupParameterRequest = new GetPlatformInstanceGroupParameterRequest(cloudCredential, cloudCredential, instanceGroups, null);
    eventBus.notify(getPlatformInstanceGroupParameterRequest.selector(), Event.wrap(getPlatformInstanceGroupParameterRequest));
    try {
        GetPlatformInstanceGroupParameterResult res = getPlatformInstanceGroupParameterRequest.await();
        LOGGER.debug("Platform instanceGroupParameterResult result: {}", res);
        if (res.getStatus().equals(EventStatus.FAILED)) {
            LOGGER.debug("Failed to get platform instanceGroupParameterResult", res.getErrorDetails());
            throw new GetCloudParameterException(String.format("Failed to get instance group parameters for the cloud provider: %s. %s", res.getStatusReason(), getCauseMessages(res.getErrorDetails())), res.getErrorDetails());
        }
        return res.getInstanceGroupParameterResponses();
    } catch (InterruptedException e) {
        LOGGER.error("Error while getting the platform instanceGroupParameterResult", e);
        throw new OperationException(e);
    }
}
Also used : GetPlatformInstanceGroupParameterRequest(com.sequenceiq.cloudbreak.cloud.event.platform.GetPlatformInstanceGroupParameterRequest) GetPlatformInstanceGroupParameterResult(com.sequenceiq.cloudbreak.cloud.event.platform.GetPlatformInstanceGroupParameterResult) OperationException(com.sequenceiq.cloudbreak.service.OperationException) Retryable(org.springframework.retry.annotation.Retryable)

Example 43 with OperationException

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

the class CloudParameterService method getOrchestrators.

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

Example 44 with OperationException

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

the class StackProvisionService method checkImage.

public CheckImageResult checkImage(StackContext context) {
    try {
        Stack stack = context.getStack();
        com.sequenceiq.cloudbreak.cloud.model.Image image = imageConverter.convert(imageService.getByStack(stack));
        CheckImageRequest<CheckImageResult> checkImageRequest = new CheckImageRequest<>(context.getCloudContext(), context.getCloudCredential(), cloudStackConverter.convert(stack), image);
        LOGGER.debug("Triggering event: {}", checkImageRequest);
        eventBus.notify(checkImageRequest.selector(), eventFactory.createEvent(checkImageRequest));
        CheckImageResult result = checkImageRequest.await();
        LOGGER.debug("Result: {}", result);
        return result;
    } catch (InterruptedException e) {
        LOGGER.error("Error while executing check image", e);
        throw new OperationException(e);
    } catch (Exception e) {
        throw new CloudbreakServiceException(e);
    }
}
Also used : CloudbreakServiceException(com.sequenceiq.cloudbreak.common.exception.CloudbreakServiceException) CheckImageResult(com.sequenceiq.cloudbreak.cloud.event.setup.CheckImageResult) OperationException(com.sequenceiq.cloudbreak.service.OperationException) CloudbreakException(com.sequenceiq.cloudbreak.service.CloudbreakException) OperationException(com.sequenceiq.cloudbreak.service.OperationException) CloudbreakServiceException(com.sequenceiq.cloudbreak.common.exception.CloudbreakServiceException) CancellationException(com.sequenceiq.cloudbreak.cloud.scheduler.CancellationException) Stack(com.sequenceiq.freeipa.entity.Stack) CheckImageRequest(com.sequenceiq.cloudbreak.cloud.event.setup.CheckImageRequest)

Example 45 with OperationException

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

the class PlatformParameterService method getPlatformParameters.

public PlatformParameters getPlatformParameters(Stack stack, Credential credential) {
    MDCBuilder.getOrGenerateRequestId();
    LOGGER.debug("Get platform parameters for: {}", stack);
    CloudContext cloudContext = CloudContext.Builder.builder().withPlatform(stack.getCloudPlatform()).withVariant(stack.getPlatformvariant()).build();
    CloudCredential cloudCredential = credentialConverter.convert(credential);
    PlatformParameterRequest parameterRequest = new PlatformParameterRequest(cloudContext, cloudCredential);
    freeIpaFlowManager.notifyNonFlowEvent(parameterRequest);
    try {
        PlatformParameterResult res = parameterRequest.await();
        LOGGER.debug("Platform parameter result: {}", res);
        if (res.getStatus().equals(EventStatus.FAILED)) {
            LOGGER.error("Failed to get platform parameters", res.getErrorDetails());
            throw new OperationException(res.getErrorDetails());
        }
        return res.getPlatformParameters();
    } catch (InterruptedException e) {
        LOGGER.error("Error while getting platform parameters: " + cloudContext, e);
        throw new OperationException(e);
    }
}
Also used : CloudCredential(com.sequenceiq.cloudbreak.cloud.model.CloudCredential) CloudContext(com.sequenceiq.cloudbreak.cloud.context.CloudContext) PlatformParameterRequest(com.sequenceiq.cloudbreak.cloud.event.platform.PlatformParameterRequest) PlatformParameterResult(com.sequenceiq.cloudbreak.cloud.event.platform.PlatformParameterResult) OperationException(com.sequenceiq.cloudbreak.service.OperationException)

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