Search in sources :

Example 1 with AdlsGen2Config

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();
}
Also used : Logging(com.sequenceiq.common.api.telemetry.model.Logging) S3Config(com.sequenceiq.cloudbreak.telemetry.fluent.cloud.S3Config) AdlsGen2Config(com.sequenceiq.cloudbreak.telemetry.fluent.cloud.AdlsGen2Config) GcsConfig(com.sequenceiq.cloudbreak.telemetry.fluent.cloud.GcsConfig) CmDiagnosticsParameters(com.sequenceiq.common.model.diagnostics.CmDiagnosticsParameters)

Example 2 with AdlsGen2Config

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);
    }
}
Also used : ResourceId(com.microsoft.azure.management.resources.fluentcore.arm.ResourceId) AdlsGen2Config(com.sequenceiq.cloudbreak.telemetry.fluent.cloud.AdlsGen2Config) RoleAssignmentInner(com.microsoft.azure.management.graphrbac.implementation.RoleAssignmentInner) Identity(com.microsoft.azure.management.msi.Identity)

Example 3 with AdlsGen2Config

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));
}
Also used : AdlsGen2Config(com.sequenceiq.cloudbreak.telemetry.fluent.cloud.AdlsGen2Config) Subscription(com.microsoft.azure.management.resources.Subscription) Before(org.junit.Before)

Example 4 with AdlsGen2Config

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());
}
Also used : AdlsGen2Config(com.sequenceiq.cloudbreak.telemetry.fluent.cloud.AdlsGen2Config)

Aggregations

AdlsGen2Config (com.sequenceiq.cloudbreak.telemetry.fluent.cloud.AdlsGen2Config)4 RoleAssignmentInner (com.microsoft.azure.management.graphrbac.implementation.RoleAssignmentInner)1 Identity (com.microsoft.azure.management.msi.Identity)1 Subscription (com.microsoft.azure.management.resources.Subscription)1 ResourceId (com.microsoft.azure.management.resources.fluentcore.arm.ResourceId)1 GcsConfig (com.sequenceiq.cloudbreak.telemetry.fluent.cloud.GcsConfig)1 S3Config (com.sequenceiq.cloudbreak.telemetry.fluent.cloud.S3Config)1 Logging (com.sequenceiq.common.api.telemetry.model.Logging)1 CmDiagnosticsParameters (com.sequenceiq.common.model.diagnostics.CmDiagnosticsParameters)1 Before (org.junit.Before)1