Search in sources :

Example 1 with OperationException

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

the class FileSystemValidator method validateFileSystem.

public void validateFileSystem(String platform, CloudCredential cloudCredential, FileSystemRequest fileSystemRequest) {
    if (fileSystemRequest == null) {
        return;
    }
    validateFilesystemRequest(fileSystemRequest);
    LOGGER.debug("Sending fileSystemRequest to {} to validate the file system", platform);
    CloudContext cloudContext = new CloudContext(null, null, platform, null, null, null);
    FileSystem fileSystem = converter.convert(fileSystemRequest);
    FileSystemValidationRequest request = new FileSystemValidationRequest(fileSystem, cloudCredential, cloudContext);
    eventBus.notify(request.selector(), eventFactory.createEvent(request));
    try {
        FileSystemValidationResult result = request.await();
        LOGGER.info("File system validation result: {}", result);
        Exception exception = result.getErrorDetails();
        if (exception != null) {
            throw new BadRequestException(result.getStatusReason(), exception);
        }
    } catch (InterruptedException e) {
        LOGGER.error("Error while sending the file system validation request", e);
        throw new OperationException(e);
    }
}
Also used : FileSystemValidationResult(com.sequenceiq.cloudbreak.cloud.event.validation.FileSystemValidationResult) FileSystemValidationRequest(com.sequenceiq.cloudbreak.cloud.event.validation.FileSystemValidationRequest) CloudContext(com.sequenceiq.cloudbreak.cloud.context.CloudContext) FileSystem(com.sequenceiq.cloudbreak.cloud.model.FileSystem) BadRequestException(com.sequenceiq.cloudbreak.controller.BadRequestException) OperationException(com.sequenceiq.cloudbreak.service.stack.connector.OperationException) IOException(java.io.IOException) ConstraintViolationException(javax.validation.ConstraintViolationException) BadRequestException(com.sequenceiq.cloudbreak.controller.BadRequestException) OperationException(com.sequenceiq.cloudbreak.service.stack.connector.OperationException)

Example 2 with OperationException

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

the class ServiceProviderSetupAdapter method checkImage.

public ImageStatusResult checkImage(Stack stack) throws Exception {
    Location location = location(region(stack.getRegion()), availabilityZone(stack.getAvailabilityZone()));
    CloudContext cloudContext = new CloudContext(stack.getId(), stack.getName(), stack.cloudPlatform(), stack.getOwner(), stack.getPlatformVariant(), location);
    CloudCredential cloudCredential = credentialConverter.convert(stack.getCredential());
    Image image = imageService.getImage(stack.getId());
    CheckImageRequest<CheckImageResult> checkImageRequest = new CheckImageRequest<>(cloudContext, cloudCredential, cloudStackConverter.convert(stack), image);
    LOGGER.info("Triggering event: {}", checkImageRequest);
    eventBus.notify(checkImageRequest.selector(), eventFactory.createEvent(checkImageRequest));
    try {
        CheckImageResult res = checkImageRequest.await();
        LOGGER.info("Result: {}", res);
        if (res.getErrorDetails() != null) {
            LOGGER.error("Failed to check image state", res.getErrorDetails());
            throw new OperationException(res.getErrorDetails());
        }
        return new ImageStatusResult(res.getImageStatus(), res.getStatusProgressValue());
    } catch (InterruptedException e) {
        LOGGER.error("Error while executing check image", e);
        throw new OperationException(e);
    }
}
Also used : CloudCredential(com.sequenceiq.cloudbreak.cloud.model.CloudCredential) CloudContext(com.sequenceiq.cloudbreak.cloud.context.CloudContext) CheckImageResult(com.sequenceiq.cloudbreak.cloud.event.setup.CheckImageResult) Image(com.sequenceiq.cloudbreak.cloud.model.Image) OperationException(com.sequenceiq.cloudbreak.service.stack.connector.OperationException) Location(com.sequenceiq.cloudbreak.cloud.model.Location) CheckImageRequest(com.sequenceiq.cloudbreak.cloud.event.setup.CheckImageRequest) ImageStatusResult(com.sequenceiq.cloudbreak.common.type.ImageStatusResult)

Example 3 with OperationException

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

the class ResourceDefinitionService method getResourceDefinition.

@Cacheable("resourceDefinitionCache")
public String getResourceDefinition(String cloudPlatform, String resource) {
    LOGGER.debug("Sending request for {} {} resource property definition", cloudPlatform, resource);
    CloudPlatformVariant platformVariant = new CloudPlatformVariant(Platform.platform(cloudPlatform), Variant.EMPTY);
    ResourceDefinitionRequest request = new ResourceDefinitionRequest(platformVariant, resource);
    eventBus.notify(request.selector(), eventFactory.createEvent(request));
    try {
        ResourceDefinitionResult result = request.await();
        LOGGER.info("Resource property definition: {}", result);
        return result.getDefinition();
    } catch (InterruptedException e) {
        LOGGER.error("Error while sending resource definition request", e);
        throw new OperationException(e);
    }
}
Also used : CloudPlatformVariant(com.sequenceiq.cloudbreak.cloud.model.CloudPlatformVariant) ResourceDefinitionResult(com.sequenceiq.cloudbreak.cloud.event.platform.ResourceDefinitionResult) ResourceDefinitionRequest(com.sequenceiq.cloudbreak.cloud.event.platform.ResourceDefinitionRequest) OperationException(com.sequenceiq.cloudbreak.service.stack.connector.OperationException) Cacheable(org.springframework.cache.annotation.Cacheable)

