use of com.sequenceiq.cloudbreak.common.json.Json in project cloudbreak by hortonworks.
the class CloudStorageValidator method validateCloudStorage.
public ObjectStorageValidateResponse validateCloudStorage(String accountId, EnvironmentCloudStorageValidationRequest environmentCloudStorageValidationRequest) {
Credential credential = credentialService.getByCrnForAccountId(environmentCloudStorageValidationRequest.getCredentialCrn(), accountId, ENVIRONMENT, false);
String attributes = credential.getAttributes();
CloudCredential cloudCredential = new CloudCredential(credential.getResourceCrn(), credential.getName(), new Json(attributes).getMap(), credential.getAccountId(), credential.isVerifyPermissions());
CloudStorageRequest cloudStorageRequest = new CloudStorageRequest();
TelemetryRequest telemetryRequest = environmentCloudStorageValidationRequest.getTelemetry();
boolean loggingConfigured = isLoggingConfigured(telemetryRequest);
if (loggingConfigured) {
LOGGER.debug("Cloud storage logging is enabled.");
addLogIdentity(cloudStorageRequest, telemetryRequest);
}
ObjectStorageValidateRequest.Builder objectStorageValidateBuilder = ObjectStorageValidateRequest.builder().withCloudPlatform(credential.getCloudPlatform()).withCredential(cloudCredential).withCloudStorageRequest(cloudStorageRequest);
if (loggingConfigured) {
objectStorageValidateBuilder.withLogsLocationBase(telemetryRequest.getLogging().getStorageLocation());
}
if (environmentCloudStorageValidationRequest.getBackup() != null) {
objectStorageValidateBuilder.withBackupLocationBase(environmentCloudStorageValidationRequest.getBackup().getStorageLocation());
}
ObjectStorageValidateRequest objectStorageValidateRequest = objectStorageValidateBuilder.build();
return ThreadBasedUserCrnProvider.doAsInternalActor(regionAwareInternalCrnGeneratorFactory.iam().getInternalCrnForServiceAsString(), () -> cloudProviderServicesV4Endpoint.validateObjectStorage(objectStorageValidateRequest));
}
use of com.sequenceiq.cloudbreak.common.json.Json in project cloudbreak by hortonworks.
the class SshJClientActions method getAwsEphemeralVolumeMountPoints.
public Set<String> getAwsEphemeralVolumeMountPoints(List<InstanceGroupV4Response> instanceGroups, List<String> hostGroupNames) {
Map<String, Pair<Integer, String>> deviceMountPointMappingsByIp = getDeviceMountPointMappingsByIp(instanceGroups, hostGroupNames, "hadoopfs");
Map<String, Pair<Integer, String>> deviceDiskTypeMappingsByIp = getDeviceDiskTypeMappingsByIp(instanceGroups, hostGroupNames);
Map<String, String> mountPoints = deviceDiskTypeMappingsByIp.entrySet().stream().findFirst().stream().map(node -> new Json(deviceMountPointMappingsByIp.get(node.getKey()).getValue()).getMap().entrySet()).flatMap(Set::stream).collect(Collectors.toMap(Entry::getKey, x -> String.valueOf(x.getValue())));
return deviceDiskTypeMappingsByIp.entrySet().stream().findFirst().stream().map(node -> new Json(node.getValue().getValue()).getMap().entrySet().stream().filter(e -> String.valueOf(e.getValue()).contains("Amazon EC2 NVMe Instance Storage")).collect(Collectors.toMap(Entry::getKey, x -> String.valueOf(x.getValue())))).map(Map::keySet).flatMap(Set::stream).map(mountPoints::get).collect(Collectors.toSet());
}
use of com.sequenceiq.cloudbreak.common.json.Json in project cloudbreak by hortonworks.
the class SshJClientActions method checkAwsEphemeralDisksMounted.
public void checkAwsEphemeralDisksMounted(List<InstanceGroupV4Response> instanceGroups, List<String> hostGroupNames, String mountDirPrefix) {
Map<String, Pair<Integer, String>> deviceMountPointMappingsByIp = getDeviceMountPointMappingsByIp(instanceGroups, hostGroupNames, "hadoopfs");
Map<String, Pair<Integer, String>> deviceDiskTypeMappingsByIp = getDeviceDiskTypeMappingsByIp(instanceGroups, hostGroupNames);
for (Entry<String, Pair<Integer, String>> node : deviceDiskTypeMappingsByIp.entrySet()) {
Map<String, String> ephemeralDisks = new Json(node.getValue().getValue()).getMap().entrySet().stream().filter(e -> String.valueOf(e.getValue()).contains("Amazon EC2 NVMe Instance Storage")).collect(Collectors.toMap(Entry::getKey, x -> String.valueOf(x.getValue())));
if (ephemeralDisks.isEmpty()) {
LOGGER.error("Instance store volume missing from node with IP {}!", node.getKey());
throw new TestFailException(format("Instance store volume missing from node with IP %s!", node.getKey()));
}
if (deviceMountPointMappingsByIp.get(node.getKey()) == null) {
LOGGER.error("No device mount point mappings found for node with IP {}!", node.getKey());
throw new TestFailException(format("No device mount point mappings found for node with IP %s!", node.getKey()));
}
Map<String, String> mountPoints = new Json(deviceMountPointMappingsByIp.get(node.getKey()).getValue()).getMap().entrySet().stream().collect(Collectors.toMap(Entry::getKey, x -> String.valueOf(x.getValue())));
for (String device : ephemeralDisks.keySet()) {
String mountPoint = mountPoints.get(device);
if (mountPoint == null) {
LOGGER.error("No mount point found for ephemeral device {} on node with IP {}!", device, node.getKey());
throw new TestFailException(format("No mount point found for device %s on node with IP %s!", device, node.getKey()));
} else if (!mountPoint.contains(mountDirPrefix)) {
LOGGER.error("Ephemeral device {} incorrectly mounted to {} on node with IP {}!", device, mountPoint, node.getKey());
throw new TestFailException(format("Ephemeral device %s incorrectly mounted to %s on node with IP %s!", device, mountPoint, node.getKey()));
}
}
}
}
use of com.sequenceiq.cloudbreak.common.json.Json in project cloudbreak by hortonworks.
the class StackToTemplatePreparationObjectConverterTest method testConvertWhenEnvironmentBackupLocationDefinedThenBaseFileSystemConfigurationsViewShouldAddIt.
@Test
public void testConvertWhenEnvironmentBackupLocationDefinedThenBaseFileSystemConfigurationsViewShouldAddIt() throws IOException {
String backupLocation = "s3a://test";
FileSystem sourceFileSystem = new FileSystem();
FileSystem clusterServiceFileSystem = new FileSystem();
ConfigQueryEntries configQueryEntries = new ConfigQueryEntries();
BaseFileSystemConfigurationsView expected = mock(BaseFileSystemConfigurationsView.class);
List<StorageLocationView> storageLocationViews = mock(List.class);
BackupResponse backupResponse = new BackupResponse();
backupResponse.setStorageLocation(backupLocation);
DetailedEnvironmentResponse environmentResponse = DetailedEnvironmentResponse.builder().withIdBrokerMappingSource(IdBrokerMappingSource.MOCK).withCredential(new CredentialResponse()).withAdminGroupName(ADMIN_GROUP_NAME).withCrn(TestConstants.CRN).withBackup(backupResponse).build();
StorageLocation storageLocation = new StorageLocation();
storageLocation.setValue(backupLocation);
storageLocation.setProperty(RangerCloudStorageServiceConfigProvider.DEFAULT_BACKUP_DIR);
StorageLocationView backupLocationView = new StorageLocationView(storageLocation);
when(sourceCluster.getFileSystem()).thenReturn(sourceFileSystem);
when(cluster.getFileSystem()).thenReturn(clusterServiceFileSystem);
when(fileSystemConfigurationProvider.fileSystemConfiguration(eq(clusterServiceFileSystem), eq(stackMock), any(), eq(new Json("")), eq(configQueryEntries))).thenReturn(expected);
when(cmCloudStorageConfigProvider.getConfigQueryEntries()).thenReturn(configQueryEntries);
when(environmentClientService.getByCrn(anyString())).thenReturn(environmentResponse);
when(blueprintViewProvider.getBlueprintView(any())).thenReturn(getBlueprintView());
when(expected.getLocations()).thenReturn(storageLocationViews);
TemplatePreparationObject result = underTest.convert(stackMock);
assertThat(result.getFileSystemConfigurationView().isPresent()).isTrue();
assertThat(result.getFileSystemConfigurationView().get()).isEqualTo(expected);
verify(fileSystemConfigurationProvider, times(1)).fileSystemConfiguration(eq(clusterServiceFileSystem), eq(stackMock), any(), eq(new Json("")), eq(configQueryEntries));
verify(expected, times(1)).getLocations();
verify(storageLocationViews, times(1)).add(eq(backupLocationView));
}
use of com.sequenceiq.cloudbreak.common.json.Json in project cloudbreak by hortonworks.
the class MockPatchServiceTest method setStackTag.
private void setStackTag(String tagValue) {
StackTags stackTags = new StackTags(Map.of(STACK_PATCH_RESULT_TAG_KEY, tagValue), Map.of(), Map.of());
stack.setTags(new Json(stackTags));
}
Aggregations