use of com.sequenceiq.cloudbreak.service.OperationException in project cloudbreak by hortonworks.
the class FileSystemValidator method validate.
public void validate(String platform, CloudCredential cloudCredential, CloudStorageBase cloudStorageRequest, Long workspaceId) {
if (cloudStorageRequest == null) {
return;
}
LOGGER.info("Sending fileSystemRequest to {} to validate the file system", platform);
CloudContext cloudContext = CloudContext.Builder.builder().withPlatform(platform).withWorkspaceId(workspaceId).build();
SpiFileSystem spiFileSystem = cloudStorageConverter.requestToSpiFileSystem(cloudStorageRequest);
FileSystemValidationRequest request = new FileSystemValidationRequest(spiFileSystem, 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.OperationException in project cloudbreak by hortonworks.
the class StackParameterService method getStackParams.
public List<StackParamValidation> getStackParams(String name, Stack stack) {
LOGGER.debug("Get stack params");
Credential credential = credentialClientService.getByEnvironmentCrn(stack.getEnvironmentCrn());
if (credential != null) {
CloudContext cloudContext = CloudContext.Builder.builder().withName(name).withCrn(credential.getCrn()).withPlatform(credential.cloudPlatform()).withWorkspaceId(stack.getWorkspace().getId()).withAccountId(stack.getTenant().getId()).build();
GetStackParamValidationRequest getStackParamValidationRequest = new GetStackParamValidationRequest(cloudContext);
eventBus.notify(getStackParamValidationRequest.selector(), eventFactory.createEvent(getStackParamValidationRequest));
try {
GetStackParamValidationResult res = getStackParamValidationRequest.await();
LOGGER.debug("Get stack params result: {}", res);
if (res.getStatus().equals(EventStatus.FAILED)) {
LOGGER.info("Failed to get stack params", res.getErrorDetails());
throw new OperationException(res.getErrorDetails());
}
return res.getStackParamValidations();
} catch (InterruptedException e) {
LOGGER.info("Error while getting the stack params", e);
throw new OperationException(e);
}
} else {
return Collections.emptyList();
}
}
use of com.sequenceiq.cloudbreak.service.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 = CloudContext.Builder.builder().withId(stack.getId()).withName(stack.getName()).withCrn(stack.getResourceCrn()).withPlatform(stack.getCloudPlatform()).withVariant(stack.getPlatformVariant()).withLocation(location).withWorkspaceId(stack.getWorkspace().getId()).withAccountId(stack.getTenant().getId()).build();
CloudCredential cloudCredential = stackUtil.getCloudCredential(stack);
Image image = imageService.getImage(stack.getId());
CheckImageRequest<CheckImageResult> checkImageRequest = new CheckImageRequest<>(cloudContext, cloudCredential, cloudStackConverter.convert(stack), image);
LOGGER.debug("Triggering event: {}", checkImageRequest);
eventBus.notify(checkImageRequest.selector(), eventFactory.createEvent(checkImageRequest));
try {
CheckImageResult res = checkImageRequest.await();
LOGGER.debug("Result: {}", res);
if (res.getErrorDetails() != null) {
LOGGER.info("Failed to check image state", res.getErrorDetails());
throw new OperationException(res.getErrorDetails());
}
return new ImageStatusResult(res.getImageStatus(), res.getStatusProgressValue());
} catch (InterruptedException e) {
LOGGER.info("Error while executing check image", e);
throw new OperationException(e);
}
}
use of com.sequenceiq.cloudbreak.service.OperationException in project cloudbreak by hortonworks.
the class CredentialPrerequisiteService method getCloudbreakPrerequisites.
public CredentialPrerequisitesResponse getCloudbreakPrerequisites(String cloudPlatform, String deploymentAddress, CredentialType type) {
CloudContext cloudContext = CloudContext.Builder.builder().withPlatform(cloudPlatform).withWorkspaceId(TEMP_WORKSPACE_ID).build();
CredentialPrerequisitesRequest request = new CredentialPrerequisitesRequest(cloudContext, userPreferencesService.getExternalIdForCurrentUser(), userPreferencesService.getAuditExternalIdForCurrentUser(), deploymentAddress, type);
LOGGER.debug("Triggering event: {}", request);
eventBus.notify(request.selector(), eventFactory.createEvent(request));
String message = String.format("Failed to get prerequisites for platform '%s': ", cloudPlatform);
try {
CredentialPrerequisitesResult res = request.await();
LOGGER.debug("Result: {}", res);
if (res.getStatus() != EventStatus.OK) {
LOGGER.info(message, res.getErrorDetails());
throw new BadRequestException(message + res.getErrorDetails(), res.getErrorDetails());
}
return res.getCredentialPrerequisitesResponse();
} catch (InterruptedException e) {
LOGGER.error(message, e);
throw new OperationException(e);
}
}
use of com.sequenceiq.cloudbreak.service.OperationException in project cloudbreak by hortonworks.
the class StackImageUpdateActions method checkImageVersion.
@Bean(name = "CHECK_IMAGE_VERSIONS_STATE")
public AbstractStackImageUpdateAction<?> checkImageVersion() {
return new AbstractStackImageUpdateAction<>(StackImageUpdateTriggerEvent.class) {
@Override
protected void doExecute(StackContext context, StackImageUpdateTriggerEvent payload, Map<Object, Object> variables) {
getFlowMessageService().fireEventAndLog(context.getStack().getId(), Status.UPDATE_IN_PROGRESS.name(), STACK_IMAGE_UPDATE_STARTED);
if (!getStackImageUpdateService().isCbVersionOk(context.getStack())) {
throw new OperationException("Stack must be created at least with Cloudbreak version [" + StackImageUpdateService.MIN_VERSION + ']');
}
StatedImage newImage = getStackImageUpdateService().getNewImageIfVersionsMatch(context.getStack(), payload.getNewImageId(), payload.getImageCatalogName(), payload.getImageCatalogUrl());
sendEvent(context, new ImageUpdateEvent(StackImageUpdateEvent.CHECK_IMAGE_VERESIONS_FINISHED_EVENT.event(), context.getStack().getId(), newImage));
}
};
}
Aggregations