Search in sources :

Example 1 with BaseFileSystemConfigurationsView

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

the class ClusterTerminationService method deleteFileSystemResources.

private void deleteFileSystemResources(Long stackId, FileSystem fileSystem, boolean force) {
    try {
        FileSystemConfigurator<BaseFileSystemConfigurationsView> fsConfigurator = fileSystemConfigurators.get(fileSystem.getType());
        ConfigQueryEntries configQueryEntries = cmCloudStorageConfigProvider.getConfigQueryEntries();
        BaseFileSystemConfigurationsView fsConfiguration = fileSystemConfigurationsViewProvider.propagateConfigurationsView(fileSystem, configQueryEntries);
        if (fsConfiguration != null) {
            fsConfiguration.setStorageContainer("cloudbreak" + stackId);
            fsConfigurator.deleteResources(fsConfiguration);
        }
    } catch (Exception e) {
        if (force) {
            LOGGER.error("Error during file system deletion, moving on based on the force flag, ", e);
        } else {
            throw new TerminationFailedException("File system resources could not be deleted: ", e);
        }
    }
}
Also used : BaseFileSystemConfigurationsView(com.sequenceiq.cloudbreak.template.filesystem.BaseFileSystemConfigurationsView) TerminationFailedException(com.sequenceiq.cloudbreak.service.stack.flow.TerminationFailedException) TerminationFailedException(com.sequenceiq.cloudbreak.service.stack.flow.TerminationFailedException) NotFoundException(com.sequenceiq.cloudbreak.common.exception.NotFoundException) TransactionExecutionException(com.sequenceiq.cloudbreak.common.service.TransactionService.TransactionExecutionException) ConfigQueryEntries(com.sequenceiq.common.api.cloudstorage.query.ConfigQueryEntries)

Example 2 with BaseFileSystemConfigurationsView

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

the class KnoxIdBrokerConfigProviderTest method getRoleConfigWhenIdBrokerAndInvalidFileSystem.

@Test
public void getRoleConfigWhenIdBrokerAndInvalidFileSystem() {
    BaseFileSystemConfigurationsView fileSystemConfigurationsView = mock(BaseFileSystemConfigurationsView.class);
    when(fileSystemConfigurationsView.getType()).thenReturn("DOS");
    TemplatePreparationObject tpo = new Builder().withCloudPlatform(CloudPlatform.AWS).withFileSystemConfigurationView(fileSystemConfigurationsView).build();
    thrown.expect(IllegalStateException.class);
    thrown.expectMessage("Unknown file system type:");
    underTest.getRoleConfigs(IDBROKER, tpo);
}
Also used : TemplatePreparationObject(com.sequenceiq.cloudbreak.template.TemplatePreparationObject) BaseFileSystemConfigurationsView(com.sequenceiq.cloudbreak.template.filesystem.BaseFileSystemConfigurationsView) Builder(com.sequenceiq.cloudbreak.template.TemplatePreparationObject.Builder) Test(org.junit.Test)

Example 3 with BaseFileSystemConfigurationsView

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

the class KnoxIdBrokerConfigProviderTest method getRoleConfigWhenIdBrokerAndAdlsGen2FileSystemAndInvalidCMVersion.

@Test
public void getRoleConfigWhenIdBrokerAndAdlsGen2FileSystemAndInvalidCMVersion() {
    BaseFileSystemConfigurationsView fileSystemConfigurationsView = mock(BaseFileSystemConfigurationsView.class);
    when(fileSystemConfigurationsView.getType()).thenReturn("ADLS_GEN_2");
    TemplatePreparationObject tpo = new Builder().withCloudPlatform(CloudPlatform.AZURE).withFileSystemConfigurationView(fileSystemConfigurationsView).withAccountMappingView(new AccountMappingView(GROUP_MAPPINGS, USER_MAPPINGS)).withProductDetails(generateCMRepo(CMRepositoryVersionUtil.CLOUDERAMANAGER_VERSION_6_3_0), null).build();
    List<ApiClusterTemplateConfig> result = underTest.getRoleConfigs(IDBROKER, tpo);
    Map<String, String> configNameToValueMap = getConfigNameToValueMap(result);
    assertThat(configNameToValueMap).containsOnly(Map.entry(IDBROKER_AZURE_USER_MAPPING, USER_MAPPINGS_STR), Map.entry(IDBROKER_AZURE_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)

Example 4 with BaseFileSystemConfigurationsView

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

the class KnoxIdBrokerConfigProviderTest method getRoleConfigWhenIdBrokerAndWasbIntegratedFileSystem.

@Test
public void getRoleConfigWhenIdBrokerAndWasbIntegratedFileSystem() {
    BaseFileSystemConfigurationsView fileSystemConfigurationsView = mock(BaseFileSystemConfigurationsView.class);
    when(fileSystemConfigurationsView.getType()).thenReturn("WASB_INTEGRATED");
    TemplatePreparationObject tpo = new Builder().withCloudPlatform(CloudPlatform.AZURE).withFileSystemConfigurationView(fileSystemConfigurationsView).withAccountMappingView(new AccountMappingView(GROUP_MAPPINGS, USER_MAPPINGS)).withProductDetails(generateCMRepo(CMRepositoryVersionUtil.CLOUDERAMANAGER_VERSION_7_1_0), null).build();
    List<ApiClusterTemplateConfig> result = underTest.getRoleConfigs(IDBROKER, tpo);
    Map<String, String> configNameToValueMap = getConfigNameToValueMap(result);
    assertThat(configNameToValueMap).containsOnly(Map.entry(IDBROKER_AZURE_USER_MAPPING, USER_MAPPINGS_STR), Map.entry(IDBROKER_AZURE_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)

Example 5 with BaseFileSystemConfigurationsView

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

the class KnoxIdBrokerConfigProviderTest method getRoleConfigWhenIdBrokerAndAdlsGen2FileSystemAndValidCMVersionValidEntity.

@Test
public void getRoleConfigWhenIdBrokerAndAdlsGen2FileSystemAndValidCMVersionValidEntity() {
    BaseFileSystemConfigurationsView fileSystemConfigurationsView = mock(BaseFileSystemConfigurationsView.class);
    when(fileSystemConfigurationsView.getType()).thenReturn("ADLS_GEN_2");
    when(fileSystemConfigurationsView.getIdBrokerIdentityId()).thenReturn(MANAGED_IDENTITY_STR);
    TemplatePreparationObject tpo = new Builder().withCloudPlatform(CloudPlatform.AZURE).withFileSystemConfigurationView(fileSystemConfigurationsView).withAccountMappingView(new AccountMappingView(GROUP_MAPPINGS, USER_MAPPINGS)).withProductDetails(generateCMRepo(CMRepositoryVersionUtil.CLOUDERAMANAGER_VERSION_7_1_0), null).build();
    List<ApiClusterTemplateConfig> result = underTest.getRoleConfigs(IDBROKER, tpo);
    Map<String, String> configNameToValueMap = getConfigNameToValueMap(result);
    assertThat(configNameToValueMap).containsOnly(Map.entry(IDBROKER_AZURE_USER_MAPPING, USER_MAPPINGS_STR), Map.entry(IDBROKER_AZURE_GROUP_MAPPING, GROUP_MAPPINGS_STR), Map.entry(IDBROKER_AZURE_VM_ASSUMER_IDENTITY, MANAGED_IDENTITY_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