use of com.sequenceiq.cloudbreak.api.model.ClusterRequest in project cloudbreak by hortonworks.
the class StackRequestToStackValidationRequestConverter method convert.
@Override
public StackValidationRequest convert(StackRequest source) {
ClusterRequest clusterRequest = source.getClusterRequest();
StackValidationRequest stackValidationRequest = new StackValidationRequest();
stackValidationRequest.setBlueprint(clusterRequest.getBlueprint());
stackValidationRequest.setBlueprintId(clusterRequest.getBlueprintId());
stackValidationRequest.setCredential(source.getCredential());
stackValidationRequest.setCredentialId(source.getCredentialId());
stackValidationRequest.setNetwork(source.getNetwork());
stackValidationRequest.setNetworkId(source.getNetworkId());
stackValidationRequest.setPlatform(source.getCloudPlatform());
CredentialSourceRequest credentialSource = source.getCredentialSource();
if (credentialSource != null) {
if (!Strings.isNullOrEmpty(credentialSource.getSourceName())) {
stackValidationRequest.setCredentialName(credentialSource.getSourceName());
} else if (credentialSource.getSourceId() != null) {
stackValidationRequest.setCredentialId(credentialSource.getSourceId());
}
}
if (!Strings.isNullOrEmpty(source.getCredentialName())) {
stackValidationRequest.setCredentialName(source.getCredentialName());
}
stackValidationRequest.setAccount(source.getAccount());
stackValidationRequest.setBlueprintName(clusterRequest.getBlueprintName());
stackValidationRequest.setFileSystem(source.getClusterRequest().getFileSystem());
stackValidationRequest.setHostGroups(source.getClusterRequest().getHostGroups());
stackValidationRequest.setInstanceGroups(new HashSet<>(source.getInstanceGroups()));
return stackValidationRequest;
}
use of com.sequenceiq.cloudbreak.api.model.ClusterRequest in project cloudbreak by hortonworks.
the class ClusterDecorator method prepareRds.
private void prepareRds(Cluster subject, IdentityUser user, ClusterRequest request, Stack stack) {
subject.setRdsConfigs(new HashSet<>());
if (request.getRdsConfigIds() != null) {
for (Long rdsConfigId : request.getRdsConfigIds()) {
RDSConfig rdsConfig = rdsConfigService.get(rdsConfigId);
subject.getRdsConfigs().add(rdsConfig);
}
}
if (request.getRdsConfigJsons() != null) {
for (RDSConfigRequest requestRdsConfig : request.getRdsConfigJsons()) {
RDSConfig rdsConfig = conversionService.convert(requestRdsConfig, RDSConfig.class);
rdsConfig.setPublicInAccount(stack.isPublicInAccount());
rdsConfig = rdsConfigService.createIfNotExists(user, rdsConfig);
subject.getRdsConfigs().add(rdsConfig);
}
}
Optional.of(request.getRdsConfigNames()).ifPresent(confs -> confs.forEach(confName -> subject.getRdsConfigs().add(rdsConfigService.getPublicRdsConfig(confName, user))));
if (request.getAmbariDatabaseDetails() != null) {
RDSConfig rdsConfig = ambariDatabaseMapper.mapAmbariDatabaseDetailsJsonToRdsConfig(request.getAmbariDatabaseDetails(), subject, stack, stack.isPublicInAccount());
subject.getRdsConfigs().add(rdsConfigService.createIfNotExists(user, rdsConfig));
}
ambariConfigurationService.createDefaultRdsConfigIfNeeded(stack, subject).ifPresent(rdsConfig -> subject.getRdsConfigs().add(rdsConfig));
}
Aggregations