Example 4 with OperationException

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

the class StackCreationService method checkImage.

public CheckImageResult checkImage(StackContext context) {
    try {
        Stack stack = context.getStack();
        Image image = imageService.getImage(stack.getId());
        CheckImageRequest<CheckImageResult> checkImageRequest = new CheckImageRequest<>(context.getCloudContext(), context.getCloudCredential(), cloudStackConverter.convert(stack), image);
        LOGGER.info("Triggering event: {}", checkImageRequest);
        eventBus.notify(checkImageRequest.selector(), eventFactory.createEvent(checkImageRequest));
        CheckImageResult result = checkImageRequest.await();
        sendNotification(result, stack);
        LOGGER.info("Result: {}", result);
        return result;
    } catch (InterruptedException e) {
        LOGGER.error("Error while executing check image", e);
        throw new OperationException(e);
    } catch (CloudbreakImageNotFoundException e) {
        throw new CloudbreakServiceException(e);
    }
}
Also used : CloudbreakServiceException(com.sequenceiq.cloudbreak.service.CloudbreakServiceException) CheckImageResult(com.sequenceiq.cloudbreak.cloud.event.setup.CheckImageResult) CloudbreakImageNotFoundException(com.sequenceiq.cloudbreak.core.CloudbreakImageNotFoundException) Image(com.sequenceiq.cloudbreak.cloud.model.Image) OperationException(com.sequenceiq.cloudbreak.service.stack.connector.OperationException) Stack(com.sequenceiq.cloudbreak.domain.Stack) CheckImageRequest(com.sequenceiq.cloudbreak.cloud.event.setup.CheckImageRequest)

Example 5 with OperationException

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

the class StackParameterService method getStackParams.

public List<StackParamValidation> getStackParams(String name, Credential credential) {
    LOGGER.debug("Get stack params");
    if (credential != null) {
        CloudContext cloudContext = new CloudContext(null, name, credential.cloudPlatform(), credential.getOwner());
        GetStackParamValidationRequest getStackParamValidationRequest = new GetStackParamValidationRequest(cloudContext);
        eventBus.notify(getStackParamValidationRequest.selector(), eventFactory.createEvent(getStackParamValidationRequest));
        try {
            GetStackParamValidationResult res = getStackParamValidationRequest.await();
            LOGGER.info("Get stack params result: {}", res);
            if (res.getStatus().equals(EventStatus.FAILED)) {
                LOGGER.error("Failed to get stack params", res.getErrorDetails());
                throw new OperationException(res.getErrorDetails());
            }
            return res.getStackParamValidations();
        } catch (InterruptedException e) {
            LOGGER.error("Error while getting the stack params", e);
            throw new OperationException(e);
        }
    } else {
        return Collections.emptyList();
    }
}
Also used : GetStackParamValidationResult(com.sequenceiq.cloudbreak.cloud.event.platform.GetStackParamValidationResult) CloudContext(com.sequenceiq.cloudbreak.cloud.context.CloudContext) GetStackParamValidationRequest(com.sequenceiq.cloudbreak.cloud.event.platform.GetStackParamValidationRequest) OperationException(com.sequenceiq.cloudbreak.service.stack.connector.OperationException)

Aggregations

OperationException (com.sequenceiq.cloudbreak.service.stack.connector.OperationException)29 CloudContext (com.sequenceiq.cloudbreak.cloud.context.CloudContext)12 ExtendedCloudCredential (com.sequenceiq.cloudbreak.cloud.model.ExtendedCloudCredential)11 CloudCredential (com.sequenceiq.cloudbreak.cloud.model.CloudCredential)9 Location (com.sequenceiq.cloudbreak.cloud.model.Location)8 CloudResource (com.sequenceiq.cloudbreak.cloud.model.CloudResource)3 BadRequestException (com.sequenceiq.cloudbreak.controller.BadRequestException)3 CheckImageRequest (com.sequenceiq.cloudbreak.cloud.event.setup.CheckImageRequest)2 CheckImageResult (com.sequenceiq.cloudbreak.cloud.event.setup.CheckImageResult)2 CloudInstance (com.sequenceiq.cloudbreak.cloud.model.CloudInstance)2 Image (com.sequenceiq.cloudbreak.cloud.model.Image)2 InstanceGroup (com.sequenceiq.cloudbreak.domain.InstanceGroup)2 InstanceMetaData (com.sequenceiq.cloudbreak.domain.InstanceMetaData)2 CredentialVerificationRequest (com.sequenceiq.cloudbreak.cloud.event.credential.CredentialVerificationRequest)1 CredentialVerificationResult (com.sequenceiq.cloudbreak.cloud.event.credential.CredentialVerificationResult)1 InteractiveLoginRequest (com.sequenceiq.cloudbreak.cloud.event.credential.InteractiveLoginRequest)1 InteractiveLoginResult (com.sequenceiq.cloudbreak.cloud.event.credential.InteractiveLoginResult)1 CollectMetadataRequest (com.sequenceiq.cloudbreak.cloud.event.instance.CollectMetadataRequest)1 CollectMetadataResult (com.sequenceiq.cloudbreak.cloud.event.instance.CollectMetadataResult)1 CheckPlatformVariantRequest (com.sequenceiq.cloudbreak.cloud.event.platform.CheckPlatformVariantRequest)1