Search in sources :

Example 16 with BaseFileSystemConfigurationsView

use of com.sequenceiq.cloudbreak.template.filesystem.BaseFileSystemConfigurationsView in project cloudbreak by hortonworks.

the class StackV4RequestToTemplatePreparationObjectConverter method getFileSystemConfigurationView.

private BaseFileSystemConfigurationsView getFileSystemConfigurationView(StackV4Request source, Json credentialAttributes) throws IOException {
    BaseFileSystemConfigurationsView fileSystemConfigurationView = null;
    if (isCloudStorageConfigured(source)) {
        FileSystem fileSystem = cloudStorageConverter.requestToFileSystem(source.getCluster().getCloudStorage());
        fileSystemConfigurationView = fileSystemConfigurationProvider.fileSystemConfiguration(fileSystem, source, credentialAttributes, cmCloudStorageConfigProvider.getConfigQueryEntries());
    }
    return fileSystemConfigurationView;
}
Also used : BaseFileSystemConfigurationsView(com.sequenceiq.cloudbreak.template.filesystem.BaseFileSystemConfigurationsView) FileSystem(com.sequenceiq.cloudbreak.domain.FileSystem)

Example 17 with BaseFileSystemConfigurationsView

use of com.sequenceiq.cloudbreak.template.filesystem.BaseFileSystemConfigurationsView in project cloudbreak by hortonworks.

the class StackV4RequestToTemplatePreparationObjectConverter method convert.

public TemplatePreparationObject convert(StackV4Request source) {
    try {
        CloudbreakUser cloudbreakUser = restRequestThreadLocalService.getCloudbreakUser();
        User user = userService.getOrCreate(cloudbreakUser);
        Workspace workspace = workspaceService.get(restRequestThreadLocalService.getRequestedWorkspaceId(), user);
        DetailedEnvironmentResponse environment = environmentClientService.getByCrn(source.getEnvironmentCrn());
        Credential credential = getCredential(source, environment);
        LdapView ldapConfig = getLdapConfig(source, environment);
        BaseFileSystemConfigurationsView fileSystemConfigurationView = getFileSystemConfigurationView(source, credential.getAttributes());
        Set<RDSConfig> rdsConfigs = getRdsConfigs(source, workspace);
        Blueprint blueprint = getBlueprint(source, workspace);
        Set<HostgroupView> hostgroupViews = getHostgroupViews(source);
        Gateway gateway = source.getCluster().getGateway() == null ? null : stackV4RequestToGatewayConverter.convert(source);
        BlueprintView blueprintView = blueprintViewProvider.getBlueprintView(blueprint);
        Optional<String> version = Optional.ofNullable(blueprintView.getVersion());
        GeneralClusterConfigs generalClusterConfigs = generalClusterConfigsProvider.generalClusterConfigs(source, cloudbreakUser.getEmail(), blueprintService.getBlueprintVariant(blueprint));
        String gatewaySignKey = null;
        if (gateway != null) {
            gatewaySignKey = gateway.getSignKey();
        }
        String envCrnForVirtualGroups = getEnvironmentCrnForVirtualGroups(environment);
        VirtualGroupRequest virtualGroupRequest = new VirtualGroupRequest(envCrnForVirtualGroups, ldapConfig != null ? ldapConfig.getAdminGroup() : "");
        Builder builder = Builder.builder().withCloudPlatform(source.getCloudPlatform()).withRdsConfigs(rdsConfigs).withHostgroupViews(hostgroupViews).withGateway(gateway, gatewaySignKey, exposedServiceCollector.getAllKnoxExposed(version)).withBlueprintView(blueprintView).withFileSystemConfigurationView(fileSystemConfigurationView).withGeneralClusterConfigs(generalClusterConfigs).withLdapConfig(ldapConfig).withCustomInputs(source.getInputs()).withKerberosConfig(getKerberosConfig(source, environment)).withStackType(source.getType()).withVirtualGroupView(virtualGroupRequest);
        decorateBuilderWithPlacement(source, builder);
        decorateBuilderWithAccountMapping(source, environment, credential, builder);
        decorateBuilderWithProductDetails(source, builder);
        decorateDatalakeView(source, builder);
        return builder.build();
    } catch (BlueprintProcessingException | IOException e) {
        throw new CloudbreakServiceException(e.getMessage(), e);
    }
}
Also used : BlueprintProcessingException(com.sequenceiq.cloudbreak.template.BlueprintProcessingException) CloudCredential(com.sequenceiq.cloudbreak.cloud.model.CloudCredential) Credential(com.sequenceiq.cloudbreak.dto.credential.Credential) CloudbreakUser(com.sequenceiq.cloudbreak.common.user.CloudbreakUser) User(com.sequenceiq.cloudbreak.workspace.model.User) GeneralClusterConfigs(com.sequenceiq.cloudbreak.template.model.GeneralClusterConfigs) BaseFileSystemConfigurationsView(com.sequenceiq.cloudbreak.template.filesystem.BaseFileSystemConfigurationsView) RDSConfig(com.sequenceiq.cloudbreak.domain.RDSConfig) Blueprint(com.sequenceiq.cloudbreak.domain.Blueprint) BlueprintView(com.sequenceiq.cloudbreak.template.views.BlueprintView) CloudbreakServiceException(com.sequenceiq.cloudbreak.common.exception.CloudbreakServiceException) Builder(com.sequenceiq.cloudbreak.template.TemplatePreparationObject.Builder) IOException(java.io.IOException) LdapView(com.sequenceiq.cloudbreak.dto.LdapView) VirtualGroupRequest(com.sequenceiq.cloudbreak.auth.altus.VirtualGroupRequest) Gateway(com.sequenceiq.cloudbreak.domain.stack.cluster.gateway.Gateway) DetailedEnvironmentResponse(com.sequenceiq.environment.api.v1.environment.model.response.DetailedEnvironmentResponse) CloudbreakUser(com.sequenceiq.cloudbreak.common.user.CloudbreakUser) HostgroupView(com.sequenceiq.cloudbreak.template.views.HostgroupView) Workspace(com.sequenceiq.cloudbreak.workspace.model.Workspace)

