use of com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.request.cluster.ClusterV4Request in project cloudbreak by hortonworks.
the class ClusterToClusterV4RequestConverterTest method testConvertSettingExecutorTypeToNull.
@Test
public void testConvertSettingExecutorTypeToNull() {
ClusterV4Request result = underTest.convert(cluster);
assertNotNull(result);
assertNull(result.getExecutorType());
}
use of com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.request.cluster.ClusterV4Request in project cloudbreak by hortonworks.
the class DistroXClusterToClusterConverterTest method testConvertWithoutEnvTheExecutionTypeShouldBeSetToDefault.
@Test
void testConvertWithoutEnvTheExecutionTypeShouldBeSetToDefault() {
ClusterV4Request result = testConvertDistroXV1Request();
assertNotNull(result);
assertEquals(ExecutorType.DEFAULT, result.getExecutorType());
}
use of com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.request.cluster.ClusterV4Request in project cloudbreak by hortonworks.
the class ClusterToClusterV4RequestConverter method convert.
public ClusterV4Request convert(Cluster source) {
ClusterV4Request clusterRequest = new ClusterV4Request();
convertClusterManager(source, clusterRequest);
clusterRequest.setBlueprintName(source.getBlueprint().getName());
clusterRequest.setValidateBlueprint(null);
clusterRequest.setUserName("");
clusterRequest.setPassword("");
if (source.getFileSystem() != null) {
clusterRequest.setCloudStorage(cloudStorageConverter.fileSystemToRequest(source.getFileSystem()));
}
clusterRequest.setName(source.getName());
if (source.getRdsConfigs() != null && !source.getRdsConfigs().isEmpty()) {
Set<String> databaseNames = source.getRdsConfigs().stream().filter(rdsConfig -> rdsConfig.getStatus() == ResourceStatus.USER_MANAGED).map(RDSConfig::getName).collect(Collectors.toSet());
clusterRequest.setDatabases(Collections.unmodifiableSet(databaseNames));
}
if (StringUtils.isNotEmpty(source.getProxyConfigCrn())) {
clusterRequest.setProxyConfigCrn(source.getProxyConfigCrn());
}
if (source.getGateway() != null) {
clusterRequest.setGateway(gatewayToGatewayV4RequestConverter.convert(source.getGateway()));
}
clusterRequest.setRangerRazEnabled(source.isRangerRazEnabled());
return clusterRequest;
}
use of com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.request.cluster.ClusterV4Request in project cloudbreak by hortonworks.
the class StackCreatorService method determineImageCatalog.
private Future<StatedImage> determineImageCatalog(String stackName, String platformString, StackV4Request stackRequest, Blueprint blueprint, User user, Workspace workspace) {
ClusterV4Request clusterRequest = stackRequest.getCluster();
if (clusterRequest == null) {
return null;
}
boolean shouldUseBaseCMImage = shouldUseBaseCMImage(clusterRequest, platformString);
boolean baseImageEnabled = imageCatalogService.baseImageEnabled();
Map<String, String> mdcContext = MDCBuilder.getMdcContextMap();
CloudbreakUser cbUser = restRequestThreadLocalService.getCloudbreakUser();
return executorService.submit(() -> {
MDCBuilder.buildMdcContextFromMap(mdcContext);
LOGGER.info("The stack with name {} has base images enabled: {} and should use base images: {}", stackName, baseImageEnabled, shouldUseBaseCMImage);
StatedImage statedImage = ThreadBasedUserCrnProvider.doAs(user.getUserCrn(), () -> {
try {
restRequestThreadLocalService.setCloudbreakUser(cbUser);
return imageService.determineImageFromCatalog(workspace.getId(), stackRequest.getImage(), platformString, stackRequest.getVariant(), blueprint, shouldUseBaseCMImage, baseImageEnabled, user, image -> true);
} catch (CloudbreakImageNotFoundException | CloudbreakImageCatalogException e) {
throw new RuntimeException(e);
}
});
MDCBuilder.cleanupMdc();
return statedImage;
});
}
use of com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.request.cluster.ClusterV4Request in project cloudbreak by hortonworks.
the class ClusterV4RequestToClusterConverterTest method testConvertClouderaManagerRequestWithNullRepo.
@Test
public void testConvertClouderaManagerRequestWithNullRepo() {
ClusterV4Request request = new ClusterV4Request();
request.setBlueprintName(BLUEPRINT);
blueprint.setStackType(StackType.CDH.name());
when(blueprintService.getByNameForWorkspaceAndLoadDefaultsIfNecessary(eq(BLUEPRINT), any())).thenReturn(blueprint);
ClouderaManagerV4Request cm = new ClouderaManagerV4Request();
ClouderaManagerProductV4Request cdp = new ClouderaManagerProductV4Request();
cdp.setName("cdp");
cdp.setParcel("cdp.parcel");
cdp.setVersion("cdp.version");
cdp.setCsd(List.of("cdp.csd"));
ClouderaManagerProductV4Request cdf = new ClouderaManagerProductV4Request();
cdf.setName("cdf");
cdf.setParcel("cdf.parcel");
cdf.setVersion("cdf.version");
cdf.setCsd(List.of("cdf.csd"));
List<ClouderaManagerProductV4Request> products = List.of(cdp, cdf);
cm.setProducts(products);
request.setCm(cm);
Cluster cluster = underTest.convert(request);
assertFalse(cluster.getComponents().isEmpty());
assertEquals(2, cluster.getComponents().size());
assertAll(cluster.getComponents().stream().map(component -> () -> assertEquals(ComponentType.CDH_PRODUCT_DETAILS, component.getComponentType())));
List<Json> cdps = cluster.getComponents().stream().map(ClusterComponent::getAttributes).filter(attr -> attr.getValue().contains("cdp")).collect(Collectors.toList());
Json cdpJson = new Json(cdp);
assertAll(() -> assertEquals(1, cdps.size()), () -> assertEquals(cdpJson, cdps.iterator().next()));
List<Json> cdfs = cluster.getComponents().stream().map(ClusterComponent::getAttributes).filter(attr -> attr.getValue().contains("cdf")).collect(Collectors.toList());
Json cdfJson = new Json(cdf);
assertAll(() -> assertEquals(1, cdfs.size()), () -> assertEquals(cdfJson, cdfs.iterator().next()));
}
Aggregations