use of com.sequenceiq.cloudbreak.telemetry.fluent.cloud.AdlsGen2Config in project cloudbreak by hortonworks.
the class CmDiagnosticsDataToParameterConverter method convert.
public CmDiagnosticsParameters convert(BaseCmDiagnosticsCollectionRequest request, Telemetry telemetry, String clusterName, String region) {
Logging logging = telemetry.getLogging();
CmDiagnosticsParameters.CmDiagnosticsParametersBuilder builder = CmDiagnosticsParameters.builder();
if (logging.getS3() != null) {
S3Config s3Config = s3ConfigGenerator.generateStorageConfig(logging.getStorageLocation());
builder.withS3Bucket(s3Config.getBucket());
builder.withS3Location(Paths.get(s3Config.getFolderPrefix(), DIAGNOSTICS_SUFFIX_PATH).toString());
builder.withS3Region(region);
} else if (logging.getAdlsGen2() != null) {
AdlsGen2Config adlsGen2Config = adlsGen2ConfigGenerator.generateStorageConfig(logging.getStorageLocation());
builder.withAdlsv2StorageAccount(adlsGen2Config.getAccount());
builder.withAdlsv2StorageContainer(adlsGen2Config.getFileSystem());
builder.withAdlsv2StorageLocation(Paths.get(adlsGen2Config.getFolderPrefix(), DIAGNOSTICS_SUFFIX_PATH).toString());
} else if (logging.getGcs() != null) {
GcsConfig gcsConfig = gcsConfigGenerator.generateStorageConfig(logging.getStorageLocation());
builder.withGcsBucket(gcsConfig.getBucket());
builder.withGcsLocation(Paths.get(gcsConfig.getFolderPrefix(), DIAGNOSTICS_SUFFIX_PATH).toString());
}
builder.withComments(request.getComments()).withDestination(request.getDestination()).withClusterName(clusterName).withStartTime(request.getStartTime()).withEndTime(request.getEndTime()).withTicketNumber(request.getTicket()).withRoles(request.getRoles()).withBundleSizeBytes(request.getBundleSizeBytes()).withEnableMonitorMetricsCollection(request.getEnableMonitorMetricsCollection()).withUpdatePackage(request.getUpdatePackage()).withSkipValidation(request.getSkipValidation());
return builder.build();
}
use of com.sequenceiq.cloudbreak.telemetry.fluent.cloud.AdlsGen2Config in project cloudbreak by hortonworks.
the class AzureIDBrokerObjectStorageValidator method validateStorageAccount.
private void validateStorageAccount(AzureClient client, Set<Identity> identities, String location, CloudIdentityType cloudIdentityType, ValidationResultBuilder resultBuilder) {
AdlsGen2Config adlsGen2Config = adlsGen2ConfigGenerator.generateStorageConfig(location);
String storageAccountName = adlsGen2Config.getAccount();
Optional<String> storageAccountIdOptional = azureStorage.findStorageAccountIdInVisibleSubscriptions(client, storageAccountName);
if (storageAccountIdOptional.isEmpty()) {
LOGGER.debug("Storage account {} not found or insufficient permission to list subscriptions and / or storage accounts.", storageAccountName);
addError(resultBuilder, String.format("Storage account with name %s not found in the given Azure subscription. %s", storageAccountName, getAdviceMessage(STORAGE_LOCATION, cloudIdentityType)));
return;
}
List<RoleAssignmentInner> roleAssignments = client.listRoleAssignmentsByScopeInner(storageAccountIdOptional.get());
ResourceId storageAccountResourceId = ResourceId.fromString(storageAccountIdOptional.get());
boolean differentSubscriptions = !client.getCurrentSubscription().subscriptionId().equals(storageAccountResourceId.subscriptionId());
List<RoleAssignmentInner> roleAssignmentsForSubscription = getRoleAssignmentsOfSubscription(roleAssignments, storageAccountResourceId.subscriptionId(), client, differentSubscriptions);
for (Identity identity : identities) {
validateRoleAssigmentAndScope(roleAssignmentsForSubscription, resultBuilder, identity, List.of(storageAccountName, storageAccountResourceId.resourceGroupName(), storageAccountResourceId.subscriptionId()), differentSubscriptions, cloudIdentityType);
}
}
use of com.sequenceiq.cloudbreak.telemetry.fluent.cloud.AdlsGen2Config in project cloudbreak by hortonworks.
the class AzureIDBrokerObjectStorageValidatorTest method setup.
@Before
public void setup() {
when(client.getIdentityById(LOG_IDENTITY)).thenReturn(logger);
when(client.getIdentityById(ASSUMER_IDENTITY)).thenReturn(assumer);
when(client.getCurrentSubscription()).thenReturn(mock(Subscription.class));
when(client.getCurrentSubscription().subscriptionId()).thenReturn(SUBSCRIPTION_ID);
when(client.getResourceGroup(RESOURCE_GROUP_NAME)).thenReturn(resourceGroup);
when(client.getStorageAccount(any(), any())).thenReturn(Optional.of(storageAccount));
when(storageAccount.isHnsEnabled()).thenReturn(Boolean.TRUE);
when(resourceGroup.id()).thenReturn(RESOURCE_GROUP_ID);
AdlsGen2Config adlsGen2Config = new AdlsGen2Config("abfs://", ABFS_FILESYSTEM_NAME, ABFS_STORAGE_ACCOUNT_NAME, false);
when(adlsGen2ConfigGenerator.generateStorageConfig(anyString())).thenReturn(adlsGen2Config);
when(logger.id()).thenReturn(LOG_IDENTITY);
when(logger.principalId()).thenReturn(LOG_IDENTITY_PRINCIPAL_ID);
when(assumer.id()).thenReturn(ASSUMER_IDENTITY);
when(assumer.principalId()).thenReturn(ASSUMER_IDENTITY_PRINCIPAL_ID);
when(azureStorage.findStorageAccountIdInVisibleSubscriptions(any(), anyString())).thenReturn(Optional.of(ABFS_STORAGE_ACCOUNT_ID));
}
use of com.sequenceiq.cloudbreak.telemetry.fluent.cloud.AdlsGen2Config in project cloudbreak by hortonworks.
the class FluentConfigService method fillAdlsGen2Configs.
private void fillAdlsGen2Configs(FluentConfigView.Builder builder, String storageLocation, AdlsGen2CloudStorageV1Parameters parameters) {
AdlsGen2Config adlsGen2Config = adlsGen2ConfigGenerator.generateStorageConfig(storageLocation);
String storageAccount = StringUtils.isNotEmpty(adlsGen2Config.getAccount()) ? adlsGen2Config.getAccount() : parameters.getAccountName();
if (StringUtils.isNotBlank(parameters.getManagedIdentity())) {
builder.withAzureInstanceMsi(parameters.getManagedIdentity());
} else {
builder.withAzureStorageAccessKey(parameters.getAccountKey());
}
builder.withProviderPrefix(ADLS_GEN2_PROVIDER_PREFIX).withAzureContainer(adlsGen2Config.getFileSystem()).withAzureStorageAccount(storageAccount).withLogFolderName(adlsGen2Config.getFolderPrefix());
}
Aggregations