use of com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.request.cluster.ClusterV4Request in project cloudbreak by hortonworks.
the class CloudStorageManifesterTest method whenEnvironmentHasOnlyLoggingEnabledThenShouldApplyAsLogIdentity.
@Test
public void whenEnvironmentHasOnlyLoggingEnabledThenShouldApplyAsLogIdentity() {
DetailedEnvironmentResponse environment = new DetailedEnvironmentResponse();
environment.setCloudPlatform("AWS");
TelemetryResponse telemetryResponse = new TelemetryResponse();
LoggingResponse loggingResponse = new LoggingResponse();
S3CloudStorageV1Parameters s3CloudStorageV1Parameters = new S3CloudStorageV1Parameters();
s3CloudStorageV1Parameters.setInstanceProfile("logprofile");
loggingResponse.setS3(s3CloudStorageV1Parameters);
telemetryResponse.setLogging(loggingResponse);
environment.setTelemetry(telemetryResponse);
ClusterV4Request clusterV4Request = new ClusterV4Request();
clusterV4Request.setBlueprintName(exampleBlueprintName);
CloudStorageRequest cloudStorageConfigReq = underTest.initCloudStorageRequest(environment, clusterV4Request, null, new SdxClusterRequest());
assertEquals(1, cloudStorageConfigReq.getIdentities().size());
assertEquals(1, cloudStorageConfigReq.getIdentities().stream().filter(r -> r.getType().equals(CloudIdentityType.LOG)).collect(Collectors.toSet()).size());
assertEquals("logprofile", cloudStorageConfigReq.getIdentities().get(0).getS3().getInstanceProfile());
}
use of com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.request.cluster.ClusterV4Request in project cloudbreak by hortonworks.
the class CloudStorageManifesterTest method whenCloudStorageEnabledFromInternalRequestWithLogging.
@Test
public void whenCloudStorageEnabledFromInternalRequestWithLogging() {
ClusterV4Request clusterV4Request = new ClusterV4Request();
clusterV4Request.setBlueprintName(exampleBlueprintName);
CloudStorageRequest cloudStorageRequest = new CloudStorageRequest();
StorageLocationBase storageLocationBase = new StorageLocationBase();
storageLocationBase.setType(CloudStorageCdpService.RANGER_AUDIT);
storageLocationBase.setValue("s3a://ranger-audit");
cloudStorageRequest.setLocations(List.of(storageLocationBase));
clusterV4Request.setCloudStorage(cloudStorageRequest);
DetailedEnvironmentResponse environment = new DetailedEnvironmentResponse();
environment.setCloudPlatform("AWS");
TelemetryResponse telemetryResponse = new TelemetryResponse();
LoggingResponse loggingResponse = new LoggingResponse();
S3CloudStorageV1Parameters s3CloudStorageV1Parameters = new S3CloudStorageV1Parameters();
s3CloudStorageV1Parameters.setInstanceProfile("logprofile");
loggingResponse.setS3(s3CloudStorageV1Parameters);
telemetryResponse.setLogging(loggingResponse);
environment.setTelemetry(telemetryResponse);
CloudStorageRequest cloudStorageConfigReq = underTest.initCloudStorageRequest(environment, clusterV4Request, null, new SdxClusterRequest());
assertEquals(CloudStorageCdpService.RANGER_AUDIT, cloudStorageConfigReq.getLocations().get(0).getType());
assertEquals(CloudIdentityType.LOG, cloudStorageConfigReq.getIdentities().get(0).getType());
}
use of com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.request.cluster.ClusterV4Request in project cloudbreak by hortonworks.
the class ClouderaManagerClusterCreationSetupService method prepareClouderaManagerCluster.
public List<ClusterComponent> prepareClouderaManagerCluster(ClusterV4Request request, Cluster cluster, Optional<Component> stackClouderaManagerRepoConfig, List<Component> stackCdhRepoConfig, Optional<Component> stackImageComponent) throws IOException, CloudbreakImageCatalogException {
List<ClusterComponent> components = new ArrayList<>();
long start = System.currentTimeMillis();
String blueprintCdhVersion = blueprintUtils.getCDHStackVersion(JsonUtil.readTree(cluster.getBlueprint().getBlueprintText()));
LOGGER.debug("blueprintUtils.getCDHStackVersion took {} ms", System.currentTimeMillis() - start);
Optional<ClouderaManagerRepositoryV4Request> cmRepoRequest = measure(() -> Optional.ofNullable(request.getCm()).map(ClouderaManagerV4Request::getRepository), LOGGER, "ClouderaManagerV4Request::getRepository {} ms");
start = System.currentTimeMillis();
String osType = getOsType(stackImageComponent);
String imageCatalogName = getImageCatalogName(stackImageComponent);
LOGGER.debug("getImageCatalogName took {} ms", System.currentTimeMillis() - start);
start = System.currentTimeMillis();
ClusterComponent cmRepoConfig = getCmRepoConfiguration(cluster, stackClouderaManagerRepoConfig, components, blueprintCdhVersion, cmRepoRequest, osType);
LOGGER.debug("getCmRepoConfiguration took {} ms", System.currentTimeMillis() - start);
start = System.currentTimeMillis();
checkCmStackRepositories(cmRepoConfig, stackImageComponent.get());
LOGGER.debug("checkCmStackRepositories took {} ms", System.currentTimeMillis() - start);
start = System.currentTimeMillis();
addProductComponentsToCluster(request, cluster, stackCdhRepoConfig, components, blueprintCdhVersion, osType, imageCatalogName);
LOGGER.debug("addProductComponentsToCluster took {} ms", System.currentTimeMillis() - start);
return components;
}
use of com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.request.cluster.ClusterV4Request in project cloudbreak by hortonworks.
the class ClusterV4RequestToClusterConverterTest method testConvertWhenCloudStorageConfiguredAndRdsAndLdapAndProxyExistsAnd.
@Test
public void testConvertWhenCloudStorageConfiguredAndRdsAndLdapAndProxyExistsAnd() {
CloudStorageRequest cloudStorageRequest = mock(CloudStorageRequest.class);
when(entitlementService.dataLakeEfsEnabled(anyString())).thenReturn(true);
String rdsConfigName = "rds-name";
String proxyConfigCrn = "proxy-config-resource-crn";
String ldapName = "ldap-name";
FileSystem fileSystem = new FileSystem();
RDSConfig rdsConfig = new RDSConfig();
rdsConfig.setName(rdsConfigName);
ClusterV4Request source = new ClusterV4Request();
source.setCloudStorage(cloudStorageRequest);
source.setDatabases(singleton(rdsConfigName));
source.setProxyConfigCrn(proxyConfigCrn);
source.setBlueprintName(BLUEPRINT);
when(blueprintService.getByNameForWorkspaceAndLoadDefaultsIfNecessary(eq(BLUEPRINT), any())).thenReturn(blueprint);
when(cloudStorageValidationUtil.isCloudStorageConfigured(cloudStorageRequest)).thenReturn(true);
when(cloudStorageConverter.requestToFileSystem(cloudStorageRequest)).thenReturn(fileSystem);
when(rdsConfigService.findByNamesInWorkspace(singleton(rdsConfigName), workspace.getId())).thenReturn(singleton(rdsConfig));
Cluster actual = ThreadBasedUserCrnProvider.doAs("crn:cdp:iam:us-west-1:1234:user:1", () -> underTest.convert(source));
assertThat(actual.getFileSystem(), is(fileSystem));
assertThat(actual.getName(), is(source.getName()));
assertThat(actual.getRdsConfigs().size(), is(1));
assertThat(actual.getRdsConfigs().stream().findFirst().get().getName(), is(rdsConfigName));
assertThat(actual.getProxyConfigCrn(), is(proxyConfigCrn));
verify(cloudStorageValidationUtil, times(1)).isCloudStorageConfigured(cloudStorageRequest);
verify(cloudStorageConverter, times(1)).requestToFileSystem(cloudStorageRequest);
verify(rdsConfigService, times(1)).findByNamesInWorkspace(singleton(rdsConfigName), workspace.getId());
}
use of com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.request.cluster.ClusterV4Request in project cloudbreak by hortonworks.
the class ClusterV4RequestToClusterConverterTest method testConvertWhenNoRdsConfig.
@Test
public void testConvertWhenNoRdsConfig() {
ClusterV4Request source = new ClusterV4Request();
source.setBlueprintName(BLUEPRINT);
when(blueprintService.getByNameForWorkspaceAndLoadDefaultsIfNecessary(eq(BLUEPRINT), any())).thenReturn(blueprint);
Set<String> rdsConfigNames = emptySet();
Cluster actual = underTest.convert(source);
assertThat(actual.getRdsConfigs(), is(nullValue()));
verify(rdsConfigService, times(0)).findByNamesInWorkspace(rdsConfigNames, workspace.getId());
}
Aggregations