Search in sources :

Example 6 with ClusterRequest

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;
}
Also used : StackValidationRequest(com.sequenceiq.cloudbreak.api.model.StackValidationRequest) ClusterRequest(com.sequenceiq.cloudbreak.api.model.ClusterRequest) CredentialSourceRequest(com.sequenceiq.cloudbreak.api.model.CredentialSourceRequest)

Example 7 with ClusterRequest

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));
}
Also used : IdentityUser(com.sequenceiq.cloudbreak.common.model.user.IdentityUser) RdsType(com.sequenceiq.cloudbreak.api.model.rds.RdsType) LoggerFactory(org.slf4j.LoggerFactory) RDSConfigRequest(com.sequenceiq.cloudbreak.api.model.rds.RDSConfigRequest) ClusterService(com.sequenceiq.cloudbreak.service.cluster.ClusterService) StringUtils(org.apache.commons.lang3.StringUtils) AmbariConfigurationService(com.sequenceiq.cloudbreak.service.cluster.ambari.AmbariConfigurationService) ArrayList(java.util.ArrayList) HashSet(java.util.HashSet) Inject(javax.inject.Inject) Strings(com.google.common.base.Strings) RdsConfigService(com.sequenceiq.cloudbreak.service.rdsconfig.RdsConfigService) BadRequestException(com.sequenceiq.cloudbreak.controller.BadRequestException) Map(java.util.Map) Blueprint(com.sequenceiq.cloudbreak.domain.Blueprint) RDSConfig(com.sequenceiq.cloudbreak.domain.RDSConfig) Json(com.sequenceiq.cloudbreak.domain.json.Json) Stack(com.sequenceiq.cloudbreak.domain.Stack) ConversionService(org.springframework.core.convert.ConversionService) BlueprintParameter(com.sequenceiq.cloudbreak.domain.BlueprintParameter) HostGroup(com.sequenceiq.cloudbreak.domain.HostGroup) RdsConnectionValidator(com.sequenceiq.cloudbreak.controller.validation.rds.RdsConnectionValidator) Logger(org.slf4j.Logger) LdapConfigValidator(com.sequenceiq.cloudbreak.controller.validation.ldapconfig.LdapConfigValidator) ClusterRequest(com.sequenceiq.cloudbreak.api.model.ClusterRequest) BlueprintParameterJson(com.sequenceiq.cloudbreak.api.model.BlueprintParameterJson) LdapConfigRequest(com.sequenceiq.cloudbreak.api.model.ldap.LdapConfigRequest) Set(java.util.Set) BlueprintValidator(com.sequenceiq.cloudbreak.blueprint.validation.BlueprintValidator) IOException(java.io.IOException) Cluster(com.sequenceiq.cloudbreak.domain.Cluster) BlueprintInputJson(com.sequenceiq.cloudbreak.api.model.BlueprintInputJson) ConnectedClusterRequest(com.sequenceiq.cloudbreak.api.model.ConnectedClusterRequest) BlueprintInputParameters(com.sequenceiq.cloudbreak.domain.BlueprintInputParameters) Component(org.springframework.stereotype.Component) HostGroupRequest(com.sequenceiq.cloudbreak.api.model.HostGroupRequest) AmbariDatabaseMapper(com.sequenceiq.cloudbreak.converter.mapper.AmbariDatabaseMapper) Optional(java.util.Optional) BlueprintService(com.sequenceiq.cloudbreak.service.blueprint.BlueprintService) LdapConfigService(com.sequenceiq.cloudbreak.service.ldapconfig.LdapConfigService) ConfigsResponse(com.sequenceiq.cloudbreak.api.model.ConfigsResponse) LdapConfig(com.sequenceiq.cloudbreak.domain.LdapConfig) StackService(com.sequenceiq.cloudbreak.service.stack.StackService) RDSConfig(com.sequenceiq.cloudbreak.domain.RDSConfig) RDSConfigRequest(com.sequenceiq.cloudbreak.api.model.rds.RDSConfigRequest)

Aggregations

ClusterRequest (com.sequenceiq.cloudbreak.api.model.ClusterRequest)7 HostGroupRequest (com.sequenceiq.cloudbreak.api.model.HostGroupRequest)4 ClusterV1Endpoint (com.sequenceiq.cloudbreak.api.endpoint.v1.ClusterV1Endpoint)3 KerberosRequest (com.sequenceiq.cloudbreak.api.model.KerberosRequest)3 IntegrationTestContext (com.sequenceiq.it.IntegrationTestContext)3 Parameters (org.testng.annotations.Parameters)3 Test (org.testng.annotations.Test)3 IdentityUser (com.sequenceiq.cloudbreak.common.model.user.IdentityUser)2 Blueprint (com.sequenceiq.cloudbreak.domain.Blueprint)2 Cluster (com.sequenceiq.cloudbreak.domain.Cluster)2 Stack (com.sequenceiq.cloudbreak.domain.Stack)2 Json (com.sequenceiq.cloudbreak.domain.json.Json)2 HostGroup (com.sequenceiq.it.cloudbreak.HostGroup)2 JsonProcessingException (com.fasterxml.jackson.core.JsonProcessingException)1 JsonNode (com.fasterxml.jackson.databind.JsonNode)1 Strings (com.google.common.base.Strings)1 Sets (com.google.common.collect.Sets)1 AmbariRepoDetailsJson (com.sequenceiq.cloudbreak.api.model.AmbariRepoDetailsJson)1 AmbariStackDetailsJson (com.sequenceiq.cloudbreak.api.model.AmbariStackDetailsJson)1 BlueprintInputJson (com.sequenceiq.cloudbreak.api.model.BlueprintInputJson)1