use of com.sequenceiq.cloudbreak.cloud.model.SpiFileSystem 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.cloud.model.SpiFileSystem in project cloudbreak by hortonworks.
the class CloudStorageConverter method requestToSpiFileSystem.
public SpiFileSystem requestToSpiFileSystem(CloudStorageBase cloudStorageRequest) {
List<CloudFileSystemView> cloudFileSystemViews = new ArrayList<>();
FileSystemType type = null;
if (cloudStorageRequest.getIdentities() != null && !cloudStorageRequest.getIdentities().isEmpty()) {
for (StorageIdentityBase storageIdentity : cloudStorageRequest.getIdentities()) {
type = getCloudFileSystemView(cloudStorageRequest, cloudFileSystemViews, storageIdentity);
}
}
validateCloudFileSystemViews(cloudFileSystemViews, type);
return new SpiFileSystem("", type, cloudFileSystemViews);
}
use of com.sequenceiq.cloudbreak.cloud.model.SpiFileSystem in project cloudbreak by hortonworks.
the class AzureObjectStorageConnector method validateObjectStorage.
@Override
public ObjectStorageValidateResponse validateObjectStorage(ObjectStorageValidateRequest request) {
String accountId = Crn.safeFromString(request.getCredential().getId()).getAccountId();
if (!entitlementService.azureCloudStorageValidationEnabled(accountId)) {
LOGGER.info("Azure Cloud storage validation entitlement is missing, not validating cloudStorageRequest: {}", JsonUtil.writeValueAsStringSilent(request));
return ObjectStorageValidateResponse.builder().withStatus(ResponseStatus.OK).build();
}
AzureClient client = azureClientService.getClient(request.getCredential());
SpiFileSystem spiFileSystem = request.getSpiFileSystem();
ValidationResult.ValidationResultBuilder resultBuilder = new ValidationResult.ValidationResultBuilder();
resultBuilder.prefix("Cloud Storage validation failed");
try {
ValidationResult validationResult = azureIDBrokerObjectStorageValidator.validateObjectStorage(client, spiFileSystem, request.getLogsLocationBase(), request.getBackupLocationBase(), getSingleResourceGroupName(request), resultBuilder);
ObjectStorageValidateResponse response;
if (validationResult.hasError()) {
response = ObjectStorageValidateResponse.builder().withStatus(ResponseStatus.ERROR).withError(validationResult.getFormattedErrors()).build();
} else {
response = ObjectStorageValidateResponse.builder().withStatus(ResponseStatus.OK).build();
}
return response;
} catch (CloudException e) {
if (e.body() != null && StringUtils.equals("AuthorizationFailed", e.body().code())) {
LOGGER.error("Object storage validation failed on Azure due to authorization failure: ", e.getMessage());
throw new AccessDeniedException("Object storage validation failed on Azure due to authorization failure: ", e);
}
throw azureUtils.convertToCloudConnectorException(e, "Object storage validation");
}
}
use of com.sequenceiq.cloudbreak.cloud.model.SpiFileSystem in project cloudbreak by hortonworks.
the class StackToCloudStackConverterTest method testConvertWhenThereIsAFileSystemInClusterThenExpectedSpiFileSystemShouldPlacedInCloudStack.
@Test
public void testConvertWhenThereIsAFileSystemInClusterThenExpectedSpiFileSystemShouldPlacedInCloudStack() {
FileSystem fileSystem = new FileSystem();
SpiFileSystem expected = mock(SpiFileSystem.class);
when(cluster.getFileSystem()).thenReturn(fileSystem);
when(fileSystemConverter.fileSystemToSpi(fileSystem)).thenReturn(expected);
CloudStack result = underTest.convert(stack);
assertTrue(result.getFileSystem().isPresent());
assertEquals(expected, result.getFileSystem().get());
verify(fileSystemConverter, times(1)).fileSystemToSpi(fileSystem);
}
use of com.sequenceiq.cloudbreak.cloud.model.SpiFileSystem in project cloudbreak by hortonworks.
the class AzureFileSystemValidator method validate.
@Override
public void validate(AuthenticatedContext ac, CloudStack cloudStack) {
if (cloudStack.getFileSystem().isEmpty()) {
return;
}
LOGGER.info("Validation azure filesystem");
try {
SpiFileSystem spiFileSystem = cloudStack.getFileSystem().get();
azureSetup.validateFileSystem(ac.getCloudCredential(), spiFileSystem);
} catch (Exception e) {
LOGGER.error("Error during the azure file system validation", e);
throw new CloudConnectorException("Error during the azure file system validation", e);
}
}
Aggregations