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);
}
}
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);
}
}
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);
}
}
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);
}
}
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();
}
}
Aggregations