Example 18 with BaseFileSystemConfigurationsView

use of com.sequenceiq.cloudbreak.template.filesystem.BaseFileSystemConfigurationsView in project cloudbreak by hortonworks.

the class ZeppelinCloudStorageRoleConfigProviderTest method assertZeppelinStorageValues.

protected void assertZeppelinStorageValues(String storagePath) {
    List<StorageLocationView> locations = new ArrayList<>();
    StorageLocation zeppelinNotebookDir = new StorageLocation();
    zeppelinNotebookDir.setProperty("zeppelin.notebook.dir");
    zeppelinNotebookDir.setValue(storagePath);
    locations.add(new StorageLocationView(zeppelinNotebookDir));
    BaseFileSystemConfigurationsView fileSystemConfigurationsView;
    if (storagePath.startsWith("s3a")) {
        fileSystemConfigurationsView = new S3FileSystemConfigurationsView(new S3FileSystem(), locations, false);
    } else if (storagePath.startsWith("gcs")) {
        fileSystemConfigurationsView = new GcsFileSystemConfigurationsView(new GcsFileSystem(), locations, false);
    } else {
        fileSystemConfigurationsView = new AdlsGen2FileSystemConfigurationsView(new AdlsGen2FileSystem(), locations, false);
    }
    TemplatePreparationObject preparationObject = getTemplatePreparationObject(fileSystemConfigurationsView);
    String inputJson = getBlueprintText("input/clouderamanager-ds.bp");
    CmTemplateProcessor cmTemplateProcessor = new CmTemplateProcessor(inputJson);
    Map<String, List<ApiClusterTemplateConfig>> roleConfigs = underTest.getRoleConfigs(cmTemplateProcessor, preparationObject);
    List<ApiClusterTemplateConfig> zeppelinStorageConfigs = roleConfigs.get("zeppelin-ZEPPELIN_SERVER-BASE");
    assertEquals(1, zeppelinStorageConfigs.size());
    assertEquals("zeppelin.notebook.dir", zeppelinStorageConfigs.get(0).getName());
    assertEquals(storagePath, zeppelinStorageConfigs.get(0).getValue());
}
Also used : GcsFileSystem(com.sequenceiq.common.api.filesystem.GcsFileSystem) StorageLocationView(com.sequenceiq.cloudbreak.template.filesystem.StorageLocationView) BaseFileSystemConfigurationsView(com.sequenceiq.cloudbreak.template.filesystem.BaseFileSystemConfigurationsView) AdlsGen2FileSystem(com.sequenceiq.common.api.filesystem.AdlsGen2FileSystem) ArrayList(java.util.ArrayList) ApiClusterTemplateConfig(com.cloudera.api.swagger.model.ApiClusterTemplateConfig) S3FileSystemConfigurationsView(com.sequenceiq.cloudbreak.template.filesystem.s3.S3FileSystemConfigurationsView) S3FileSystem(com.sequenceiq.common.api.filesystem.S3FileSystem) TemplatePreparationObject(com.sequenceiq.cloudbreak.template.TemplatePreparationObject) AdlsGen2FileSystemConfigurationsView(com.sequenceiq.cloudbreak.template.filesystem.adlsgen2.AdlsGen2FileSystemConfigurationsView) GcsFileSystemConfigurationsView(com.sequenceiq.cloudbreak.template.filesystem.gcs.GcsFileSystemConfigurationsView) ArrayList(java.util.ArrayList) List(java.util.List) CmTemplateProcessor(com.sequenceiq.cloudbreak.cmtemplate.CmTemplateProcessor) StorageLocation(com.sequenceiq.cloudbreak.domain.StorageLocation)

