use of com.sequenceiq.cloudbreak.domain.RDSConfig in project cloudbreak by hortonworks.
the class StackRequestToBlueprintPreparationObjectConverter method convert.
@Override
public BlueprintPreparationObject convert(StackV2Request source) {
try {
IdentityUser identityUser = userDetailsService.getDetails(source.getOwner(), UserFilterField.USERID);
FlexSubscription flexSubscription = getFlexSubscription(source);
String smartsenseSubscriptionId = getSmartsenseSubscriptionId(source, flexSubscription);
KerberosConfig kerberosConfig = getKerberosConfig(source);
LdapConfig ldapConfig = getLdapConfig(source, identityUser);
FileSystemConfigurationView fileSystemConfigurationView = getFileSystemConfigurationView(source);
Set<RDSConfig> rdsConfigs = getRdsConfigs(source, identityUser);
Blueprint blueprint = getBlueprint(source, identityUser);
BlueprintStackInfo blueprintStackInfo = stackInfoService.blueprintStackInfo(blueprint.getBlueprintText());
Set<HostgroupView> hostgroupViews = getHostgroupViews(source);
BlueprintView blueprintView = new BlueprintView(blueprint.getBlueprintText(), blueprintStackInfo.getVersion(), blueprintStackInfo.getType());
GeneralClusterConfigs generalClusterConfigs = generalClusterConfigsProvider.generalClusterConfigs(source, identityUser);
return BlueprintPreparationObject.Builder.builder().withFlexSubscription(flexSubscription).withRdsConfigs(rdsConfigs).withHostgroupViews(hostgroupViews).withBlueprintView(blueprintView).withStackRepoDetailsHdpVersion(blueprintStackInfo.getVersion()).withFileSystemConfigurationView(fileSystemConfigurationView).withGeneralClusterConfigs(generalClusterConfigs).withSmartSenseSubscriptionId(smartsenseSubscriptionId).withLdapConfig(ldapConfig).withKerberosConfig(kerberosConfig).build();
} catch (BlueprintProcessingException e) {
throw new CloudbreakServiceException(e.getMessage(), e);
} catch (IOException e) {
throw new CloudbreakServiceException(e.getMessage(), e);
}
}
use of com.sequenceiq.cloudbreak.domain.RDSConfig in project cloudbreak by hortonworks.
the class RdsConfigController method createRdsConfig.
private RDSConfigResponse createRdsConfig(IdentityUser user, RDSConfigRequest rdsConfigJson, boolean publicInAccount) {
RDSConfig rdsConfig = conversionService.convert(rdsConfigJson, RDSConfig.class);
rdsConfig.setPublicInAccount(publicInAccount);
try {
rdsConfig = rdsConfigService.create(user, rdsConfig);
notify(user, ResourceEvent.RDS_CONFIG_CREATED);
} catch (DataIntegrityViolationException ex) {
String msg = String.format("Error with resource [%s], error: [%s]", APIResourceType.RDS_CONFIG, getProperSqlErrorMessage(ex));
throw new BadRequestException(msg);
}
return conversionService.convert(rdsConfig, RDSConfigResponse.class);
}
use of com.sequenceiq.cloudbreak.domain.RDSConfig in project cloudbreak by hortonworks.
the class RdsConfigController method getPrivates.
@Override
public Set<RDSConfigResponse> getPrivates() {
IdentityUser user = authenticatedUserService.getCbUser();
Set<RDSConfig> rdsConfigs = rdsConfigService.retrievePrivateRdsConfigs(user);
return toJsonList(rdsConfigs);
}
use of com.sequenceiq.cloudbreak.domain.RDSConfig in project cloudbreak by hortonworks.
the class ClusterDecorator method prepareConnectedClusterParameters.
private void prepareConnectedClusterParameters(Cluster requestedCluster, IdentityUser user, ConnectedClusterRequest connectedClusterRequest) {
if (connectedClusterRequest != null) {
Long stackId;
Stack publicStack;
if (!Strings.isNullOrEmpty(connectedClusterRequest.getSourceClusterName())) {
publicStack = stackService.getPublicStack(connectedClusterRequest.getSourceClusterName(), user);
stackId = publicStack.getId();
} else {
stackId = connectedClusterRequest.getSourceClusterId();
publicStack = stackService.get(connectedClusterRequest.getSourceClusterId());
}
// We should set the ldap to the source cluster ldap
requestedCluster.setLdapConfig(publicStack.getCluster().getLdapConfig());
// We should set the ranger metastore to the source cluster ranger metastore if exist!
RDSConfig rangerRds = rdsConfigService.findByClusterIdAndType(publicStack.getOwner(), publicStack.getAccount(), publicStack.getCluster().getId(), RdsType.RANGER);
if (rangerRds != null) {
requestedCluster.getRdsConfigs().add(rangerRds);
}
try {
Set<BlueprintParameterJson> requests = new HashSet<>();
Json blueprintAttributes = requestedCluster.getBlueprint().getInputParameters();
if (blueprintAttributes != null && StringUtils.isNoneEmpty(blueprintAttributes.getValue())) {
BlueprintInputParameters inputParametersObj = blueprintAttributes.get(BlueprintInputParameters.class);
for (BlueprintParameter blueprintParameter : inputParametersObj.getParameters()) {
BlueprintParameterJson blueprintParameterJson = new BlueprintParameterJson();
blueprintParameterJson.setName(blueprintParameter.getName());
blueprintParameterJson.setReferenceConfiguration(blueprintParameter.getReferenceConfiguration());
blueprintParameterJson.setDescription(blueprintParameter.getDescription());
requests.add(blueprintParameterJson);
}
}
ConfigsResponse configsResponse = clusterService.retrieveOutputs(stackId, requests);
Map<String, String> newInputs = requestedCluster.getBlueprintInputs().get(Map.class);
for (BlueprintInputJson blueprintInputJson : configsResponse.getInputs()) {
newInputs.put(blueprintInputJson.getName(), blueprintInputJson.getPropertyValue());
}
requestedCluster.setBlueprintInputs(new Json(newInputs));
} catch (IOException e) {
LOGGER.error("Could not propagate cluster input parameters", e);
throw new BadRequestException("Could not propagate cluster input parameters: " + e.getMessage());
}
}
}
use of com.sequenceiq.cloudbreak.domain.RDSConfig in project cloudbreak by hortonworks.
the class AmbariConfigurationService method createAmbariDefaultRdsConf.
private RDSConfig createAmbariDefaultRdsConf(Stack stack, Cluster cluster) {
RDSConfig rdsConfig = new RDSConfig();
rdsConfig.setName(ambariDatabaseMapper.mapName(stack, cluster));
rdsConfig.setConnectionUserName(userName);
rdsConfig.setConnectionPassword(PasswordUtil.generatePassword());
rdsConfig.setConnectionURL("jdbc:postgresql://" + host + ":" + port + "/" + name);
rdsConfig.setDatabaseEngine(databaseEngine);
rdsConfig.setType(RdsType.AMBARI.name());
rdsConfig.setStatus(ResourceStatus.DEFAULT);
rdsConfig.setCreationDate(new Date().getTime());
rdsConfig.setOwner(stack.getOwner());
rdsConfig.setAccount(stack.getAccount());
rdsConfig.setClusters(Collections.singleton(cluster));
rdsConfig.setConnectionDriver("org.postgresql.Driver");
return rdsConfigService.create(rdsConfig);
}
Aggregations