use of com.sequenceiq.cloudbreak.template.TemplatePreparationObject.Builder in project cloudbreak by hortonworks.
the class DasConfigProviderTest method isConfigurationNeededFalseWhenNoDasOnClusterr.
@Test
@SuppressWarnings("unchecked")
public void isConfigurationNeededFalseWhenNoDasOnClusterr() {
CmTemplateProcessor mockTemplateProcessor = mock(CmTemplateProcessor.class);
when(mockTemplateProcessor.isRoleTypePresentInService(anyString(), any(List.class))).thenReturn(false);
RDSConfig rdsConfig = new RDSConfig();
rdsConfig.setType(HIVE_DAS);
rdsConfig.setConnectionURL(String.format("jdbc:%s://%s:%s/%s", DB_PROVIDER, HOST, PORT, DB_NAME));
rdsConfig.setConnectionUserName(USER_NAME);
rdsConfig.setConnectionPassword(PASSWORD);
TemplatePreparationObject tpo = new Builder().withRdsConfigs(Set.of(rdsConfig)).build();
boolean result = underTest.isConfigurationNeeded(mockTemplateProcessor, tpo);
assertThat(result).isFalse();
}
use of com.sequenceiq.cloudbreak.template.TemplatePreparationObject.Builder in project cloudbreak by hortonworks.
the class DasConfigProviderTest method isConfigurationNeededFalseWhenNoDBRegistered.
@Test
@SuppressWarnings("unchecked")
public void isConfigurationNeededFalseWhenNoDBRegistered() {
CmTemplateProcessor mockTemplateProcessor = mock(CmTemplateProcessor.class);
when(mockTemplateProcessor.isRoleTypePresentInService(anyString(), any(List.class))).thenReturn(true);
TemplatePreparationObject tpo = new Builder().build();
boolean result = underTest.isConfigurationNeeded(mockTemplateProcessor, tpo);
assertThat(result).isFalse();
}
use of com.sequenceiq.cloudbreak.template.TemplatePreparationObject.Builder in project cloudbreak by hortonworks.
the class StackToTemplatePreparationObjectConverter method convert.
public TemplatePreparationObject convert(Stack source) {
try {
Map<String, Collection<ClusterExposedServiceView>> views = serviceEndpointCollector.prepareClusterExposedServicesViews(source.getCluster(), stackUtil.extractClusterManagerAddress(source));
DetailedEnvironmentResponse environment = environmentClientService.getByCrn(source.getEnvironmentCrn());
Credential credential = credentialConverter.convert(environment.getCredential());
Cluster cluster = clusterService.getById(source.getCluster().getId());
FileSystem fileSystem = cluster.getFileSystem();
Optional<LdapView> ldapView = ldapConfigService.get(source.getEnvironmentCrn(), source.getName());
ClouderaManagerRepo cm = clusterComponentConfigProvider.getClouderaManagerRepoDetails(cluster.getId());
List<ClouderaManagerProduct> products = clusterComponentConfigProvider.getClouderaManagerProductDetails(cluster.getId());
BaseFileSystemConfigurationsView fileSystemConfigurationView = getFileSystemConfigurationView(credential, source, fileSystem);
updateFileSystemViewWithBackupLocation(environment, fileSystemConfigurationView);
StackInputs stackInputs = getStackInputs(source);
Map<String, Object> fixInputs = stackInputs.getFixInputs() == null ? new HashMap<>() : stackInputs.getFixInputs();
fixInputs.putAll(stackInputs.getDatalakeInputs() == null ? new HashMap<>() : stackInputs.getDatalakeInputs());
Gateway gateway = cluster.getGateway();
String gatewaySignKey = null;
if (gateway != null) {
gatewaySignKey = gateway.getSignKey();
}
IdBroker idbroker = idBrokerService.getByCluster(cluster);
if (idbroker == null) {
idbroker = idBrokerConverterUtil.generateIdBrokerSignKeys(cluster);
idBrokerService.save(idbroker);
}
String envCrnForVirtualGroups = getEnvironmentCrnForVirtualGroups(environment);
VirtualGroupRequest virtualGroupRequest = new VirtualGroupRequest(envCrnForVirtualGroups, ldapView.map(LdapView::getAdminGroup).orElse(""));
String accountId = Crn.safeFromString(source.getResourceCrn()).getAccountId();
List<UserManagementProto.ServicePrincipalCloudIdentities> servicePrincipalCloudIdentities = grpcUmsClient.listServicePrincipalCloudIdentities(accountId, source.getEnvironmentCrn(), MDCUtils.getRequestId());
BlueprintView blueprintView = blueprintViewProvider.getBlueprintView(cluster.getBlueprint());
Optional<String> version = Optional.ofNullable(blueprintView.getVersion());
Builder builder = Builder.builder().withCloudPlatform(CloudPlatform.valueOf(source.getCloudPlatform())).withRdsConfigs(postgresConfigService.createRdsConfigIfNeeded(source, cluster)).withRdsSslCertificateFilePath(dbCertificateProvider.getSslCertsFilePath()).withGateway(gateway, gatewaySignKey, exposedServiceCollector.getAllKnoxExposed(version)).withIdBroker(idbroker).withCustomConfigurationsView(getCustomConfigurationsView(source, cluster)).withCustomInputs(stackInputs.getCustomInputs() == null ? new HashMap<>() : stackInputs.getCustomInputs()).withFixInputs(fixInputs).withBlueprintView(blueprintView).withFileSystemConfigurationView(fileSystemConfigurationView).withGeneralClusterConfigs(calculateGeneralClusterConfigs(source, cluster)).withLdapConfig(ldapView.orElse(null)).withKerberosConfig(kerberosConfigService.get(source.getEnvironmentCrn(), source.getName()).orElse(null)).withProductDetails(cm, products).withExposedServices(views).withDefaultTags(getStackTags(source)).withSharedServiceConfigs(datalakeService.createSharedServiceConfigsView(source)).withStackType(source.getType()).withVirtualGroupView(virtualGroupRequest);
transactionService.required(() -> {
builder.withHostgroups(hostGroupService.getByCluster(cluster.getId()));
});
decorateBuilderWithPlacement(source, builder);
decorateBuilderWithAccountMapping(source, environment, credential, builder, virtualGroupRequest);
decorateBuilderWithServicePrincipals(source, builder, servicePrincipalCloudIdentities);
decorateDatalakeView(source, builder);
return builder.build();
} catch (AccountTagValidationFailed aTVF) {
throw new CloudbreakServiceException(aTVF);
} catch (BlueprintProcessingException | IOException | TransactionService.TransactionExecutionException e) {
throw new CloudbreakServiceException(e.getMessage(), e);
}
}
use of com.sequenceiq.cloudbreak.template.TemplatePreparationObject.Builder 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);
}
}
use of com.sequenceiq.cloudbreak.template.TemplatePreparationObject.Builder in project cloudbreak by hortonworks.
the class HueConfigProviderTest method getServiceConfigVariablesWhenKnoxConfiguredToExternalDomain.
@Test
public void getServiceConfigVariablesWhenKnoxConfiguredToExternalDomain() {
BlueprintView blueprintView = getMockBlueprintView("7.0.1", "7.0.1");
RDSConfig rdsConfig = new RDSConfig();
rdsConfig.setType(HUE);
rdsConfig.setConnectionURL(String.format("jdbc:%s://%s:%s/%s", DB_PROVIDER, HOST, PORT, DB_NAME));
rdsConfig.setConnectionUserName(USER_NAME);
rdsConfig.setConnectionPassword(PASSWORD);
String expectedExternalFQDN = "myaddress.cloudera.site";
String expectedInternalFQDN = "private-gateway.cloudera.site";
GeneralClusterConfigs generalClusterConfigs = new GeneralClusterConfigs();
generalClusterConfigs.setExternalFQDN(expectedExternalFQDN);
generalClusterConfigs.setKnoxUserFacingCertConfigured(true);
generalClusterConfigs.setPrimaryGatewayInstanceDiscoveryFQDN(Optional.of(expectedInternalFQDN));
TemplatePreparationObject tpo = new Builder().withGeneralClusterConfigs(generalClusterConfigs).withGateway(new Gateway(), "", new HashSet<>()).withBlueprintView(blueprintView).withRdsConfigs(Set.of(rdsConfig)).build();
List<ApiClusterTemplateVariable> result = underTest.getServiceConfigVariables(tpo);
Map<String, String> paramToVariable = result.stream().collect(Collectors.toMap(ApiClusterTemplateVariable::getName, ApiClusterTemplateVariable::getValue));
String proxyHostsExpected1 = String.join(",", expectedInternalFQDN, expectedExternalFQDN);
String proxyHostsExpected2 = String.join(",", expectedExternalFQDN, expectedInternalFQDN);
String expectedSafetyValveValue1 = "[desktop]\n[[knox]]\nknox_proxyhosts=".concat(proxyHostsExpected1);
String expectedSafetyValveValue2 = "[desktop]\n[[knox]]\nknox_proxyhosts=".concat(proxyHostsExpected2);
assertEquals(7, paramToVariable.size());
assertThat(paramToVariable).contains(new SimpleEntry<>("hue-hue_database_host", HOST), new SimpleEntry<>("hue-hue_database_port", PORT), new SimpleEntry<>("hue-hue_database_name", DB_NAME), new SimpleEntry<>("hue-hue_database_type", DB_PROVIDER), new SimpleEntry<>("hue-hue_database_user", USER_NAME), new SimpleEntry<>("hue-hue_database_password", PASSWORD));
assertThat(paramToVariable).containsAnyOf(new SimpleEntry<>("hue-hue_service_safety_valve", expectedSafetyValveValue1), new SimpleEntry<>("hue-hue_service_safety_valve", expectedSafetyValveValue2));
}
Aggregations