Example 19 with BaseFileSystemConfigurationsView

use of com.sequenceiq.cloudbreak.template.filesystem.BaseFileSystemConfigurationsView in project cloudbreak by hortonworks.

the class HdfsConfigProviderTest method getTemplatePreparationObject.

private TemplatePreparationObject getTemplatePreparationObject(boolean useS3FileSystem, boolean fillDynamoTableName, boolean includeLocations) {
    HostgroupView master = new HostgroupView("master", 1, InstanceGroupType.GATEWAY, 1);
    HostgroupView worker = new HostgroupView("worker", 2, InstanceGroupType.CORE, 2);
    List<StorageLocationView> locations = new ArrayList<>();
    if (includeLocations) {
        locations.add(new StorageLocationView(getStorageLocation("hive.metastore.warehouse.dir", "s3a://bucket/warehouse/managed")));
        locations.add(new StorageLocationView(getStorageLocation("hive.metastore.warehouse.external.dir", "s3a://bucket/warehouse/external")));
    }
    BaseFileSystemConfigurationsView fileSystemConfigurationsView;
    if (useS3FileSystem) {
        S3FileSystem s3FileSystem = new S3FileSystem();
        if (fillDynamoTableName) {
            s3FileSystem.setS3GuardDynamoTableName("dynamoTable");
        }
        fileSystemConfigurationsView = new S3FileSystemConfigurationsView(s3FileSystem, locations, false);
    } else {
        fileSystemConfigurationsView = new AdlsFileSystemConfigurationsView(new AdlsFileSystem(), locations, false);
    }
    Gateway gateway = TestUtil.gatewayEnabledWithExposedKnoxServices(ExposedServiceUtil.exposedService("NAMENODE").getKnoxService());
    PlacementView placementView = new PlacementView("region", "az");
    return Builder.builder().withFileSystemConfigurationView(fileSystemConfigurationsView).withHostgroupViews(Set.of(master, worker)).withGateway(gateway, "/cb/secret/signkey", new HashSet<>()).withPlacementView(placementView).withDefaultTags(Map.of("apple", "apple1")).withProductDetails(new ClouderaManagerRepo().withVersion("7.1.0"), List.of()).withStackType(StackType.DATALAKE).build();
}
Also used : StorageLocationView(com.sequenceiq.cloudbreak.template.filesystem.StorageLocationView) BaseFileSystemConfigurationsView(com.sequenceiq.cloudbreak.template.filesystem.BaseFileSystemConfigurationsView) ArrayList(java.util.ArrayList) PlacementView(com.sequenceiq.cloudbreak.template.views.PlacementView) S3FileSystemConfigurationsView(com.sequenceiq.cloudbreak.template.filesystem.s3.S3FileSystemConfigurationsView) S3FileSystem(com.sequenceiq.common.api.filesystem.S3FileSystem) ClouderaManagerRepo(com.sequenceiq.cloudbreak.cloud.model.ClouderaManagerRepo) Gateway(com.sequenceiq.cloudbreak.domain.stack.cluster.gateway.Gateway) HostgroupView(com.sequenceiq.cloudbreak.template.views.HostgroupView) AdlsFileSystem(com.sequenceiq.common.api.filesystem.AdlsFileSystem) AdlsFileSystemConfigurationsView(com.sequenceiq.cloudbreak.template.filesystem.adls.AdlsFileSystemConfigurationsView) HashSet(java.util.HashSet)

Example 20 with BaseFileSystemConfigurationsView

use of com.sequenceiq.cloudbreak.template.filesystem.BaseFileSystemConfigurationsView in project cloudbreak by hortonworks.

the class KnoxIdBrokerConfigProviderTest method getRoleConfigWhenIdBrokerAndS3FileSystem.

@Test
public void getRoleConfigWhenIdBrokerAndS3FileSystem() {
    BaseFileSystemConfigurationsView fileSystemConfigurationsView = mock(BaseFileSystemConfigurationsView.class);
    when(fileSystemConfigurationsView.getType()).thenReturn("S3");
    TemplatePreparationObject tpo = new Builder().withCloudPlatform(CloudPlatform.AWS).withFileSystemConfigurationView(fileSystemConfigurationsView).withAccountMappingView(new AccountMappingView(GROUP_MAPPINGS, USER_MAPPINGS)).build();
    List<ApiClusterTemplateConfig> result = underTest.getRoleConfigs(IDBROKER, tpo);
    Map<String, String> configNameToValueMap = getConfigNameToValueMap(result);
    assertThat(configNameToValueMap).containsOnly(Map.entry(IDBROKER_AWS_USER_MAPPING, USER_MAPPINGS_STR), Map.entry(IDBROKER_AWS_GROUP_MAPPING, GROUP_MAPPINGS_STR));
    Map<String, String> configNameToVariableNameMap = getConfigNameToVariableNameMap(result);
    assertThat(configNameToVariableNameMap).isEmpty();
}
Also used : TemplatePreparationObject(com.sequenceiq.cloudbreak.template.TemplatePreparationObject) BaseFileSystemConfigurationsView(com.sequenceiq.cloudbreak.template.filesystem.BaseFileSystemConfigurationsView) Builder(com.sequenceiq.cloudbreak.template.TemplatePreparationObject.Builder) ApiClusterTemplateConfig(com.cloudera.api.swagger.model.ApiClusterTemplateConfig) AccountMappingView(com.sequenceiq.cloudbreak.template.views.AccountMappingView) Test(org.junit.Test)

Aggregations

BaseFileSystemConfigurationsView (com.sequenceiq.cloudbreak.template.filesystem.BaseFileSystemConfigurationsView)26 TemplatePreparationObject (com.sequenceiq.cloudbreak.template.TemplatePreparationObject)20 Test (org.junit.Test)16 Builder (com.sequenceiq.cloudbreak.template.TemplatePreparationObject.Builder)10 ApiClusterTemplateConfig (com.cloudera.api.swagger.model.ApiClusterTemplateConfig)9 CmTemplateProcessor (com.sequenceiq.cloudbreak.cmtemplate.CmTemplateProcessor)7 StorageLocationView (com.sequenceiq.cloudbreak.template.filesystem.StorageLocationView)7 AccountMappingView (com.sequenceiq.cloudbreak.template.views.AccountMappingView)7 FileSystem (com.sequenceiq.cloudbreak.domain.FileSystem)6 StorageLocation (com.sequenceiq.cloudbreak.domain.StorageLocation)5 Gateway (com.sequenceiq.cloudbreak.domain.stack.cluster.gateway.Gateway)5 ConfigQueryEntries (com.sequenceiq.common.api.cloudstorage.query.ConfigQueryEntries)5 ArrayList (java.util.ArrayList)5 S3FileSystemConfigurationsView (com.sequenceiq.cloudbreak.template.filesystem.s3.S3FileSystemConfigurationsView)4 HostgroupView (com.sequenceiq.cloudbreak.template.views.HostgroupView)4 S3FileSystem (com.sequenceiq.common.api.filesystem.S3FileSystem)4 Json (com.sequenceiq.cloudbreak.common.json.Json)3 DetailedEnvironmentResponse (com.sequenceiq.environment.api.v1.environment.model.response.DetailedEnvironmentResponse)3 Test (org.junit.jupiter.api.Test)3 VirtualGroupRequest (com.sequenceiq.cloudbreak.auth.altus.VirtualGroupRequest)2